@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | print '</ul>You <strong>must</strong> add these modules/fix errors.</div>'; |
| 94 | 94 | require('../footer.php'); |
| 95 | - exit; |
|
| 95 | + exit; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | if (!isset($_SESSION['install']) && !isset($_POST['dbtype']) && (count($error) == 0)) { |
@@ -301,17 +301,17 @@ discard block |
||
| 301 | 301 | </tr> |
| 302 | 302 | <!-- |
| 303 | 303 | <?php |
| 304 | - require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
| 305 | - $Connection = new Connection(); |
|
| 304 | + require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
| 305 | + $Connection = new Connection(); |
|
| 306 | 306 | ?> |
| 307 | 307 | --> |
| 308 | 308 | <?php |
| 309 | - if ($Connection->db != NULL) { |
|
| 309 | + if ($Connection->db != NULL) { |
|
| 310 | 310 | if ($Connection->tableExists('source_location')) { |
| 311 | - require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
| 312 | - $Source = new Source(); |
|
| 313 | - $alllocations = $Source->getAllLocationInfo(); |
|
| 314 | - foreach ($alllocations as $location) { |
|
| 311 | + require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
| 312 | + $Source = new Source(); |
|
| 313 | + $alllocations = $Source->getAllLocationInfo(); |
|
| 314 | + foreach ($alllocations as $location) { |
|
| 315 | 315 | ?> |
| 316 | 316 | <tr> |
| 317 | 317 | <input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" /> |
@@ -325,9 +325,9 @@ discard block |
||
| 325 | 325 | </tr> |
| 326 | 326 | |
| 327 | 327 | <?php |
| 328 | - } |
|
| 328 | + } |
|
| 329 | + } |
|
| 329 | 330 | } |
| 330 | - } |
|
| 331 | 331 | ?> |
| 332 | 332 | |
| 333 | 333 | <tr> |
@@ -418,12 +418,12 @@ discard block |
||
| 418 | 418 | ?> |
| 419 | 419 | <tr> |
| 420 | 420 | <?php |
| 421 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
| 421 | + if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
| 422 | 422 | ?> |
| 423 | 423 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
| 424 | 424 | <td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td> |
| 425 | 425 | <?php |
| 426 | - } else { |
|
| 426 | + } else { |
|
| 427 | 427 | $hostport = explode(':',$source['host']); |
| 428 | 428 | if (isset($hostport[1])) { |
| 429 | 429 | $host = $hostport[0]; |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | <td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td> |
| 437 | 437 | <td><input type="number" name="port[]" id="port" value="<?php print $port; ?>" /></td> |
| 438 | 438 | <?php |
| 439 | - } |
|
| 439 | + } |
|
| 440 | 440 | ?> |
| 441 | 441 | <td> |
| 442 | 442 | <select name="format[]" id="format"> |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | <br /> |
| 728 | 728 | <p> |
| 729 | 729 | <?php |
| 730 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 730 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
| 731 | 731 | ?> |
| 732 | 732 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
| 733 | 733 | <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
@@ -737,11 +737,11 @@ discard block |
||
| 737 | 737 | <b>The directory cache is not writable, aircraft icon will not be cached</b> |
| 738 | 738 | <?php |
| 739 | 739 | } |
| 740 | - } else { |
|
| 740 | + } else { |
|
| 741 | 741 | ?> |
| 742 | 742 | <b>PHP GD is not installed, you can t change color of aircraft icon on map</b> |
| 743 | 743 | <?php |
| 744 | - } |
|
| 744 | + } |
|
| 745 | 745 | ?> |
| 746 | 746 | </p> |
| 747 | 747 | <br /> |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | </p> |
| 761 | 761 | <?php |
| 762 | 762 | require('../footer.php'); |
| 763 | - exit; |
|
| 763 | + exit; |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | $settings = array(); |
@@ -850,8 +850,8 @@ discard block |
||
| 850 | 850 | |
| 851 | 851 | $sources = array(); |
| 852 | 852 | foreach ($source_name as $keys => $name) { |
| 853 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 854 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 853 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 854 | + else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 855 | 855 | } |
| 856 | 856 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
| 857 | 857 | |
@@ -1116,14 +1116,14 @@ discard block |
||
| 1116 | 1116 | |
| 1117 | 1117 | // Set some defaults values... |
| 1118 | 1118 | if (!isset($globalAircraftImageSources)) { |
| 1119 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 1120 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
| 1119 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 1120 | + $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | if (!isset($globalSchedulesSources)) { |
| 1124 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1125 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
| 1126 | - } |
|
| 1124 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1125 | + $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
| 1126 | + } |
|
| 1127 | 1127 | |
| 1128 | 1128 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
| 1129 | 1129 | |
@@ -1175,21 +1175,21 @@ discard block |
||
| 1175 | 1175 | $popi = false; |
| 1176 | 1176 | $popw = false; |
| 1177 | 1177 | foreach ($_SESSION['done'] as $done) { |
| 1178 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
| 1179 | - if ($done == 'Create database') $pop = true; |
|
| 1180 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
| 1181 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
| 1182 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
| 1178 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
| 1179 | + if ($done == 'Create database') $pop = true; |
|
| 1180 | + if ($_SESSION['install'] == 'database_create') $pop = true; |
|
| 1181 | + if ($_SESSION['install'] == 'database_import') $popi = true; |
|
| 1182 | + if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
| 1183 | 1183 | } |
| 1184 | 1184 | if ($pop) { |
| 1185 | - sleep(5); |
|
| 1186 | - print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
| 1185 | + sleep(5); |
|
| 1186 | + print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
| 1187 | 1187 | } else if ($popi) { |
| 1188 | - sleep(5); |
|
| 1189 | - print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
| 1188 | + sleep(5); |
|
| 1189 | + print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
| 1190 | 1190 | } else if ($popw) { |
| 1191 | - sleep(5); |
|
| 1192 | - print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
| 1191 | + sleep(5); |
|
| 1192 | + print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
| 1193 | 1193 | } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
| 1194 | 1194 | print '</div></ul>'; |
| 1195 | 1195 | print '<div id="error"></div>'; |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | unset($_COOKIE['install']); |
| 1253 | 1253 | print '<div class="info column"><ul>'; |
| 1254 | 1254 | foreach ($_SESSION['done'] as $done) { |
| 1255 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
| 1255 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
| 1256 | 1256 | } |
| 1257 | 1257 | print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>'; |
| 1258 | 1258 | print '</ul></div>'; |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.create_db.php'); |
| 10 | 10 | require_once(dirname(__FILE__).'/class.update_schema.php'); |
| 11 | 11 | require_once(dirname(__FILE__).'/class.settings.php'); |
| 12 | -$title="Install"; |
|
| 12 | +$title = "Install"; |
|
| 13 | 13 | require(dirname(__FILE__).'/../require/settings.php'); |
| 14 | 14 | require(dirname(__FILE__).'/header.php'); |
| 15 | 15 | |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | if (!extension_loaded('curl')) { |
| 64 | 64 | $error[] = "Curl is not loaded."; |
| 65 | 65 | } |
| 66 | -if(function_exists('apache_get_modules') ){ |
|
| 67 | - if(!in_array('mod_rewrite',apache_get_modules())) { |
|
| 66 | +if (function_exists('apache_get_modules')) { |
|
| 67 | + if (!in_array('mod_rewrite', apache_get_modules())) { |
|
| 68 | 68 | $error[] = "mod_rewrite is not available."; |
| 69 | 69 | } |
| 70 | 70 | /* |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) { |
| 81 | 81 | if (function_exists('get_headers')) { |
| 82 | - $check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"]))); |
|
| 83 | - if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) { |
|
| 82 | + $check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"]))); |
|
| 83 | + if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) { |
|
| 84 | 84 | print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>'; |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -420,13 +420,13 @@ discard block |
||
| 420 | 420 | ?> |
| 421 | 421 | <tr> |
| 422 | 422 | <?php |
| 423 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
| 423 | + if (filter_var($source['host'], FILTER_VALIDATE_URL)) { |
|
| 424 | 424 | ?> |
| 425 | 425 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
| 426 | 426 | <td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td> |
| 427 | 427 | <?php |
| 428 | 428 | } else { |
| 429 | - $hostport = explode(':',$source['host']); |
|
| 429 | + $hostport = explode(':', $source['host']); |
|
| 430 | 430 | if (isset($hostport[1])) { |
| 431 | 431 | $host = $hostport[0]; |
| 432 | 432 | $port = $hostport[1]; |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | <br /> |
| 741 | 741 | <p> |
| 742 | 742 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
| 743 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
| 743 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" /> |
|
| 744 | 744 | </p> |
| 745 | 745 | <br /> |
| 746 | 746 | <p> |
@@ -786,14 +786,14 @@ discard block |
||
| 786 | 786 | $error = ''; |
| 787 | 787 | |
| 788 | 788 | if (isset($_POST['dbtype'])) { |
| 789 | - $dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING); |
|
| 790 | - $dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING); |
|
| 791 | - $dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING); |
|
| 792 | - $dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING); |
|
| 793 | - $dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING); |
|
| 794 | - $dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING); |
|
| 795 | - $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
|
| 796 | - $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
|
| 789 | + $dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING); |
|
| 790 | + $dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING); |
|
| 791 | + $dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING); |
|
| 792 | + $dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING); |
|
| 793 | + $dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING); |
|
| 794 | + $dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING); |
|
| 795 | + $dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING); |
|
| 796 | + $dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING); |
|
| 797 | 797 | |
| 798 | 798 | if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
| 799 | 799 | if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
@@ -813,48 +813,48 @@ discard block |
||
| 813 | 813 | } else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname)); |
| 814 | 814 | */ |
| 815 | 815 | |
| 816 | - $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname)); |
|
| 816 | + $settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname)); |
|
| 817 | 817 | |
| 818 | - $sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING); |
|
| 819 | - $siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING); |
|
| 820 | - $timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING); |
|
| 821 | - $language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING); |
|
| 822 | - $settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language)); |
|
| 818 | + $sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING); |
|
| 819 | + $siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING); |
|
| 820 | + $timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING); |
|
| 821 | + $language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING); |
|
| 822 | + $settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language)); |
|
| 823 | 823 | |
| 824 | - $mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING); |
|
| 825 | - $mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING); |
|
| 826 | - $mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING); |
|
| 827 | - $googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING); |
|
| 828 | - $bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING); |
|
| 829 | - $mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING); |
|
| 830 | - $hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING); |
|
| 831 | - $hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING); |
|
| 832 | - $settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey)); |
|
| 824 | + $mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING); |
|
| 825 | + $mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING); |
|
| 826 | + $mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING); |
|
| 827 | + $googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING); |
|
| 828 | + $bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING); |
|
| 829 | + $mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING); |
|
| 830 | + $hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING); |
|
| 831 | + $hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING); |
|
| 832 | + $settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey)); |
|
| 833 | 833 | |
| 834 | - $latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING); |
|
| 835 | - $latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING); |
|
| 836 | - $longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING); |
|
| 837 | - $longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING); |
|
| 838 | - $livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT); |
|
| 839 | - $settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom)); |
|
| 834 | + $latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING); |
|
| 835 | + $latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING); |
|
| 836 | + $longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING); |
|
| 837 | + $longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING); |
|
| 838 | + $livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT); |
|
| 839 | + $settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom)); |
|
| 840 | 840 | |
| 841 | - $squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING); |
|
| 842 | - $settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country)); |
|
| 841 | + $squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING); |
|
| 842 | + $settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country)); |
|
| 843 | 843 | |
| 844 | - $latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING); |
|
| 845 | - $longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING); |
|
| 846 | - $settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter)); |
|
| 844 | + $latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING); |
|
| 845 | + $longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING); |
|
| 846 | + $settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter)); |
|
| 847 | 847 | |
| 848 | - $acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING); |
|
| 848 | + $acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING); |
|
| 849 | 849 | if ($acars == 'acars') { |
| 850 | - $settings = array_merge($settings,array('globalACARS' => 'TRUE')); |
|
| 850 | + $settings = array_merge($settings, array('globalACARS' => 'TRUE')); |
|
| 851 | 851 | } else { |
| 852 | - $settings = array_merge($settings,array('globalACARS' => 'FALSE')); |
|
| 852 | + $settings = array_merge($settings, array('globalACARS' => 'FALSE')); |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | - $flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING); |
|
| 856 | - $flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING); |
|
| 857 | - $settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword)); |
|
| 855 | + $flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING); |
|
| 856 | + $flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING); |
|
| 857 | + $settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword)); |
|
| 858 | 858 | |
| 859 | 859 | $source_name = $_POST['source_name']; |
| 860 | 860 | $source_latitude = $_POST['source_latitude']; |
@@ -868,8 +868,8 @@ discard block |
||
| 868 | 868 | |
| 869 | 869 | $sources = array(); |
| 870 | 870 | foreach ($source_name as $keys => $name) { |
| 871 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 872 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 871 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]); |
|
| 872 | + else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]); |
|
| 873 | 873 | } |
| 874 | 874 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
| 875 | 875 | |
@@ -882,13 +882,13 @@ discard block |
||
| 882 | 882 | $sbsurl = $_POST['sbsurl']; |
| 883 | 883 | */ |
| 884 | 884 | |
| 885 | - $globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING); |
|
| 886 | - $globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING); |
|
| 887 | - $globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING); |
|
| 888 | - $globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING); |
|
| 889 | - $globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING); |
|
| 890 | - $globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING); |
|
| 891 | - $datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING); |
|
| 885 | + $globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING); |
|
| 886 | + $globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING); |
|
| 887 | + $globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING); |
|
| 888 | + $globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING); |
|
| 889 | + $globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING); |
|
| 890 | + $globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING); |
|
| 891 | + $datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING); |
|
| 892 | 892 | |
| 893 | 893 | /* |
| 894 | 894 | $globalSBS1Hosts = array(); |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | } |
| 905 | 905 | $settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts)); |
| 906 | 906 | */ |
| 907 | - $settings_comment = array_merge($settings_comment,array('globalSBS1Hosts')); |
|
| 907 | + $settings_comment = array_merge($settings_comment, array('globalSBS1Hosts')); |
|
| 908 | 908 | $host = $_POST['host']; |
| 909 | 909 | $port = $_POST['port']; |
| 910 | 910 | $name = $_POST['name']; |
@@ -915,88 +915,88 @@ discard block |
||
| 915 | 915 | foreach ($host as $key => $h) { |
| 916 | 916 | if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE'; |
| 917 | 917 | else $cov = 'FALSE'; |
| 918 | - if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov); |
|
| 918 | + if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov); |
|
| 919 | 919 | } |
| 920 | - $settings = array_merge($settings,array('globalSources' => $gSources)); |
|
| 920 | + $settings = array_merge($settings, array('globalSources' => $gSources)); |
|
| 921 | 921 | |
| 922 | - $sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT); |
|
| 923 | - $settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout)); |
|
| 922 | + $sbstimeout = filter_input(INPUT_POST, 'sbstimeout', FILTER_SANITIZE_NUMBER_INT); |
|
| 923 | + $settings = array_merge($settings, array('globalSourcesTimeOut' => $sbstimeout)); |
|
| 924 | 924 | |
| 925 | - $acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING); |
|
| 926 | - $acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT); |
|
| 927 | - $settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport)); |
|
| 925 | + $acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING); |
|
| 926 | + $acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT); |
|
| 927 | + $settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport)); |
|
| 928 | 928 | |
| 929 | - $bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING); |
|
| 930 | - $settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly)); |
|
| 929 | + $bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING); |
|
| 930 | + $settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly)); |
|
| 931 | 931 | |
| 932 | - $notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING); |
|
| 933 | - $settings = array_merge($settings,array('globalNOTAMSource' => $notamsource)); |
|
| 934 | - $metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING); |
|
| 935 | - $settings = array_merge($settings,array('globalMETARurl' => $metarsource)); |
|
| 932 | + $notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING); |
|
| 933 | + $settings = array_merge($settings, array('globalNOTAMSource' => $notamsource)); |
|
| 934 | + $metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING); |
|
| 935 | + $settings = array_merge($settings, array('globalMETARurl' => $metarsource)); |
|
| 936 | 936 | |
| 937 | - $zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING); |
|
| 938 | - $zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING); |
|
| 939 | - $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
|
| 937 | + $zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING); |
|
| 938 | + $zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING); |
|
| 939 | + $zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT); |
|
| 940 | 940 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
| 941 | - $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
|
| 942 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
| 941 | + $settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance))); |
|
| 942 | + } else $settings = array_merge($settings, array('globalDistanceIgnore' => array())); |
|
| 943 | 943 | |
| 944 | - $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
|
| 945 | - $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
|
| 946 | - $maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT); |
|
| 947 | - $settings = array_merge($settings,array('globalMapRefresh' => $maprefresh)); |
|
| 948 | - $mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT); |
|
| 949 | - $settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle)); |
|
| 950 | - $closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT); |
|
| 951 | - $settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist)); |
|
| 944 | + $refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT); |
|
| 945 | + $settings = array_merge($settings, array('globalLiveInterval' => $refresh)); |
|
| 946 | + $maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT); |
|
| 947 | + $settings = array_merge($settings, array('globalMapRefresh' => $maprefresh)); |
|
| 948 | + $mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT); |
|
| 949 | + $settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle)); |
|
| 950 | + $closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT); |
|
| 951 | + $settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist)); |
|
| 952 | 952 | |
| 953 | - $aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT); |
|
| 954 | - $settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize)); |
|
| 953 | + $aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT); |
|
| 954 | + $settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize)); |
|
| 955 | 955 | |
| 956 | - $archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT); |
|
| 957 | - $settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths)); |
|
| 956 | + $archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT); |
|
| 957 | + $settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths)); |
|
| 958 | 958 | |
| 959 | - $archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING); |
|
| 959 | + $archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING); |
|
| 960 | 960 | if ($archiveyear == "archiveyear") { |
| 961 | - $settings = array_merge($settings,array('globalArchiveYear' => 'TRUE')); |
|
| 961 | + $settings = array_merge($settings, array('globalArchiveYear' => 'TRUE')); |
|
| 962 | 962 | } else { |
| 963 | - $settings = array_merge($settings,array('globalArchiveYear' => 'FALSE')); |
|
| 963 | + $settings = array_merge($settings, array('globalArchiveYear' => 'FALSE')); |
|
| 964 | 964 | } |
| 965 | - $archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT); |
|
| 966 | - $settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths)); |
|
| 967 | - $archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT); |
|
| 968 | - $settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths)); |
|
| 965 | + $archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT); |
|
| 966 | + $settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths)); |
|
| 967 | + $archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT); |
|
| 968 | + $settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths)); |
|
| 969 | 969 | |
| 970 | - $britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING); |
|
| 971 | - $settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways)); |
|
| 972 | - $transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING); |
|
| 973 | - $settings = array_merge($settings,array('globalTransaviaKey' => $transavia)); |
|
| 970 | + $britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING); |
|
| 971 | + $settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways)); |
|
| 972 | + $transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING); |
|
| 973 | + $settings = array_merge($settings, array('globalTransaviaKey' => $transavia)); |
|
| 974 | 974 | |
| 975 | - $lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING); |
|
| 976 | - $lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING); |
|
| 977 | - $settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret))); |
|
| 975 | + $lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING); |
|
| 976 | + $lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING); |
|
| 977 | + $settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret))); |
|
| 978 | 978 | |
| 979 | 979 | // Create in settings.php keys not yet configurable if not already here |
| 980 | 980 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
| 981 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
| 981 | + if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE')); |
|
| 982 | 982 | |
| 983 | - $archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING); |
|
| 983 | + $archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING); |
|
| 984 | 984 | if ($archive == 'archive') { |
| 985 | - $settings = array_merge($settings,array('globalArchive' => 'TRUE')); |
|
| 985 | + $settings = array_merge($settings, array('globalArchive' => 'TRUE')); |
|
| 986 | 986 | } else { |
| 987 | - $settings = array_merge($settings,array('globalArchive' => 'FALSE')); |
|
| 987 | + $settings = array_merge($settings, array('globalArchive' => 'FALSE')); |
|
| 988 | 988 | } |
| 989 | - $daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING); |
|
| 989 | + $daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING); |
|
| 990 | 990 | if ($daemon == 'daemon') { |
| 991 | - $settings = array_merge($settings,array('globalDaemon' => 'TRUE')); |
|
| 991 | + $settings = array_merge($settings, array('globalDaemon' => 'TRUE')); |
|
| 992 | 992 | } else { |
| 993 | - $settings = array_merge($settings,array('globalDaemon' => 'FALSE')); |
|
| 993 | + $settings = array_merge($settings, array('globalDaemon' => 'FALSE')); |
|
| 994 | 994 | } |
| 995 | - $schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING); |
|
| 995 | + $schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING); |
|
| 996 | 996 | if ($schedules == 'schedules') { |
| 997 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE')); |
|
| 997 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE')); |
|
| 998 | 998 | } else { |
| 999 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE')); |
|
| 999 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE')); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /* |
@@ -1007,165 +1007,165 @@ discard block |
||
| 1007 | 1007 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE')); |
| 1008 | 1008 | } |
| 1009 | 1009 | */ |
| 1010 | - $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
|
| 1011 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
| 1012 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
| 1013 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
| 1014 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
| 1010 | + $settings = array_merge($settings, array('globalFlightAware' => 'FALSE')); |
|
| 1011 | + if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE')); |
|
| 1012 | + else $settings = array_merge($settings, array('globalSBS1' => 'FALSE')); |
|
| 1013 | + if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE')); |
|
| 1014 | + else $settings = array_merge($settings, array('globalAPRS' => 'FALSE')); |
|
| 1015 | 1015 | if ($globalivao == 'ivao') { |
| 1016 | 1016 | //$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE')); |
| 1017 | - $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
|
| 1018 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
| 1017 | + $settings = array_merge($settings, array('globalIVAO' => 'TRUE')); |
|
| 1018 | + } else $settings = array_merge($settings, array('globalIVAO' => 'FALSE')); |
|
| 1019 | 1019 | if ($globalvatsim == 'vatsim') { |
| 1020 | 1020 | //$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE')); |
| 1021 | - $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
|
| 1022 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
| 1021 | + $settings = array_merge($settings, array('globalVATSIM' => 'TRUE')); |
|
| 1022 | + } else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE')); |
|
| 1023 | 1023 | if ($globalphpvms == 'phpvms') { |
| 1024 | - $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
|
| 1025 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
| 1024 | + $settings = array_merge($settings, array('globalphpVMS' => 'TRUE')); |
|
| 1025 | + } else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE')); |
|
| 1026 | 1026 | if ($globalvam == 'vam') { |
| 1027 | - $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
|
| 1028 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
| 1027 | + $settings = array_merge($settings, array('globalVAM' => 'TRUE')); |
|
| 1028 | + } else $settings = array_merge($settings, array('globalVAM' => 'FALSE')); |
|
| 1029 | 1029 | if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') { |
| 1030 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
|
| 1031 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
| 1030 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE')); |
|
| 1031 | + } else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE')); |
|
| 1032 | 1032 | |
| 1033 | 1033 | |
| 1034 | 1034 | |
| 1035 | - $notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING); |
|
| 1035 | + $notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING); |
|
| 1036 | 1036 | if ($notam == 'notam') { |
| 1037 | - $settings = array_merge($settings,array('globalNOTAM' => 'TRUE')); |
|
| 1037 | + $settings = array_merge($settings, array('globalNOTAM' => 'TRUE')); |
|
| 1038 | 1038 | } else { |
| 1039 | - $settings = array_merge($settings,array('globalNOTAM' => 'FALSE')); |
|
| 1039 | + $settings = array_merge($settings, array('globalNOTAM' => 'FALSE')); |
|
| 1040 | 1040 | } |
| 1041 | - $owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING); |
|
| 1041 | + $owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING); |
|
| 1042 | 1042 | if ($owner == 'owner') { |
| 1043 | - $settings = array_merge($settings,array('globalOwner' => 'TRUE')); |
|
| 1043 | + $settings = array_merge($settings, array('globalOwner' => 'TRUE')); |
|
| 1044 | 1044 | } else { |
| 1045 | - $settings = array_merge($settings,array('globalOwner' => 'FALSE')); |
|
| 1045 | + $settings = array_merge($settings, array('globalOwner' => 'FALSE')); |
|
| 1046 | 1046 | } |
| 1047 | - $map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING); |
|
| 1047 | + $map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING); |
|
| 1048 | 1048 | if ($map3d == 'map3d') { |
| 1049 | - $settings = array_merge($settings,array('globalMap3D' => 'TRUE')); |
|
| 1049 | + $settings = array_merge($settings, array('globalMap3D' => 'TRUE')); |
|
| 1050 | 1050 | } else { |
| 1051 | - $settings = array_merge($settings,array('globalMap3D' => 'FALSE')); |
|
| 1051 | + $settings = array_merge($settings, array('globalMap3D' => 'FALSE')); |
|
| 1052 | 1052 | } |
| 1053 | - $mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING); |
|
| 1053 | + $mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING); |
|
| 1054 | 1054 | if ($mapsatellites == 'mapsatellites') { |
| 1055 | - $settings = array_merge($settings,array('globalMapSatellites' => 'TRUE')); |
|
| 1055 | + $settings = array_merge($settings, array('globalMapSatellites' => 'TRUE')); |
|
| 1056 | 1056 | } else { |
| 1057 | - $settings = array_merge($settings,array('globalMapSatellites' => 'FALSE')); |
|
| 1057 | + $settings = array_merge($settings, array('globalMapSatellites' => 'FALSE')); |
|
| 1058 | 1058 | } |
| 1059 | - $map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING); |
|
| 1059 | + $map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING); |
|
| 1060 | 1060 | if ($map3ddefault == 'map3ddefault') { |
| 1061 | - $settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE')); |
|
| 1061 | + $settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE')); |
|
| 1062 | 1062 | } else { |
| 1063 | - $settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE')); |
|
| 1063 | + $settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE')); |
|
| 1064 | 1064 | } |
| 1065 | - $translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING); |
|
| 1065 | + $translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING); |
|
| 1066 | 1066 | if ($translate == 'translate') { |
| 1067 | - $settings = array_merge($settings,array('globalTranslate' => 'TRUE')); |
|
| 1067 | + $settings = array_merge($settings, array('globalTranslate' => 'TRUE')); |
|
| 1068 | 1068 | } else { |
| 1069 | - $settings = array_merge($settings,array('globalTranslate' => 'FALSE')); |
|
| 1069 | + $settings = array_merge($settings, array('globalTranslate' => 'FALSE')); |
|
| 1070 | 1070 | } |
| 1071 | - $realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING); |
|
| 1071 | + $realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING); |
|
| 1072 | 1072 | if ($realairlines == 'realairlines') { |
| 1073 | - $settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE')); |
|
| 1073 | + $settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE')); |
|
| 1074 | 1074 | } else { |
| 1075 | - $settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE')); |
|
| 1075 | + $settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE')); |
|
| 1076 | 1076 | } |
| 1077 | - $estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING); |
|
| 1077 | + $estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING); |
|
| 1078 | 1078 | if ($estimation == 'estimation') { |
| 1079 | - $settings = array_merge($settings,array('globalMapEstimation' => 'TRUE')); |
|
| 1079 | + $settings = array_merge($settings, array('globalMapEstimation' => 'TRUE')); |
|
| 1080 | 1080 | } else { |
| 1081 | - $settings = array_merge($settings,array('globalMapEstimation' => 'FALSE')); |
|
| 1081 | + $settings = array_merge($settings, array('globalMapEstimation' => 'FALSE')); |
|
| 1082 | 1082 | } |
| 1083 | - $metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING); |
|
| 1083 | + $metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING); |
|
| 1084 | 1084 | if ($metar == 'metar') { |
| 1085 | - $settings = array_merge($settings,array('globalMETAR' => 'TRUE')); |
|
| 1085 | + $settings = array_merge($settings, array('globalMETAR' => 'TRUE')); |
|
| 1086 | 1086 | } else { |
| 1087 | - $settings = array_merge($settings,array('globalMETAR' => 'FALSE')); |
|
| 1087 | + $settings = array_merge($settings, array('globalMETAR' => 'FALSE')); |
|
| 1088 | 1088 | } |
| 1089 | - $metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING); |
|
| 1089 | + $metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING); |
|
| 1090 | 1090 | if ($metarcycle == 'metarcycle') { |
| 1091 | - $settings = array_merge($settings,array('globalMETARcycle' => 'TRUE')); |
|
| 1091 | + $settings = array_merge($settings, array('globalMETARcycle' => 'TRUE')); |
|
| 1092 | 1092 | } else { |
| 1093 | - $settings = array_merge($settings,array('globalMETARcycle' => 'FALSE')); |
|
| 1093 | + $settings = array_merge($settings, array('globalMETARcycle' => 'FALSE')); |
|
| 1094 | 1094 | } |
| 1095 | - $fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING); |
|
| 1095 | + $fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING); |
|
| 1096 | 1096 | if ($fork == 'fork') { |
| 1097 | - $settings = array_merge($settings,array('globalFork' => 'TRUE')); |
|
| 1097 | + $settings = array_merge($settings, array('globalFork' => 'TRUE')); |
|
| 1098 | 1098 | } else { |
| 1099 | - $settings = array_merge($settings,array('globalFork' => 'FALSE')); |
|
| 1099 | + $settings = array_merge($settings, array('globalFork' => 'FALSE')); |
|
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | - $colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING); |
|
| 1102 | + $colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING); |
|
| 1103 | 1103 | if ($colormap == 'colormap') { |
| 1104 | - $settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE')); |
|
| 1104 | + $settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE')); |
|
| 1105 | 1105 | } else { |
| 1106 | - $settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE')); |
|
| 1106 | + $settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE')); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | if (isset($_POST['aircrafticoncolor'])) { |
| 1110 | - $aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING); |
|
| 1111 | - $settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1))); |
|
| 1110 | + $aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING); |
|
| 1111 | + $settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1))); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - $airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT); |
|
| 1115 | - $settings = array_merge($settings,array('globalAirportZoom' => $airportzoom)); |
|
| 1114 | + $airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT); |
|
| 1115 | + $settings = array_merge($settings, array('globalAirportZoom' => $airportzoom)); |
|
| 1116 | 1116 | |
| 1117 | - $unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING); |
|
| 1118 | - $settings = array_merge($settings,array('globalUnitDistance' => $unitdistance)); |
|
| 1119 | - $unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING); |
|
| 1120 | - $settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude)); |
|
| 1121 | - $unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING); |
|
| 1122 | - $settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed)); |
|
| 1117 | + $unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING); |
|
| 1118 | + $settings = array_merge($settings, array('globalUnitDistance' => $unitdistance)); |
|
| 1119 | + $unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING); |
|
| 1120 | + $settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude)); |
|
| 1121 | + $unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING); |
|
| 1122 | + $settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed)); |
|
| 1123 | 1123 | |
| 1124 | - $mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING); |
|
| 1124 | + $mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING); |
|
| 1125 | 1125 | if ($mappopup == 'mappopup') { |
| 1126 | - $settings = array_merge($settings,array('globalMapPopup' => 'TRUE')); |
|
| 1126 | + $settings = array_merge($settings, array('globalMapPopup' => 'TRUE')); |
|
| 1127 | 1127 | } else { |
| 1128 | - $settings = array_merge($settings,array('globalMapPopup' => 'FALSE')); |
|
| 1128 | + $settings = array_merge($settings, array('globalMapPopup' => 'FALSE')); |
|
| 1129 | 1129 | } |
| 1130 | - $airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING); |
|
| 1130 | + $airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING); |
|
| 1131 | 1131 | if ($airportpopup == 'airportpopup') { |
| 1132 | - $settings = array_merge($settings,array('globalAirportPopup' => 'TRUE')); |
|
| 1132 | + $settings = array_merge($settings, array('globalAirportPopup' => 'TRUE')); |
|
| 1133 | 1133 | } else { |
| 1134 | - $settings = array_merge($settings,array('globalAirportPopup' => 'FALSE')); |
|
| 1134 | + $settings = array_merge($settings, array('globalAirportPopup' => 'FALSE')); |
|
| 1135 | 1135 | } |
| 1136 | - $maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING); |
|
| 1136 | + $maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING); |
|
| 1137 | 1137 | if ($maphistory == 'maphistory') { |
| 1138 | - $settings = array_merge($settings,array('globalMapHistory' => 'TRUE')); |
|
| 1138 | + $settings = array_merge($settings, array('globalMapHistory' => 'TRUE')); |
|
| 1139 | 1139 | } else { |
| 1140 | - $settings = array_merge($settings,array('globalMapHistory' => 'FALSE')); |
|
| 1140 | + $settings = array_merge($settings, array('globalMapHistory' => 'FALSE')); |
|
| 1141 | 1141 | } |
| 1142 | - $flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING); |
|
| 1142 | + $flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING); |
|
| 1143 | 1143 | if ($flightroute == 'flightroute') { |
| 1144 | - $settings = array_merge($settings,array('globalMapRoute' => 'TRUE')); |
|
| 1144 | + $settings = array_merge($settings, array('globalMapRoute' => 'TRUE')); |
|
| 1145 | 1145 | } else { |
| 1146 | - $settings = array_merge($settings,array('globalMapRoute' => 'FALSE')); |
|
| 1146 | + $settings = array_merge($settings, array('globalMapRoute' => 'FALSE')); |
|
| 1147 | 1147 | } |
| 1148 | - $waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING); |
|
| 1148 | + $waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING); |
|
| 1149 | 1149 | if ($waypoints == 'waypoints') { |
| 1150 | - $settings = array_merge($settings,array('globalWaypoints' => 'TRUE')); |
|
| 1150 | + $settings = array_merge($settings, array('globalWaypoints' => 'TRUE')); |
|
| 1151 | 1151 | } else { |
| 1152 | - $settings = array_merge($settings,array('globalWaypoints' => 'FALSE')); |
|
| 1152 | + $settings = array_merge($settings, array('globalWaypoints' => 'FALSE')); |
|
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
| 1155 | + if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE')); |
|
| 1156 | 1156 | |
| 1157 | 1157 | // Set some defaults values... |
| 1158 | 1158 | if (!isset($globalAircraftImageSources)) { |
| 1159 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 1160 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
| 1159 | + $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
| 1160 | + $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | if (!isset($globalSchedulesSources)) { |
| 1164 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1165 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
| 1164 | + $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
| 1165 | + $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources)); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | - $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
|
| 1168 | + $settings = array_merge($settings, array('globalInstalled' => 'TRUE')); |
|
| 1169 | 1169 | |
| 1170 | 1170 | if ($error == '') settings::modify_settings($settings); |
| 1171 | 1171 | if ($error == '') settings::comment_settings($settings_comment); |
@@ -124,45 +124,72 @@ discard block |
||
| 124 | 124 | </div> |
| 125 | 125 | <p> |
| 126 | 126 | <label for="dbhost">Database hostname</label> |
| 127 | - <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" /> |
|
| 127 | + <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) { |
|
| 128 | + print $globalDBhost; |
|
| 129 | +} |
|
| 130 | +?>" /> |
|
| 128 | 131 | </p> |
| 129 | 132 | <p> |
| 130 | 133 | <label for="dbport">Database port</label> |
| 131 | - <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" /> |
|
| 134 | + <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) { |
|
| 135 | + print $globalDBport; |
|
| 136 | +} |
|
| 137 | +?>" /> |
|
| 132 | 138 | <p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p> |
| 133 | 139 | </p> |
| 134 | 140 | <p> |
| 135 | 141 | <label for="dbname">Database name</label> |
| 136 | - <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" /> |
|
| 142 | + <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) { |
|
| 143 | + print $globalDBname; |
|
| 144 | +} |
|
| 145 | +?>" /> |
|
| 137 | 146 | </p> |
| 138 | 147 | <p> |
| 139 | 148 | <label for="dbuser">Database user</label> |
| 140 | - <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" /> |
|
| 149 | + <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) { |
|
| 150 | + print $globalDBuser; |
|
| 151 | +} |
|
| 152 | +?>" /> |
|
| 141 | 153 | </p> |
| 142 | 154 | <p> |
| 143 | 155 | <label for="dbuserpass">Database user password</label> |
| 144 | - <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" /> |
|
| 156 | + <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) { |
|
| 157 | + print $globalDBpass; |
|
| 158 | +} |
|
| 159 | +?>" /> |
|
| 145 | 160 | </p> |
| 146 | 161 | </fieldset> |
| 147 | 162 | <fieldset id="site"> |
| 148 | 163 | <legend>Site configuration</legend> |
| 149 | 164 | <p> |
| 150 | 165 | <label for="sitename">Site name</label> |
| 151 | - <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" /> |
|
| 166 | + <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) { |
|
| 167 | + print $globalName; |
|
| 168 | +} |
|
| 169 | +?>" /> |
|
| 152 | 170 | </p> |
| 153 | 171 | <p> |
| 154 | 172 | <label for="siteurl">Site directory</label> |
| 155 | - <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" /> |
|
| 173 | + <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) { |
|
| 174 | + print $globalURL; |
|
| 175 | +} |
|
| 176 | +?>" /> |
|
| 156 | 177 | <p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p> |
| 157 | 178 | </p> |
| 158 | 179 | <p> |
| 159 | 180 | <label for="timezone">Timezone</label> |
| 160 | - <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" /> |
|
| 181 | + <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) { |
|
| 182 | + print $globalTimezone; |
|
| 183 | +} |
|
| 184 | +?>" /> |
|
| 161 | 185 | <p class="help-block">ex : UTC, Europe/Paris,...</p> |
| 162 | 186 | </p> |
| 163 | 187 | <p> |
| 164 | 188 | <label for="language">Language</label> |
| 165 | - <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" /> |
|
| 189 | + <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) { |
|
| 190 | + print $globalLanguage; |
|
| 191 | +} |
|
| 192 | +?>" /> |
|
| 166 | 193 | <p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p> |
| 167 | 194 | </p> |
| 168 | 195 | </fieldset> |
@@ -183,11 +210,17 @@ discard block |
||
| 183 | 210 | <div id="mapbox_data"> |
| 184 | 211 | <p> |
| 185 | 212 | <label for="mapboxid">Mapbox id</label> |
| 186 | - <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" /> |
|
| 213 | + <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) { |
|
| 214 | + print $globalMapboxId; |
|
| 215 | +} |
|
| 216 | +?>" /> |
|
| 187 | 217 | </p> |
| 188 | 218 | <p> |
| 189 | 219 | <label for="mapboxtoken">Mapbox token</label> |
| 190 | - <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" /> |
|
| 220 | + <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) { |
|
| 221 | + print $globalMapboxToken; |
|
| 222 | +} |
|
| 223 | +?>" /> |
|
| 191 | 224 | </p> |
| 192 | 225 | <p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p> |
| 193 | 226 | </div> |
@@ -195,7 +228,10 @@ discard block |
||
| 195 | 228 | <div id="google_data"> |
| 196 | 229 | <p> |
| 197 | 230 | <label for="googlekey">Google API key</label> |
| 198 | - <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" /> |
|
| 231 | + <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) { |
|
| 232 | + print $globalGoogleAPIKey; |
|
| 233 | +} |
|
| 234 | +?>" /> |
|
| 199 | 235 | <p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p> |
| 200 | 236 | </p> |
| 201 | 237 | </div> |
@@ -203,7 +239,10 @@ discard block |
||
| 203 | 239 | <div id="bing_data"> |
| 204 | 240 | <p> |
| 205 | 241 | <label for="bingkey">Bing Map key</label> |
| 206 | - <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" /> |
|
| 242 | + <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) { |
|
| 243 | + print $globalBingMapKey; |
|
| 244 | +} |
|
| 245 | +?>" /> |
|
| 207 | 246 | <p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p> |
| 208 | 247 | </p> |
| 209 | 248 | </div> |
@@ -211,7 +250,10 @@ discard block |
||
| 211 | 250 | <div id="mapquest_data"> |
| 212 | 251 | <p> |
| 213 | 252 | <label for="mapquestkey">MapQuest key</label> |
| 214 | - <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" /> |
|
| 253 | + <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) { |
|
| 254 | + print $globalMapQuestKey; |
|
| 255 | +} |
|
| 256 | +?>" /> |
|
| 215 | 257 | <p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p> |
| 216 | 258 | </p> |
| 217 | 259 | </div> |
@@ -219,11 +261,17 @@ discard block |
||
| 219 | 261 | <div id="here_data"> |
| 220 | 262 | <p> |
| 221 | 263 | <label for="hereappid">Here App_Id</label> |
| 222 | - <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" /> |
|
| 264 | + <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) { |
|
| 265 | + print $globalHereappId; |
|
| 266 | +} |
|
| 267 | +?>" /> |
|
| 223 | 268 | </p> |
| 224 | 269 | <p> |
| 225 | 270 | <label for="hereappcode">Here App_Code</label> |
| 226 | - <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" /> |
|
| 271 | + <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) { |
|
| 272 | + print $globalHereappCode; |
|
| 273 | +} |
|
| 274 | +?>" /> |
|
| 227 | 275 | </p> |
| 228 | 276 | <p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p> |
| 229 | 277 | </div> |
@@ -232,42 +280,86 @@ discard block |
||
| 232 | 280 | <legend>Coverage area</legend> |
| 233 | 281 | <p> |
| 234 | 282 | <label for="latitudemax">The maximum latitude (north)</label> |
| 235 | - <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" /> |
|
| 283 | + <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) { |
|
| 284 | + print $globalLatitudeMax; |
|
| 285 | +} |
|
| 286 | +?>" /> |
|
| 236 | 287 | </p> |
| 237 | 288 | <p> |
| 238 | 289 | <label for="latitudemin">The minimum latitude (south)</label> |
| 239 | - <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" /> |
|
| 290 | + <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) { |
|
| 291 | + print $globalLatitudeMin; |
|
| 292 | +} |
|
| 293 | +?>" /> |
|
| 240 | 294 | </p> |
| 241 | 295 | <p> |
| 242 | 296 | <label for="longitudemax">The maximum longitude (west)</label> |
| 243 | - <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" /> |
|
| 297 | + <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) { |
|
| 298 | + print $globalLongitudeMax; |
|
| 299 | +} |
|
| 300 | +?>" /> |
|
| 244 | 301 | </p> |
| 245 | 302 | <p> |
| 246 | 303 | <label for="longitudemin">The minimum longitude (east)</label> |
| 247 | - <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" /> |
|
| 304 | + <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) { |
|
| 305 | + print $globalLongitudeMin; |
|
| 306 | +} |
|
| 307 | +?>" /> |
|
| 248 | 308 | </p> |
| 249 | 309 | <p> |
| 250 | 310 | <label for="latitudecenter">The latitude center</label> |
| 251 | - <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" /> |
|
| 311 | + <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) { |
|
| 312 | + print $globalCenterLatitude; |
|
| 313 | +} |
|
| 314 | +?>" /> |
|
| 252 | 315 | </p> |
| 253 | 316 | <p> |
| 254 | 317 | <label for="longitudecenter">The longitude center</label> |
| 255 | - <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" /> |
|
| 318 | + <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) { |
|
| 319 | + print $globalCenterLongitude; |
|
| 320 | +} |
|
| 321 | +?>" /> |
|
| 256 | 322 | </p> |
| 257 | 323 | <p> |
| 258 | 324 | <label for="livezoom">Default Zoom on live map</label> |
| 259 | - <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" /> |
|
| 325 | + <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) { |
|
| 326 | + print $globalLiveZoom; |
|
| 327 | +} else { |
|
| 328 | + print '9'; |
|
| 329 | +} |
|
| 330 | +?>" /> |
|
| 260 | 331 | </p> |
| 261 | 332 | <p> |
| 262 | 333 | <label for="squawk_country">Country for squawk usage</label> |
| 263 | 334 | <select name="squawk_country" id="squawk_country"> |
| 264 | - <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option> |
|
| 265 | - <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option> |
|
| 266 | - <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option> |
|
| 267 | - <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option> |
|
| 268 | - <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option> |
|
| 269 | - <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option> |
|
| 270 | - <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option> |
|
| 335 | + <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') { |
|
| 336 | + print ' selected '; |
|
| 337 | +} |
|
| 338 | +?>>UK</option> |
|
| 339 | + <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') { |
|
| 340 | + print ' selected '; |
|
| 341 | +} |
|
| 342 | +?>>NZ</option> |
|
| 343 | + <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') { |
|
| 344 | + print ' selected '; |
|
| 345 | +} |
|
| 346 | +?>>US</option> |
|
| 347 | + <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') { |
|
| 348 | + print ' selected '; |
|
| 349 | +} |
|
| 350 | +?>>AU</option> |
|
| 351 | + <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') { |
|
| 352 | + print ' selected '; |
|
| 353 | +} |
|
| 354 | +?>>NL</option> |
|
| 355 | + <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') { |
|
| 356 | + print ' selected '; |
|
| 357 | +} |
|
| 358 | +?>>FR</option> |
|
| 359 | + <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') { |
|
| 360 | + print ' selected '; |
|
| 361 | +} |
|
| 362 | +?>>TR</option> |
|
| 271 | 363 | </select> |
| 272 | 364 | </p> |
| 273 | 365 | </fieldset> |
@@ -276,15 +368,24 @@ discard block |
||
| 276 | 368 | <p><i>Only put in DB flights that are inside a circle</i></p> |
| 277 | 369 | <p> |
| 278 | 370 | <label for="latitude">Center latitude</label> |
| 279 | - <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" /> |
|
| 371 | + <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) { |
|
| 372 | + echo $globalDistanceIgnore['latitude']; |
|
| 373 | +} |
|
| 374 | +?>" /> |
|
| 280 | 375 | </p> |
| 281 | 376 | <p> |
| 282 | 377 | <label for="longitude">Center longitude</label> |
| 283 | - <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" /> |
|
| 378 | + <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) { |
|
| 379 | + echo $globalDistanceIgnore['longitude']; |
|
| 380 | +} |
|
| 381 | +?>" /> |
|
| 284 | 382 | </p> |
| 285 | 383 | <p> |
| 286 | 384 | <label for="Distance">Distance (in km)</label> |
| 287 | - <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" /> |
|
| 385 | + <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) { |
|
| 386 | + echo $globalDistanceIgnore['distance']; |
|
| 387 | +} |
|
| 388 | +?>" /> |
|
| 288 | 389 | </p> |
| 289 | 390 | </fieldset> |
| 290 | 391 | <fieldset id="sourceloc"> |
@@ -379,11 +480,17 @@ discard block |
||
| 379 | 480 | <div id="flightaware_data"> |
| 380 | 481 | <p> |
| 381 | 482 | <label for="flightawareusername">FlightAware username</label> |
| 382 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
| 483 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
| 484 | + print $globalFlightAwareUsername; |
|
| 485 | +} |
|
| 486 | +?>" /> |
|
| 383 | 487 | </p> |
| 384 | 488 | <p> |
| 385 | 489 | <label for="flightawarepassword">FlightAware password/API key</label> |
| 386 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
| 490 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
| 491 | + print $globalFlightAwarePassword; |
|
| 492 | +} |
|
| 493 | +?>" /> |
|
| 387 | 494 | </p> |
| 388 | 495 | </div> |
| 389 | 496 | --> |
@@ -442,23 +549,68 @@ discard block |
||
| 442 | 549 | ?> |
| 443 | 550 | <td> |
| 444 | 551 | <select name="format[]" id="format"> |
| 445 | - <option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option> |
|
| 446 | - <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option> |
|
| 447 | - <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option> |
|
| 448 | - <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option> |
|
| 449 | - <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option> |
|
| 450 | - <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option> |
|
| 451 | - <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option> |
|
| 452 | - <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server</option> |
|
| 453 | - <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option> |
|
| 454 | - <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option> |
|
| 455 | - <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option> |
|
| 456 | - <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option> |
|
| 457 | - <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option> |
|
| 552 | + <option value="auto" <?php if (!isset($source['format'])) { |
|
| 553 | + print 'selected'; |
|
| 554 | +} |
|
| 555 | +?>>Auto</option> |
|
| 556 | + <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') { |
|
| 557 | + print 'selected'; |
|
| 558 | +} |
|
| 559 | +?>>SBS</option> |
|
| 560 | + <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') { |
|
| 561 | + print 'selected'; |
|
| 562 | +} |
|
| 563 | +?>>TSV</option> |
|
| 564 | + <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') { |
|
| 565 | + print 'selected'; |
|
| 566 | +} |
|
| 567 | +?>>Raw</option> |
|
| 568 | + <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 569 | + print 'selected'; |
|
| 570 | +} |
|
| 571 | +?>>APRS</option> |
|
| 572 | + <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') { |
|
| 573 | + print 'selected'; |
|
| 574 | +} |
|
| 575 | +?>>Radarcape deltadb.txt</option> |
|
| 576 | + <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') { |
|
| 577 | + print 'selected'; |
|
| 578 | +} |
|
| 579 | +?>>Vatsim</option> |
|
| 580 | + <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') { |
|
| 581 | + print 'selected'; |
|
| 582 | +} |
|
| 583 | +?>>Virtual Radar Server</option> |
|
| 584 | + <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
| 585 | + print 'selected'; |
|
| 586 | +} |
|
| 587 | +?>>phpVMS</option> |
|
| 588 | + <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') { |
|
| 589 | + print 'selected'; |
|
| 590 | +} |
|
| 591 | +?>>Virtual Airlines Manager</option> |
|
| 592 | + <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') { |
|
| 593 | + print 'selected'; |
|
| 594 | +} |
|
| 595 | +?>>IVAO</option> |
|
| 596 | + <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') { |
|
| 597 | + print 'selected'; |
|
| 598 | +} |
|
| 599 | +?>>FlightGear Multiplayer</option> |
|
| 600 | + <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') { |
|
| 601 | + print 'selected'; |
|
| 602 | +} |
|
| 603 | +?>>FlightGear Singleplayer</option> |
|
| 458 | 604 | </select> |
| 459 | 605 | </td> |
| 460 | - <td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td> |
|
| 461 | - <td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td> |
|
| 606 | + <td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) { |
|
| 607 | + print $source['name']; |
|
| 608 | +} |
|
| 609 | +?>" /></td> |
|
| 610 | + <td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) { |
|
| 611 | + print 'checked'; |
|
| 612 | +} |
|
| 613 | +?> /></td> |
|
| 462 | 614 | <td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td> |
| 463 | 615 | </tr> |
| 464 | 616 | <?php |
@@ -502,11 +654,17 @@ discard block |
||
| 502 | 654 | <p>Listen UDP server for acarsdec/acarsdeco2/...</p> |
| 503 | 655 | <p> |
| 504 | 656 | <label for="acarshost">ACARS UDP host</label> |
| 505 | - <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" /> |
|
| 657 | + <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) { |
|
| 658 | + print $globalACARSHost; |
|
| 659 | +} |
|
| 660 | +?>" /> |
|
| 506 | 661 | </p> |
| 507 | 662 | <p> |
| 508 | 663 | <label for="acarsport">ACARS UDP port</label> |
| 509 | - <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" /> |
|
| 664 | + <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) { |
|
| 665 | + print $globalACARSPort; |
|
| 666 | +} |
|
| 667 | +?>" /> |
|
| 510 | 668 | </p> |
| 511 | 669 | </fieldset> |
| 512 | 670 | </div> |
@@ -581,13 +739,19 @@ discard block |
||
| 581 | 739 | <div id="schedules_options"> |
| 582 | 740 | <p> |
| 583 | 741 | <label for="britishairways">British Airways API Key</label> |
| 584 | - <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" /> |
|
| 742 | + <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) { |
|
| 743 | + print $globalBritishAirwaysKey; |
|
| 744 | +} |
|
| 745 | +?>" /> |
|
| 585 | 746 | <p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p> |
| 586 | 747 | </p> |
| 587 | 748 | <!-- |
| 588 | 749 | <p> |
| 589 | 750 | <label for="transavia">Transavia Test API Consumer Key</label> |
| 590 | - <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" /> |
|
| 751 | + <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) { |
|
| 752 | + print $globalTransaviaKey; |
|
| 753 | +} |
|
| 754 | +?>" /> |
|
| 591 | 755 | <p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p> |
| 592 | 756 | </p> |
| 593 | 757 | --> |
@@ -596,10 +760,16 @@ discard block |
||
| 596 | 760 | <b>Lufthansa API Key</b> |
| 597 | 761 | <p> |
| 598 | 762 | <label for="lufthansakey">Key</label> |
| 599 | - <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" /> |
|
| 763 | + <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) { |
|
| 764 | + print $globalLufthansaKey['key']; |
|
| 765 | +} |
|
| 766 | +?>" /> |
|
| 600 | 767 | </p><p> |
| 601 | 768 | <label for="lufthansasecret">Secret</label> |
| 602 | - <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" /> |
|
| 769 | + <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) { |
|
| 770 | + print $globalLufthansaKey['secret']; |
|
| 771 | +} |
|
| 772 | +?>" /> |
|
| 603 | 773 | </p> |
| 604 | 774 | </div> |
| 605 | 775 | <p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p> |
@@ -619,7 +789,10 @@ discard block |
||
| 619 | 789 | </p> |
| 620 | 790 | <p> |
| 621 | 791 | <label for="notamsource">URL of your feed from notaminfo.com</label> |
| 622 | - <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" /> |
|
| 792 | + <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) { |
|
| 793 | + print $globalNOTAMSource; |
|
| 794 | +} |
|
| 795 | +?>" /> |
|
| 623 | 796 | <p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p> |
| 624 | 797 | </p> |
| 625 | 798 | <br /> |
@@ -635,14 +808,20 @@ discard block |
||
| 635 | 808 | <div id="metarsrc"> |
| 636 | 809 | <p> |
| 637 | 810 | <label for="metarsource">URL of your METAR source</label> |
| 638 | - <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" /> |
|
| 811 | + <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) { |
|
| 812 | + print $globalMETARurl; |
|
| 813 | +} |
|
| 814 | +?>" /> |
|
| 639 | 815 | <p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p> |
| 640 | 816 | </p> |
| 641 | 817 | </div> |
| 642 | 818 | <br /> |
| 643 | 819 | <p> |
| 644 | 820 | <label for="bitly">Bit.ly access token api (used in search page)</label> |
| 645 | - <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" /> |
|
| 821 | + <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) { |
|
| 822 | + print $globalBitlyAccessToken; |
|
| 823 | +} |
|
| 824 | +?>" /> |
|
| 646 | 825 | </p> |
| 647 | 826 | <br /> |
| 648 | 827 | <p> |
@@ -656,7 +835,12 @@ discard block |
||
| 656 | 835 | </p> |
| 657 | 836 | <p> |
| 658 | 837 | <label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label> |
| 659 | - <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" /> |
|
| 838 | + <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) { |
|
| 839 | + print $globalArchiveMonths; |
|
| 840 | +} else { |
|
| 841 | + echo '0'; |
|
| 842 | +} |
|
| 843 | +?>" /> |
|
| 660 | 844 | <p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p> |
| 661 | 845 | </p> |
| 662 | 846 | <p> |
@@ -666,12 +850,22 @@ discard block |
||
| 666 | 850 | </p> |
| 667 | 851 | <p> |
| 668 | 852 | <label for="archivekeepmonths">Keep flights data for xx months in archive</label> |
| 669 | - <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" /> |
|
| 853 | + <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) { |
|
| 854 | + print $globalArchiveKeepMonths; |
|
| 855 | +} else { |
|
| 856 | + echo '0'; |
|
| 857 | +} |
|
| 858 | +?>" /> |
|
| 670 | 859 | <p class="help-block">0 to disable</p> |
| 671 | 860 | </p> |
| 672 | 861 | <p> |
| 673 | 862 | <label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label> |
| 674 | - <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" /> |
|
| 863 | + <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) { |
|
| 864 | + print $globalArchiveKeepTrackMonths; |
|
| 865 | +} else { |
|
| 866 | + echo '0'; |
|
| 867 | +} |
|
| 868 | +?>" /> |
|
| 675 | 869 | <p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p> |
| 676 | 870 | </p> |
| 677 | 871 | <br /> |
@@ -681,7 +875,12 @@ discard block |
||
| 681 | 875 | <p class="help-block">Uncheck if the script is running as cron job</p> |
| 682 | 876 | <div id="cronends"> |
| 683 | 877 | <label for="cronend">Run script for xx seconds</label> |
| 684 | - <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" /> |
|
| 878 | + <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) { |
|
| 879 | + print $globalCronEnd; |
|
| 880 | +} else { |
|
| 881 | + print '0'; |
|
| 882 | +} |
|
| 883 | +?>" /> |
|
| 685 | 884 | <p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p> |
| 686 | 885 | </div> |
| 687 | 886 | </p> |
@@ -721,26 +920,49 @@ discard block |
||
| 721 | 920 | <br /> |
| 722 | 921 | <p> |
| 723 | 922 | <label for="refresh">Show flights detected since xxx seconds</label> |
| 724 | - <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" /> |
|
| 923 | + <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) { |
|
| 924 | + echo $globalLiveInterval; |
|
| 925 | +} else { |
|
| 926 | + echo '200'; |
|
| 927 | +} |
|
| 928 | +?>" /> |
|
| 725 | 929 | </p> |
| 726 | 930 | <p> |
| 727 | 931 | <label for="maprefresh">Live map refresh (in seconds)</label> |
| 728 | - <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" /> |
|
| 932 | + <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) { |
|
| 933 | + echo $globalMapRefresh; |
|
| 934 | +} else { |
|
| 935 | + echo '30'; |
|
| 936 | +} |
|
| 937 | +?>" /> |
|
| 729 | 938 | </p> |
| 730 | 939 | <p> |
| 731 | 940 | <label for="mapidle">Map idle timeout (in minutes)</label> |
| 732 | - <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" /> |
|
| 941 | + <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) { |
|
| 942 | + echo $globalMapIdleTimeout; |
|
| 943 | +} else { |
|
| 944 | + echo '30'; |
|
| 945 | +} |
|
| 946 | +?>" /> |
|
| 733 | 947 | <p class="help-block">0 to disable</p> |
| 734 | 948 | </p> |
| 735 | 949 | <br /> |
| 736 | 950 | <p> |
| 737 | 951 | <label for="closestmindist">Distance to airport set as arrival (in km)</label> |
| 738 | - <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" /> |
|
| 952 | + <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) { |
|
| 953 | + echo $globalClosestMinDist; |
|
| 954 | +} else { |
|
| 955 | + echo '50'; |
|
| 956 | +} |
|
| 957 | +?>" /> |
|
| 739 | 958 | </p> |
| 740 | 959 | <br /> |
| 741 | 960 | <p> |
| 742 | 961 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
| 743 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
| 962 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) { |
|
| 963 | + echo $globalAircraftSize; |
|
| 964 | +} |
|
| 965 | +?>" /> |
|
| 744 | 966 | </p> |
| 745 | 967 | <br /> |
| 746 | 968 | <p> |
@@ -748,7 +970,12 @@ discard block |
||
| 748 | 970 | if (extension_loaded('gd') && function_exists('gd_info')) { |
| 749 | 971 | ?> |
| 750 | 972 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
| 751 | - <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
|
| 973 | + <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) { |
|
| 974 | + echo $globalAircraftIconColor; |
|
| 975 | +} else { |
|
| 976 | + echo '1a3151'; |
|
| 977 | +} |
|
| 978 | +?>" /> |
|
| 752 | 979 | <?php |
| 753 | 980 | if (!is_writable('../cache')) { |
| 754 | 981 | ?> |
@@ -766,8 +993,18 @@ discard block |
||
| 766 | 993 | <p> |
| 767 | 994 | <label for="airportzoom">Zoom level minimum to see airports icons</label> |
| 768 | 995 | <div class="range"> |
| 769 | - <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" /> |
|
| 770 | - <output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output> |
|
| 996 | + <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) { |
|
| 997 | + echo $globalAirportZoom; |
|
| 998 | +} else { |
|
| 999 | + echo '7'; |
|
| 1000 | +} |
|
| 1001 | +?>" /> |
|
| 1002 | + <output id="range"><?php if (isset($globalAirportZoom)) { |
|
| 1003 | + echo $globalAirportZoom; |
|
| 1004 | +} else { |
|
| 1005 | + echo '7'; |
|
| 1006 | +} |
|
| 1007 | +?></output> |
|
| 771 | 1008 | </div> |
| 772 | 1009 | </p> |
| 773 | 1010 | </fieldset> |
@@ -795,8 +1032,12 @@ discard block |
||
| 795 | 1032 | $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
| 796 | 1033 | $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
| 797 | 1034 | |
| 798 | - if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
|
| 799 | - if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
| 1035 | + if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) { |
|
| 1036 | + $error .= 'Mysql driver for PDO must be loaded'; |
|
| 1037 | + } |
|
| 1038 | + if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) { |
|
| 1039 | + $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
| 1040 | + } |
|
| 800 | 1041 | |
| 801 | 1042 | $_SESSION['database_root'] = $dbroot; |
| 802 | 1043 | $_SESSION['database_rootpass'] = $dbrootpass; |
@@ -863,15 +1104,23 @@ discard block |
||
| 863 | 1104 | $source_city = $_POST['source_city']; |
| 864 | 1105 | $source_country = $_POST['source_country']; |
| 865 | 1106 | $source_ref = $_POST['source_ref']; |
| 866 | - if (isset($source_id)) $source_id = $_POST['source_id']; |
|
| 867 | - else $source_id = array(); |
|
| 1107 | + if (isset($source_id)) { |
|
| 1108 | + $source_id = $_POST['source_id']; |
|
| 1109 | + } else { |
|
| 1110 | + $source_id = array(); |
|
| 1111 | + } |
|
| 868 | 1112 | |
| 869 | 1113 | $sources = array(); |
| 870 | 1114 | foreach ($source_name as $keys => $name) { |
| 871 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 872 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 1115 | + if (isset($source_id[$keys])) { |
|
| 1116 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 1117 | + } else { |
|
| 1118 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 1119 | + } |
|
| 1120 | + } |
|
| 1121 | + if (count($sources) > 0) { |
|
| 1122 | + $_SESSION['sources'] = $sources; |
|
| 873 | 1123 | } |
| 874 | - if (count($sources) > 0) $_SESSION['sources'] = $sources; |
|
| 875 | 1124 | |
| 876 | 1125 | //$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING); |
| 877 | 1126 | //$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT); |
@@ -909,13 +1158,21 @@ discard block |
||
| 909 | 1158 | $port = $_POST['port']; |
| 910 | 1159 | $name = $_POST['name']; |
| 911 | 1160 | $format = $_POST['format']; |
| 912 | - if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats']; |
|
| 913 | - else $sourcestats = array(); |
|
| 1161 | + if (isset($_POST['sourcestats'])) { |
|
| 1162 | + $sourcestats = $_POST['sourcestats']; |
|
| 1163 | + } else { |
|
| 1164 | + $sourcestats = array(); |
|
| 1165 | + } |
|
| 914 | 1166 | $gSources = array(); |
| 915 | 1167 | foreach ($host as $key => $h) { |
| 916 | - if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE'; |
|
| 917 | - else $cov = 'FALSE'; |
|
| 918 | - if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov); |
|
| 1168 | + if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) { |
|
| 1169 | + $cov = 'TRUE'; |
|
| 1170 | + } else { |
|
| 1171 | + $cov = 'FALSE'; |
|
| 1172 | + } |
|
| 1173 | + if ($h != '') { |
|
| 1174 | + $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov); |
|
| 1175 | + } |
|
| 919 | 1176 | } |
| 920 | 1177 | $settings = array_merge($settings,array('globalSources' => $gSources)); |
| 921 | 1178 | |
@@ -939,7 +1196,9 @@ discard block |
||
| 939 | 1196 | $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
| 940 | 1197 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
| 941 | 1198 | $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
| 942 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
| 1199 | + } else { |
|
| 1200 | + $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
| 1201 | + } |
|
| 943 | 1202 | |
| 944 | 1203 | $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
| 945 | 1204 | $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
@@ -978,7 +1237,9 @@ discard block |
||
| 978 | 1237 | |
| 979 | 1238 | // Create in settings.php keys not yet configurable if not already here |
| 980 | 1239 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
| 981 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
| 1240 | + if (!isset($globalDebug)) { |
|
| 1241 | + $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
| 1242 | + } |
|
| 982 | 1243 | |
| 983 | 1244 | $archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING); |
| 984 | 1245 | if ($archive == 'archive') { |
@@ -1008,27 +1269,43 @@ discard block |
||
| 1008 | 1269 | } |
| 1009 | 1270 | */ |
| 1010 | 1271 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
| 1011 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
| 1012 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
| 1013 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
| 1014 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
| 1272 | + if ($globalsbs == 'sbs') { |
|
| 1273 | + $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
| 1274 | + } else { |
|
| 1275 | + $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
| 1276 | + } |
|
| 1277 | + if ($globalaprs == 'aprs') { |
|
| 1278 | + $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
| 1279 | + } else { |
|
| 1280 | + $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
| 1281 | + } |
|
| 1015 | 1282 | if ($globalivao == 'ivao') { |
| 1016 | 1283 | //$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE')); |
| 1017 | 1284 | $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
| 1018 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
| 1285 | + } else { |
|
| 1286 | + $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
| 1287 | + } |
|
| 1019 | 1288 | if ($globalvatsim == 'vatsim') { |
| 1020 | 1289 | //$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE')); |
| 1021 | 1290 | $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
| 1022 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
| 1291 | + } else { |
|
| 1292 | + $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
| 1293 | + } |
|
| 1023 | 1294 | if ($globalphpvms == 'phpvms') { |
| 1024 | 1295 | $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
| 1025 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
| 1296 | + } else { |
|
| 1297 | + $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
| 1298 | + } |
|
| 1026 | 1299 | if ($globalvam == 'vam') { |
| 1027 | 1300 | $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
| 1028 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
| 1301 | + } else { |
|
| 1302 | + $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
| 1303 | + } |
|
| 1029 | 1304 | if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') { |
| 1030 | 1305 | $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
| 1031 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
| 1306 | + } else { |
|
| 1307 | + $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
| 1308 | + } |
|
| 1032 | 1309 | |
| 1033 | 1310 | |
| 1034 | 1311 | |
@@ -1152,7 +1429,9 @@ discard block |
||
| 1152 | 1429 | $settings = array_merge($settings,array('globalWaypoints' => 'FALSE')); |
| 1153 | 1430 | } |
| 1154 | 1431 | |
| 1155 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
| 1432 | + if (!isset($globalTransaction)) { |
|
| 1433 | + $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
| 1434 | + } |
|
| 1156 | 1435 | |
| 1157 | 1436 | // Set some defaults values... |
| 1158 | 1437 | if (!isset($globalAircraftImageSources)) { |
@@ -1167,15 +1446,23 @@ discard block |
||
| 1167 | 1446 | |
| 1168 | 1447 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
| 1169 | 1448 | |
| 1170 | - if ($error == '') settings::modify_settings($settings); |
|
| 1171 | - if ($error == '') settings::comment_settings($settings_comment); |
|
| 1449 | + if ($error == '') { |
|
| 1450 | + settings::modify_settings($settings); |
|
| 1451 | + } |
|
| 1452 | + if ($error == '') { |
|
| 1453 | + settings::comment_settings($settings_comment); |
|
| 1454 | + } |
|
| 1172 | 1455 | if ($error != '') { |
| 1173 | 1456 | print '<div class="info column">'.$error.'</div>'; |
| 1174 | 1457 | require('../footer.php'); |
| 1175 | 1458 | exit; |
| 1176 | 1459 | } else { |
| 1177 | - if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1; |
|
| 1178 | - if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1; |
|
| 1460 | + if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') { |
|
| 1461 | + $_SESSION['waypoints'] = 1; |
|
| 1462 | + } |
|
| 1463 | + if (isset($_POST['owner']) && $_POST['owner'] == 'owner') { |
|
| 1464 | + $_SESSION['owner'] = 1; |
|
| 1465 | + } |
|
| 1179 | 1466 | if (isset($_POST['createdb'])) { |
| 1180 | 1467 | $_SESSION['install'] = 'database_create'; |
| 1181 | 1468 | } else { |
@@ -1216,10 +1503,18 @@ discard block |
||
| 1216 | 1503 | $popw = false; |
| 1217 | 1504 | foreach ($_SESSION['done'] as $done) { |
| 1218 | 1505 | print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
| 1219 | - if ($done == 'Create database') $pop = true; |
|
| 1220 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
| 1221 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
| 1222 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
| 1506 | + if ($done == 'Create database') { |
|
| 1507 | + $pop = true; |
|
| 1508 | + } |
|
| 1509 | + if ($_SESSION['install'] == 'database_create') { |
|
| 1510 | + $pop = true; |
|
| 1511 | + } |
|
| 1512 | + if ($_SESSION['install'] == 'database_import') { |
|
| 1513 | + $popi = true; |
|
| 1514 | + } |
|
| 1515 | + if ($_SESSION['install'] == 'waypoints') { |
|
| 1516 | + $popw = true; |
|
| 1517 | + } |
|
| 1223 | 1518 | } |
| 1224 | 1519 | if ($pop) { |
| 1225 | 1520 | sleep(5); |
@@ -1230,7 +1525,9 @@ discard block |
||
| 1230 | 1525 | } else if ($popw) { |
| 1231 | 1526 | sleep(5); |
| 1232 | 1527 | print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
| 1233 | - } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
| 1528 | + } else { |
|
| 1529 | + print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
| 1530 | + } |
|
| 1234 | 1531 | print '</div></ul>'; |
| 1235 | 1532 | print '<div id="error"></div>'; |
| 1236 | 1533 | /* foreach ($_SESSION['done'] as $done) { |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | $this->SI = new SpotterImport($this->db); |
| 17 | 17 | } |
| 18 | 18 | /** |
| 19 | - * Change IATA to ICAO value for ident |
|
| 20 | - * |
|
| 21 | - * @param String $ident ident |
|
| 22 | - * @return String the icao |
|
| 23 | - */ |
|
| 19 | + * Change IATA to ICAO value for ident |
|
| 20 | + * |
|
| 21 | + * @param String $ident ident |
|
| 22 | + * @return String the icao |
|
| 23 | + */ |
|
| 24 | 24 | public function ident2icao($ident) { |
| 25 | 25 | if (substr($ident,0,2) == 'AF') { |
| 26 | 26 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * Deletes all info in the live table |
|
| 40 | - * |
|
| 41 | - * @return String success or false |
|
| 42 | - * |
|
| 43 | - */ |
|
| 39 | + * Deletes all info in the live table |
|
| 40 | + * |
|
| 41 | + * @return String success or false |
|
| 42 | + * |
|
| 43 | + */ |
|
| 44 | 44 | public function deleteLiveAcarsData() |
| 45 | 45 | { |
| 46 | 46 | global $globalDBdriver; |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * Deletes all info in the archive table |
|
| 64 | - * |
|
| 65 | - * @return String success or false |
|
| 66 | - * |
|
| 67 | - */ |
|
| 63 | + * Deletes all info in the archive table |
|
| 64 | + * |
|
| 65 | + * @return String success or false |
|
| 66 | + * |
|
| 67 | + */ |
|
| 68 | 68 | public function deleteArchiveAcarsData() |
| 69 | 69 | { |
| 70 | 70 | global $globalACARSArchiveKeepMonths, $globalDBdriver; |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | - * Parse ACARS data |
|
| 89 | - * |
|
| 90 | - * @param String ACARS data in acarsdec data |
|
| 91 | - * |
|
| 92 | - */ |
|
| 88 | + * Parse ACARS data |
|
| 89 | + * |
|
| 90 | + * @param String ACARS data in acarsdec data |
|
| 91 | + * |
|
| 92 | + */ |
|
| 93 | 93 | public function parse($data) { |
| 94 | 94 | global $globalDebug, $globalACARSArchive; |
| 95 | 95 | //$Image = new Image($this->db); |
@@ -666,11 +666,11 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | |
| 668 | 668 | /** |
| 669 | - * Add ACARS data |
|
| 670 | - * |
|
| 671 | - * @param String ACARS data in acarsdec data |
|
| 672 | - * |
|
| 673 | - */ |
|
| 669 | + * Add ACARS data |
|
| 670 | + * |
|
| 671 | + * @param String ACARS data in acarsdec data |
|
| 672 | + * |
|
| 673 | + */ |
|
| 674 | 674 | function add($data) { |
| 675 | 675 | global $globalDebug, $globalACARSArchive; |
| 676 | 676 | $Image = new Image($this->db); |
@@ -725,15 +725,15 @@ discard block |
||
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | /** |
| 728 | - * Add Live ACARS data in DB |
|
| 729 | - * |
|
| 730 | - * @param String $ident ident |
|
| 731 | - * @param String $registration Registration of the aircraft |
|
| 732 | - * @param String $label Label of the ACARS message |
|
| 733 | - * @param String $block_id Block id of the ACARS message |
|
| 734 | - * @param String $msg_no Number of the ACARS message |
|
| 735 | - * @param String $message ACARS message |
|
| 736 | - */ |
|
| 728 | + * Add Live ACARS data in DB |
|
| 729 | + * |
|
| 730 | + * @param String $ident ident |
|
| 731 | + * @param String $registration Registration of the aircraft |
|
| 732 | + * @param String $label Label of the ACARS message |
|
| 733 | + * @param String $block_id Block id of the ACARS message |
|
| 734 | + * @param String $msg_no Number of the ACARS message |
|
| 735 | + * @param String $message ACARS message |
|
| 736 | + */ |
|
| 737 | 737 | public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
| 738 | 738 | global $globalDebug; |
| 739 | 739 | date_default_timezone_set('UTC'); |
@@ -771,15 +771,15 @@ discard block |
||
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
| 774 | - * Add Archive ACARS data in DB |
|
| 775 | - * |
|
| 776 | - * @param String $ident ident |
|
| 777 | - * @param String $registration Registration of the aircraft |
|
| 778 | - * @param String $label Label of the ACARS message |
|
| 779 | - * @param String $block_id Block id of the ACARS message |
|
| 780 | - * @param String $msg_no Number of the ACARS message |
|
| 781 | - * @param String $message ACARS message |
|
| 782 | - */ |
|
| 774 | + * Add Archive ACARS data in DB |
|
| 775 | + * |
|
| 776 | + * @param String $ident ident |
|
| 777 | + * @param String $registration Registration of the aircraft |
|
| 778 | + * @param String $label Label of the ACARS message |
|
| 779 | + * @param String $block_id Block id of the ACARS message |
|
| 780 | + * @param String $msg_no Number of the ACARS message |
|
| 781 | + * @param String $message ACARS message |
|
| 782 | + */ |
|
| 783 | 783 | public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
| 784 | 784 | global $globalDebug; |
| 785 | 785 | date_default_timezone_set('UTC'); |
@@ -813,11 +813,11 @@ discard block |
||
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | - * Get Message title from label from DB |
|
| 817 | - * |
|
| 818 | - * @param String $label |
|
| 819 | - * @return String Return ACARS title |
|
| 820 | - */ |
|
| 816 | + * Get Message title from label from DB |
|
| 817 | + * |
|
| 818 | + * @param String $label |
|
| 819 | + * @return String Return ACARS title |
|
| 820 | + */ |
|
| 821 | 821 | public function getTitlefromLabel($label) { |
| 822 | 822 | $Connection = new Connection($this->db); |
| 823 | 823 | $this->db = $Connection->db; |
@@ -837,10 +837,10 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
| 840 | - * List all Message title & label from DB |
|
| 841 | - * |
|
| 842 | - * @return Array Return ACARS data in array |
|
| 843 | - */ |
|
| 840 | + * List all Message title & label from DB |
|
| 841 | + * |
|
| 842 | + * @return Array Return ACARS data in array |
|
| 843 | + */ |
|
| 844 | 844 | public function getAllTitleLabel() { |
| 845 | 845 | $query = "SELECT * FROM acars_label ORDER BY title"; |
| 846 | 846 | $query_values = array(); |
@@ -858,11 +858,11 @@ discard block |
||
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | /** |
| 861 | - * Get Live ACARS data from DB |
|
| 862 | - * |
|
| 863 | - * @param String $ident |
|
| 864 | - * @return Array Return ACARS data in array |
|
| 865 | - */ |
|
| 861 | + * Get Live ACARS data from DB |
|
| 862 | + * |
|
| 863 | + * @param String $ident |
|
| 864 | + * @return Array Return ACARS data in array |
|
| 865 | + */ |
|
| 866 | 866 | public function getLiveAcarsData($ident) { |
| 867 | 867 | $query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC"; |
| 868 | 868 | $query_values = array(':ident' => $ident); |
@@ -880,10 +880,10 @@ discard block |
||
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | /** |
| 883 | - * Get Latest ACARS data from DB |
|
| 884 | - * |
|
| 885 | - * @return Array Return ACARS data in array |
|
| 886 | - */ |
|
| 883 | + * Get Latest ACARS data from DB |
|
| 884 | + * |
|
| 885 | + * @return Array Return ACARS data in array |
|
| 886 | + */ |
|
| 887 | 887 | public function getLatestAcarsData($limit = '',$label = '') { |
| 888 | 888 | global $globalURL, $globalDBdriver; |
| 889 | 889 | $Image = new Image($this->db); |
@@ -980,10 +980,10 @@ discard block |
||
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | /** |
| 983 | - * Get Archive ACARS data from DB |
|
| 984 | - * |
|
| 985 | - * @return Array Return ACARS data in array |
|
| 986 | - */ |
|
| 983 | + * Get Archive ACARS data from DB |
|
| 984 | + * |
|
| 985 | + * @return Array Return ACARS data in array |
|
| 986 | + */ |
|
| 987 | 987 | public function getArchiveAcarsData($limit = '',$label = '') { |
| 988 | 988 | global $globalURL, $globalDBdriver; |
| 989 | 989 | $Image = new Image($this->db); |
@@ -1085,13 +1085,13 @@ discard block |
||
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | /** |
| 1088 | - * Add ModeS data to DB |
|
| 1089 | - * |
|
| 1090 | - * @param String $ident ident |
|
| 1091 | - * @param String $registration Registration of the aircraft |
|
| 1092 | - * @param String $icao |
|
| 1093 | - * @param String $ICAOTypeCode |
|
| 1094 | - */ |
|
| 1088 | + * Add ModeS data to DB |
|
| 1089 | + * |
|
| 1090 | + * @param String $ident ident |
|
| 1091 | + * @param String $registration Registration of the aircraft |
|
| 1092 | + * @param String $icao |
|
| 1093 | + * @param String $ICAOTypeCode |
|
| 1094 | + */ |
|
| 1095 | 1095 | public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
| 1096 | 1096 | global $globalDebug, $globalDBdriver; |
| 1097 | 1097 | $ident = trim($ident); |
@@ -23,14 +23,19 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function ident2icao($ident) { |
| 25 | 25 | if (substr($ident,0,2) == 'AF') { |
| 26 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 27 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 26 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 27 | + $icao = $ident; |
|
| 28 | + } else { |
|
| 29 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 30 | + } |
|
| 28 | 31 | } else { |
| 29 | 32 | $Spotter = new Spotter($this->db); |
| 30 | 33 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
| 31 | 34 | if (isset($identicao[0])) { |
| 32 | 35 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
| 33 | - } else $icao = $ident; |
|
| 36 | + } else { |
|
| 37 | + $icao = $ident; |
|
| 38 | + } |
|
| 34 | 39 | } |
| 35 | 40 | return $icao; |
| 36 | 41 | } |
@@ -103,12 +108,18 @@ discard block |
||
| 103 | 108 | $message = ''; |
| 104 | 109 | $result = array(); |
| 105 | 110 | $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
| 106 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 111 | + if ($n == 0) { |
|
| 112 | + $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 113 | + } |
|
| 107 | 114 | if ($n != 0) { |
| 108 | 115 | $registration = str_replace('.','',$registration); |
| 109 | 116 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
| 110 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 111 | - } else $message = $data; |
|
| 117 | + if ($globalDebug) { |
|
| 118 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 121 | + $message = $data; |
|
| 122 | + } |
|
| 112 | 123 | $icao = ''; |
| 113 | 124 | $airicao = ''; |
| 114 | 125 | $decode = array(); |
@@ -122,12 +133,21 @@ discard block |
||
| 122 | 133 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 123 | 134 | $latitude = $la / 10000.0; |
| 124 | 135 | $longitude = $ln / 10000.0; |
| 125 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 126 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 136 | + if ($lac == 'S') { |
|
| 137 | + $latitude = '-'.$latitude; |
|
| 138 | + } |
|
| 139 | + if ($lnc == 'W') { |
|
| 140 | + $longitude = '-'.$longitude; |
|
| 141 | + } |
|
| 127 | 142 | // Temp not always available |
| 128 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 129 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 130 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 143 | + if ($globalDebug) { |
|
| 144 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 145 | + } |
|
| 146 | + if ($temp == '') { |
|
| 147 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 148 | + } else { |
|
| 149 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 150 | + } |
|
| 131 | 151 | |
| 132 | 152 | //$icao = $Translation->checkTranslation($ident); |
| 133 | 153 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -137,25 +157,35 @@ discard block |
||
| 137 | 157 | if (!$found && ($label == '10')) { |
| 138 | 158 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
| 139 | 159 | if ($n == 4 && strlen($darr) == 4) { |
| 140 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 141 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 142 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 160 | + if ($dhour != '') { |
|
| 161 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 162 | + } |
|
| 163 | + if ($ahour != '') { |
|
| 164 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 165 | + } |
|
| 166 | + if ($globalDebug) { |
|
| 167 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 168 | + } |
|
| 143 | 169 | //$icao = ACARS->ident2icao($ident); |
| 144 | 170 | //$icao = $Translation->checkTranslation($ident); |
| 145 | 171 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 146 | 172 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
| 147 | 173 | $found = true; |
| 148 | - } |
|
| 149 | - elseif ($n == 2 || $n == 4) { |
|
| 150 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 151 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 174 | + } elseif ($n == 2 || $n == 4) { |
|
| 175 | + if ($dhour != '') { |
|
| 176 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 177 | + } |
|
| 178 | + if ($globalDebug) { |
|
| 179 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 180 | + } |
|
| 152 | 181 | //$icao = ACARS->ident2icao($ident); |
| 153 | 182 | //$icao = $Translation->checkTranslation($ident); |
| 154 | 183 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
| 155 | 184 | $found = true; |
| 156 | - } |
|
| 157 | - elseif ($n == 1) { |
|
| 158 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
| 185 | + } elseif ($n == 1) { |
|
| 186 | + if ($globalDebug) { |
|
| 187 | + echo 'airport arrival : '.$darr."\n"; |
|
| 188 | + } |
|
| 159 | 189 | //$icao = ACARS->ident2icao($ident); |
| 160 | 190 | //$icao = $Translation->checkTranslation($ident); |
| 161 | 191 | $decode = array('Arrival airport' => $darr); |
@@ -172,7 +202,9 @@ discard block |
||
| 172 | 202 | |
| 173 | 203 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
| 174 | 204 | if ($n == 4) { |
| 175 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 205 | + if ($globalDebug) { |
|
| 206 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 207 | + } |
|
| 176 | 208 | //$icao = ACARS->ident2icao($ident); |
| 177 | 209 | //$icao = $Translation->checkTranslation($ident); |
| 178 | 210 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -197,14 +229,23 @@ discard block |
||
| 197 | 229 | //$n = sscanf($message, "%*[0-9A-Z]/%*3d/%4s/%*c\nSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d\n%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
| 198 | 230 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
| 199 | 231 | if ($n > 8) { |
| 200 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
| 201 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 202 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 232 | + if ($globalDebug) { |
|
| 233 | + echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
| 234 | + } |
|
| 235 | + if ($dhour != '') { |
|
| 236 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 237 | + } |
|
| 238 | + if ($ahour != '') { |
|
| 239 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 240 | + } |
|
| 203 | 241 | $icao = trim($aident); |
| 204 | 242 | |
| 205 | 243 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
| 206 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 207 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 244 | + if ($ahour == '') { |
|
| 245 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 246 | + } else { |
|
| 247 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 248 | + } |
|
| 208 | 249 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 209 | 250 | $decode['icao'] = $icao; |
| 210 | 251 | $found = true; |
@@ -221,9 +262,15 @@ discard block |
||
| 221 | 262 | $lns = $lns.'.'.$lns; |
| 222 | 263 | $latitude = $las / 1000.0; |
| 223 | 264 | $longitude = $lns / 1000.0; |
| 224 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 225 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 226 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 265 | + if ($lac == 'S') { |
|
| 266 | + $latitude = '-'.$latitude; |
|
| 267 | + } |
|
| 268 | + if ($lnc == 'W') { |
|
| 269 | + $longitude = '-'.$longitude; |
|
| 270 | + } |
|
| 271 | + if ($globalDebug) { |
|
| 272 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 273 | + } |
|
| 227 | 274 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
| 228 | 275 | $found = true; |
| 229 | 276 | } |
@@ -239,7 +286,9 @@ discard block |
||
| 239 | 286 | */ |
| 240 | 287 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
| 241 | 288 | if ($n == 4) { |
| 242 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 289 | + if ($globalDebug) { |
|
| 290 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 291 | + } |
|
| 243 | 292 | //$icao = $Translation->checkTranslation($ident); |
| 244 | 293 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 245 | 294 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -250,7 +299,9 @@ discard block |
||
| 250 | 299 | // example message : "Reg. : TS-ION - Ident : TU0634 - Label : 1L - Message : 000442152001337,DTTJ,LFPO,1609" |
| 251 | 300 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
| 252 | 301 | if ($n == 4) { |
| 253 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 302 | + if ($globalDebug) { |
|
| 303 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 304 | + } |
|
| 254 | 305 | //$icao = $Translation->checkTranslation($ident); |
| 255 | 306 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 256 | 307 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -261,7 +312,9 @@ discard block |
||
| 261 | 312 | // example message : "Reg. : OO-TAH - Ident : 3V042J - Label : 5U - Message : 002AF EBLG EBBR N4621.5E 524.2195" |
| 262 | 313 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
| 263 | 314 | if ($n == 2) { |
| 264 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 315 | + if ($globalDebug) { |
|
| 316 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 317 | + } |
|
| 265 | 318 | //$icao = $Translation->checkTranslation($ident); |
| 266 | 319 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
| 267 | 320 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -273,7 +326,9 @@ discard block |
||
| 273 | 326 | // example message : 'Reg. : F-GHQJ - Ident : AF6241 - Label : H1 - Message : #DFBA01/CCF-GHQJ,FEB27,205556,LFMN,LFPO,0241/C106,17404,5000,42,0010,0,0100,42,X/CEN270,36012,257,778,6106,299,B5B7G8/EC731134,42387,01439,41194,12/EE731212,44932,11870,43555,12/N10875,0875,0910,6330,1205,-----' |
| 274 | 327 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 275 | 328 | if ($n == 6) { |
| 276 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 329 | + if ($globalDebug) { |
|
| 330 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 331 | + } |
|
| 277 | 332 | //$icao = $Translation->checkTranslation($ident); |
| 278 | 333 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 279 | 334 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -284,7 +339,9 @@ discard block |
||
| 284 | 339 | // example message : 'Reg. : F-GUGP - Ident : AF1842 - Label : H1 - Message : #DFBA01/A31801,1,1/CCF-GUGP,MAR11,093856,LFPG,LSGG,1842/C106,55832,5000,37,0010,0,0100,37,X/CEN282,31018,277,750,5515,255,C11036/EC577870,02282,07070,01987,73,14/EE577871,02282,06947,01987,73/N10790,0790,0903,5' |
| 285 | 340 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 286 | 341 | if ($n == 7) { |
| 287 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 342 | + if ($globalDebug) { |
|
| 343 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 344 | + } |
|
| 288 | 345 | //$icao = $Translation->checkTranslation($ident); |
| 289 | 346 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 290 | 347 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -304,8 +361,12 @@ discard block |
||
| 304 | 361 | $decode['icao'] = $icao; |
| 305 | 362 | $latitude = $las / 100.0; |
| 306 | 363 | $longitude = $lns / 100.0; |
| 307 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 308 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 364 | + if ($lac == 'S') { |
|
| 365 | + $latitude = '-'.$latitude; |
|
| 366 | + } |
|
| 367 | + if ($lnc == 'W') { |
|
| 368 | + $longitude = '-'.$longitude; |
|
| 369 | + } |
|
| 309 | 370 | |
| 310 | 371 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
| 311 | 372 | $found = true; |
@@ -319,8 +380,12 @@ discard block |
||
| 319 | 380 | if ($n == 4) { |
| 320 | 381 | $latitude = $las; |
| 321 | 382 | $longitude = $lns; |
| 322 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 323 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 383 | + if ($lac == 'S') { |
|
| 384 | + $latitude = '-'.$latitude; |
|
| 385 | + } |
|
| 386 | + if ($lnc == 'W') { |
|
| 387 | + $longitude = '-'.$longitude; |
|
| 388 | + } |
|
| 324 | 389 | |
| 325 | 390 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
| 326 | 391 | $found = true; |
@@ -334,7 +399,9 @@ discard block |
||
| 334 | 399 | */ |
| 335 | 400 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
| 336 | 401 | if ($n == 5) { |
| 337 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 402 | + if ($globalDebug) { |
|
| 403 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 404 | + } |
|
| 338 | 405 | //$icao = $Translation->checkTranslation($ident); |
| 339 | 406 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 340 | 407 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -352,7 +419,9 @@ discard block |
||
| 352 | 419 | // $n = sscanf($message, "%*[0-9A-Z],,\n%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,\n%*4[A-Z],\n%[0-9A-Z],", $dair, $darr, $aident); |
| 353 | 420 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
| 354 | 421 | if ($n == 8) { |
| 355 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 422 | + if ($globalDebug) { |
|
| 423 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 424 | + } |
|
| 356 | 425 | $icao = trim($aident); |
| 357 | 426 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 358 | 427 | $decode['icao'] = $icao; |
@@ -367,7 +436,9 @@ discard block |
||
| 367 | 436 | */ |
| 368 | 437 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
| 369 | 438 | if ($n == 5) { |
| 370 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 439 | + if ($globalDebug) { |
|
| 440 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 441 | + } |
|
| 371 | 442 | //$icao = $Translation->checkTranslation($ident); |
| 372 | 443 | |
| 373 | 444 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -381,7 +452,9 @@ discard block |
||
| 381 | 452 | */ |
| 382 | 453 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
| 383 | 454 | if ($n == 3) { |
| 384 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 455 | + if ($globalDebug) { |
|
| 456 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 457 | + } |
|
| 385 | 458 | //$icao = $Translation->checkTranslation($ident); |
| 386 | 459 | |
| 387 | 460 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -395,7 +468,9 @@ discard block |
||
| 395 | 468 | */ |
| 396 | 469 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
| 397 | 470 | if ($n == 3) { |
| 398 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 471 | + if ($globalDebug) { |
|
| 472 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 473 | + } |
|
| 399 | 474 | //$icao = $Translation->checkTranslation($ident); |
| 400 | 475 | |
| 401 | 476 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -406,7 +481,9 @@ discard block |
||
| 406 | 481 | if (!$found) { |
| 407 | 482 | $n = sscanf($message,'MET01%4c',$airport); |
| 408 | 483 | if ($n == 1) { |
| 409 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
| 484 | + if ($globalDebug) { |
|
| 485 | + echo 'airport name : '.$airport; |
|
| 486 | + } |
|
| 410 | 487 | $decode = array('Airport/Waypoint name' => $airport); |
| 411 | 488 | $found = true; |
| 412 | 489 | } |
@@ -415,184 +492,126 @@ discard block |
||
| 415 | 492 | if ($label == 'H1') { |
| 416 | 493 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
| 417 | 494 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
| 418 | - } |
|
| 419 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 495 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 420 | 496 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
| 421 | - } |
|
| 422 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 497 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 423 | 498 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
| 424 | - } |
|
| 425 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 499 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 426 | 500 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
| 427 | - } |
|
| 428 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 501 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 429 | 502 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
| 430 | - } |
|
| 431 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 503 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 432 | 504 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
| 433 | - } |
|
| 434 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 505 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 435 | 506 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
| 436 | - } |
|
| 437 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 507 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 438 | 508 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
| 439 | - } |
|
| 440 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 509 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 441 | 510 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
| 442 | - } |
|
| 443 | - elseif (preg_match(':^#CF:',$message)) { |
|
| 511 | + } elseif (preg_match(':^#CF:',$message)) { |
|
| 444 | 512 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
| 445 | - } |
|
| 446 | - elseif (preg_match(':^#DF:',$message)) { |
|
| 513 | + } elseif (preg_match(':^#DF:',$message)) { |
|
| 447 | 514 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
| 448 | - } |
|
| 449 | - elseif (preg_match(':^#EC:',$message)) { |
|
| 515 | + } elseif (preg_match(':^#EC:',$message)) { |
|
| 450 | 516 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
| 451 | - } |
|
| 452 | - elseif (preg_match(':^#EI:',$message)) { |
|
| 517 | + } elseif (preg_match(':^#EI:',$message)) { |
|
| 453 | 518 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
| 454 | - } |
|
| 455 | - elseif (preg_match(':^#H1:',$message)) { |
|
| 519 | + } elseif (preg_match(':^#H1:',$message)) { |
|
| 456 | 520 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
| 457 | - } |
|
| 458 | - elseif (preg_match(':^#H2:',$message)) { |
|
| 521 | + } elseif (preg_match(':^#H2:',$message)) { |
|
| 459 | 522 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
| 460 | - } |
|
| 461 | - elseif (preg_match(':^#HD:',$message)) { |
|
| 523 | + } elseif (preg_match(':^#HD:',$message)) { |
|
| 462 | 524 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
| 463 | - } |
|
| 464 | - elseif (preg_match(':^#M1:',$message)) { |
|
| 525 | + } elseif (preg_match(':^#M1:',$message)) { |
|
| 465 | 526 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
| 466 | - } |
|
| 467 | - elseif (preg_match(':^#M2:',$message)) { |
|
| 527 | + } elseif (preg_match(':^#M2:',$message)) { |
|
| 468 | 528 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
| 469 | - } |
|
| 470 | - elseif (preg_match(':^#M3:',$message)) { |
|
| 529 | + } elseif (preg_match(':^#M3:',$message)) { |
|
| 471 | 530 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
| 472 | - } |
|
| 473 | - elseif (preg_match(':^#MD:',$message)) { |
|
| 531 | + } elseif (preg_match(':^#MD:',$message)) { |
|
| 474 | 532 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
| 475 | - } |
|
| 476 | - elseif (preg_match(':^#PS:',$message)) { |
|
| 533 | + } elseif (preg_match(':^#PS:',$message)) { |
|
| 477 | 534 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
| 478 | - } |
|
| 479 | - elseif (preg_match(':^#S1:',$message)) { |
|
| 535 | + } elseif (preg_match(':^#S1:',$message)) { |
|
| 480 | 536 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
| 481 | - } |
|
| 482 | - elseif (preg_match(':^#S2:',$message)) { |
|
| 537 | + } elseif (preg_match(':^#S2:',$message)) { |
|
| 483 | 538 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
| 484 | - } |
|
| 485 | - elseif (preg_match(':^#SD:',$message)) { |
|
| 539 | + } elseif (preg_match(':^#SD:',$message)) { |
|
| 486 | 540 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
| 487 | - } |
|
| 488 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 541 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 489 | 542 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
| 490 | - } |
|
| 491 | - elseif (preg_match(':^#WO:',$message)) { |
|
| 543 | + } elseif (preg_match(':^#WO:',$message)) { |
|
| 492 | 544 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
| 493 | - } |
|
| 494 | - elseif (preg_match(':^#A1:',$message)) { |
|
| 545 | + } elseif (preg_match(':^#A1:',$message)) { |
|
| 495 | 546 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
| 496 | - } |
|
| 497 | - elseif (preg_match(':^#A3:',$message)) { |
|
| 547 | + } elseif (preg_match(':^#A3:',$message)) { |
|
| 498 | 548 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
| 499 | - } |
|
| 500 | - elseif (preg_match(':^#A4:',$message)) { |
|
| 549 | + } elseif (preg_match(':^#A4:',$message)) { |
|
| 501 | 550 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
| 502 | - } |
|
| 503 | - elseif (preg_match(':^#A6:',$message)) { |
|
| 551 | + } elseif (preg_match(':^#A6:',$message)) { |
|
| 504 | 552 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
| 505 | - } |
|
| 506 | - elseif (preg_match(':^#A8:',$message)) { |
|
| 553 | + } elseif (preg_match(':^#A8:',$message)) { |
|
| 507 | 554 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
| 508 | - } |
|
| 509 | - elseif (preg_match(':^#A9:',$message)) { |
|
| 555 | + } elseif (preg_match(':^#A9:',$message)) { |
|
| 510 | 556 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
| 511 | - } |
|
| 512 | - elseif (preg_match(':^#A0:',$message)) { |
|
| 557 | + } elseif (preg_match(':^#A0:',$message)) { |
|
| 513 | 558 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
| 514 | - } |
|
| 515 | - elseif (preg_match(':^#AA:',$message)) { |
|
| 559 | + } elseif (preg_match(':^#AA:',$message)) { |
|
| 516 | 560 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 517 | - } |
|
| 518 | - elseif (preg_match(':^#AB:',$message)) { |
|
| 561 | + } elseif (preg_match(':^#AB:',$message)) { |
|
| 519 | 562 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
| 520 | - } |
|
| 521 | - elseif (preg_match(':^#AC:',$message)) { |
|
| 563 | + } elseif (preg_match(':^#AC:',$message)) { |
|
| 522 | 564 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
| 523 | - } |
|
| 524 | - elseif (preg_match(':^#AD:',$message)) { |
|
| 565 | + } elseif (preg_match(':^#AD:',$message)) { |
|
| 525 | 566 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
| 526 | - } |
|
| 527 | - elseif (preg_match(':^#AF:',$message)) { |
|
| 567 | + } elseif (preg_match(':^#AF:',$message)) { |
|
| 528 | 568 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
| 529 | - } |
|
| 530 | - elseif (preg_match(':^#B1:',$message)) { |
|
| 569 | + } elseif (preg_match(':^#B1:',$message)) { |
|
| 531 | 570 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
| 532 | - } |
|
| 533 | - elseif (preg_match(':^#B2:',$message)) { |
|
| 571 | + } elseif (preg_match(':^#B2:',$message)) { |
|
| 534 | 572 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
| 535 | - } |
|
| 536 | - elseif (preg_match(':^#B3:',$message)) { |
|
| 573 | + } elseif (preg_match(':^#B3:',$message)) { |
|
| 537 | 574 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
| 538 | - } |
|
| 539 | - elseif (preg_match(':^#B4:',$message)) { |
|
| 575 | + } elseif (preg_match(':^#B4:',$message)) { |
|
| 540 | 576 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
| 541 | - } |
|
| 542 | - elseif (preg_match(':^#B6:',$message)) { |
|
| 577 | + } elseif (preg_match(':^#B6:',$message)) { |
|
| 543 | 578 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
| 544 | - } |
|
| 545 | - elseif (preg_match(':^#B8:',$message)) { |
|
| 579 | + } elseif (preg_match(':^#B8:',$message)) { |
|
| 546 | 580 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
| 547 | - } |
|
| 548 | - elseif (preg_match(':^#B9:',$message)) { |
|
| 581 | + } elseif (preg_match(':^#B9:',$message)) { |
|
| 549 | 582 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
| 550 | - } |
|
| 551 | - elseif (preg_match(':^#B0:',$message)) { |
|
| 583 | + } elseif (preg_match(':^#B0:',$message)) { |
|
| 552 | 584 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
| 553 | - } |
|
| 554 | - elseif (preg_match(':^#BA:',$message)) { |
|
| 585 | + } elseif (preg_match(':^#BA:',$message)) { |
|
| 555 | 586 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 556 | - } |
|
| 557 | - elseif (preg_match(':^#BB:',$message)) { |
|
| 587 | + } elseif (preg_match(':^#BB:',$message)) { |
|
| 558 | 588 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
| 559 | - } |
|
| 560 | - elseif (preg_match(':^#BC:',$message)) { |
|
| 589 | + } elseif (preg_match(':^#BC:',$message)) { |
|
| 561 | 590 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
| 562 | - } |
|
| 563 | - elseif (preg_match(':^#BD:',$message)) { |
|
| 591 | + } elseif (preg_match(':^#BD:',$message)) { |
|
| 564 | 592 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
| 565 | - } |
|
| 566 | - elseif (preg_match(':^#BE:',$message)) { |
|
| 593 | + } elseif (preg_match(':^#BE:',$message)) { |
|
| 567 | 594 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
| 568 | - } |
|
| 569 | - elseif (preg_match(':^#BF:',$message)) { |
|
| 595 | + } elseif (preg_match(':^#BF:',$message)) { |
|
| 570 | 596 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
| 571 | - } |
|
| 572 | - elseif (preg_match(':^#H3:',$message)) { |
|
| 597 | + } elseif (preg_match(':^#H3:',$message)) { |
|
| 573 | 598 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
| 574 | 599 | } |
| 575 | 600 | } |
| 576 | 601 | if ($label == '10') { |
| 577 | 602 | if (preg_match(':^DTO01:',$message)) { |
| 578 | 603 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
| 579 | - } |
|
| 580 | - elseif (preg_match(':^AIS01:',$message)) { |
|
| 604 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
| 581 | 605 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
| 582 | - } |
|
| 583 | - elseif (preg_match(':^FTX01:',$message)) { |
|
| 606 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
| 584 | 607 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
| 585 | - } |
|
| 586 | - elseif (preg_match(':^FPL01:',$message)) { |
|
| 608 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
| 587 | 609 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
| 588 | - } |
|
| 589 | - elseif (preg_match(':^WAB01:',$message)) { |
|
| 610 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
| 590 | 611 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
| 591 | - } |
|
| 592 | - elseif (preg_match(':^MET01:',$message)) { |
|
| 612 | + } elseif (preg_match(':^MET01:',$message)) { |
|
| 593 | 613 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
| 594 | - } |
|
| 595 | - elseif (preg_match(':^WAB02:',$message)) { |
|
| 614 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
| 596 | 615 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
| 597 | 616 | } |
| 598 | 617 | } |
@@ -607,38 +626,28 @@ discard block |
||
| 607 | 626 | $vsta = array('Version' => $version); |
| 608 | 627 | if ($state == 'E') { |
| 609 | 628 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
| 610 | - } |
|
| 611 | - elseif ($state == 'L') { |
|
| 629 | + } elseif ($state == 'L') { |
|
| 612 | 630 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
| 613 | - } |
|
| 614 | - else { |
|
| 631 | + } else { |
|
| 615 | 632 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
| 616 | 633 | } |
| 617 | 634 | if ($type == 'V') { |
| 618 | 635 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
| 619 | - } |
|
| 620 | - elseif ($type == 'S') { |
|
| 636 | + } elseif ($type == 'S') { |
|
| 621 | 637 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
| 622 | - } |
|
| 623 | - elseif ($type == 'H') { |
|
| 638 | + } elseif ($type == 'H') { |
|
| 624 | 639 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
| 625 | - } |
|
| 626 | - elseif ($type == 'G') { |
|
| 640 | + } elseif ($type == 'G') { |
|
| 627 | 641 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
| 628 | - } |
|
| 629 | - elseif ($type == 'C') { |
|
| 642 | + } elseif ($type == 'C') { |
|
| 630 | 643 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
| 631 | - } |
|
| 632 | - elseif ($type == '2') { |
|
| 644 | + } elseif ($type == '2') { |
|
| 633 | 645 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
| 634 | - } |
|
| 635 | - elseif ($type == 'X') { |
|
| 646 | + } elseif ($type == 'X') { |
|
| 636 | 647 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
| 637 | - } |
|
| 638 | - elseif ($type == 'I') { |
|
| 648 | + } elseif ($type == 'I') { |
|
| 639 | 649 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
| 640 | - } |
|
| 641 | - else { |
|
| 650 | + } else { |
|
| 642 | 651 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
| 643 | 652 | } |
| 644 | 653 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -647,7 +656,9 @@ discard block |
||
| 647 | 656 | } |
| 648 | 657 | |
| 649 | 658 | $title = $this->getTitlefromLabel($label); |
| 650 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
| 659 | + if ($title != '') { |
|
| 660 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
| 661 | + } |
|
| 651 | 662 | |
| 652 | 663 | /* |
| 653 | 664 | // Business jets always use GS0001 |
@@ -688,14 +699,26 @@ discard block |
||
| 688 | 699 | $decode = $message['decode']; |
| 689 | 700 | $registration = $message['registration']; |
| 690 | 701 | |
| 691 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
| 692 | - else $latitude = ''; |
|
| 693 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
| 694 | - else $longitude = ''; |
|
| 695 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
| 696 | - else $airicao = ''; |
|
| 697 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
| 698 | - else $icao = $Translation->checkTranslation($ident); |
|
| 702 | + if (isset($decode['latitude'])) { |
|
| 703 | + $latitude = $decode['latitude']; |
|
| 704 | + } else { |
|
| 705 | + $latitude = ''; |
|
| 706 | + } |
|
| 707 | + if (isset($decode['longitude'])) { |
|
| 708 | + $longitude = $decode['longitude']; |
|
| 709 | + } else { |
|
| 710 | + $longitude = ''; |
|
| 711 | + } |
|
| 712 | + if (isset($decode['airicao'])) { |
|
| 713 | + $airicao = $decode['airicao']; |
|
| 714 | + } else { |
|
| 715 | + $airicao = ''; |
|
| 716 | + } |
|
| 717 | + if (isset($decode['icao'])) { |
|
| 718 | + $icao = $decode['icao']; |
|
| 719 | + } else { |
|
| 720 | + $icao = $Translation->checkTranslation($ident); |
|
| 721 | + } |
|
| 699 | 722 | |
| 700 | 723 | $image_array = $Image->getSpotterImage($registration); |
| 701 | 724 | if (!isset($image_array[0]['registration'])) { |
@@ -703,11 +726,18 @@ discard block |
||
| 703 | 726 | } |
| 704 | 727 | |
| 705 | 728 | // Business jets always use GS0001 |
| 706 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 707 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
| 729 | + if ($ident != 'GS0001') { |
|
| 730 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 731 | + } |
|
| 732 | + if ($globalDebug && isset($info) && $info != '') { |
|
| 733 | + echo $info; |
|
| 734 | + } |
|
| 708 | 735 | |
| 709 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
| 710 | - else $decode_json = ''; |
|
| 736 | + if (count($decode) > 0) { |
|
| 737 | + $decode_json = json_encode($decode); |
|
| 738 | + } else { |
|
| 739 | + $decode_json = ''; |
|
| 740 | + } |
|
| 711 | 741 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 712 | 742 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
| 713 | 743 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
@@ -715,8 +745,12 @@ discard block |
||
| 715 | 745 | } |
| 716 | 746 | |
| 717 | 747 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
| 718 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 719 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 748 | + if (!isset($globalACARSArchive)) { |
|
| 749 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 750 | + } |
|
| 751 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
| 752 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 753 | + } |
|
| 720 | 754 | |
| 721 | 755 | if ($globalDebug && count($decode) > 0) { |
| 722 | 756 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
@@ -741,7 +775,9 @@ discard block |
||
| 741 | 775 | $Connection = new Connection($this->db); |
| 742 | 776 | $this->db = $Connection->db; |
| 743 | 777 | |
| 744 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
| 778 | + if ($globalDebug) { |
|
| 779 | + echo "Test if not already in Live ACARS table..."; |
|
| 780 | + } |
|
| 745 | 781 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 746 | 782 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
| 747 | 783 | try { |
@@ -751,7 +787,9 @@ discard block |
||
| 751 | 787 | return "error : ".$e->getMessage(); |
| 752 | 788 | } |
| 753 | 789 | if ($stht->fetchColumn() == 0) { |
| 754 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 790 | + if ($globalDebug) { |
|
| 791 | + echo "Add Live ACARS data..."; |
|
| 792 | + } |
|
| 755 | 793 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
| 756 | 794 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
| 757 | 795 | try { |
@@ -762,10 +800,14 @@ discard block |
||
| 762 | 800 | return "error : ".$e->getMessage(); |
| 763 | 801 | } |
| 764 | 802 | } else { |
| 765 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
| 803 | + if ($globalDebug) { |
|
| 804 | + echo "Data already in DB...\n"; |
|
| 805 | + } |
|
| 766 | 806 | return false; |
| 767 | 807 | } |
| 768 | - if ($globalDebug) echo "Done\n"; |
|
| 808 | + if ($globalDebug) { |
|
| 809 | + echo "Done\n"; |
|
| 810 | + } |
|
| 769 | 811 | return true; |
| 770 | 812 | } |
| 771 | 813 | } |
@@ -797,7 +839,9 @@ discard block |
||
| 797 | 839 | } |
| 798 | 840 | if ($stht->fetchColumn() == 0) { |
| 799 | 841 | */ |
| 800 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 842 | + if ($globalDebug) { |
|
| 843 | + echo "Add Live ACARS data..."; |
|
| 844 | + } |
|
| 801 | 845 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 802 | 846 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
| 803 | 847 | try { |
@@ -808,7 +852,9 @@ discard block |
||
| 808 | 852 | return "error : ".$e->getMessage(); |
| 809 | 853 | } |
| 810 | 854 | // } |
| 811 | - if ($globalDebug) echo "Done\n"; |
|
| 855 | + if ($globalDebug) { |
|
| 856 | + echo "Done\n"; |
|
| 857 | + } |
|
| 812 | 858 | } |
| 813 | 859 | } |
| 814 | 860 | |
@@ -832,8 +878,11 @@ discard block |
||
| 832 | 878 | die; |
| 833 | 879 | } |
| 834 | 880 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 835 | - if (count($row) > 0) return $row[0]['title']; |
|
| 836 | - else return ''; |
|
| 881 | + if (count($row) > 0) { |
|
| 882 | + return $row[0]['title']; |
|
| 883 | + } else { |
|
| 884 | + return ''; |
|
| 885 | + } |
|
| 837 | 886 | } |
| 838 | 887 | |
| 839 | 888 | /** |
@@ -853,8 +902,11 @@ discard block |
||
| 853 | 902 | die; |
| 854 | 903 | } |
| 855 | 904 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 856 | - if (count($row) > 0) return $row; |
|
| 857 | - else return array(); |
|
| 905 | + if (count($row) > 0) { |
|
| 906 | + return $row; |
|
| 907 | + } else { |
|
| 908 | + return array(); |
|
| 909 | + } |
|
| 858 | 910 | } |
| 859 | 911 | |
| 860 | 912 | /** |
@@ -875,8 +927,11 @@ discard block |
||
| 875 | 927 | die; |
| 876 | 928 | } |
| 877 | 929 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 878 | - if (count($row) > 0) return $row[0]; |
|
| 879 | - else return array(); |
|
| 930 | + if (count($row) > 0) { |
|
| 931 | + return $row[0]; |
|
| 932 | + } else { |
|
| 933 | + return array(); |
|
| 934 | + } |
|
| 880 | 935 | } |
| 881 | 936 | |
| 882 | 937 | /** |
@@ -928,20 +983,36 @@ discard block |
||
| 928 | 983 | if ($row['registration'] != '') { |
| 929 | 984 | $row['registration'] = str_replace('.','',$row['registration']); |
| 930 | 985 | $image_array = $Image->getSpotterImage($row['registration']); |
| 931 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 932 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 933 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 934 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 935 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 986 | + if (count($image_array) > 0) { |
|
| 987 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 988 | + } else { |
|
| 989 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 990 | + } |
|
| 991 | + } else { |
|
| 992 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 993 | + } |
|
| 994 | + if ($row['registration'] == '') { |
|
| 995 | + $row['registration'] = 'NA'; |
|
| 996 | + } |
|
| 997 | + if ($row['ident'] == '') { |
|
| 998 | + $row['ident'] = 'NA'; |
|
| 999 | + } |
|
| 936 | 1000 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 937 | 1001 | if (isset($identicao[0])) { |
| 938 | 1002 | if (substr($row['ident'],0,2) == 'AF') { |
| 939 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 940 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 941 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1003 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1004 | + $icao = $row['ident']; |
|
| 1005 | + } else { |
|
| 1006 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1007 | + } |
|
| 1008 | + } else { |
|
| 1009 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1010 | + } |
|
| 942 | 1011 | |
| 943 | 1012 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 944 | - } else $icao = $row['ident']; |
|
| 1013 | + } else { |
|
| 1014 | + $icao = $row['ident']; |
|
| 1015 | + } |
|
| 945 | 1016 | $icao = $Translation->checkTranslation($icao,false); |
| 946 | 1017 | |
| 947 | 1018 | $decode = json_decode($row['decode'],true); |
@@ -967,7 +1038,9 @@ discard block |
||
| 967 | 1038 | $found = true; |
| 968 | 1039 | } |
| 969 | 1040 | } |
| 970 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1041 | + if ($found) { |
|
| 1042 | + $row['decode'] = json_encode($decode); |
|
| 1043 | + } |
|
| 971 | 1044 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 972 | 1045 | $result[] = $data; |
| 973 | 1046 | $i++; |
@@ -975,8 +1048,9 @@ discard block |
||
| 975 | 1048 | if (isset($result)) { |
| 976 | 1049 | $result[0]['query_number_rows'] = $i; |
| 977 | 1050 | return $result; |
| 1051 | + } else { |
|
| 1052 | + return array(); |
|
| 978 | 1053 | } |
| 979 | - else return array(); |
|
| 980 | 1054 | } |
| 981 | 1055 | |
| 982 | 1056 | /** |
@@ -1036,20 +1110,36 @@ discard block |
||
| 1036 | 1110 | if ($row['registration'] != '') { |
| 1037 | 1111 | $row['registration'] = str_replace('.','',$row['registration']); |
| 1038 | 1112 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1039 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 1040 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1041 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1113 | + if (count($image_array) > 0) { |
|
| 1114 | + $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 1115 | + } else { |
|
| 1116 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1117 | + } |
|
| 1118 | + } else { |
|
| 1119 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1120 | + } |
|
| 1042 | 1121 | $icao = ''; |
| 1043 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 1044 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1122 | + if ($row['registration'] == '') { |
|
| 1123 | + $row['registration'] = 'NA'; |
|
| 1124 | + } |
|
| 1125 | + if ($row['ident'] == '') { |
|
| 1126 | + $row['ident'] = 'NA'; |
|
| 1127 | + } |
|
| 1045 | 1128 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 1046 | 1129 | if (isset($identicao[0])) { |
| 1047 | 1130 | if (substr($row['ident'],0,2) == 'AF') { |
| 1048 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1049 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1050 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1131 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1132 | + $icao = $row['ident']; |
|
| 1133 | + } else { |
|
| 1134 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1135 | + } |
|
| 1136 | + } else { |
|
| 1137 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1138 | + } |
|
| 1051 | 1139 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 1052 | - } else $icao = $row['ident']; |
|
| 1140 | + } else { |
|
| 1141 | + $icao = $row['ident']; |
|
| 1142 | + } |
|
| 1053 | 1143 | $icao = $Translation->checkTranslation($icao); |
| 1054 | 1144 | |
| 1055 | 1145 | |
@@ -1057,12 +1147,16 @@ discard block |
||
| 1057 | 1147 | $found = false; |
| 1058 | 1148 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
| 1059 | 1149 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1060 | - if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1150 | + if (isset($airport_info[0]['icao'])) { |
|
| 1151 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1152 | + } |
|
| 1061 | 1153 | $found = true; |
| 1062 | 1154 | } |
| 1063 | 1155 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
| 1064 | 1156 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1065 | - if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1157 | + if (isset($airport_info[0]['icao'])) { |
|
| 1158 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1159 | + } |
|
| 1066 | 1160 | $found = true; |
| 1067 | 1161 | } |
| 1068 | 1162 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1072,7 +1166,9 @@ discard block |
||
| 1072 | 1166 | $found = true; |
| 1073 | 1167 | } |
| 1074 | 1168 | } |
| 1075 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1169 | + if ($found) { |
|
| 1170 | + $row['decode'] = json_encode($decode); |
|
| 1171 | + } |
|
| 1076 | 1172 | |
| 1077 | 1173 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1078 | 1174 | $result[] = $data; |
@@ -1081,7 +1177,9 @@ discard block |
||
| 1081 | 1177 | if (isset($result)) { |
| 1082 | 1178 | $result[0]['query_number_rows'] = $i; |
| 1083 | 1179 | return $result; |
| 1084 | - } else return array(); |
|
| 1180 | + } else { |
|
| 1181 | + return array(); |
|
| 1182 | + } |
|
| 1085 | 1183 | } |
| 1086 | 1184 | |
| 1087 | 1185 | /** |
@@ -1097,19 +1195,29 @@ discard block |
||
| 1097 | 1195 | $ident = trim($ident); |
| 1098 | 1196 | $Translation = new Translation($this->db); |
| 1099 | 1197 | $Spotter = new Spotter($this->db); |
| 1100 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
| 1198 | + if ($globalDebug) { |
|
| 1199 | + echo "Test if we add ModeS data..."; |
|
| 1200 | + } |
|
| 1101 | 1201 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
| 1102 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
| 1103 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
| 1202 | + if ($icao == '') { |
|
| 1203 | + $icao = $Translation->checkTranslation($ident); |
|
| 1204 | + } |
|
| 1205 | + if ($globalDebug) { |
|
| 1206 | + echo '- Ident : '.$icao.' - '; |
|
| 1207 | + } |
|
| 1104 | 1208 | if ($ident == '' || $registration == '') { |
| 1105 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
| 1209 | + if ($globalDebug) { |
|
| 1210 | + echo "Ident or registration null, exit\n"; |
|
| 1211 | + } |
|
| 1106 | 1212 | return ''; |
| 1107 | 1213 | } |
| 1108 | 1214 | |
| 1109 | 1215 | $registration = str_replace('.','',$registration); |
| 1110 | 1216 | $ident = $Translation->ident2icao($ident); |
| 1111 | 1217 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1112 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
| 1218 | + if ($globalDebug) { |
|
| 1219 | + echo "Check if needed to add translation ".$ident.'... '; |
|
| 1220 | + } |
|
| 1113 | 1221 | $querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1"; |
| 1114 | 1222 | $querysi_values = array(':registration' => $registration); |
| 1115 | 1223 | try { |
@@ -1117,7 +1225,9 @@ discard block |
||
| 1117 | 1225 | $sthsi = $this->db->prepare($querysi); |
| 1118 | 1226 | $sthsi->execute($querysi_values); |
| 1119 | 1227 | } catch(PDOException $e) { |
| 1120 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1228 | + if ($globalDebug) { |
|
| 1229 | + echo $e->getMessage(); |
|
| 1230 | + } |
|
| 1121 | 1231 | return "error : ".$e->getMessage(); |
| 1122 | 1232 | } |
| 1123 | 1233 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1125,9 +1235,14 @@ discard block |
||
| 1125 | 1235 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
| 1126 | 1236 | $Translation = new Translation($this->db); |
| 1127 | 1237 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1128 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1129 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1130 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1238 | + if ($globalDebug) { |
|
| 1239 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1240 | + } |
|
| 1241 | + if ($ident != $trans_ident) { |
|
| 1242 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1243 | + } elseif ($trans_ident == $ident) { |
|
| 1244 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1245 | + } |
|
| 1131 | 1246 | } else { |
| 1132 | 1247 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1133 | 1248 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1136,17 +1251,24 @@ discard block |
||
| 1136 | 1251 | $sth = $this->db->prepare($query); |
| 1137 | 1252 | $sth->execute($query_values); |
| 1138 | 1253 | } catch(PDOException $e) { |
| 1139 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1254 | + if ($globalDebug) { |
|
| 1255 | + echo $e->getMessage(); |
|
| 1256 | + } |
|
| 1140 | 1257 | return "error : ".$e->getMessage(); |
| 1141 | 1258 | } |
| 1142 | 1259 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1143 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
| 1144 | - else $hex = ''; |
|
| 1260 | + if (isset($result['modes'])) { |
|
| 1261 | + $hex = $result['modes']; |
|
| 1262 | + } else { |
|
| 1263 | + $hex = ''; |
|
| 1264 | + } |
|
| 1145 | 1265 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
| 1146 | 1266 | $this->SI->add($SI_data); |
| 1147 | 1267 | } |
| 1148 | 1268 | } |
| 1149 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1269 | + if ($globalDebug) { |
|
| 1270 | + echo 'Done'."\n"; |
|
| 1271 | + } |
|
| 1150 | 1272 | |
| 1151 | 1273 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
| 1152 | 1274 | $query_values = array(':ident' => $icao); |
@@ -1155,14 +1277,19 @@ discard block |
||
| 1155 | 1277 | $sth = $this->db->prepare($query); |
| 1156 | 1278 | $sth->execute($query_values); |
| 1157 | 1279 | } catch(PDOException $e) { |
| 1158 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1280 | + if ($globalDebug) { |
|
| 1281 | + echo $e->getMessage(); |
|
| 1282 | + } |
|
| 1159 | 1283 | return "error : ".$e->getMessage(); |
| 1160 | 1284 | } |
| 1161 | 1285 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1162 | 1286 | //print_r($result); |
| 1163 | 1287 | if (isset($result['flightaware_id'])) { |
| 1164 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
| 1165 | - else $ModeS = ''; |
|
| 1288 | + if (isset($result['ModeS'])) { |
|
| 1289 | + $ModeS = $result['ModeS']; |
|
| 1290 | + } else { |
|
| 1291 | + $ModeS = ''; |
|
| 1292 | + } |
|
| 1166 | 1293 | if ($ModeS == '') { |
| 1167 | 1294 | $id = explode('-',$result['flightaware_id']); |
| 1168 | 1295 | $ModeS = $id[0]; |
@@ -1176,13 +1303,17 @@ discard block |
||
| 1176 | 1303 | $sthc = $this->db->prepare($queryc); |
| 1177 | 1304 | $sthc->execute($queryc_values); |
| 1178 | 1305 | } catch(PDOException $e) { |
| 1179 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1306 | + if ($globalDebug) { |
|
| 1307 | + echo $e->getMessage(); |
|
| 1308 | + } |
|
| 1180 | 1309 | return "error : ".$e->getMessage(); |
| 1181 | 1310 | } |
| 1182 | 1311 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1183 | 1312 | |
| 1184 | 1313 | if (count($row) == 0) { |
| 1185 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
| 1314 | + if ($globalDebug) { |
|
| 1315 | + echo " Add to ModeS table - "; |
|
| 1316 | + } |
|
| 1186 | 1317 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1187 | 1318 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
| 1188 | 1319 | try { |
@@ -1190,11 +1321,15 @@ discard block |
||
| 1190 | 1321 | $sthi = $this->db->prepare($queryi); |
| 1191 | 1322 | $sthi->execute($queryi_values); |
| 1192 | 1323 | } catch(PDOException $e) { |
| 1193 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1324 | + if ($globalDebug) { |
|
| 1325 | + echo $e->getMessage(); |
|
| 1326 | + } |
|
| 1194 | 1327 | return "error : ".$e->getMessage(); |
| 1195 | 1328 | } |
| 1196 | 1329 | } else { |
| 1197 | - if ($globalDebug) echo " Update ModeS table - "; |
|
| 1330 | + if ($globalDebug) { |
|
| 1331 | + echo " Update ModeS table - "; |
|
| 1332 | + } |
|
| 1198 | 1333 | if ($ICAOTypeCode != '') { |
| 1199 | 1334 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1200 | 1335 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1207,7 +1342,9 @@ discard block |
||
| 1207 | 1342 | $sthi = $this->db->prepare($queryi); |
| 1208 | 1343 | $sthi->execute($queryi_values); |
| 1209 | 1344 | } catch(PDOException $e) { |
| 1210 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1345 | + if ($globalDebug) { |
|
| 1346 | + echo $e->getMessage(); |
|
| 1347 | + } |
|
| 1211 | 1348 | return "error : ".$e->getMessage(); |
| 1212 | 1349 | } |
| 1213 | 1350 | } |
@@ -1229,7 +1366,9 @@ discard block |
||
| 1229 | 1366 | return "error : ".$e->getMessage(); |
| 1230 | 1367 | } |
| 1231 | 1368 | */ |
| 1232 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
| 1369 | + if ($globalDebug) { |
|
| 1370 | + echo " Update Spotter_output table - "; |
|
| 1371 | + } |
|
| 1233 | 1372 | if ($ICAOTypeCode != '') { |
| 1234 | 1373 | if ($globalDBdriver == 'mysql') { |
| 1235 | 1374 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1240,8 +1379,7 @@ discard block |
||
| 1240 | 1379 | } else { |
| 1241 | 1380 | if ($globalDBdriver == 'mysql') { |
| 1242 | 1381 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
| 1243 | - } |
|
| 1244 | - elseif ($globalDBdriver == 'pgsql') { |
|
| 1382 | + } elseif ($globalDBdriver == 'pgsql') { |
|
| 1245 | 1383 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1246 | 1384 | } |
| 1247 | 1385 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1251,15 +1389,21 @@ discard block |
||
| 1251 | 1389 | $sthi = $this->db->prepare($queryi); |
| 1252 | 1390 | $sthi->execute($queryi_values); |
| 1253 | 1391 | } catch(PDOException $e) { |
| 1254 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1392 | + if ($globalDebug) { |
|
| 1393 | + echo $e->getMessage(); |
|
| 1394 | + } |
|
| 1255 | 1395 | return "error : ".$e->getMessage(); |
| 1256 | 1396 | } |
| 1257 | 1397 | |
| 1258 | 1398 | } |
| 1259 | 1399 | } else { |
| 1260 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
| 1400 | + if ($globalDebug) { |
|
| 1401 | + echo " Can't find ModeS in spotter_output - "; |
|
| 1402 | + } |
|
| 1403 | + } |
|
| 1404 | + if ($globalDebug) { |
|
| 1405 | + echo "Done\n"; |
|
| 1261 | 1406 | } |
| 1262 | - if ($globalDebug) echo "Done\n"; |
|
| 1263 | 1407 | } |
| 1264 | 1408 | } |
| 1265 | 1409 | ?> |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | * @return String the icao |
| 23 | 23 | */ |
| 24 | 24 | public function ident2icao($ident) { |
| 25 | - if (substr($ident,0,2) == 'AF') { |
|
| 26 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 27 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 25 | + if (substr($ident, 0, 2) == 'AF') { |
|
| 26 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 27 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
| 28 | 28 | } else { |
| 29 | 29 | $Spotter = new Spotter($this->db); |
| 30 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
| 30 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
| 31 | 31 | if (isset($identicao[0])) { |
| 32 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
| 32 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
| 33 | 33 | } else $icao = $ident; |
| 34 | 34 | } |
| 35 | 35 | return $icao; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $sth = $this->db->prepare($query); |
| 55 | 55 | $sth->execute(); |
| 56 | - } catch(PDOException $e) { |
|
| 56 | + } catch (PDOException $e) { |
|
| 57 | 57 | return "error"; |
| 58 | 58 | } |
| 59 | 59 | return "success"; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $sth = $this->db->prepare($query); |
| 79 | 79 | $sth->execute(); |
| 80 | - } catch(PDOException $e) { |
|
| 80 | + } catch (PDOException $e) { |
|
| 81 | 81 | return "error"; |
| 82 | 82 | } |
| 83 | 83 | return "success"; |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | $ident = ''; |
| 103 | 103 | $message = ''; |
| 104 | 104 | $result = array(); |
| 105 | - $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 106 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 105 | + $n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 106 | + if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 107 | 107 | if ($n != 0) { |
| 108 | - $registration = str_replace('.','',$registration); |
|
| 109 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
| 108 | + $registration = str_replace('.', '', $registration); |
|
| 109 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
| 110 | 110 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
| 111 | 111 | } else $message = $data; |
| 112 | 112 | $airicao = ''; |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | $temp = ''; |
| 128 | 128 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
| 129 | 129 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 130 | - $latitude = $la / 10000.0; |
|
| 131 | - $longitude = $ln / 10000.0; |
|
| 130 | + $latitude = $la/10000.0; |
|
| 131 | + $longitude = $ln/10000.0; |
|
| 132 | 132 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 133 | 133 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 134 | 134 | // Temp not always available |
| 135 | 135 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
| 136 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 137 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 136 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
| 137 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
| 138 | 138 | |
| 139 | 139 | //$icao = $Translation->checkTranslation($ident); |
| 140 | 140 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -146,19 +146,19 @@ discard block |
||
| 146 | 146 | $dhour = ''; |
| 147 | 147 | $darr = ''; |
| 148 | 148 | $ahour = ''; |
| 149 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
| 149 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
| 150 | 150 | if ($n == 4 && strlen($darr) == 4) { |
| 151 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 152 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 153 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 151 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 152 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
| 153 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
| 154 | 154 | //$icao = ACARS->ident2icao($ident); |
| 155 | 155 | //$icao = $Translation->checkTranslation($ident); |
| 156 | 156 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 157 | 157 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
| 158 | 158 | $found = true; |
| 159 | 159 | } |
| 160 | - elseif ($n == 2 || $n == 4) { |
|
| 161 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 160 | + elseif ($n == 2 || $n == 4) { |
|
| 161 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 162 | 162 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
| 163 | 163 | //$icao = ACARS->ident2icao($ident); |
| 164 | 164 | //$icao = $Translation->checkTranslation($ident); |
@@ -216,11 +216,11 @@ discard block |
||
| 216 | 216 | $ahour = ''; |
| 217 | 217 | $aair = ''; |
| 218 | 218 | $apiste = ''; |
| 219 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
|
| 219 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste); |
|
| 220 | 220 | if ($n > 8) { |
| 221 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
| 222 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 223 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 221 | + if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
| 222 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 223 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
| 224 | 224 | $icao = trim($aident); |
| 225 | 225 | |
| 226 | 226 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -245,8 +245,8 @@ discard block |
||
| 245 | 245 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 246 | 246 | $las = $las.'.'.$lass; |
| 247 | 247 | $lns = $lns.'.'.$lns; |
| 248 | - $latitude = $las / 1000.0; |
|
| 249 | - $longitude = $lns / 1000.0; |
|
| 248 | + $latitude = $las/1000.0; |
|
| 249 | + $longitude = $lns/1000.0; |
|
| 250 | 250 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 251 | 251 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 252 | 252 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -341,17 +341,17 @@ discard block |
||
| 341 | 341 | $alt = ''; |
| 342 | 342 | $fuel = ''; |
| 343 | 343 | $speed = ''; |
| 344 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
| 344 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
| 345 | 345 | if ($n == 9) { |
| 346 | 346 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 347 | 347 | $icao = trim($aident); |
| 348 | 348 | $decode['icao'] = $icao; |
| 349 | - $latitude = $las / 100.0; |
|
| 350 | - $longitude = $lns / 100.0; |
|
| 349 | + $latitude = $las/100.0; |
|
| 350 | + $longitude = $lns/100.0; |
|
| 351 | 351 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 352 | 352 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 353 | 353 | |
| 354 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
| 354 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
| 355 | 355 | $found = true; |
| 356 | 356 | } |
| 357 | 357 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 371 | 371 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 372 | 372 | |
| 373 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
| 373 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
| 374 | 374 | $found = true; |
| 375 | 375 | } |
| 376 | 376 | } |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | $dair = ''; |
| 404 | 404 | $darr = ''; |
| 405 | 405 | $aident = ''; |
| 406 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
| 406 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
| 407 | 407 | if ($n == 8) { |
| 408 | 408 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 409 | 409 | $icao = trim($aident); |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | $dair = ''; |
| 438 | 438 | $darr = ''; |
| 439 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
| 439 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
| 440 | 440 | if ($n == 3) { |
| 441 | 441 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 442 | 442 | //$icao = $Translation->checkTranslation($ident); |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | $dair = ''; |
| 454 | 454 | $darr = ''; |
| 455 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
| 455 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
| 456 | 456 | if ($n == 3) { |
| 457 | 457 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 458 | 458 | //$icao = $Translation->checkTranslation($ident); |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | if (!$found) { |
| 466 | - $n = sscanf($message,'MET01%4c',$airport); |
|
| 466 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
| 467 | 467 | if ($n == 1) { |
| 468 | 468 | if ($globalDebug) echo 'airport name : '.$airport; |
| 469 | 469 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -472,241 +472,241 @@ discard block |
||
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | if ($label == 'H1') { |
| 475 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
| 476 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
| 475 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
| 476 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
| 477 | 477 | } |
| 478 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 479 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
| 478 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
| 479 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
| 480 | 480 | } |
| 481 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 482 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
| 481 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
| 482 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
| 483 | 483 | } |
| 484 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 485 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
| 484 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
| 485 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
| 486 | 486 | } |
| 487 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 488 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
| 487 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
| 488 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
| 489 | 489 | } |
| 490 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 491 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
| 490 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
| 491 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
| 492 | 492 | } |
| 493 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 494 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
| 493 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
| 494 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
| 495 | 495 | } |
| 496 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 497 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
| 496 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
| 497 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
| 498 | 498 | } |
| 499 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 500 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
| 499 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
| 500 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
| 501 | 501 | } |
| 502 | - elseif (preg_match(':^#CF:',$message)) { |
|
| 503 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
| 502 | + elseif (preg_match(':^#CF:', $message)) { |
|
| 503 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
| 504 | 504 | } |
| 505 | - elseif (preg_match(':^#DF:',$message)) { |
|
| 506 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
| 505 | + elseif (preg_match(':^#DF:', $message)) { |
|
| 506 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
| 507 | 507 | } |
| 508 | - elseif (preg_match(':^#EC:',$message)) { |
|
| 509 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
| 508 | + elseif (preg_match(':^#EC:', $message)) { |
|
| 509 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
| 510 | 510 | } |
| 511 | - elseif (preg_match(':^#EI:',$message)) { |
|
| 512 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
| 511 | + elseif (preg_match(':^#EI:', $message)) { |
|
| 512 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
| 513 | 513 | } |
| 514 | - elseif (preg_match(':^#H1:',$message)) { |
|
| 515 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
| 514 | + elseif (preg_match(':^#H1:', $message)) { |
|
| 515 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
| 516 | 516 | } |
| 517 | - elseif (preg_match(':^#H2:',$message)) { |
|
| 518 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
| 517 | + elseif (preg_match(':^#H2:', $message)) { |
|
| 518 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
| 519 | 519 | } |
| 520 | - elseif (preg_match(':^#HD:',$message)) { |
|
| 521 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
| 520 | + elseif (preg_match(':^#HD:', $message)) { |
|
| 521 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
| 522 | 522 | } |
| 523 | - elseif (preg_match(':^#M1:',$message)) { |
|
| 524 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
| 523 | + elseif (preg_match(':^#M1:', $message)) { |
|
| 524 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
| 525 | 525 | } |
| 526 | - elseif (preg_match(':^#M2:',$message)) { |
|
| 527 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
| 526 | + elseif (preg_match(':^#M2:', $message)) { |
|
| 527 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
| 528 | 528 | } |
| 529 | - elseif (preg_match(':^#M3:',$message)) { |
|
| 530 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
| 529 | + elseif (preg_match(':^#M3:', $message)) { |
|
| 530 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
| 531 | 531 | } |
| 532 | - elseif (preg_match(':^#MD:',$message)) { |
|
| 533 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
| 532 | + elseif (preg_match(':^#MD:', $message)) { |
|
| 533 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
| 534 | 534 | } |
| 535 | - elseif (preg_match(':^#PS:',$message)) { |
|
| 536 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
| 535 | + elseif (preg_match(':^#PS:', $message)) { |
|
| 536 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
| 537 | 537 | } |
| 538 | - elseif (preg_match(':^#S1:',$message)) { |
|
| 539 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
| 538 | + elseif (preg_match(':^#S1:', $message)) { |
|
| 539 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
| 540 | 540 | } |
| 541 | - elseif (preg_match(':^#S2:',$message)) { |
|
| 542 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
| 541 | + elseif (preg_match(':^#S2:', $message)) { |
|
| 542 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
| 543 | 543 | } |
| 544 | - elseif (preg_match(':^#SD:',$message)) { |
|
| 545 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
| 544 | + elseif (preg_match(':^#SD:', $message)) { |
|
| 545 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
| 546 | 546 | } |
| 547 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 548 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
| 547 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
| 548 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
| 549 | 549 | } |
| 550 | - elseif (preg_match(':^#WO:',$message)) { |
|
| 551 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
| 550 | + elseif (preg_match(':^#WO:', $message)) { |
|
| 551 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
| 552 | 552 | } |
| 553 | - elseif (preg_match(':^#A1:',$message)) { |
|
| 554 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
| 553 | + elseif (preg_match(':^#A1:', $message)) { |
|
| 554 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
| 555 | 555 | } |
| 556 | - elseif (preg_match(':^#A3:',$message)) { |
|
| 557 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
| 556 | + elseif (preg_match(':^#A3:', $message)) { |
|
| 557 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
| 558 | 558 | } |
| 559 | - elseif (preg_match(':^#A4:',$message)) { |
|
| 560 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
| 559 | + elseif (preg_match(':^#A4:', $message)) { |
|
| 560 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
| 561 | 561 | } |
| 562 | - elseif (preg_match(':^#A6:',$message)) { |
|
| 563 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
| 562 | + elseif (preg_match(':^#A6:', $message)) { |
|
| 563 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
| 564 | 564 | } |
| 565 | - elseif (preg_match(':^#A8:',$message)) { |
|
| 566 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
| 565 | + elseif (preg_match(':^#A8:', $message)) { |
|
| 566 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
| 567 | 567 | } |
| 568 | - elseif (preg_match(':^#A9:',$message)) { |
|
| 569 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
| 568 | + elseif (preg_match(':^#A9:', $message)) { |
|
| 569 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
| 570 | 570 | } |
| 571 | - elseif (preg_match(':^#A0:',$message)) { |
|
| 572 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
| 571 | + elseif (preg_match(':^#A0:', $message)) { |
|
| 572 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
| 573 | 573 | } |
| 574 | - elseif (preg_match(':^#AA:',$message)) { |
|
| 575 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
| 574 | + elseif (preg_match(':^#AA:', $message)) { |
|
| 575 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
| 576 | 576 | } |
| 577 | - elseif (preg_match(':^#AB:',$message)) { |
|
| 578 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
| 577 | + elseif (preg_match(':^#AB:', $message)) { |
|
| 578 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
| 579 | 579 | } |
| 580 | - elseif (preg_match(':^#AC:',$message)) { |
|
| 581 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
| 580 | + elseif (preg_match(':^#AC:', $message)) { |
|
| 581 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
| 582 | 582 | } |
| 583 | - elseif (preg_match(':^#AD:',$message)) { |
|
| 584 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
| 583 | + elseif (preg_match(':^#AD:', $message)) { |
|
| 584 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
| 585 | 585 | } |
| 586 | - elseif (preg_match(':^#AF:',$message)) { |
|
| 587 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
| 586 | + elseif (preg_match(':^#AF:', $message)) { |
|
| 587 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
| 588 | 588 | } |
| 589 | - elseif (preg_match(':^#B1:',$message)) { |
|
| 590 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
| 589 | + elseif (preg_match(':^#B1:', $message)) { |
|
| 590 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
| 591 | 591 | } |
| 592 | - elseif (preg_match(':^#B2:',$message)) { |
|
| 593 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
| 592 | + elseif (preg_match(':^#B2:', $message)) { |
|
| 593 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
| 594 | 594 | } |
| 595 | - elseif (preg_match(':^#B3:',$message)) { |
|
| 596 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
| 595 | + elseif (preg_match(':^#B3:', $message)) { |
|
| 596 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
| 597 | 597 | } |
| 598 | - elseif (preg_match(':^#B4:',$message)) { |
|
| 599 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
| 598 | + elseif (preg_match(':^#B4:', $message)) { |
|
| 599 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
| 600 | 600 | } |
| 601 | - elseif (preg_match(':^#B6:',$message)) { |
|
| 602 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
| 601 | + elseif (preg_match(':^#B6:', $message)) { |
|
| 602 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
| 603 | 603 | } |
| 604 | - elseif (preg_match(':^#B8:',$message)) { |
|
| 605 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
| 604 | + elseif (preg_match(':^#B8:', $message)) { |
|
| 605 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
| 606 | 606 | } |
| 607 | - elseif (preg_match(':^#B9:',$message)) { |
|
| 608 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
| 607 | + elseif (preg_match(':^#B9:', $message)) { |
|
| 608 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
| 609 | 609 | } |
| 610 | - elseif (preg_match(':^#B0:',$message)) { |
|
| 611 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
| 610 | + elseif (preg_match(':^#B0:', $message)) { |
|
| 611 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
| 612 | 612 | } |
| 613 | - elseif (preg_match(':^#BA:',$message)) { |
|
| 614 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
| 613 | + elseif (preg_match(':^#BA:', $message)) { |
|
| 614 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
| 615 | 615 | } |
| 616 | - elseif (preg_match(':^#BB:',$message)) { |
|
| 617 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
| 616 | + elseif (preg_match(':^#BB:', $message)) { |
|
| 617 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
| 618 | 618 | } |
| 619 | - elseif (preg_match(':^#BC:',$message)) { |
|
| 620 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
| 619 | + elseif (preg_match(':^#BC:', $message)) { |
|
| 620 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
| 621 | 621 | } |
| 622 | - elseif (preg_match(':^#BD:',$message)) { |
|
| 623 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
| 622 | + elseif (preg_match(':^#BD:', $message)) { |
|
| 623 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
| 624 | 624 | } |
| 625 | - elseif (preg_match(':^#BE:',$message)) { |
|
| 626 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
| 625 | + elseif (preg_match(':^#BE:', $message)) { |
|
| 626 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
| 627 | 627 | } |
| 628 | - elseif (preg_match(':^#BF:',$message)) { |
|
| 629 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
| 628 | + elseif (preg_match(':^#BF:', $message)) { |
|
| 629 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
| 630 | 630 | } |
| 631 | - elseif (preg_match(':^#H3:',$message)) { |
|
| 632 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
| 631 | + elseif (preg_match(':^#H3:', $message)) { |
|
| 632 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
| 633 | 633 | } |
| 634 | 634 | } |
| 635 | 635 | if ($label == '10') { |
| 636 | - if (preg_match(':^DTO01:',$message)) { |
|
| 637 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
| 636 | + if (preg_match(':^DTO01:', $message)) { |
|
| 637 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
| 638 | 638 | } |
| 639 | - elseif (preg_match(':^AIS01:',$message)) { |
|
| 640 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
| 639 | + elseif (preg_match(':^AIS01:', $message)) { |
|
| 640 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
| 641 | 641 | } |
| 642 | - elseif (preg_match(':^FTX01:',$message)) { |
|
| 643 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
| 642 | + elseif (preg_match(':^FTX01:', $message)) { |
|
| 643 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
| 644 | 644 | } |
| 645 | - elseif (preg_match(':^FPL01:',$message)) { |
|
| 646 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
| 645 | + elseif (preg_match(':^FPL01:', $message)) { |
|
| 646 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
| 647 | 647 | } |
| 648 | - elseif (preg_match(':^WAB01:',$message)) { |
|
| 649 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
| 648 | + elseif (preg_match(':^WAB01:', $message)) { |
|
| 649 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
| 650 | 650 | } |
| 651 | - elseif (preg_match(':^MET01:',$message)) { |
|
| 652 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
| 651 | + elseif (preg_match(':^MET01:', $message)) { |
|
| 652 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
| 653 | 653 | } |
| 654 | - elseif (preg_match(':^WAB02:',$message)) { |
|
| 655 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
| 654 | + elseif (preg_match(':^WAB02:', $message)) { |
|
| 655 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
| 656 | 656 | } |
| 657 | 657 | } |
| 658 | 658 | if ($label == '15') { |
| 659 | - if (preg_match(':^FST01:',$message)) { |
|
| 660 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
| 659 | + if (preg_match(':^FST01:', $message)) { |
|
| 660 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | if (!$found && $label == 'SA') { |
| 664 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
| 664 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
| 665 | 665 | if ($n == 4) { |
| 666 | 666 | $vsta = array('Version' => $version); |
| 667 | 667 | if ($state == 'E') { |
| 668 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
| 668 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
| 669 | 669 | } |
| 670 | 670 | elseif ($state == 'L') { |
| 671 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
| 671 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
| 672 | 672 | } |
| 673 | 673 | else { |
| 674 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
| 674 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
| 675 | 675 | } |
| 676 | 676 | if ($type == 'V') { |
| 677 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
| 677 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
| 678 | 678 | } |
| 679 | 679 | elseif ($type == 'S') { |
| 680 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
| 680 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
| 681 | 681 | } |
| 682 | 682 | elseif ($type == 'H') { |
| 683 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
| 683 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
| 684 | 684 | } |
| 685 | 685 | elseif ($type == 'G') { |
| 686 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
| 686 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
| 687 | 687 | } |
| 688 | 688 | elseif ($type == 'C') { |
| 689 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
| 689 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
| 690 | 690 | } |
| 691 | 691 | elseif ($type == '2') { |
| 692 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
| 692 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
| 693 | 693 | } |
| 694 | 694 | elseif ($type == 'X') { |
| 695 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
| 695 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
| 696 | 696 | } |
| 697 | 697 | elseif ($type == 'I') { |
| 698 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
| 698 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
| 699 | 699 | } |
| 700 | 700 | else { |
| 701 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
| 701 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
| 702 | 702 | } |
| 703 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
| 704 | - $decode = array_merge($vsta,$decode); |
|
| 703 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
| 704 | + $decode = array_merge($vsta, $decode); |
|
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | $title = $this->getTitlefromLabel($label); |
| 709 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
| 709 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
| 710 | 710 | |
| 711 | 711 | /* |
| 712 | 712 | // Business jets always use GS0001 |
@@ -739,13 +739,13 @@ discard block |
||
| 739 | 739 | $message = $this->parse($data); |
| 740 | 740 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
| 741 | 741 | |
| 742 | - $ident = (string)$message['ident']; |
|
| 742 | + $ident = (string) $message['ident']; |
|
| 743 | 743 | $label = $message['label']; |
| 744 | 744 | $block_id = $message['block_id']; |
| 745 | 745 | $msg_no = $message['msg_no']; |
| 746 | 746 | $msg = $message['message']; |
| 747 | 747 | $decode = $message['decode']; |
| 748 | - $registration = (string)$message['registration']; |
|
| 748 | + $registration = (string) $message['registration']; |
|
| 749 | 749 | |
| 750 | 750 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
| 751 | 751 | else $latitude = ''; |
@@ -762,23 +762,23 @@ discard block |
||
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | // Business jets always use GS0001 |
| 765 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 765 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
| 766 | 766 | if ($globalDebug && isset($info) && $info != '') echo $info; |
| 767 | 767 | |
| 768 | 768 | if (count($decode) > 0) $decode_json = json_encode($decode); |
| 769 | 769 | else $decode_json = ''; |
| 770 | 770 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 771 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
| 771 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
| 772 | 772 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
| 773 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
| 773 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 777 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 778 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 776 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
| 777 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
| 778 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
| 779 | 779 | |
| 780 | 780 | if ($globalDebug && count($decode) > 0) { |
| 781 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
| 781 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | } |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | * @param String $msg_no Number of the ACARS message |
| 794 | 794 | * @param String $message ACARS message |
| 795 | 795 | */ |
| 796 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
| 796 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
| 797 | 797 | global $globalDebug; |
| 798 | 798 | date_default_timezone_set('UTC'); |
| 799 | 799 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -802,22 +802,22 @@ discard block |
||
| 802 | 802 | |
| 803 | 803 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
| 804 | 804 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 805 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
| 805 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
| 806 | 806 | try { |
| 807 | 807 | $stht = $this->db->prepare($query_test); |
| 808 | 808 | $stht->execute($query_test_values); |
| 809 | - } catch(PDOException $e) { |
|
| 809 | + } catch (PDOException $e) { |
|
| 810 | 810 | return "error : ".$e->getMessage(); |
| 811 | 811 | } |
| 812 | 812 | if ($stht->fetchColumn() == 0) { |
| 813 | 813 | if ($globalDebug) echo "Add Live ACARS data..."; |
| 814 | 814 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
| 815 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
|
| 815 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s")); |
|
| 816 | 816 | try { |
| 817 | 817 | |
| 818 | 818 | $sth = $this->db->prepare($query); |
| 819 | 819 | $sth->execute($query_values); |
| 820 | - } catch(PDOException $e) { |
|
| 820 | + } catch (PDOException $e) { |
|
| 821 | 821 | return "error : ".$e->getMessage(); |
| 822 | 822 | } |
| 823 | 823 | } else { |
@@ -839,10 +839,10 @@ discard block |
||
| 839 | 839 | * @param String $msg_no Number of the ACARS message |
| 840 | 840 | * @param String $message ACARS message |
| 841 | 841 | */ |
| 842 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
| 842 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
| 843 | 843 | global $globalDebug; |
| 844 | 844 | date_default_timezone_set('UTC'); |
| 845 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
| 845 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
| 846 | 846 | /* |
| 847 | 847 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
| 848 | 848 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -858,12 +858,12 @@ discard block |
||
| 858 | 858 | */ |
| 859 | 859 | if ($globalDebug) echo "Add Live ACARS data..."; |
| 860 | 860 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 861 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
| 861 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
| 862 | 862 | try { |
| 863 | 863 | |
| 864 | 864 | $sth = $this->db->prepare($query); |
| 865 | 865 | $sth->execute($query_values); |
| 866 | - } catch(PDOException $e) { |
|
| 866 | + } catch (PDOException $e) { |
|
| 867 | 867 | return "error : ".$e->getMessage(); |
| 868 | 868 | } |
| 869 | 869 | // } |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | |
| 887 | 887 | $sth = $this->db->prepare($query); |
| 888 | 888 | $sth->execute($query_values); |
| 889 | - } catch(PDOException $e) { |
|
| 889 | + } catch (PDOException $e) { |
|
| 890 | 890 | echo "error : ".$e->getMessage(); |
| 891 | 891 | die; |
| 892 | 892 | } |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | |
| 908 | 908 | $sth = $this->db->prepare($query); |
| 909 | 909 | $sth->execute($query_values); |
| 910 | - } catch(PDOException $e) { |
|
| 910 | + } catch (PDOException $e) { |
|
| 911 | 911 | echo "error : ".$e->getMessage(); |
| 912 | 912 | die; |
| 913 | 913 | } |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | |
| 930 | 930 | $sth = $this->db->prepare($query); |
| 931 | 931 | $sth->execute($query_values); |
| 932 | - } catch(PDOException $e) { |
|
| 932 | + } catch (PDOException $e) { |
|
| 933 | 933 | echo "error : ".$e->getMessage(); |
| 934 | 934 | die; |
| 935 | 935 | } |
@@ -943,7 +943,7 @@ discard block |
||
| 943 | 943 | * |
| 944 | 944 | * @return Array Return ACARS data in array |
| 945 | 945 | */ |
| 946 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
| 946 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
| 947 | 947 | global $globalURL, $globalDBdriver; |
| 948 | 948 | $Image = new Image($this->db); |
| 949 | 949 | $Spotter = new Spotter($this->db); |
@@ -955,8 +955,8 @@ discard block |
||
| 955 | 955 | { |
| 956 | 956 | $limit_array = explode(",", $limit); |
| 957 | 957 | |
| 958 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 959 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 958 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 959 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 960 | 960 | |
| 961 | 961 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 962 | 962 | { |
@@ -978,48 +978,48 @@ discard block |
||
| 978 | 978 | |
| 979 | 979 | $sth = $this->db->prepare($query); |
| 980 | 980 | $sth->execute($query_values); |
| 981 | - } catch(PDOException $e) { |
|
| 981 | + } catch (PDOException $e) { |
|
| 982 | 982 | return "error : ".$e->getMessage(); |
| 983 | 983 | } |
| 984 | 984 | $i = 0; |
| 985 | 985 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 986 | 986 | $data = array(); |
| 987 | 987 | if ($row['registration'] != '') { |
| 988 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
| 988 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
| 989 | 989 | $image_array = $Image->getSpotterImage($row['registration']); |
| 990 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 991 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 992 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 990 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 991 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 992 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 993 | 993 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 994 | 994 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 995 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
| 995 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
| 996 | 996 | if (isset($identicao[0])) { |
| 997 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 998 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 999 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1000 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 997 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 998 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 999 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 1000 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 1001 | 1001 | |
| 1002 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 1002 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 1003 | 1003 | } else $icao = $row['ident']; |
| 1004 | - $icao = $Translation->checkTranslation($icao,false); |
|
| 1004 | + $icao = $Translation->checkTranslation($icao, false); |
|
| 1005 | 1005 | |
| 1006 | - $decode = json_decode($row['decode'],true); |
|
| 1006 | + $decode = json_decode($row['decode'], true); |
|
| 1007 | 1007 | $found = false; |
| 1008 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
| 1008 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
| 1009 | 1009 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1010 | 1010 | if (isset($airport_info[0]['icao'])) { |
| 1011 | 1011 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1012 | 1012 | $found = true; |
| 1013 | 1013 | } |
| 1014 | 1014 | } |
| 1015 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
| 1015 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
| 1016 | 1016 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1017 | 1017 | if (isset($airport_info[0]['icao'])) { |
| 1018 | 1018 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1019 | 1019 | $found = true; |
| 1020 | 1020 | } |
| 1021 | 1021 | } |
| 1022 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
| 1022 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
| 1023 | 1023 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
| 1024 | 1024 | if (isset($airport_info[0]['icao'])) { |
| 1025 | 1025 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1027,7 +1027,7 @@ discard block |
||
| 1027 | 1027 | } |
| 1028 | 1028 | } |
| 1029 | 1029 | if ($found) $row['decode'] = json_encode($decode); |
| 1030 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1030 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1031 | 1031 | $result[] = $data; |
| 1032 | 1032 | $i++; |
| 1033 | 1033 | } |
@@ -1043,7 +1043,7 @@ discard block |
||
| 1043 | 1043 | * |
| 1044 | 1044 | * @return Array Return ACARS data in array |
| 1045 | 1045 | */ |
| 1046 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
| 1046 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
| 1047 | 1047 | global $globalURL, $globalDBdriver; |
| 1048 | 1048 | $Image = new Image($this->db); |
| 1049 | 1049 | $Spotter = new Spotter($this->db); |
@@ -1055,8 +1055,8 @@ discard block |
||
| 1055 | 1055 | { |
| 1056 | 1056 | $limit_array = explode(",", $limit); |
| 1057 | 1057 | |
| 1058 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1059 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1058 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1059 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1060 | 1060 | |
| 1061 | 1061 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1062 | 1062 | { |
@@ -1086,45 +1086,45 @@ discard block |
||
| 1086 | 1086 | |
| 1087 | 1087 | $sth = $this->db->prepare($query); |
| 1088 | 1088 | $sth->execute($query_values); |
| 1089 | - } catch(PDOException $e) { |
|
| 1089 | + } catch (PDOException $e) { |
|
| 1090 | 1090 | return "error : ".$e->getMessage(); |
| 1091 | 1091 | } |
| 1092 | - $i=0; |
|
| 1092 | + $i = 0; |
|
| 1093 | 1093 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 1094 | 1094 | $data = array(); |
| 1095 | 1095 | if ($row['registration'] != '') { |
| 1096 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
| 1096 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
| 1097 | 1097 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1098 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 1099 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1100 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1098 | + if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 1099 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 1100 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 1101 | 1101 | $icao = ''; |
| 1102 | 1102 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 1103 | 1103 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 1104 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
| 1104 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
| 1105 | 1105 | if (isset($identicao[0])) { |
| 1106 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 1107 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1108 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1109 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1110 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 1106 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 1107 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1108 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 1109 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 1110 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 1111 | 1111 | } else $icao = $row['ident']; |
| 1112 | 1112 | $icao = $Translation->checkTranslation($icao); |
| 1113 | 1113 | |
| 1114 | 1114 | |
| 1115 | - $decode = json_decode($row['decode'],true); |
|
| 1115 | + $decode = json_decode($row['decode'], true); |
|
| 1116 | 1116 | $found = false; |
| 1117 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
| 1117 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
| 1118 | 1118 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1119 | 1119 | if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1120 | 1120 | $found = true; |
| 1121 | 1121 | } |
| 1122 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
| 1122 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
| 1123 | 1123 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1124 | 1124 | if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1125 | 1125 | $found = true; |
| 1126 | 1126 | } |
| 1127 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
| 1127 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
| 1128 | 1128 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
| 1129 | 1129 | if (isset($airport_info[0]['icao'])) { |
| 1130 | 1130 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1133,7 +1133,7 @@ discard block |
||
| 1133 | 1133 | } |
| 1134 | 1134 | if ($found) $row['decode'] = json_encode($decode); |
| 1135 | 1135 | |
| 1136 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1136 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1137 | 1137 | $result[] = $data; |
| 1138 | 1138 | $i++; |
| 1139 | 1139 | } |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | * @param String $icao |
| 1152 | 1152 | * @param String $ICAOTypeCode |
| 1153 | 1153 | */ |
| 1154 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
| 1154 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
| 1155 | 1155 | global $globalDebug, $globalDBdriver; |
| 1156 | 1156 | $ident = trim($ident); |
| 1157 | 1157 | $Translation = new Translation($this->db); |
@@ -1165,7 +1165,7 @@ discard block |
||
| 1165 | 1165 | return ''; |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | - $registration = str_replace('.','',$registration); |
|
| 1168 | + $registration = str_replace('.', '', $registration); |
|
| 1169 | 1169 | $ident = $Translation->ident2icao($ident); |
| 1170 | 1170 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1171 | 1171 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | |
| 1176 | 1176 | $sthsi = $this->db->prepare($querysi); |
| 1177 | 1177 | $sthsi->execute($querysi_values); |
| 1178 | - } catch(PDOException $e) { |
|
| 1178 | + } catch (PDOException $e) { |
|
| 1179 | 1179 | if ($globalDebug) echo $e->getMessage(); |
| 1180 | 1180 | return "error : ".$e->getMessage(); |
| 1181 | 1181 | } |
@@ -1185,8 +1185,8 @@ discard block |
||
| 1185 | 1185 | $Translation = new Translation($this->db); |
| 1186 | 1186 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1187 | 1187 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
| 1188 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1189 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1188 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
| 1189 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
| 1190 | 1190 | } else { |
| 1191 | 1191 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1192 | 1192 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1194,14 +1194,14 @@ discard block |
||
| 1194 | 1194 | try { |
| 1195 | 1195 | $sth = $this->db->prepare($query); |
| 1196 | 1196 | $sth->execute($query_values); |
| 1197 | - } catch(PDOException $e) { |
|
| 1197 | + } catch (PDOException $e) { |
|
| 1198 | 1198 | if ($globalDebug) echo $e->getMessage(); |
| 1199 | 1199 | return "error : ".$e->getMessage(); |
| 1200 | 1200 | } |
| 1201 | 1201 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1202 | 1202 | if (isset($result['modes'])) $hex = $result['modes']; |
| 1203 | 1203 | else $hex = ''; |
| 1204 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
| 1204 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
| 1205 | 1205 | $this->SI->add($SI_data); |
| 1206 | 1206 | } |
| 1207 | 1207 | } |
@@ -1213,7 +1213,7 @@ discard block |
||
| 1213 | 1213 | |
| 1214 | 1214 | $sth = $this->db->prepare($query); |
| 1215 | 1215 | $sth->execute($query_values); |
| 1216 | - } catch(PDOException $e) { |
|
| 1216 | + } catch (PDOException $e) { |
|
| 1217 | 1217 | if ($globalDebug) echo $e->getMessage(); |
| 1218 | 1218 | return "error : ".$e->getMessage(); |
| 1219 | 1219 | } |
@@ -1223,7 +1223,7 @@ discard block |
||
| 1223 | 1223 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
| 1224 | 1224 | else $ModeS = ''; |
| 1225 | 1225 | if ($ModeS == '') { |
| 1226 | - $id = explode('-',$result['flightaware_id']); |
|
| 1226 | + $id = explode('-', $result['flightaware_id']); |
|
| 1227 | 1227 | $ModeS = $id[0]; |
| 1228 | 1228 | } |
| 1229 | 1229 | if ($ModeS != '') { |
@@ -1234,21 +1234,21 @@ discard block |
||
| 1234 | 1234 | |
| 1235 | 1235 | $sthc = $this->db->prepare($queryc); |
| 1236 | 1236 | $sthc->execute($queryc_values); |
| 1237 | - } catch(PDOException $e) { |
|
| 1237 | + } catch (PDOException $e) { |
|
| 1238 | 1238 | if ($globalDebug) echo $e->getMessage(); |
| 1239 | 1239 | return "error : ".$e->getMessage(); |
| 1240 | 1240 | } |
| 1241 | 1241 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1242 | 1242 | |
| 1243 | - if (count($row) == 0) { |
|
| 1243 | + if (count($row) == 0) { |
|
| 1244 | 1244 | if ($globalDebug) echo " Add to ModeS table - "; |
| 1245 | 1245 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1246 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1246 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1247 | 1247 | try { |
| 1248 | 1248 | |
| 1249 | 1249 | $sthi = $this->db->prepare($queryi); |
| 1250 | 1250 | $sthi->execute($queryi_values); |
| 1251 | - } catch(PDOException $e) { |
|
| 1251 | + } catch (PDOException $e) { |
|
| 1252 | 1252 | if ($globalDebug) echo $e->getMessage(); |
| 1253 | 1253 | return "error : ".$e->getMessage(); |
| 1254 | 1254 | } |
@@ -1256,16 +1256,16 @@ discard block |
||
| 1256 | 1256 | if ($globalDebug) echo " Update ModeS table - "; |
| 1257 | 1257 | if ($ICAOTypeCode != '') { |
| 1258 | 1258 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1259 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1259 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1260 | 1260 | } else { |
| 1261 | 1261 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1262 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
| 1262 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
| 1263 | 1263 | } |
| 1264 | 1264 | try { |
| 1265 | 1265 | |
| 1266 | 1266 | $sthi = $this->db->prepare($queryi); |
| 1267 | 1267 | $sthi->execute($queryi_values); |
| 1268 | - } catch(PDOException $e) { |
|
| 1268 | + } catch (PDOException $e) { |
|
| 1269 | 1269 | if ($globalDebug) echo $e->getMessage(); |
| 1270 | 1270 | return "error : ".$e->getMessage(); |
| 1271 | 1271 | } |
@@ -1303,13 +1303,13 @@ discard block |
||
| 1303 | 1303 | elseif ($globalDBdriver == 'pgsql') { |
| 1304 | 1304 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1305 | 1305 | } |
| 1306 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
| 1306 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
| 1307 | 1307 | } |
| 1308 | 1308 | try { |
| 1309 | 1309 | |
| 1310 | 1310 | $sthi = $this->db->prepare($queryi); |
| 1311 | 1311 | $sthi->execute($queryi_values); |
| 1312 | - } catch(PDOException $e) { |
|
| 1312 | + } catch (PDOException $e) { |
|
| 1313 | 1313 | if ($globalDebug) echo $e->getMessage(); |
| 1314 | 1314 | return "error : ".$e->getMessage(); |
| 1315 | 1315 | } |
@@ -319,6 +319,9 @@ |
||
| 319 | 319 | return false; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | + /** |
|
| 323 | + * @param string $aircraft_icao |
|
| 324 | + */ |
|
| 322 | 325 | public function fromIvaoMtl($aircraft_icao,$airline_icao) { |
| 323 | 326 | $Common = new Common(); |
| 324 | 327 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Gets the images based on the aircraft registration |
|
| 16 | - * |
|
| 17 | - * @return Array the images list |
|
| 18 | - * |
|
| 19 | - */ |
|
| 15 | + * Gets the images based on the aircraft registration |
|
| 16 | + * |
|
| 17 | + * @return Array the images list |
|
| 18 | + * |
|
| 19 | + */ |
|
| 20 | 20 | public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 21 | 21 | { |
| 22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | WHERE spotter_image.registration = :registration"; |
| 30 | 30 | $sth = $this->db->prepare($query); |
| 31 | 31 | $sth->execute(array(':registration' => $registration)); |
| 32 | - /* |
|
| 32 | + /* |
|
| 33 | 33 | $images_array = array(); |
| 34 | 34 | $temp_array = array(); |
| 35 | 35 | |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * Gets the image copyright based on the Exif data |
|
| 56 | - * |
|
| 57 | - * @return String image copyright |
|
| 58 | - * |
|
| 59 | - */ |
|
| 55 | + * Gets the image copyright based on the Exif data |
|
| 56 | + * |
|
| 57 | + * @return String image copyright |
|
| 58 | + * |
|
| 59 | + */ |
|
| 60 | 60 | public function getExifCopyright($url) { |
| 61 | 61 | $exif = exif_read_data($url); |
| 62 | 62 | $copyright = ''; |
@@ -71,11 +71,11 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * Adds the images based on the aircraft registration |
|
| 75 | - * |
|
| 76 | - * @return String either success or error |
|
| 77 | - * |
|
| 78 | - */ |
|
| 74 | + * Adds the images based on the aircraft registration |
|
| 75 | + * |
|
| 76 | + * @return String either success or error |
|
| 77 | + * |
|
| 78 | + */ |
|
| 79 | 79 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 80 | 80 | { |
| 81 | 81 | global $globalDebug,$globalAircraftImageFetch; |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | - * Gets the aircraft image |
|
| 108 | - * |
|
| 109 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 110 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 111 | - * |
|
| 112 | - */ |
|
| 107 | + * Gets the aircraft image |
|
| 108 | + * |
|
| 109 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 110 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 111 | + * |
|
| 112 | + */ |
|
| 113 | 113 | public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
| 114 | 114 | { |
| 115 | 115 | global $globalAircraftImageSources, $globalIVAO; |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | - * Gets the aircraft image from Planespotters |
|
| 153 | - * |
|
| 154 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 155 | - * @param String $aircraft_name type of the aircraft |
|
| 156 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 157 | - * |
|
| 158 | - */ |
|
| 152 | + * Gets the aircraft image from Planespotters |
|
| 153 | + * |
|
| 154 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 155 | + * @param String $aircraft_name type of the aircraft |
|
| 156 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 157 | + * |
|
| 158 | + */ |
|
| 159 | 159 | public function fromPlanespotters($aircraft_registration, $aircraft_name='') { |
| 160 | 160 | $Common = new Common(); |
| 161 | 161 | // If aircraft registration is only number, also check with aircraft model |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | - * Gets the aircraft image from Deviantart |
|
| 186 | - * |
|
| 187 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 188 | - * @param String $aircraft_name type of the aircraft |
|
| 189 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 190 | - * |
|
| 191 | - */ |
|
| 185 | + * Gets the aircraft image from Deviantart |
|
| 186 | + * |
|
| 187 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 188 | + * @param String $aircraft_name type of the aircraft |
|
| 189 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 190 | + * |
|
| 191 | + */ |
|
| 192 | 192 | public function fromDeviantart($aircraft_registration, $aircraft_name='') { |
| 193 | 193 | $Common = new Common(); |
| 194 | 194 | // If aircraft registration is only number, also check with aircraft model |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
| 219 | - * Gets the aircraft image from JetPhotos |
|
| 220 | - * |
|
| 221 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 222 | - * @param String $aircraft_name type of the aircraft |
|
| 223 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 224 | - * |
|
| 225 | - */ |
|
| 219 | + * Gets the aircraft image from JetPhotos |
|
| 220 | + * |
|
| 221 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 222 | + * @param String $aircraft_name type of the aircraft |
|
| 223 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 224 | + * |
|
| 225 | + */ |
|
| 226 | 226 | public function fromJetPhotos($aircraft_registration, $aircraft_name='') { |
| 227 | 227 | $Common = new Common(); |
| 228 | 228 | $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
@@ -258,13 +258,13 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | - * Gets the aircraft image from PlanePictures |
|
| 262 | - * |
|
| 263 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 264 | - * @param String $aircraft_name type of the aircraft |
|
| 265 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 266 | - * |
|
| 267 | - */ |
|
| 261 | + * Gets the aircraft image from PlanePictures |
|
| 262 | + * |
|
| 263 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 264 | + * @param String $aircraft_name type of the aircraft |
|
| 265 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 266 | + * |
|
| 267 | + */ |
|
| 268 | 268 | public function fromPlanePictures($aircraft_registration, $aircraft_name='') { |
| 269 | 269 | $Common = new Common(); |
| 270 | 270 | $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
@@ -292,13 +292,13 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | - * Gets the aircraft image from Flickr |
|
| 296 | - * |
|
| 297 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 298 | - * @param String $aircraft_name type of the aircraft |
|
| 299 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 300 | - * |
|
| 301 | - */ |
|
| 295 | + * Gets the aircraft image from Flickr |
|
| 296 | + * |
|
| 297 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 298 | + * @param String $aircraft_name type of the aircraft |
|
| 299 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 300 | + * |
|
| 301 | + */ |
|
| 302 | 302 | public function fromFlickr($aircraft_registration,$aircraft_name='') { |
| 303 | 303 | $Common = new Common(); |
| 304 | 304 | if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
@@ -336,13 +336,13 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | - * Gets the aircraft image from Bing |
|
| 340 | - * |
|
| 341 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 342 | - * @param String $aircraft_name type of the aircraft |
|
| 343 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 344 | - * |
|
| 345 | - */ |
|
| 339 | + * Gets the aircraft image from Bing |
|
| 340 | + * |
|
| 341 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 342 | + * @param String $aircraft_name type of the aircraft |
|
| 343 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 344 | + * |
|
| 345 | + */ |
|
| 346 | 346 | public function fromBing($aircraft_registration,$aircraft_name='') { |
| 347 | 347 | global $globalImageBingKey; |
| 348 | 348 | $Common = new Common(); |
@@ -368,13 +368,13 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
| 371 | - * Gets the aircraft image from airport-data |
|
| 372 | - * |
|
| 373 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 374 | - * @param String $aircraft_name type of the aircraft |
|
| 375 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 376 | - * |
|
| 377 | - */ |
|
| 371 | + * Gets the aircraft image from airport-data |
|
| 372 | + * |
|
| 373 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 374 | + * @param String $aircraft_name type of the aircraft |
|
| 375 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 376 | + * |
|
| 377 | + */ |
|
| 378 | 378 | public function fromAirportData($aircraft_registration,$aircraft_name='') { |
| 379 | 379 | $Common = new Common(); |
| 380 | 380 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
@@ -393,13 +393,13 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | - * Gets the aircraft image from WikiMedia |
|
| 397 | - * |
|
| 398 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 399 | - * @param String $aircraft_name type of the aircraft |
|
| 400 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 401 | - * |
|
| 402 | - */ |
|
| 396 | + * Gets the aircraft image from WikiMedia |
|
| 397 | + * |
|
| 398 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 399 | + * @param String $aircraft_name type of the aircraft |
|
| 400 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 401 | + * |
|
| 402 | + */ |
|
| 403 | 403 | public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
| 404 | 404 | $Common = new Common(); |
| 405 | 405 | if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
@@ -449,13 +449,13 @@ discard block |
||
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /** |
| 452 | - * Gets the aircraft image from custom url |
|
| 453 | - * |
|
| 454 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 455 | - * @param String $aircraft_name type of the aircraft |
|
| 456 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 457 | - * |
|
| 458 | - */ |
|
| 452 | + * Gets the aircraft image from custom url |
|
| 453 | + * |
|
| 454 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 455 | + * @param String $aircraft_name type of the aircraft |
|
| 456 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 457 | + * |
|
| 458 | + */ |
|
| 459 | 459 | public function fromCustomSource($aircraft_registration,$aircraft_name='') { |
| 460 | 460 | global $globalAircraftCustomSources; |
| 461 | 461 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
@@ -17,14 +17,14 @@ discard block |
||
| 17 | 17 | * @return Array the images list |
| 18 | 18 | * |
| 19 | 19 | */ |
| 20 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 20 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 21 | 21 | { |
| 22 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 23 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 24 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 22 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 23 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 24 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 25 | 25 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
| 26 | 26 | $registration = trim($registration); |
| 27 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright |
|
| 27 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright |
|
| 28 | 28 | FROM spotter_image |
| 29 | 29 | WHERE spotter_image.registration = :registration"; |
| 30 | 30 | $sth = $this->db->prepare($query); |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
| 64 | 64 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
| 65 | 65 | if ($copyright != '') { |
| 66 | - $copyright = str_replace('Copyright ','',$copyright); |
|
| 67 | - $copyright = str_replace('© ','',$copyright); |
|
| 68 | - $copyright = str_replace('(c) ','',$copyright); |
|
| 66 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
| 67 | + $copyright = str_replace('© ', '', $copyright); |
|
| 68 | + $copyright = str_replace('(c) ', '', $copyright); |
|
| 69 | 69 | } |
| 70 | 70 | return $copyright; |
| 71 | 71 | } |
@@ -76,26 +76,26 @@ discard block |
||
| 76 | 76 | * @return String either success or error |
| 77 | 77 | * |
| 78 | 78 | */ |
| 79 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 79 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 80 | 80 | { |
| 81 | - global $globalDebug,$globalAircraftImageFetch; |
|
| 81 | + global $globalDebug, $globalAircraftImageFetch; |
|
| 82 | 82 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
| 83 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 83 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 84 | 84 | $registration = trim($registration); |
| 85 | 85 | //getting the aircraft image |
| 86 | 86 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
| 87 | 87 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
| 88 | 88 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
| 89 | 89 | else return "success"; |
| 90 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
| 90 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
| 91 | 91 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
| 92 | 92 | if ($image_url['original'] != '') { |
| 93 | 93 | if ($globalDebug) echo 'Found !'."\n"; |
| 94 | - $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 94 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 95 | 95 | try { |
| 96 | 96 | $sth = $this->db->prepare($query); |
| 97 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
| 98 | - } catch(PDOException $e) { |
|
| 97 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
| 98 | + } catch (PDOException $e) { |
|
| 99 | 99 | echo $e->getMessage()."\n"; |
| 100 | 100 | return "error"; |
| 101 | 101 | } |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | global $globalAircraftImageSources, $globalIVAO; |
| 116 | 116 | $Spotter = new Spotter($this->db); |
| 117 | 117 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
| 118 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
| 118 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
| 119 | 119 | if ($aircraft_registration != '') { |
| 120 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 120 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 121 | 121 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 122 | 122 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 123 | 123 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -129,23 +129,23 @@ discard block |
||
| 129 | 129 | } elseif ($aircraft_icao != '') { |
| 130 | 130 | $aircraft_registration = $aircraft_icao; |
| 131 | 131 | $aircraft_name = ''; |
| 132 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 133 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 132 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 133 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
| 134 | 134 | foreach ($globalAircraftImageSources as $source) { |
| 135 | 135 | $source = strtolower($source); |
| 136 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
| 137 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
| 138 | - if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
| 139 | - if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
| 140 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
| 141 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
| 142 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
| 143 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
| 144 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
| 145 | - if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
| 136 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao, $airline_icao); |
|
| 137 | + if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration, $aircraft_name); |
|
| 138 | + if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration, $aircraft_name); |
|
| 139 | + if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration, $aircraft_name); |
|
| 140 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration, $aircraft_name); |
|
| 141 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration, $aircraft_name); |
|
| 142 | + if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration, $aircraft_name); |
|
| 143 | + if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration, $aircraft_name); |
|
| 144 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration, $aircraft_name); |
|
| 145 | + if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration, $aircraft_name); |
|
| 146 | 146 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 147 | 147 | } |
| 148 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 148 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -156,24 +156,24 @@ discard block |
||
| 156 | 156 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 157 | 157 | * |
| 158 | 158 | */ |
| 159 | - public function fromPlanespotters($aircraft_registration, $aircraft_name='') { |
|
| 159 | + public function fromPlanespotters($aircraft_registration, $aircraft_name = '') { |
|
| 160 | 160 | $Common = new Common(); |
| 161 | 161 | // If aircraft registration is only number, also check with aircraft model |
| 162 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
| 163 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 162 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
| 163 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 164 | 164 | } else { |
| 165 | 165 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
| 166 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 166 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 167 | 167 | } |
| 168 | 168 | $data = $Common->getData($url); |
| 169 | 169 | if ($xml = simplexml_load_string($data)) { |
| 170 | 170 | if (isset($xml->channel->item)) { |
| 171 | 171 | $image_url = array(); |
| 172 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 172 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 173 | 173 | $image_url['thumbnail'] = $thumbnail_url; |
| 174 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
| 175 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 176 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 174 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
| 175 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 176 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 177 | 177 | $image_url['source'] = 'planespotters'; |
| 178 | 178 | return $image_url; |
| 179 | 179 | } |
@@ -189,25 +189,25 @@ discard block |
||
| 189 | 189 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 190 | 190 | * |
| 191 | 191 | */ |
| 192 | - public function fromDeviantart($aircraft_registration, $aircraft_name='') { |
|
| 192 | + public function fromDeviantart($aircraft_registration, $aircraft_name = '') { |
|
| 193 | 193 | $Common = new Common(); |
| 194 | 194 | // If aircraft registration is only number, also check with aircraft model |
| 195 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
| 196 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name); |
|
| 195 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
| 196 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name); |
|
| 197 | 197 | } else { |
| 198 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration; |
|
| 198 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $data = $Common->getData($url); |
| 202 | 202 | if ($xml = simplexml_load_string($data)) { |
| 203 | 203 | if (isset($xml->channel->item->link)) { |
| 204 | 204 | $image_url = array(); |
| 205 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 205 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 206 | 206 | $image_url['thumbnail'] = $thumbnail_url; |
| 207 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 207 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 208 | 208 | $image_url['original'] = $original_url; |
| 209 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 210 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 209 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 210 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 211 | 211 | $image_url['source'] = 'deviantart'; |
| 212 | 212 | return $image_url; |
| 213 | 213 | } |
@@ -223,32 +223,32 @@ discard block |
||
| 223 | 223 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 224 | 224 | * |
| 225 | 225 | */ |
| 226 | - public function fromJetPhotos($aircraft_registration, $aircraft_name='') { |
|
| 226 | + public function fromJetPhotos($aircraft_registration, $aircraft_name = '') { |
|
| 227 | 227 | $Common = new Common(); |
| 228 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 228 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 229 | 229 | $data = $Common->getData($url); |
| 230 | 230 | $dom = new DOMDocument(); |
| 231 | 231 | @$dom->loadHTML($data); |
| 232 | 232 | $all_pics = array(); |
| 233 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 233 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 234 | 234 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
| 235 | 235 | $all_pics[] = $image->getAttribute('src'); |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | $all_authors = array(); |
| 239 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
| 239 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
| 240 | 240 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
| 241 | 241 | $all_authors[] = $author->getAttribute('content'); |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | $all_ref = array(); |
| 245 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 245 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 246 | 246 | $all_ref[] = $link->getAttribute('href'); |
| 247 | 247 | } |
| 248 | 248 | if (isset($all_pics[0])) { |
| 249 | 249 | $image_url = array(); |
| 250 | 250 | $image_url['thumbnail'] = $all_pics[0]; |
| 251 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
| 251 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
| 252 | 252 | $image_url['copyright'] = $all_authors[0]; |
| 253 | 253 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
| 254 | 254 | $image_url['source'] = 'JetPhotos'; |
@@ -265,24 +265,24 @@ discard block |
||
| 265 | 265 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 266 | 266 | * |
| 267 | 267 | */ |
| 268 | - public function fromPlanePictures($aircraft_registration, $aircraft_name='') { |
|
| 268 | + public function fromPlanePictures($aircraft_registration, $aircraft_name = '') { |
|
| 269 | 269 | $Common = new Common(); |
| 270 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 270 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 271 | 271 | $data = $Common->getData($url); |
| 272 | 272 | $dom = new DOMDocument(); |
| 273 | 273 | @$dom->loadHTML($data); |
| 274 | 274 | $all_pics = array(); |
| 275 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 275 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 276 | 276 | $all_pics[] = $image->getAttribute('src'); |
| 277 | 277 | } |
| 278 | 278 | $all_links = array(); |
| 279 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 280 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
| 279 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 280 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
| 281 | 281 | } |
| 282 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1])) { |
|
| 282 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1])) { |
|
| 283 | 283 | $image_url = array(); |
| 284 | 284 | $image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[1]; |
| 285 | - $image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN','',$all_pics[1]); |
|
| 285 | + $image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN', '', $all_pics[1]); |
|
| 286 | 286 | $image_url['copyright'] = $all_links[6]['text']; |
| 287 | 287 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
| 288 | 288 | $image_url['source'] = 'PlanePictures'; |
@@ -299,19 +299,19 @@ discard block |
||
| 299 | 299 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 300 | 300 | * |
| 301 | 301 | */ |
| 302 | - public function fromFlickr($aircraft_registration,$aircraft_name='') { |
|
| 302 | + public function fromFlickr($aircraft_registration, $aircraft_name = '') { |
|
| 303 | 303 | $Common = new Common(); |
| 304 | 304 | if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
| 305 | 305 | else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
| 306 | 306 | $data = $Common->getData($url); |
| 307 | 307 | if ($xml = simplexml_load_string($data)) { |
| 308 | 308 | if (isset($xml->channel->item)) { |
| 309 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
| 309 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
| 310 | 310 | $image_url = array(); |
| 311 | 311 | $image_url['thumbnail'] = $original_url; |
| 312 | 312 | $image_url['original'] = $original_url; |
| 313 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 314 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 313 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 314 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 315 | 315 | $image_url['source'] = 'flickr'; |
| 316 | 316 | return $image_url; |
| 317 | 317 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | return false; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - public function fromIvaoMtl($aircraft_icao,$airline_icao) { |
|
| 322 | + public function fromIvaoMtl($aircraft_icao, $airline_icao) { |
|
| 323 | 323 | $Common = new Common(); |
| 324 | 324 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
| 325 | 325 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -343,14 +343,14 @@ discard block |
||
| 343 | 343 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 344 | 344 | * |
| 345 | 345 | */ |
| 346 | - public function fromBing($aircraft_registration,$aircraft_name='') { |
|
| 346 | + public function fromBing($aircraft_registration, $aircraft_name = '') { |
|
| 347 | 347 | global $globalImageBingKey; |
| 348 | 348 | $Common = new Common(); |
| 349 | 349 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
| 350 | 350 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
| 351 | 351 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
| 352 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
| 353 | - $data = $Common->getData($url,'get','',$headers); |
|
| 352 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
| 353 | + $data = $Common->getData($url, 'get', '', $headers); |
|
| 354 | 354 | $result = json_decode($data); |
| 355 | 355 | if (isset($result->d->results[0]->MediaUrl)) { |
| 356 | 356 | $image_url = array(); |
@@ -375,14 +375,14 @@ discard block |
||
| 375 | 375 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 376 | 376 | * |
| 377 | 377 | */ |
| 378 | - public function fromAirportData($aircraft_registration,$aircraft_name='') { |
|
| 378 | + public function fromAirportData($aircraft_registration, $aircraft_name = '') { |
|
| 379 | 379 | $Common = new Common(); |
| 380 | 380 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
| 381 | 381 | $data = $Common->getData($url); |
| 382 | 382 | $result = json_decode($data); |
| 383 | 383 | if (isset($result->count) && $result->count > 0) { |
| 384 | 384 | $image_url = array(); |
| 385 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
| 385 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
| 386 | 386 | $image_url['source_website'] = $result->data[0]->link; |
| 387 | 387 | $image_url['thumbnail'] = $result->data[0]->image; |
| 388 | 388 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 401 | 401 | * |
| 402 | 402 | */ |
| 403 | - public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
|
| 403 | + public function fromWikimedia($aircraft_registration, $aircraft_name = '') { |
|
| 404 | 404 | $Common = new Common(); |
| 405 | 405 | if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
| 406 | 406 | else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | $result = json_decode($data); |
| 409 | 409 | if (isset($result->query->search[0]->title)) { |
| 410 | 410 | $fileo = $result->query->search[0]->title; |
| 411 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 411 | + if (substr($fileo, -3) == 'pdf') return false; |
|
| 412 | 412 | $file = urlencode($fileo); |
| 413 | 413 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
| 414 | 414 | $data2 = $Common->getData($url2); |
@@ -433,11 +433,11 @@ discard block |
||
| 433 | 433 | if (isset($result2->query->pages)) { |
| 434 | 434 | foreach ($result2->query->pages as $page) { |
| 435 | 435 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
| 436 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 436 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 437 | 437 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
| 438 | 438 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
| 439 | 439 | } |
| 440 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
| 440 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
| 441 | 441 | return $image_url; |
| 442 | 442 | } |
| 443 | 443 | } |
@@ -456,22 +456,22 @@ discard block |
||
| 456 | 456 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 457 | 457 | * |
| 458 | 458 | */ |
| 459 | - public function fromCustomSource($aircraft_registration,$aircraft_name='') { |
|
| 459 | + public function fromCustomSource($aircraft_registration, $aircraft_name = '') { |
|
| 460 | 460 | global $globalAircraftCustomSources; |
| 461 | 461 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 462 | 462 | if (!empty($globalAircraftImageCustomSources)) { |
| 463 | 463 | if (!isset($globalAircraftImageCustomSources[0])) $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources; |
| 464 | 464 | foreach ($globalAircraftImageCustomSources as $source) { |
| 465 | 465 | $Common = new Common(); |
| 466 | - $url = str_replace('{registration}',$aircraft_registration,$source['original']); |
|
| 467 | - $url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['original']); |
|
| 466 | + $url = str_replace('{registration}', $aircraft_registration, $source['original']); |
|
| 467 | + $url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['original']); |
|
| 468 | 468 | if ($Common->urlexist($url)) { |
| 469 | 469 | $image_url = array(); |
| 470 | 470 | $image_url['thumbnail'] = $url_thumbnail; |
| 471 | 471 | $image_url['original'] = $url; |
| 472 | 472 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 473 | 473 | else $exifCopyright = ''; |
| 474 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 474 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 475 | 475 | else $image_url['copyright'] = $source['copyright']; |
| 476 | 476 | $image_url['source_website'] = $source['source_website']; |
| 477 | 477 | $image_url['source'] = $source['source']; |
@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 23 | 23 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
| 24 | 24 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
| 25 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 25 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 26 | + $registration = $aircraft_icao.$airline_icao; |
|
| 27 | + } |
|
| 26 | 28 | $registration = trim($registration); |
| 27 | 29 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright |
| 28 | 30 | FROM spotter_image |
@@ -60,8 +62,11 @@ discard block |
||
| 60 | 62 | public function getExifCopyright($url) { |
| 61 | 63 | $exif = exif_read_data($url); |
| 62 | 64 | $copyright = ''; |
| 63 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
| 64 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
| 65 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
| 66 | + $copyright = $exif['COMPUTED']['copyright']; |
|
| 67 | + } elseif (isset($exif['copyright'])) { |
|
| 68 | + $copyright = $exif['copyright']; |
|
| 69 | + } |
|
| 65 | 70 | if ($copyright != '') { |
| 66 | 71 | $copyright = str_replace('Copyright ','',$copyright); |
| 67 | 72 | $copyright = str_replace('© ','',$copyright); |
@@ -79,18 +84,29 @@ discard block |
||
| 79 | 84 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 80 | 85 | { |
| 81 | 86 | global $globalDebug,$globalAircraftImageFetch; |
| 82 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
| 87 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
| 88 | + return ''; |
|
| 89 | + } |
|
| 83 | 90 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 84 | 91 | $registration = trim($registration); |
| 85 | 92 | //getting the aircraft image |
| 86 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 87 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 88 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 89 | - else return "success"; |
|
| 93 | + if ($globalDebug && $registration != '') { |
|
| 94 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 95 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
| 96 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 97 | + } elseif ($globalDebug && $airline_icao != '') { |
|
| 98 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 99 | + } else { |
|
| 100 | + return "success"; |
|
| 101 | + } |
|
| 90 | 102 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
| 91 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 103 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 104 | + $registration = $aircraft_icao.$airline_icao; |
|
| 105 | + } |
|
| 92 | 106 | if ($image_url['original'] != '') { |
| 93 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 107 | + if ($globalDebug) { |
|
| 108 | + echo 'Found !'."\n"; |
|
| 109 | + } |
|
| 94 | 110 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 95 | 111 | try { |
| 96 | 112 | $sth = $this->db->prepare($query); |
@@ -99,7 +115,9 @@ discard block |
||
| 99 | 115 | echo $e->getMessage()."\n"; |
| 100 | 116 | return "error"; |
| 101 | 117 | } |
| 102 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 118 | + } elseif ($globalDebug) { |
|
| 119 | + echo "Not found :'(\n"; |
|
| 120 | + } |
|
| 103 | 121 | return "success"; |
| 104 | 122 | } |
| 105 | 123 | |
@@ -114,36 +132,75 @@ discard block |
||
| 114 | 132 | { |
| 115 | 133 | global $globalAircraftImageSources, $globalIVAO; |
| 116 | 134 | $Spotter = new Spotter($this->db); |
| 117 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
| 135 | + if (!isset($globalIVAO)) { |
|
| 136 | + $globalIVAO = FALSE; |
|
| 137 | + } |
|
| 118 | 138 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
| 119 | 139 | if ($aircraft_registration != '') { |
| 120 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 140 | + if (strpos($aircraft_registration,'/') !== false) { |
|
| 141 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 142 | + } |
|
| 121 | 143 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 122 | 144 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 123 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 124 | - else $aircraft_name = ''; |
|
| 125 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 126 | - else $aircraft_icao = ''; |
|
| 127 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 128 | - else $airline_icao = ''; |
|
| 145 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
| 146 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 147 | + } else { |
|
| 148 | + $aircraft_name = ''; |
|
| 149 | + } |
|
| 150 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
| 151 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 152 | + } else { |
|
| 153 | + $aircraft_icao = ''; |
|
| 154 | + } |
|
| 155 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
| 156 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 157 | + } else { |
|
| 158 | + $airline_icao = ''; |
|
| 159 | + } |
|
| 129 | 160 | } elseif ($aircraft_icao != '') { |
| 130 | 161 | $aircraft_registration = $aircraft_icao; |
| 131 | 162 | $aircraft_name = ''; |
| 132 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 133 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 163 | + } else { |
|
| 164 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 165 | + } |
|
| 166 | + if (!isset($globalAircraftImageSources)) { |
|
| 167 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 168 | + } |
|
| 134 | 169 | foreach ($globalAircraftImageSources as $source) { |
| 135 | 170 | $source = strtolower($source); |
| 136 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
| 137 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
| 138 | - if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
| 139 | - if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
| 140 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
| 141 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
| 142 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
| 143 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
| 144 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
| 145 | - if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
| 146 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 171 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
| 172 | + $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
| 173 | + } |
|
| 174 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
| 175 | + $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
| 176 | + } |
|
| 177 | + if ($source == 'flickr') { |
|
| 178 | + $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
| 179 | + } |
|
| 180 | + if ($source == 'bing') { |
|
| 181 | + $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
| 182 | + } |
|
| 183 | + if ($source == 'deviantart') { |
|
| 184 | + $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
| 185 | + } |
|
| 186 | + if ($source == 'wikimedia') { |
|
| 187 | + $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
| 188 | + } |
|
| 189 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
| 190 | + $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
| 191 | + } |
|
| 192 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
| 193 | + $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
| 194 | + } |
|
| 195 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
| 196 | + $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
| 197 | + } |
|
| 198 | + if ($source == 'customsources') { |
|
| 199 | + $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
| 200 | + } |
|
| 201 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 202 | + return $images_array; |
|
| 203 | + } |
|
| 147 | 204 | } |
| 148 | 205 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 149 | 206 | } |
@@ -301,8 +358,11 @@ discard block |
||
| 301 | 358 | */ |
| 302 | 359 | public function fromFlickr($aircraft_registration,$aircraft_name='') { |
| 303 | 360 | $Common = new Common(); |
| 304 | - if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
|
| 305 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
|
| 361 | + if ($aircraft_name != '') { |
|
| 362 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
|
| 363 | + } else { |
|
| 364 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
|
| 365 | + } |
|
| 306 | 366 | $data = $Common->getData($url); |
| 307 | 367 | if ($xml = simplexml_load_string($data)) { |
| 308 | 368 | if (isset($xml->channel->item)) { |
@@ -346,9 +406,14 @@ discard block |
||
| 346 | 406 | public function fromBing($aircraft_registration,$aircraft_name='') { |
| 347 | 407 | global $globalImageBingKey; |
| 348 | 408 | $Common = new Common(); |
| 349 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
| 350 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 351 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 409 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
| 410 | + return false; |
|
| 411 | + } |
|
| 412 | + if ($aircraft_name != '') { |
|
| 413 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 414 | + } else { |
|
| 415 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 416 | + } |
|
| 352 | 417 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
| 353 | 418 | $data = $Common->getData($url,'get','',$headers); |
| 354 | 419 | $result = json_decode($data); |
@@ -402,13 +467,18 @@ discard block |
||
| 402 | 467 | */ |
| 403 | 468 | public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
| 404 | 469 | $Common = new Common(); |
| 405 | - if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
|
| 406 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
| 470 | + if ($aircraft_name != '') { |
|
| 471 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
|
| 472 | + } else { |
|
| 473 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
| 474 | + } |
|
| 407 | 475 | $data = $Common->getData($url); |
| 408 | 476 | $result = json_decode($data); |
| 409 | 477 | if (isset($result->query->search[0]->title)) { |
| 410 | 478 | $fileo = $result->query->search[0]->title; |
| 411 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 479 | + if (substr($fileo,-3) == 'pdf') { |
|
| 480 | + return false; |
|
| 481 | + } |
|
| 412 | 482 | $file = urlencode($fileo); |
| 413 | 483 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
| 414 | 484 | $data2 = $Common->getData($url2); |
@@ -460,7 +530,9 @@ discard block |
||
| 460 | 530 | global $globalAircraftCustomSources; |
| 461 | 531 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 462 | 532 | if (!empty($globalAircraftImageCustomSources)) { |
| 463 | - if (!isset($globalAircraftImageCustomSources[0])) $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources; |
|
| 533 | + if (!isset($globalAircraftImageCustomSources[0])) { |
|
| 534 | + $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources; |
|
| 535 | + } |
|
| 464 | 536 | foreach ($globalAircraftImageCustomSources as $source) { |
| 465 | 537 | $Common = new Common(); |
| 466 | 538 | $url = str_replace('{registration}',$aircraft_registration,$source['original']); |
@@ -469,17 +541,25 @@ discard block |
||
| 469 | 541 | $image_url = array(); |
| 470 | 542 | $image_url['thumbnail'] = $url_thumbnail; |
| 471 | 543 | $image_url['original'] = $url; |
| 472 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 473 | - else $exifCopyright = ''; |
|
| 474 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 475 | - else $image_url['copyright'] = $source['copyright']; |
|
| 544 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 545 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 546 | + } else { |
|
| 547 | + $exifCopyright = ''; |
|
| 548 | + } |
|
| 549 | + if ($exifCopyright != '') { |
|
| 550 | + $image_url['copyright'] = $exifCopyright; |
|
| 551 | + } else { |
|
| 552 | + $image_url['copyright'] = $source['copyright']; |
|
| 553 | + } |
|
| 476 | 554 | $image_url['source_website'] = $source['source_website']; |
| 477 | 555 | $image_url['source'] = $source['source']; |
| 478 | 556 | return $image_url; |
| 479 | 557 | } |
| 480 | 558 | } |
| 481 | 559 | return false; |
| 482 | - } else return false; |
|
| 560 | + } else { |
|
| 561 | + return false; |
|
| 562 | + } |
|
| 483 | 563 | } |
| 484 | 564 | } |
| 485 | 565 | |
@@ -14,10 +14,17 @@ discard block |
||
| 14 | 14 | if ($over_country == '') { |
| 15 | 15 | $Spotter = new Spotter($this->db); |
| 16 | 16 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 17 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 18 | - else $country = ''; |
|
| 19 | - } else $country = $over_country; |
|
| 20 | - if ($airline_type === NULL) $airline_type =''; |
|
| 17 | + if (!empty($data_country)) { |
|
| 18 | + $country = $data_country['iso2']; |
|
| 19 | + } else { |
|
| 20 | + $country = ''; |
|
| 21 | + } |
|
| 22 | + } else { |
|
| 23 | + $country = $over_country; |
|
| 24 | + } |
|
| 25 | + if ($airline_type === NULL) { |
|
| 26 | + $airline_type =''; |
|
| 27 | + } |
|
| 21 | 28 | |
| 22 | 29 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 23 | 30 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -502,7 +509,9 @@ discard block |
||
| 502 | 509 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 503 | 510 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
| 504 | 511 | $translate = $Translation->ident2icao($q_item); |
| 505 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 512 | + if ($translate != $q_item) { |
|
| 513 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 514 | + } |
|
| 506 | 515 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
| 507 | 516 | $additional_query .= ")"; |
| 508 | 517 | } |
@@ -720,7 +729,9 @@ discard block |
||
| 720 | 729 | date_default_timezone_set($globalTimezone); |
| 721 | 730 | $datetime = new DateTime(); |
| 722 | 731 | $offset = $datetime->format('P'); |
| 723 | - } else $offset = '+00:00'; |
|
| 732 | + } else { |
|
| 733 | + $offset = '+00:00'; |
|
| 734 | + } |
|
| 724 | 735 | |
| 725 | 736 | |
| 726 | 737 | if ($date_array[1] != "") |
@@ -883,9 +894,13 @@ discard block |
||
| 883 | 894 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 884 | 895 | } |
| 885 | 896 | } |
| 886 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 897 | + if ($sincedate != '') { |
|
| 898 | + $query .= "AND date > '".$sincedate."' "; |
|
| 899 | + } |
|
| 887 | 900 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 888 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 901 | + if ($limit) { |
|
| 902 | + $query .= " LIMIT 0,10"; |
|
| 903 | + } |
|
| 889 | 904 | |
| 890 | 905 | |
| 891 | 906 | $sth = $this->db->prepare($query); |
@@ -57,44 +57,44 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Gets all the spotter information based on a particular callsign |
|
| 62 | - * |
|
| 63 | - * @return Array the spotter information |
|
| 64 | - * |
|
| 65 | - */ |
|
| 66 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
| 67 | - { |
|
| 60 | + /** |
|
| 61 | + * Gets all the spotter information based on a particular callsign |
|
| 62 | + * |
|
| 63 | + * @return Array the spotter information |
|
| 64 | + * |
|
| 65 | + */ |
|
| 66 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
| 67 | + { |
|
| 68 | 68 | $Spotter = new Spotter($this->db); |
| 69 | - date_default_timezone_set('UTC'); |
|
| 69 | + date_default_timezone_set('UTC'); |
|
| 70 | 70 | |
| 71 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 72 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 73 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 71 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 72 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 73 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 74 | 74 | |
| 75 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 75 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 76 | 76 | |
| 77 | - return $spotter_array; |
|
| 78 | - } |
|
| 77 | + return $spotter_array; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Gets last the spotter information based on a particular id |
|
| 83 | - * |
|
| 84 | - * @return Array the spotter information |
|
| 85 | - * |
|
| 86 | - */ |
|
| 87 | - public function getLastArchiveSpotterDataById($id) |
|
| 88 | - { |
|
| 89 | - $Spotter = new Spotter($this->db); |
|
| 90 | - date_default_timezone_set('UTC'); |
|
| 91 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 92 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 93 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 94 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 81 | + /** |
|
| 82 | + * Gets last the spotter information based on a particular id |
|
| 83 | + * |
|
| 84 | + * @return Array the spotter information |
|
| 85 | + * |
|
| 86 | + */ |
|
| 87 | + public function getLastArchiveSpotterDataById($id) |
|
| 88 | + { |
|
| 89 | + $Spotter = new Spotter($this->db); |
|
| 90 | + date_default_timezone_set('UTC'); |
|
| 91 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 92 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 93 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 94 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 95 | 95 | |
| 96 | 96 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 97 | - /* |
|
| 97 | + /* |
|
| 98 | 98 | try { |
| 99 | 99 | $Connection = new Connection(); |
| 100 | 100 | $sth = Connection->$db->prepare($query); |
@@ -104,232 +104,232 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 106 | 106 | */ |
| 107 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 108 | - |
|
| 109 | - return $spotter_array; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Gets all the spotter information based on a particular id |
|
| 114 | - * |
|
| 115 | - * @return Array the spotter information |
|
| 116 | - * |
|
| 117 | - */ |
|
| 118 | - public function getAllArchiveSpotterDataById($id) |
|
| 119 | - { |
|
| 120 | - date_default_timezone_set('UTC'); |
|
| 121 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 122 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 107 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 108 | + |
|
| 109 | + return $spotter_array; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Gets all the spotter information based on a particular id |
|
| 114 | + * |
|
| 115 | + * @return Array the spotter information |
|
| 116 | + * |
|
| 117 | + */ |
|
| 118 | + public function getAllArchiveSpotterDataById($id) |
|
| 119 | + { |
|
| 120 | + date_default_timezone_set('UTC'); |
|
| 121 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 122 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 123 | 123 | |
| 124 | 124 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 125 | 125 | |
| 126 | - try { |
|
| 127 | - $sth = $this->db->prepare($query); |
|
| 128 | - $sth->execute(array(':id' => $id)); |
|
| 129 | - } catch(PDOException $e) { |
|
| 130 | - echo $e->getMessage(); |
|
| 131 | - die; |
|
| 132 | - } |
|
| 133 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 134 | - |
|
| 135 | - return $spotter_array; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Gets coordinate & time spotter information based on a particular id |
|
| 140 | - * |
|
| 141 | - * @return Array the spotter information |
|
| 142 | - * |
|
| 143 | - */ |
|
| 144 | - public function getCoordArchiveSpotterDataById($id) |
|
| 145 | - { |
|
| 146 | - date_default_timezone_set('UTC'); |
|
| 147 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 148 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 126 | + try { |
|
| 127 | + $sth = $this->db->prepare($query); |
|
| 128 | + $sth->execute(array(':id' => $id)); |
|
| 129 | + } catch(PDOException $e) { |
|
| 130 | + echo $e->getMessage(); |
|
| 131 | + die; |
|
| 132 | + } |
|
| 133 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 134 | + |
|
| 135 | + return $spotter_array; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Gets coordinate & time spotter information based on a particular id |
|
| 140 | + * |
|
| 141 | + * @return Array the spotter information |
|
| 142 | + * |
|
| 143 | + */ |
|
| 144 | + public function getCoordArchiveSpotterDataById($id) |
|
| 145 | + { |
|
| 146 | + date_default_timezone_set('UTC'); |
|
| 147 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 148 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 149 | 149 | |
| 150 | 150 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 151 | 151 | |
| 152 | - try { |
|
| 153 | - $sth = $this->db->prepare($query); |
|
| 154 | - $sth->execute(array(':id' => $id)); |
|
| 155 | - } catch(PDOException $e) { |
|
| 156 | - echo $e->getMessage(); |
|
| 157 | - die; |
|
| 158 | - } |
|
| 159 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 152 | + try { |
|
| 153 | + $sth = $this->db->prepare($query); |
|
| 154 | + $sth->execute(array(':id' => $id)); |
|
| 155 | + } catch(PDOException $e) { |
|
| 156 | + echo $e->getMessage(); |
|
| 157 | + die; |
|
| 158 | + } |
|
| 159 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 160 | 160 | |
| 161 | - return $spotter_array; |
|
| 162 | - } |
|
| 161 | + return $spotter_array; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * Gets altitude information based on a particular callsign |
|
| 167 | - * |
|
| 168 | - * @return Array the spotter information |
|
| 169 | - * |
|
| 170 | - */ |
|
| 171 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 172 | - { |
|
| 165 | + /** |
|
| 166 | + * Gets altitude information based on a particular callsign |
|
| 167 | + * |
|
| 168 | + * @return Array the spotter information |
|
| 169 | + * |
|
| 170 | + */ |
|
| 171 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 172 | + { |
|
| 173 | 173 | |
| 174 | - date_default_timezone_set('UTC'); |
|
| 174 | + date_default_timezone_set('UTC'); |
|
| 175 | 175 | |
| 176 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 177 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
| 176 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 177 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
| 178 | 178 | |
| 179 | - try { |
|
| 180 | - $sth = $this->db->prepare($query); |
|
| 181 | - $sth->execute(array(':ident' => $ident)); |
|
| 182 | - } catch(PDOException $e) { |
|
| 183 | - echo $e->getMessage(); |
|
| 184 | - die; |
|
| 185 | - } |
|
| 186 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 179 | + try { |
|
| 180 | + $sth = $this->db->prepare($query); |
|
| 181 | + $sth->execute(array(':ident' => $ident)); |
|
| 182 | + } catch(PDOException $e) { |
|
| 183 | + echo $e->getMessage(); |
|
| 184 | + die; |
|
| 185 | + } |
|
| 186 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 187 | 187 | |
| 188 | - return $spotter_array; |
|
| 189 | - } |
|
| 188 | + return $spotter_array; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Gets altitude information based on a particular id |
|
| 193 | - * |
|
| 194 | - * @return Array the spotter information |
|
| 195 | - * |
|
| 196 | - */ |
|
| 197 | - public function getAltitudeArchiveSpotterDataById($id) |
|
| 198 | - { |
|
| 191 | + /** |
|
| 192 | + * Gets altitude information based on a particular id |
|
| 193 | + * |
|
| 194 | + * @return Array the spotter information |
|
| 195 | + * |
|
| 196 | + */ |
|
| 197 | + public function getAltitudeArchiveSpotterDataById($id) |
|
| 198 | + { |
|
| 199 | 199 | |
| 200 | - date_default_timezone_set('UTC'); |
|
| 200 | + date_default_timezone_set('UTC'); |
|
| 201 | 201 | |
| 202 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 203 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 202 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 203 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 204 | 204 | |
| 205 | - try { |
|
| 206 | - $sth = $this->db->prepare($query); |
|
| 207 | - $sth->execute(array(':id' => $id)); |
|
| 208 | - } catch(PDOException $e) { |
|
| 209 | - echo $e->getMessage(); |
|
| 210 | - die; |
|
| 211 | - } |
|
| 212 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 205 | + try { |
|
| 206 | + $sth = $this->db->prepare($query); |
|
| 207 | + $sth->execute(array(':id' => $id)); |
|
| 208 | + } catch(PDOException $e) { |
|
| 209 | + echo $e->getMessage(); |
|
| 210 | + die; |
|
| 211 | + } |
|
| 212 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 213 | 213 | |
| 214 | - return $spotter_array; |
|
| 215 | - } |
|
| 214 | + return $spotter_array; |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - /** |
|
| 218 | - * Gets altitude & speed information based on a particular id |
|
| 219 | - * |
|
| 220 | - * @return Array the spotter information |
|
| 221 | - * |
|
| 222 | - */ |
|
| 223 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 224 | - { |
|
| 217 | + /** |
|
| 218 | + * Gets altitude & speed information based on a particular id |
|
| 219 | + * |
|
| 220 | + * @return Array the spotter information |
|
| 221 | + * |
|
| 222 | + */ |
|
| 223 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 224 | + { |
|
| 225 | 225 | |
| 226 | - date_default_timezone_set('UTC'); |
|
| 226 | + date_default_timezone_set('UTC'); |
|
| 227 | 227 | |
| 228 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 229 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 228 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 229 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 230 | 230 | |
| 231 | - try { |
|
| 232 | - $sth = $this->db->prepare($query); |
|
| 233 | - $sth->execute(array(':id' => $id)); |
|
| 234 | - } catch(PDOException $e) { |
|
| 235 | - echo $e->getMessage(); |
|
| 236 | - die; |
|
| 237 | - } |
|
| 238 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 231 | + try { |
|
| 232 | + $sth = $this->db->prepare($query); |
|
| 233 | + $sth->execute(array(':id' => $id)); |
|
| 234 | + } catch(PDOException $e) { |
|
| 235 | + echo $e->getMessage(); |
|
| 236 | + die; |
|
| 237 | + } |
|
| 238 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 239 | 239 | |
| 240 | - return $spotter_array; |
|
| 241 | - } |
|
| 240 | + return $spotter_array; |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | 243 | |
| 244 | - /** |
|
| 245 | - * Gets altitude information based on a particular callsign |
|
| 246 | - * |
|
| 247 | - * @return Array the spotter information |
|
| 248 | - * |
|
| 249 | - */ |
|
| 250 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 251 | - { |
|
| 244 | + /** |
|
| 245 | + * Gets altitude information based on a particular callsign |
|
| 246 | + * |
|
| 247 | + * @return Array the spotter information |
|
| 248 | + * |
|
| 249 | + */ |
|
| 250 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 251 | + { |
|
| 252 | 252 | |
| 253 | - date_default_timezone_set('UTC'); |
|
| 253 | + date_default_timezone_set('UTC'); |
|
| 254 | 254 | |
| 255 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 256 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 255 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 256 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 257 | 257 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 258 | 258 | |
| 259 | - try { |
|
| 260 | - $sth = $this->db->prepare($query); |
|
| 261 | - $sth->execute(array(':ident' => $ident)); |
|
| 262 | - } catch(PDOException $e) { |
|
| 263 | - echo $e->getMessage(); |
|
| 264 | - die; |
|
| 265 | - } |
|
| 266 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 259 | + try { |
|
| 260 | + $sth = $this->db->prepare($query); |
|
| 261 | + $sth->execute(array(':ident' => $ident)); |
|
| 262 | + } catch(PDOException $e) { |
|
| 263 | + echo $e->getMessage(); |
|
| 264 | + die; |
|
| 265 | + } |
|
| 266 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 267 | 267 | |
| 268 | - return $spotter_array; |
|
| 269 | - } |
|
| 268 | + return $spotter_array; |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | 271 | |
| 272 | 272 | |
| 273 | - /** |
|
| 274 | - * Gets all the archive spotter information |
|
| 275 | - * |
|
| 276 | - * @return Array the spotter information |
|
| 277 | - * |
|
| 278 | - */ |
|
| 279 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 280 | - { |
|
| 281 | - $Spotter = new Spotter($this->db); |
|
| 282 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 283 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 273 | + /** |
|
| 274 | + * Gets all the archive spotter information |
|
| 275 | + * |
|
| 276 | + * @return Array the spotter information |
|
| 277 | + * |
|
| 278 | + */ |
|
| 279 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 280 | + { |
|
| 281 | + $Spotter = new Spotter($this->db); |
|
| 282 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 283 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 284 | 284 | |
| 285 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 285 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 286 | 286 | |
| 287 | - return $spotter_array; |
|
| 288 | - } |
|
| 287 | + return $spotter_array; |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - public function deleteSpotterArchiveTrackData() |
|
| 291 | - { |
|
| 290 | + public function deleteSpotterArchiveTrackData() |
|
| 291 | + { |
|
| 292 | 292 | global $globalArchiveKeepTrackMonths; |
| 293 | - date_default_timezone_set('UTC'); |
|
| 293 | + date_default_timezone_set('UTC'); |
|
| 294 | 294 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 295 | - try { |
|
| 296 | - $sth = $this->db->prepare($query); |
|
| 297 | - $sth->execute(); |
|
| 298 | - } catch(PDOException $e) { |
|
| 299 | - echo $e->getMessage(); |
|
| 300 | - die; |
|
| 301 | - } |
|
| 295 | + try { |
|
| 296 | + $sth = $this->db->prepare($query); |
|
| 297 | + $sth->execute(); |
|
| 298 | + } catch(PDOException $e) { |
|
| 299 | + echo $e->getMessage(); |
|
| 300 | + die; |
|
| 301 | + } |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | - * Gets Minimal Live Spotter data |
|
| 306 | - * |
|
| 307 | - * @return Array the spotter information |
|
| 308 | - * |
|
| 309 | - */ |
|
| 310 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 311 | - { |
|
| 312 | - global $globalDBdriver, $globalLiveInterval; |
|
| 313 | - date_default_timezone_set('UTC'); |
|
| 314 | - |
|
| 315 | - $filter_query = ''; |
|
| 316 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 317 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 318 | - } |
|
| 319 | - // Use spotter_output also ? |
|
| 320 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 321 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 322 | - } |
|
| 323 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 324 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 325 | - } |
|
| 326 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 327 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 331 | - if ($globalDBdriver == 'mysql') { |
|
| 332 | - /* |
|
| 305 | + * Gets Minimal Live Spotter data |
|
| 306 | + * |
|
| 307 | + * @return Array the spotter information |
|
| 308 | + * |
|
| 309 | + */ |
|
| 310 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 311 | + { |
|
| 312 | + global $globalDBdriver, $globalLiveInterval; |
|
| 313 | + date_default_timezone_set('UTC'); |
|
| 314 | + |
|
| 315 | + $filter_query = ''; |
|
| 316 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 317 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 318 | + } |
|
| 319 | + // Use spotter_output also ? |
|
| 320 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 321 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 322 | + } |
|
| 323 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 324 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 325 | + } |
|
| 326 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 327 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 331 | + if ($globalDBdriver == 'mysql') { |
|
| 332 | + /* |
|
| 333 | 333 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 334 | 334 | FROM spotter_archive |
| 335 | 335 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -341,51 +341,51 @@ discard block |
||
| 341 | 341 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".') |
| 342 | 342 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
| 343 | 343 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 344 | - } else { |
|
| 345 | - $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 346 | - } |
|
| 347 | - //echo $query; |
|
| 348 | - try { |
|
| 349 | - $sth = $this->db->prepare($query); |
|
| 350 | - $sth->execute(); |
|
| 351 | - } catch(PDOException $e) { |
|
| 352 | - echo $e->getMessage(); |
|
| 353 | - die; |
|
| 354 | - } |
|
| 355 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 356 | - |
|
| 357 | - return $spotter_array; |
|
| 358 | - } |
|
| 344 | + } else { |
|
| 345 | + $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 346 | + } |
|
| 347 | + //echo $query; |
|
| 348 | + try { |
|
| 349 | + $sth = $this->db->prepare($query); |
|
| 350 | + $sth->execute(); |
|
| 351 | + } catch(PDOException $e) { |
|
| 352 | + echo $e->getMessage(); |
|
| 353 | + die; |
|
| 354 | + } |
|
| 355 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 356 | + |
|
| 357 | + return $spotter_array; |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | 360 | /** |
| 361 | - * Gets Minimal Live Spotter data |
|
| 362 | - * |
|
| 363 | - * @return Array the spotter information |
|
| 364 | - * |
|
| 365 | - */ |
|
| 366 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 367 | - { |
|
| 368 | - global $globalDBdriver, $globalLiveInterval; |
|
| 369 | - date_default_timezone_set('UTC'); |
|
| 370 | - |
|
| 371 | - $filter_query = ''; |
|
| 372 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 373 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 374 | - } |
|
| 375 | - // Should use spotter_output also ? |
|
| 376 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 377 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 378 | - } |
|
| 379 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 380 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 381 | - } |
|
| 382 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 383 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 387 | - if ($globalDBdriver == 'mysql') { |
|
| 388 | - /* |
|
| 361 | + * Gets Minimal Live Spotter data |
|
| 362 | + * |
|
| 363 | + * @return Array the spotter information |
|
| 364 | + * |
|
| 365 | + */ |
|
| 366 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 367 | + { |
|
| 368 | + global $globalDBdriver, $globalLiveInterval; |
|
| 369 | + date_default_timezone_set('UTC'); |
|
| 370 | + |
|
| 371 | + $filter_query = ''; |
|
| 372 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 373 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 374 | + } |
|
| 375 | + // Should use spotter_output also ? |
|
| 376 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 377 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 378 | + } |
|
| 379 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 380 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 381 | + } |
|
| 382 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 383 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 387 | + if ($globalDBdriver == 'mysql') { |
|
| 388 | + /* |
|
| 389 | 389 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 390 | 390 | FROM spotter_archive |
| 391 | 391 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -396,94 +396,94 @@ discard block |
||
| 396 | 396 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 397 | 397 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 398 | 398 | |
| 399 | - } else { |
|
| 400 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 401 | - /* |
|
| 399 | + } else { |
|
| 400 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 401 | + /* |
|
| 402 | 402 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
| 403 | 403 | FROM spotter_archive_output |
| 404 | 404 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 405 | 405 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 406 | 406 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 407 | 407 | */ |
| 408 | - $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow |
|
| 408 | + $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow |
|
| 409 | 409 | FROM spotter_output |
| 410 | 410 | INNER JOIN (SELECT * FROM aircraft) a on spotter_output.aircraft_icao = a.icao |
| 411 | 411 | WHERE spotter_output.date >= '."'".$begindate."'".' AND spotter_output.date <= '."'".$enddate."'".' |
| 412 | 412 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 413 | 413 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 414 | 414 | |
| 415 | - } |
|
| 416 | - //echo $query; |
|
| 417 | - try { |
|
| 418 | - $sth = $this->db->prepare($query); |
|
| 419 | - $sth->execute(); |
|
| 420 | - } catch(PDOException $e) { |
|
| 421 | - echo $e->getMessage(); |
|
| 422 | - die; |
|
| 423 | - } |
|
| 424 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 425 | - |
|
| 426 | - return $spotter_array; |
|
| 427 | - } |
|
| 415 | + } |
|
| 416 | + //echo $query; |
|
| 417 | + try { |
|
| 418 | + $sth = $this->db->prepare($query); |
|
| 419 | + $sth->execute(); |
|
| 420 | + } catch(PDOException $e) { |
|
| 421 | + echo $e->getMessage(); |
|
| 422 | + die; |
|
| 423 | + } |
|
| 424 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 425 | + |
|
| 426 | + return $spotter_array; |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | 429 | /** |
| 430 | - * Gets count Live Spotter data |
|
| 431 | - * |
|
| 432 | - * @return Array the spotter information |
|
| 433 | - * |
|
| 434 | - */ |
|
| 435 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 436 | - { |
|
| 437 | - global $globalDBdriver, $globalLiveInterval; |
|
| 438 | - date_default_timezone_set('UTC'); |
|
| 439 | - |
|
| 440 | - $filter_query = ''; |
|
| 441 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 442 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 443 | - } |
|
| 444 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 445 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 446 | - } |
|
| 447 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 448 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 449 | - } |
|
| 450 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 451 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 455 | - if ($globalDBdriver == 'mysql') { |
|
| 430 | + * Gets count Live Spotter data |
|
| 431 | + * |
|
| 432 | + * @return Array the spotter information |
|
| 433 | + * |
|
| 434 | + */ |
|
| 435 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 436 | + { |
|
| 437 | + global $globalDBdriver, $globalLiveInterval; |
|
| 438 | + date_default_timezone_set('UTC'); |
|
| 439 | + |
|
| 440 | + $filter_query = ''; |
|
| 441 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 442 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 443 | + } |
|
| 444 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 445 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 446 | + } |
|
| 447 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 448 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 449 | + } |
|
| 450 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 451 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 455 | + if ($globalDBdriver == 'mysql') { |
|
| 456 | 456 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
| 457 | 457 | FROM spotter_archive l |
| 458 | 458 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 459 | - } else { |
|
| 459 | + } else { |
|
| 460 | 460 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 461 | - } |
|
| 462 | - //echo $query; |
|
| 463 | - try { |
|
| 464 | - $sth = $this->db->prepare($query); |
|
| 465 | - $sth->execute(); |
|
| 466 | - } catch(PDOException $e) { |
|
| 467 | - echo $e->getMessage(); |
|
| 468 | - die; |
|
| 469 | - } |
|
| 461 | + } |
|
| 462 | + //echo $query; |
|
| 463 | + try { |
|
| 464 | + $sth = $this->db->prepare($query); |
|
| 465 | + $sth->execute(); |
|
| 466 | + } catch(PDOException $e) { |
|
| 467 | + echo $e->getMessage(); |
|
| 468 | + die; |
|
| 469 | + } |
|
| 470 | 470 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 471 | - return $result['nb']; |
|
| 471 | + return $result['nb']; |
|
| 472 | 472 | |
| 473 | - } |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | 475 | |
| 476 | 476 | |
| 477 | 477 | // Spotter_Archive_output |
| 478 | 478 | |
| 479 | - /** |
|
| 480 | - * Gets all the spotter information |
|
| 481 | - * |
|
| 482 | - * @return Array the spotter information |
|
| 483 | - * |
|
| 484 | - */ |
|
| 485 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filter=array()) |
|
| 486 | - { |
|
| 479 | + /** |
|
| 480 | + * Gets all the spotter information |
|
| 481 | + * |
|
| 482 | + * @return Array the spotter information |
|
| 483 | + * |
|
| 484 | + */ |
|
| 485 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filter=array()) |
|
| 486 | + { |
|
| 487 | 487 | global $globalTimezone, $globalDBdriver; |
| 488 | 488 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 489 | 489 | $Translation = new Translation(); |
@@ -497,159 +497,159 @@ discard block |
||
| 497 | 497 | $filter_query = $this->getFilter($filter); |
| 498 | 498 | if ($q != "") |
| 499 | 499 | { |
| 500 | - if (!is_string($q)) |
|
| 501 | - { |
|
| 500 | + if (!is_string($q)) |
|
| 501 | + { |
|
| 502 | 502 | return false; |
| 503 | - } else { |
|
| 503 | + } else { |
|
| 504 | 504 | |
| 505 | 505 | $q_array = explode(" ", $q); |
| 506 | 506 | |
| 507 | 507 | foreach ($q_array as $q_item){ |
| 508 | - $additional_query .= " AND ("; |
|
| 509 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 510 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 511 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 512 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 513 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 514 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 515 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 516 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 517 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 518 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 519 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 520 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 521 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 522 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 523 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 524 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 525 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 526 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 527 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 528 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 529 | - $translate = $Translation->ident2icao($q_item); |
|
| 530 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 531 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 532 | - $additional_query .= ")"; |
|
| 533 | - } |
|
| 534 | - } |
|
| 508 | + $additional_query .= " AND ("; |
|
| 509 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 510 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 511 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 512 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 513 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 514 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 515 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 516 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 517 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 518 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 519 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 520 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 521 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 522 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 523 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 524 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 525 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 526 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 527 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 528 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 529 | + $translate = $Translation->ident2icao($q_item); |
|
| 530 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 531 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 532 | + $additional_query .= ")"; |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | if ($registration != "") |
| 538 | 538 | { |
| 539 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 540 | - if (!is_string($registration)) |
|
| 541 | - { |
|
| 539 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 540 | + if (!is_string($registration)) |
|
| 541 | + { |
|
| 542 | 542 | return false; |
| 543 | - } else { |
|
| 543 | + } else { |
|
| 544 | 544 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
| 545 | - } |
|
| 545 | + } |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | if ($aircraft_icao != "") |
| 549 | 549 | { |
| 550 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 551 | - if (!is_string($aircraft_icao)) |
|
| 552 | - { |
|
| 550 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 551 | + if (!is_string($aircraft_icao)) |
|
| 552 | + { |
|
| 553 | 553 | return false; |
| 554 | - } else { |
|
| 554 | + } else { |
|
| 555 | 555 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 556 | - } |
|
| 556 | + } |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | if ($aircraft_manufacturer != "") |
| 560 | 560 | { |
| 561 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 562 | - if (!is_string($aircraft_manufacturer)) |
|
| 563 | - { |
|
| 561 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 562 | + if (!is_string($aircraft_manufacturer)) |
|
| 563 | + { |
|
| 564 | 564 | return false; |
| 565 | - } else { |
|
| 565 | + } else { |
|
| 566 | 566 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 567 | - } |
|
| 567 | + } |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | if ($highlights == "true") |
| 571 | 571 | { |
| 572 | - if (!is_string($highlights)) |
|
| 573 | - { |
|
| 572 | + if (!is_string($highlights)) |
|
| 573 | + { |
|
| 574 | 574 | return false; |
| 575 | - } else { |
|
| 575 | + } else { |
|
| 576 | 576 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
| 577 | - } |
|
| 577 | + } |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | if ($airline_icao != "") |
| 581 | 581 | { |
| 582 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 583 | - if (!is_string($airline_icao)) |
|
| 584 | - { |
|
| 582 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 583 | + if (!is_string($airline_icao)) |
|
| 584 | + { |
|
| 585 | 585 | return false; |
| 586 | - } else { |
|
| 586 | + } else { |
|
| 587 | 587 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
| 588 | - } |
|
| 588 | + } |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | if ($airline_country != "") |
| 592 | 592 | { |
| 593 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 594 | - if (!is_string($airline_country)) |
|
| 595 | - { |
|
| 593 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 594 | + if (!is_string($airline_country)) |
|
| 595 | + { |
|
| 596 | 596 | return false; |
| 597 | - } else { |
|
| 597 | + } else { |
|
| 598 | 598 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
| 599 | - } |
|
| 599 | + } |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | if ($airline_type != "") |
| 603 | 603 | { |
| 604 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 605 | - if (!is_string($airline_type)) |
|
| 606 | - { |
|
| 604 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 605 | + if (!is_string($airline_type)) |
|
| 606 | + { |
|
| 607 | 607 | return false; |
| 608 | - } else { |
|
| 608 | + } else { |
|
| 609 | 609 | if ($airline_type == "passenger") |
| 610 | 610 | { |
| 611 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 611 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 612 | 612 | } |
| 613 | 613 | if ($airline_type == "cargo") |
| 614 | 614 | { |
| 615 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 615 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 616 | 616 | } |
| 617 | 617 | if ($airline_type == "military") |
| 618 | 618 | { |
| 619 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 619 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 620 | + } |
|
| 620 | 621 | } |
| 621 | - } |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | if ($airport != "") |
| 625 | 625 | { |
| 626 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 627 | - if (!is_string($airport)) |
|
| 628 | - { |
|
| 626 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 627 | + if (!is_string($airport)) |
|
| 628 | + { |
|
| 629 | 629 | return false; |
| 630 | - } else { |
|
| 630 | + } else { |
|
| 631 | 631 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 632 | - } |
|
| 632 | + } |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | if ($airport_country != "") |
| 636 | 636 | { |
| 637 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 638 | - if (!is_string($airport_country)) |
|
| 639 | - { |
|
| 637 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 638 | + if (!is_string($airport_country)) |
|
| 639 | + { |
|
| 640 | 640 | return false; |
| 641 | - } else { |
|
| 641 | + } else { |
|
| 642 | 642 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 643 | - } |
|
| 643 | + } |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | if ($callsign != "") |
| 647 | 647 | { |
| 648 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 649 | - if (!is_string($callsign)) |
|
| 650 | - { |
|
| 648 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 649 | + if (!is_string($callsign)) |
|
| 650 | + { |
|
| 651 | 651 | return false; |
| 652 | - } else { |
|
| 652 | + } else { |
|
| 653 | 653 | $translate = $Translation->ident2icao($callsign); |
| 654 | 654 | if ($translate != $callsign) { |
| 655 | 655 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -657,99 +657,99 @@ discard block |
||
| 657 | 657 | } else { |
| 658 | 658 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 659 | 659 | } |
| 660 | - } |
|
| 660 | + } |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | if ($owner != "") |
| 664 | 664 | { |
| 665 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 666 | - if (!is_string($owner)) |
|
| 667 | - { |
|
| 665 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 666 | + if (!is_string($owner)) |
|
| 667 | + { |
|
| 668 | 668 | return false; |
| 669 | - } else { |
|
| 669 | + } else { |
|
| 670 | 670 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
| 671 | - } |
|
| 671 | + } |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | if ($pilot_name != "") |
| 675 | 675 | { |
| 676 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 677 | - if (!is_string($pilot_name)) |
|
| 678 | - { |
|
| 676 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 677 | + if (!is_string($pilot_name)) |
|
| 678 | + { |
|
| 679 | 679 | return false; |
| 680 | - } else { |
|
| 680 | + } else { |
|
| 681 | 681 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
| 682 | - } |
|
| 682 | + } |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | if ($pilot_id != "") |
| 686 | 686 | { |
| 687 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 688 | - if (!is_string($pilot_id)) |
|
| 689 | - { |
|
| 687 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 688 | + if (!is_string($pilot_id)) |
|
| 689 | + { |
|
| 690 | 690 | return false; |
| 691 | - } else { |
|
| 691 | + } else { |
|
| 692 | 692 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
| 693 | - } |
|
| 693 | + } |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | if ($departure_airport_route != "") |
| 697 | 697 | { |
| 698 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 699 | - if (!is_string($departure_airport_route)) |
|
| 700 | - { |
|
| 698 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 699 | + if (!is_string($departure_airport_route)) |
|
| 700 | + { |
|
| 701 | 701 | return false; |
| 702 | - } else { |
|
| 702 | + } else { |
|
| 703 | 703 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 704 | - } |
|
| 704 | + } |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | if ($arrival_airport_route != "") |
| 708 | 708 | { |
| 709 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 710 | - if (!is_string($arrival_airport_route)) |
|
| 711 | - { |
|
| 709 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 710 | + if (!is_string($arrival_airport_route)) |
|
| 711 | + { |
|
| 712 | 712 | return false; |
| 713 | - } else { |
|
| 713 | + } else { |
|
| 714 | 714 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 715 | - } |
|
| 715 | + } |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | if ($altitude != "") |
| 719 | 719 | { |
| 720 | - $altitude_array = explode(",", $altitude); |
|
| 720 | + $altitude_array = explode(",", $altitude); |
|
| 721 | 721 | |
| 722 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 723 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 722 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 723 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 724 | 724 | |
| 725 | 725 | |
| 726 | - if ($altitude_array[1] != "") |
|
| 727 | - { |
|
| 726 | + if ($altitude_array[1] != "") |
|
| 727 | + { |
|
| 728 | 728 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 729 | 729 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 730 | 730 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 731 | - } else { |
|
| 731 | + } else { |
|
| 732 | 732 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 733 | 733 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 734 | - } |
|
| 734 | + } |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | if ($date_posted != "") |
| 738 | 738 | { |
| 739 | - $date_array = explode(",", $date_posted); |
|
| 739 | + $date_array = explode(",", $date_posted); |
|
| 740 | 740 | |
| 741 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 742 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 741 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 742 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 743 | 743 | |
| 744 | - if ($globalTimezone != '') { |
|
| 744 | + if ($globalTimezone != '') { |
|
| 745 | 745 | date_default_timezone_set($globalTimezone); |
| 746 | 746 | $datetime = new DateTime(); |
| 747 | 747 | $offset = $datetime->format('P'); |
| 748 | - } else $offset = '+00:00'; |
|
| 748 | + } else $offset = '+00:00'; |
|
| 749 | 749 | |
| 750 | 750 | |
| 751 | - if ($date_array[1] != "") |
|
| 752 | - { |
|
| 751 | + if ($date_array[1] != "") |
|
| 752 | + { |
|
| 753 | 753 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 754 | 754 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 755 | 755 | if ($globalDBdriver == 'mysql') { |
@@ -757,28 +757,28 @@ discard block |
||
| 757 | 757 | } else { |
| 758 | 758 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
| 759 | 759 | } |
| 760 | - } else { |
|
| 760 | + } else { |
|
| 761 | 761 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 762 | - if ($globalDBdriver == 'mysql') { |
|
| 762 | + if ($globalDBdriver == 'mysql') { |
|
| 763 | 763 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 764 | 764 | } else { |
| 765 | 765 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 766 | 766 | } |
| 767 | - } |
|
| 767 | + } |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | if ($limit != "") |
| 771 | 771 | { |
| 772 | - $limit_array = explode(",", $limit); |
|
| 772 | + $limit_array = explode(",", $limit); |
|
| 773 | 773 | |
| 774 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 775 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 774 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 775 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 776 | 776 | |
| 777 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 778 | - { |
|
| 777 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 778 | + { |
|
| 779 | 779 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 780 | 780 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 781 | - } |
|
| 781 | + } |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | |
@@ -809,33 +809,33 @@ discard block |
||
| 809 | 809 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
| 810 | 810 | |
| 811 | 811 | return $spotter_array; |
| 812 | - } |
|
| 812 | + } |
|
| 813 | 813 | |
| 814 | - public function deleteSpotterArchiveData() |
|
| 815 | - { |
|
| 814 | + public function deleteSpotterArchiveData() |
|
| 815 | + { |
|
| 816 | 816 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 817 | - date_default_timezone_set('UTC'); |
|
| 818 | - if ($globalDBdriver == 'mysql') { |
|
| 817 | + date_default_timezone_set('UTC'); |
|
| 818 | + if ($globalDBdriver == 'mysql') { |
|
| 819 | 819 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 820 | 820 | } else { |
| 821 | 821 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 822 | 822 | } |
| 823 | - try { |
|
| 824 | - $sth = $this->db->prepare($query); |
|
| 825 | - $sth->execute(); |
|
| 826 | - } catch(PDOException $e) { |
|
| 827 | - return "error"; |
|
| 828 | - } |
|
| 823 | + try { |
|
| 824 | + $sth = $this->db->prepare($query); |
|
| 825 | + $sth->execute(); |
|
| 826 | + } catch(PDOException $e) { |
|
| 827 | + return "error"; |
|
| 828 | + } |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | - /** |
|
| 832 | - * Gets all the spotter information based on the callsign |
|
| 833 | - * |
|
| 834 | - * @return Array the spotter information |
|
| 835 | - * |
|
| 836 | - */ |
|
| 837 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 838 | - { |
|
| 831 | + /** |
|
| 832 | + * Gets all the spotter information based on the callsign |
|
| 833 | + * |
|
| 834 | + * @return Array the spotter information |
|
| 835 | + * |
|
| 836 | + */ |
|
| 837 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 838 | + { |
|
| 839 | 839 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 840 | 840 | |
| 841 | 841 | date_default_timezone_set('UTC'); |
@@ -847,35 +847,35 @@ discard block |
||
| 847 | 847 | |
| 848 | 848 | if ($ident != "") |
| 849 | 849 | { |
| 850 | - if (!is_string($ident)) |
|
| 851 | - { |
|
| 850 | + if (!is_string($ident)) |
|
| 851 | + { |
|
| 852 | 852 | return false; |
| 853 | - } else { |
|
| 853 | + } else { |
|
| 854 | 854 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
| 855 | 855 | $query_values = array(':ident' => $ident); |
| 856 | - } |
|
| 856 | + } |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | if ($limit != "") |
| 860 | 860 | { |
| 861 | - $limit_array = explode(",", $limit); |
|
| 861 | + $limit_array = explode(",", $limit); |
|
| 862 | 862 | |
| 863 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 864 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 863 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 864 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 865 | 865 | |
| 866 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 867 | - { |
|
| 866 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 867 | + { |
|
| 868 | 868 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 869 | 869 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 870 | - } |
|
| 870 | + } |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | if ($sort != "") |
| 874 | 874 | { |
| 875 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 876 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 875 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 876 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 877 | 877 | } else { |
| 878 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 878 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -883,16 +883,16 @@ discard block |
||
| 883 | 883 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 884 | 884 | |
| 885 | 885 | return $spotter_array; |
| 886 | - } |
|
| 887 | - |
|
| 888 | - /** |
|
| 889 | - * Gets all number of flight over countries |
|
| 890 | - * |
|
| 891 | - * @return Array the airline country list |
|
| 892 | - * |
|
| 893 | - */ |
|
| 894 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 895 | - { |
|
| 886 | + } |
|
| 887 | + |
|
| 888 | + /** |
|
| 889 | + * Gets all number of flight over countries |
|
| 890 | + * |
|
| 891 | + * @return Array the airline country list |
|
| 892 | + * |
|
| 893 | + */ |
|
| 894 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 895 | + { |
|
| 896 | 896 | global $globalDBdriver; |
| 897 | 897 | /* |
| 898 | 898 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -902,14 +902,14 @@ discard block |
||
| 902 | 902 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 903 | 903 | FROM countries c, spotter_archive s |
| 904 | 904 | WHERE c.iso2 = s.over_country "; |
| 905 | - if ($olderthanmonths > 0) { |
|
| 906 | - if ($globalDBdriver == 'mysql') { |
|
| 905 | + if ($olderthanmonths > 0) { |
|
| 906 | + if ($globalDBdriver == 'mysql') { |
|
| 907 | 907 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 908 | 908 | } else { |
| 909 | 909 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 910 | 910 | } |
| 911 | 911 | } |
| 912 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 912 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 913 | 913 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 914 | 914 | if ($limit) $query .= " LIMIT 0,10"; |
| 915 | 915 | |
@@ -922,14 +922,14 @@ discard block |
||
| 922 | 922 | |
| 923 | 923 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 924 | 924 | { |
| 925 | - $temp_array['flight_count'] = $row['nb']; |
|
| 926 | - $temp_array['flight_country'] = $row['name']; |
|
| 927 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 928 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 929 | - $flight_array[] = $temp_array; |
|
| 925 | + $temp_array['flight_count'] = $row['nb']; |
|
| 926 | + $temp_array['flight_country'] = $row['name']; |
|
| 927 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 928 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 929 | + $flight_array[] = $temp_array; |
|
| 930 | 930 | } |
| 931 | 931 | return $flight_array; |
| 932 | - } |
|
| 932 | + } |
|
| 933 | 933 | |
| 934 | 934 | } |
| 935 | 935 | ?> |
| 936 | 936 | \ No newline at end of file |
@@ -11,46 +11,46 @@ discard block |
||
| 11 | 11 | public function getFilter($filter) { |
| 12 | 12 | $filter_query = ''; |
| 13 | 13 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 14 | - $filter_query = " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 14 | + $filter_query = " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 15 | 15 | } |
| 16 | 16 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 17 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 17 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 18 | 18 | } |
| 19 | 19 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 20 | 20 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
| 21 | 21 | } |
| 22 | 22 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 23 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 23 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 24 | 24 | } |
| 25 | 25 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 26 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 26 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
| 27 | 27 | } |
| 28 | 28 | return $filter_query; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // Spotter_archive |
| 32 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 32 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
| 33 | 33 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
| 34 | 34 | if ($over_country == '') { |
| 35 | 35 | $Spotter = new Spotter($this->db); |
| 36 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 36 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 37 | 37 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 38 | 38 | else $country = ''; |
| 39 | 39 | } else $country = $over_country; |
| 40 | - if ($airline_type === NULL) $airline_type =''; |
|
| 40 | + if ($airline_type === NULL) $airline_type = ''; |
|
| 41 | 41 | |
| 42 | 42 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 43 | 43 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
| 44 | 44 | |
| 45 | 45 | // Route is not added in spotter_archive |
| 46 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
| 46 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
| 47 | 47 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
| 48 | 48 | |
| 49 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
| 49 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
| 50 | 50 | try { |
| 51 | 51 | $sth = $this->db->prepare($query); |
| 52 | 52 | $sth->execute($query_values); |
| 53 | - } catch(PDOException $e) { |
|
| 53 | + } catch (PDOException $e) { |
|
| 54 | 54 | return "error : ".$e->getMessage(); |
| 55 | 55 | } |
| 56 | 56 | return "success"; |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 72 | 72 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 73 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 73 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 74 | 74 | |
| 75 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 75 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
| 76 | 76 | |
| 77 | 77 | return $spotter_array; |
| 78 | 78 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 92 | 92 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
| 93 | 93 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 94 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 94 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 95 | 95 | |
| 96 | 96 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 97 | 97 | /* |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 106 | 106 | */ |
| 107 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 107 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
| 108 | 108 | |
| 109 | 109 | return $spotter_array; |
| 110 | 110 | } |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | date_default_timezone_set('UTC'); |
| 121 | 121 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 122 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 122 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 123 | 123 | |
| 124 | 124 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 125 | 125 | |
| 126 | 126 | try { |
| 127 | 127 | $sth = $this->db->prepare($query); |
| 128 | 128 | $sth->execute(array(':id' => $id)); |
| 129 | - } catch(PDOException $e) { |
|
| 129 | + } catch (PDOException $e) { |
|
| 130 | 130 | echo $e->getMessage(); |
| 131 | 131 | die; |
| 132 | 132 | } |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | date_default_timezone_set('UTC'); |
| 147 | 147 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 148 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 148 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 149 | 149 | |
| 150 | 150 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 151 | 151 | |
| 152 | 152 | try { |
| 153 | 153 | $sth = $this->db->prepare($query); |
| 154 | 154 | $sth->execute(array(':id' => $id)); |
| 155 | - } catch(PDOException $e) { |
|
| 155 | + } catch (PDOException $e) { |
|
| 156 | 156 | echo $e->getMessage(); |
| 157 | 157 | die; |
| 158 | 158 | } |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | date_default_timezone_set('UTC'); |
| 175 | 175 | |
| 176 | 176 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 177 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
| 177 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
| 178 | 178 | |
| 179 | 179 | try { |
| 180 | 180 | $sth = $this->db->prepare($query); |
| 181 | 181 | $sth->execute(array(':ident' => $ident)); |
| 182 | - } catch(PDOException $e) { |
|
| 182 | + } catch (PDOException $e) { |
|
| 183 | 183 | echo $e->getMessage(); |
| 184 | 184 | die; |
| 185 | 185 | } |
@@ -200,12 +200,12 @@ discard block |
||
| 200 | 200 | date_default_timezone_set('UTC'); |
| 201 | 201 | |
| 202 | 202 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 203 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 203 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 204 | 204 | |
| 205 | 205 | try { |
| 206 | 206 | $sth = $this->db->prepare($query); |
| 207 | 207 | $sth->execute(array(':id' => $id)); |
| 208 | - } catch(PDOException $e) { |
|
| 208 | + } catch (PDOException $e) { |
|
| 209 | 209 | echo $e->getMessage(); |
| 210 | 210 | die; |
| 211 | 211 | } |
@@ -226,12 +226,12 @@ discard block |
||
| 226 | 226 | date_default_timezone_set('UTC'); |
| 227 | 227 | |
| 228 | 228 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 229 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 229 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 230 | 230 | |
| 231 | 231 | try { |
| 232 | 232 | $sth = $this->db->prepare($query); |
| 233 | 233 | $sth->execute(array(':id' => $id)); |
| 234 | - } catch(PDOException $e) { |
|
| 234 | + } catch (PDOException $e) { |
|
| 235 | 235 | echo $e->getMessage(); |
| 236 | 236 | die; |
| 237 | 237 | } |
@@ -253,13 +253,13 @@ discard block |
||
| 253 | 253 | date_default_timezone_set('UTC'); |
| 254 | 254 | |
| 255 | 255 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 256 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 256 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 257 | 257 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 258 | 258 | |
| 259 | 259 | try { |
| 260 | 260 | $sth = $this->db->prepare($query); |
| 261 | 261 | $sth->execute(array(':ident' => $ident)); |
| 262 | - } catch(PDOException $e) { |
|
| 262 | + } catch (PDOException $e) { |
|
| 263 | 263 | echo $e->getMessage(); |
| 264 | 264 | die; |
| 265 | 265 | } |
@@ -276,13 +276,13 @@ discard block |
||
| 276 | 276 | * @return Array the spotter information |
| 277 | 277 | * |
| 278 | 278 | */ |
| 279 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 279 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
| 280 | 280 | { |
| 281 | 281 | $Spotter = new Spotter($this->db); |
| 282 | 282 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 283 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 283 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 284 | 284 | |
| 285 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 285 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
| 286 | 286 | |
| 287 | 287 | return $spotter_array; |
| 288 | 288 | } |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | try { |
| 296 | 296 | $sth = $this->db->prepare($query); |
| 297 | 297 | $sth->execute(); |
| 298 | - } catch(PDOException $e) { |
|
| 298 | + } catch (PDOException $e) { |
|
| 299 | 299 | echo $e->getMessage(); |
| 300 | 300 | die; |
| 301 | 301 | } |
@@ -307,24 +307,24 @@ discard block |
||
| 307 | 307 | * @return Array the spotter information |
| 308 | 308 | * |
| 309 | 309 | */ |
| 310 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 310 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
| 311 | 311 | { |
| 312 | 312 | global $globalDBdriver, $globalLiveInterval; |
| 313 | 313 | date_default_timezone_set('UTC'); |
| 314 | 314 | |
| 315 | 315 | $filter_query = ''; |
| 316 | 316 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 317 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 317 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 318 | 318 | } |
| 319 | 319 | // Use spotter_output also ? |
| 320 | 320 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 321 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 321 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 322 | 322 | } |
| 323 | 323 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 324 | 324 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 325 | 325 | } |
| 326 | 326 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 327 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 327 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | FROM spotter_archive |
| 335 | 335 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 336 | 336 | */ |
| 337 | - $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
|
| 337 | + $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
|
| 338 | 338 | FROM spotter_archive |
| 339 | 339 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 340 | 340 | FROM spotter_archive l |
@@ -342,13 +342,13 @@ discard block |
||
| 342 | 342 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
| 343 | 343 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 344 | 344 | } else { |
| 345 | - $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 345 | + $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 346 | 346 | } |
| 347 | 347 | //echo $query; |
| 348 | 348 | try { |
| 349 | 349 | $sth = $this->db->prepare($query); |
| 350 | 350 | $sth->execute(); |
| 351 | - } catch(PDOException $e) { |
|
| 351 | + } catch (PDOException $e) { |
|
| 352 | 352 | echo $e->getMessage(); |
| 353 | 353 | die; |
| 354 | 354 | } |
@@ -363,24 +363,24 @@ discard block |
||
| 363 | 363 | * @return Array the spotter information |
| 364 | 364 | * |
| 365 | 365 | */ |
| 366 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 366 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
| 367 | 367 | { |
| 368 | 368 | global $globalDBdriver, $globalLiveInterval; |
| 369 | 369 | date_default_timezone_set('UTC'); |
| 370 | 370 | |
| 371 | 371 | $filter_query = ''; |
| 372 | 372 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 373 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 373 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 374 | 374 | } |
| 375 | 375 | // Should use spotter_output also ? |
| 376 | 376 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 377 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 377 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 378 | 378 | } |
| 379 | 379 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 380 | 380 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 381 | 381 | } |
| 382 | 382 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 383 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 383 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | FROM spotter_archive |
| 391 | 391 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 392 | 392 | */ |
| 393 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 393 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 394 | 394 | FROM spotter_archive_output |
| 395 | 395 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
| 396 | 396 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 406 | 406 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 407 | 407 | */ |
| 408 | - $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow |
|
| 408 | + $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow |
|
| 409 | 409 | FROM spotter_output |
| 410 | 410 | INNER JOIN (SELECT * FROM aircraft) a on spotter_output.aircraft_icao = a.icao |
| 411 | 411 | WHERE spotter_output.date >= '."'".$begindate."'".' AND spotter_output.date <= '."'".$enddate."'".' |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | try { |
| 418 | 418 | $sth = $this->db->prepare($query); |
| 419 | 419 | $sth->execute(); |
| 420 | - } catch(PDOException $e) { |
|
| 420 | + } catch (PDOException $e) { |
|
| 421 | 421 | echo $e->getMessage(); |
| 422 | 422 | die; |
| 423 | 423 | } |
@@ -432,23 +432,23 @@ discard block |
||
| 432 | 432 | * @return Array the spotter information |
| 433 | 433 | * |
| 434 | 434 | */ |
| 435 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 435 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
| 436 | 436 | { |
| 437 | 437 | global $globalDBdriver, $globalLiveInterval; |
| 438 | 438 | date_default_timezone_set('UTC'); |
| 439 | 439 | |
| 440 | 440 | $filter_query = ''; |
| 441 | 441 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 442 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 442 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 443 | 443 | } |
| 444 | 444 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 445 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 445 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 446 | 446 | } |
| 447 | 447 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 448 | 448 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 449 | 449 | } |
| 450 | 450 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 451 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 451 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | try { |
| 464 | 464 | $sth = $this->db->prepare($query); |
| 465 | 465 | $sth->execute(); |
| 466 | - } catch(PDOException $e) { |
|
| 466 | + } catch (PDOException $e) { |
|
| 467 | 467 | echo $e->getMessage(); |
| 468 | 468 | die; |
| 469 | 469 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | * @return Array the spotter information |
| 483 | 483 | * |
| 484 | 484 | */ |
| 485 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filter=array()) |
|
| 485 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filter = array()) |
|
| 486 | 486 | { |
| 487 | 487 | global $globalTimezone, $globalDBdriver; |
| 488 | 488 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | $q_array = explode(" ", $q); |
| 506 | 506 | |
| 507 | - foreach ($q_array as $q_item){ |
|
| 507 | + foreach ($q_array as $q_item) { |
|
| 508 | 508 | $additional_query .= " AND ("; |
| 509 | 509 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 510 | 510 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | if ($registration != "") |
| 538 | 538 | { |
| 539 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 539 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 540 | 540 | if (!is_string($registration)) |
| 541 | 541 | { |
| 542 | 542 | return false; |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | |
| 548 | 548 | if ($aircraft_icao != "") |
| 549 | 549 | { |
| 550 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 550 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 551 | 551 | if (!is_string($aircraft_icao)) |
| 552 | 552 | { |
| 553 | 553 | return false; |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | |
| 559 | 559 | if ($aircraft_manufacturer != "") |
| 560 | 560 | { |
| 561 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 561 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 562 | 562 | if (!is_string($aircraft_manufacturer)) |
| 563 | 563 | { |
| 564 | 564 | return false; |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | |
| 580 | 580 | if ($airline_icao != "") |
| 581 | 581 | { |
| 582 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 582 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 583 | 583 | if (!is_string($airline_icao)) |
| 584 | 584 | { |
| 585 | 585 | return false; |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | |
| 591 | 591 | if ($airline_country != "") |
| 592 | 592 | { |
| 593 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 593 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 594 | 594 | if (!is_string($airline_country)) |
| 595 | 595 | { |
| 596 | 596 | return false; |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | if ($airline_type != "") |
| 603 | 603 | { |
| 604 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 604 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 605 | 605 | if (!is_string($airline_type)) |
| 606 | 606 | { |
| 607 | 607 | return false; |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | |
| 624 | 624 | if ($airport != "") |
| 625 | 625 | { |
| 626 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 626 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 627 | 627 | if (!is_string($airport)) |
| 628 | 628 | { |
| 629 | 629 | return false; |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | |
| 635 | 635 | if ($airport_country != "") |
| 636 | 636 | { |
| 637 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 637 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 638 | 638 | if (!is_string($airport_country)) |
| 639 | 639 | { |
| 640 | 640 | return false; |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | |
| 646 | 646 | if ($callsign != "") |
| 647 | 647 | { |
| 648 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 648 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 649 | 649 | if (!is_string($callsign)) |
| 650 | 650 | { |
| 651 | 651 | return false; |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | $translate = $Translation->ident2icao($callsign); |
| 654 | 654 | if ($translate != $callsign) { |
| 655 | 655 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
| 656 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 656 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 657 | 657 | } else { |
| 658 | 658 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 659 | 659 | } |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | |
| 663 | 663 | if ($owner != "") |
| 664 | 664 | { |
| 665 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 665 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 666 | 666 | if (!is_string($owner)) |
| 667 | 667 | { |
| 668 | 668 | return false; |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | |
| 674 | 674 | if ($pilot_name != "") |
| 675 | 675 | { |
| 676 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 676 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 677 | 677 | if (!is_string($pilot_name)) |
| 678 | 678 | { |
| 679 | 679 | return false; |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | |
| 685 | 685 | if ($pilot_id != "") |
| 686 | 686 | { |
| 687 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 687 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 688 | 688 | if (!is_string($pilot_id)) |
| 689 | 689 | { |
| 690 | 690 | return false; |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | |
| 696 | 696 | if ($departure_airport_route != "") |
| 697 | 697 | { |
| 698 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 698 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 699 | 699 | if (!is_string($departure_airport_route)) |
| 700 | 700 | { |
| 701 | 701 | return false; |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | |
| 707 | 707 | if ($arrival_airport_route != "") |
| 708 | 708 | { |
| 709 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 709 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 710 | 710 | if (!is_string($arrival_airport_route)) |
| 711 | 711 | { |
| 712 | 712 | return false; |
@@ -719,8 +719,8 @@ discard block |
||
| 719 | 719 | { |
| 720 | 720 | $altitude_array = explode(",", $altitude); |
| 721 | 721 | |
| 722 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 723 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 722 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 723 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 724 | 724 | |
| 725 | 725 | |
| 726 | 726 | if ($altitude_array[1] != "") |
@@ -738,8 +738,8 @@ discard block |
||
| 738 | 738 | { |
| 739 | 739 | $date_array = explode(",", $date_posted); |
| 740 | 740 | |
| 741 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 742 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 741 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 742 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 743 | 743 | |
| 744 | 744 | if ($globalTimezone != '') { |
| 745 | 745 | date_default_timezone_set($globalTimezone); |
@@ -771,8 +771,8 @@ discard block |
||
| 771 | 771 | { |
| 772 | 772 | $limit_array = explode(",", $limit); |
| 773 | 773 | |
| 774 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 775 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 774 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 775 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 776 | 776 | |
| 777 | 777 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 778 | 778 | { |
@@ -783,8 +783,8 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | |
| 785 | 785 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 786 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 787 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 786 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 787 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 788 | 788 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 789 | 789 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 790 | 790 | } else { |
@@ -801,12 +801,12 @@ discard block |
||
| 801 | 801 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 804 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 805 | 805 | WHERE spotter_archive_output.ident <> '' |
| 806 | 806 | ".$additional_query." |
| 807 | 807 | ".$filter_query.$orderby_query; |
| 808 | 808 | } |
| 809 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
| 809 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
| 810 | 810 | |
| 811 | 811 | return $spotter_array; |
| 812 | 812 | } |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | try { |
| 824 | 824 | $sth = $this->db->prepare($query); |
| 825 | 825 | $sth->execute(); |
| 826 | - } catch(PDOException $e) { |
|
| 826 | + } catch (PDOException $e) { |
|
| 827 | 827 | return "error"; |
| 828 | 828 | } |
| 829 | 829 | } |
@@ -860,8 +860,8 @@ discard block |
||
| 860 | 860 | { |
| 861 | 861 | $limit_array = explode(",", $limit); |
| 862 | 862 | |
| 863 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 864 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 863 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 864 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 865 | 865 | |
| 866 | 866 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 867 | 867 | { |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | * @return Array the airline country list |
| 892 | 892 | * |
| 893 | 893 | */ |
| 894 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 894 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 895 | 895 | { |
| 896 | 896 | global $globalDBdriver; |
| 897 | 897 | /* |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | $flight_array = array(); |
| 921 | 921 | $temp_array = array(); |
| 922 | 922 | |
| 923 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 923 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 924 | 924 | { |
| 925 | 925 | $temp_array['flight_count'] = $row['nb']; |
| 926 | 926 | $temp_array['flight_country'] = $row['name']; |
@@ -8,29 +8,29 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class Schedule { |
| 10 | 10 | protected $cookies = array(); |
| 11 | - public $db; |
|
| 11 | + public $db; |
|
| 12 | 12 | public function __construct($dbc = null) { |
| 13 | 13 | $Connection = new Connection($dbc); |
| 14 | 14 | $this->db = $Connection->db(); |
| 15 | - } |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Add schedule data to database |
|
| 19 | - * @param String $ident aircraft ident |
|
| 20 | - * @param String $departure_airport_icao departure airport icao |
|
| 21 | - * @param String $departure_airport_time departure airport time |
|
| 22 | - * @param String $arrival_airport_icao arrival airport icao |
|
| 23 | - * @param String $arrival_airport_time arrival airport time |
|
| 18 | + * Add schedule data to database |
|
| 19 | + * @param String $ident aircraft ident |
|
| 20 | + * @param String $departure_airport_icao departure airport icao |
|
| 21 | + * @param String $departure_airport_time departure airport time |
|
| 22 | + * @param String $arrival_airport_icao arrival airport icao |
|
| 23 | + * @param String $arrival_airport_time arrival airport time |
|
| 24 | 24 | / @param String $source source of data |
| 25 | - */ |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | 27 | public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
| 28 | 28 | date_default_timezone_set('UTC'); |
| 29 | 29 | $date = date("Y-m-d H:i:s",time()); |
| 30 | - //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
|
| 31 | - //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
|
| 32 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
|
| 33 | - $query_values = array(':ident' => $ident); |
|
| 30 | + //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
|
| 31 | + //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
|
| 32 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
|
| 33 | + $query_values = array(':ident' => $ident); |
|
| 34 | 34 | try { |
| 35 | 35 | $sth = $this->db->prepare($query); |
| 36 | 36 | $sth->execute($query_values); |
@@ -39,18 +39,18 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | if ($sth->fetchColumn() > 0) { |
| 41 | 41 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 42 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 43 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 42 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 43 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 44 | 44 | } elseif ($arrival_airport_time == '') { |
| 45 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 46 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 45 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 46 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 47 | 47 | } elseif ($departure_airport_time == '') { |
| 48 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 49 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 48 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 49 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 50 | 50 | } else { |
| 51 | - //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
| 52 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 53 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 51 | + //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
| 52 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 53 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 54 | 54 | } |
| 55 | 55 | try { |
| 56 | 56 | $sth = $this->db->prepare($query); |
@@ -61,17 +61,17 @@ discard block |
||
| 61 | 61 | if ($sth->fetchColumn() == 0) { |
| 62 | 62 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
| 63 | 63 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 64 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 65 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 64 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 65 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 66 | 66 | } elseif ($arrival_airport_time == '') { |
| 67 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 68 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 67 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 68 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 69 | 69 | } elseif ($departure_airport_time == '') { |
| 70 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 71 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 70 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 71 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 72 | 72 | } else { |
| 73 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 74 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 73 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 74 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 75 | 75 | } |
| 76 | 76 | try { |
| 77 | 77 | $sth = $this->db->prepare($query); |
@@ -104,15 +104,15 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function getSchedule($ident) { |
| 107 | - $Translation = new Translation($this->db); |
|
| 108 | - $operator = $Translation->checkTranslation($ident,false); |
|
| 109 | - if ($ident != $operator) { |
|
| 110 | - $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1"; |
|
| 111 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
| 112 | - } else { |
|
| 113 | - $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1"; |
|
| 114 | - $query_values = array(':ident' => $ident); |
|
| 115 | - } |
|
| 107 | + $Translation = new Translation($this->db); |
|
| 108 | + $operator = $Translation->checkTranslation($ident,false); |
|
| 109 | + if ($ident != $operator) { |
|
| 110 | + $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1"; |
|
| 111 | + $query_values = array(':ident' => $ident,'operator' => $operator); |
|
| 112 | + } else { |
|
| 113 | + $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1"; |
|
| 114 | + $query_values = array(':ident' => $ident); |
|
| 115 | + } |
|
| 116 | 116 | try { |
| 117 | 117 | $sth = $this->db->prepare($query); |
| 118 | 118 | $sth->execute($query_values); |
@@ -127,15 +127,15 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function checkSchedule($ident) { |
| 129 | 129 | global $globalDBdriver; |
| 130 | - //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
| 131 | - if ($globalDBdriver == 'mysql') { |
|
| 130 | + //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
| 131 | + if ($globalDBdriver == 'mysql') { |
|
| 132 | 132 | $query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1"; |
| 133 | 133 | } else { |
| 134 | 134 | $query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident |
| 135 | 135 | AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL) |
| 136 | 136 | OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1"; |
| 137 | 137 | } |
| 138 | - $query_values = array(':ident' => $ident); |
|
| 138 | + $query_values = array(':ident' => $ident); |
|
| 139 | 139 | try { |
| 140 | 140 | $sth = $this->db->prepare($query); |
| 141 | 141 | $sth->execute($query_values); |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | - * Get flight info from Air France |
|
| 151 | - * @param String $callsign The callsign |
|
| 152 | - * @param String $date date we want flight number info |
|
| 153 | - * @param String $carrier IATA code |
|
| 154 | - * @return Flight departure and arrival airports and time |
|
| 155 | - */ |
|
| 150 | + * Get flight info from Air France |
|
| 151 | + * @param String $callsign The callsign |
|
| 152 | + * @param String $date date we want flight number info |
|
| 153 | + * @param String $carrier IATA code |
|
| 154 | + * @return Flight departure and arrival airports and time |
|
| 155 | + */ |
|
| 156 | 156 | private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
| 157 | 157 | $Common = new Common(); |
| 158 | 158 | $check_date = new Datetime($date); |
@@ -188,11 +188,11 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | - * Get flight info from EasyJet |
|
| 192 | - * @param String $callsign The callsign |
|
| 193 | - * @param String $date date we want flight number info |
|
| 194 | - * @return Flight departure and arrival airports and time |
|
| 195 | - */ |
|
| 191 | + * Get flight info from EasyJet |
|
| 192 | + * @param String $callsign The callsign |
|
| 193 | + * @param String $date date we want flight number info |
|
| 194 | + * @return Flight departure and arrival airports and time |
|
| 195 | + */ |
|
| 196 | 196 | private function getEasyJet($callsign, $date = 'NOW') { |
| 197 | 197 | global $globalTimezone; |
| 198 | 198 | $Common = new Common(); |
@@ -216,10 +216,10 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
| 219 | - * Get flight info from Ryanair |
|
| 220 | - * @param String $callsign The callsign |
|
| 221 | - * @return Flight departure and arrival airports and time |
|
| 222 | - */ |
|
| 219 | + * Get flight info from Ryanair |
|
| 220 | + * @param String $callsign The callsign |
|
| 221 | + * @return Flight departure and arrival airports and time |
|
| 222 | + */ |
|
| 223 | 223 | private function getRyanair($callsign) { |
| 224 | 224 | $Common = new Common(); |
| 225 | 225 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | - * Get flight info from Swiss |
|
| 246 | - * @param String $callsign The callsign |
|
| 247 | - * @return Flight departure and arrival airports and time |
|
| 248 | - */ |
|
| 245 | + * Get flight info from Swiss |
|
| 246 | + * @param String $callsign The callsign |
|
| 247 | + * @return Flight departure and arrival airports and time |
|
| 248 | + */ |
|
| 249 | 249 | private function getSwiss($callsign) { |
| 250 | 250 | $Common = new Common(); |
| 251 | 251 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
| 277 | - * Get flight info from British Airways API |
|
| 278 | - * @param String $callsign The callsign |
|
| 279 | - * @param String $date date we want flight number info |
|
| 280 | - * @return Flight departure and arrival airports and time |
|
| 281 | - */ |
|
| 277 | + * Get flight info from British Airways API |
|
| 278 | + * @param String $callsign The callsign |
|
| 279 | + * @param String $date date we want flight number info |
|
| 280 | + * @return Flight departure and arrival airports and time |
|
| 281 | + */ |
|
| 282 | 282 | public function getBritishAirways($callsign, $date = 'NOW') { |
| 283 | 283 | global $globalBritishAirwaysKey; |
| 284 | 284 | $Common = new Common(); |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | - * Get flight info from Lutfhansa API |
|
| 306 | - * @param String $callsign The callsign |
|
| 307 | - * @param String $date date we want flight number info |
|
| 308 | - * @return Flight departure and arrival airports and time |
|
| 309 | - */ |
|
| 305 | + * Get flight info from Lutfhansa API |
|
| 306 | + * @param String $callsign The callsign |
|
| 307 | + * @param String $date date we want flight number info |
|
| 308 | + * @return Flight departure and arrival airports and time |
|
| 309 | + */ |
|
| 310 | 310 | public function getLufthansa($callsign, $date = 'NOW') { |
| 311 | 311 | global $globalLufthansaKey; |
| 312 | 312 | $Common = new Common(); |
@@ -336,11 +336,11 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | - * Get flight info from Transavia API |
|
| 340 | - * @param String $callsign The callsign |
|
| 341 | - * @param String $date date we want flight number info |
|
| 342 | - * @return Flight departure and arrival airports and time |
|
| 343 | - */ |
|
| 339 | + * Get flight info from Transavia API |
|
| 340 | + * @param String $callsign The callsign |
|
| 341 | + * @param String $date date we want flight number info |
|
| 342 | + * @return Flight departure and arrival airports and time |
|
| 343 | + */ |
|
| 344 | 344 | public function getTransavia($callsign, $date = 'NOW') { |
| 345 | 345 | global $globalTransaviaKey; |
| 346 | 346 | $Common = new Common(); |
@@ -366,10 +366,10 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | /** |
| 369 | - * Get flight info from Tunisair |
|
| 370 | - * @param String $callsign The callsign |
|
| 371 | - * @return Flight departure and arrival airports and time |
|
| 372 | - */ |
|
| 369 | + * Get flight info from Tunisair |
|
| 370 | + * @param String $callsign The callsign |
|
| 371 | + * @return Flight departure and arrival airports and time |
|
| 372 | + */ |
|
| 373 | 373 | public function getTunisair($callsign) { |
| 374 | 374 | $Common = new Common(); |
| 375 | 375 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -386,10 +386,10 @@ discard block |
||
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
| 389 | - * Get flight info from Vueling |
|
| 390 | - * @param String $callsign The callsign |
|
| 391 | - * @return Flight departure and arrival airports and time |
|
| 392 | - */ |
|
| 389 | + * Get flight info from Vueling |
|
| 390 | + * @param String $callsign The callsign |
|
| 391 | + * @return Flight departure and arrival airports and time |
|
| 392 | + */ |
|
| 393 | 393 | public function getVueling($callsign,$date = 'NOW') { |
| 394 | 394 | $Common = new Common(); |
| 395 | 395 | $check_date = new Datetime($date); |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
| 414 | - * Get flight info from Iberia |
|
| 415 | - * @param String $callsign The callsign |
|
| 416 | - * @param String $date date we want flight number info |
|
| 417 | - * @return Flight departure and arrival airports and time |
|
| 418 | - */ |
|
| 414 | + * Get flight info from Iberia |
|
| 415 | + * @param String $callsign The callsign |
|
| 416 | + * @param String $date date we want flight number info |
|
| 417 | + * @return Flight departure and arrival airports and time |
|
| 418 | + */ |
|
| 419 | 419 | public function getIberia($callsign, $date = 'NOW') { |
| 420 | 420 | $Common = new Common(); |
| 421 | 421 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -445,11 +445,11 @@ discard block |
||
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | - * Get flight info from Star Alliance |
|
| 449 | - * @param String $callsign The callsign |
|
| 450 | - * @param String $date date we want flight number info |
|
| 451 | - * @return Flight departure and arrival airports and time |
|
| 452 | - */ |
|
| 448 | + * Get flight info from Star Alliance |
|
| 449 | + * @param String $callsign The callsign |
|
| 450 | + * @param String $date date we want flight number info |
|
| 451 | + * @return Flight departure and arrival airports and time |
|
| 452 | + */ |
|
| 453 | 453 | |
| 454 | 454 | private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
| 455 | 455 | $Common = new Common(); |
@@ -481,11 +481,11 @@ discard block |
||
| 481 | 481 | |
| 482 | 482 | |
| 483 | 483 | /** |
| 484 | - * Get flight info from Alitalia |
|
| 485 | - * @param String $callsign The callsign |
|
| 486 | - * @param String $date date we want flight number info |
|
| 487 | - * @return Flight departure and arrival airports and time |
|
| 488 | - */ |
|
| 484 | + * Get flight info from Alitalia |
|
| 485 | + * @param String $callsign The callsign |
|
| 486 | + * @param String $date date we want flight number info |
|
| 487 | + * @return Flight departure and arrival airports and time |
|
| 488 | + */ |
|
| 489 | 489 | private function getAlitalia($callsign, $date = 'NOW') { |
| 490 | 490 | $Common = new Common(); |
| 491 | 491 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -504,11 +504,11 @@ discard block |
||
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
| 507 | - * Get flight info from Brussels airlines |
|
| 508 | - * @param String $callsign The callsign |
|
| 509 | - * @param String $date date we want flight number info |
|
| 510 | - * @return Flight departure and arrival airports and time |
|
| 511 | - */ |
|
| 507 | + * Get flight info from Brussels airlines |
|
| 508 | + * @param String $callsign The callsign |
|
| 509 | + * @param String $date date we want flight number info |
|
| 510 | + * @return Flight departure and arrival airports and time |
|
| 511 | + */ |
|
| 512 | 512 | private function getBrussels($callsign, $date = 'NOW') { |
| 513 | 513 | $Common = new Common(); |
| 514 | 514 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -518,24 +518,24 @@ discard block |
||
| 518 | 518 | if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
| 519 | 519 | $data = $Common->getData($url); |
| 520 | 520 | if ($data != '') { |
| 521 | - //echo $data; |
|
| 522 | - $parsed_json = json_decode($data); |
|
| 523 | - if (isset($parsed_json[0]->FromAirportCode)) { |
|
| 521 | + //echo $data; |
|
| 522 | + $parsed_json = json_decode($data); |
|
| 523 | + if (isset($parsed_json[0]->FromAirportCode)) { |
|
| 524 | 524 | $DepartureAirportIata = $parsed_json[0]->FromAirportCode; |
| 525 | 525 | $ArrivalAirportIata = $parsed_json[0]->ToAirportCode; |
| 526 | 526 | $departureTime = date('H:i',strtotime($parsed_json[0]->ScheduledDepatureDate)); |
| 527 | 527 | $arrivalTime = date('H:i',strtotime($parsed_json[0]->ScheduledArrivalDate)); |
| 528 | 528 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
| 529 | - } |
|
| 529 | + } |
|
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
| 534 | - * Get flight info from FlightRadar24 |
|
| 535 | - * @param String $callsign The callsign |
|
| 536 | - * @param String $date date we want flight number info |
|
| 537 | - * @return Flight departure and arrival airports and time |
|
| 538 | - */ |
|
| 534 | + * Get flight info from FlightRadar24 |
|
| 535 | + * @param String $callsign The callsign |
|
| 536 | + * @param String $date date we want flight number info |
|
| 537 | + * @return Flight departure and arrival airports and time |
|
| 538 | + */ |
|
| 539 | 539 | /* |
| 540 | 540 | public function getFlightRadar24($callsign, $date = 'NOW') { |
| 541 | 541 | $Common = new Common(); |
@@ -564,11 +564,11 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | */ |
| 566 | 566 | /** |
| 567 | - * Get flight info from Lufthansa |
|
| 568 | - * @param String $callsign The callsign |
|
| 569 | - * @param String $date date we want flight number info |
|
| 570 | - * @return Flight departure and arrival airports and time |
|
| 571 | - */ |
|
| 567 | + * Get flight info from Lufthansa |
|
| 568 | + * @param String $callsign The callsign |
|
| 569 | + * @param String $date date we want flight number info |
|
| 570 | + * @return Flight departure and arrival airports and time |
|
| 571 | + */ |
|
| 572 | 572 | |
| 573 | 573 | /* private function getLufthansa($callsign, $date = 'NOW') { |
| 574 | 574 | $Common = new Common(); |
@@ -596,10 +596,10 @@ discard block |
||
| 596 | 596 | } |
| 597 | 597 | */ |
| 598 | 598 | /** |
| 599 | - * Get flight info from flytap |
|
| 600 | - * @param String $callsign The callsign |
|
| 601 | - * @return Flight departure and arrival airports and time |
|
| 602 | - */ |
|
| 599 | + * Get flight info from flytap |
|
| 600 | + * @param String $callsign The callsign |
|
| 601 | + * @return Flight departure and arrival airports and time |
|
| 602 | + */ |
|
| 603 | 603 | private function getFlyTap($callsign) { |
| 604 | 604 | $Common = new Common(); |
| 605 | 605 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -622,10 +622,10 @@ discard block |
||
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | /** |
| 625 | - * Get flight info from flightmapper |
|
| 626 | - * @param String $callsign The callsign |
|
| 627 | - * @return Flight departure and arrival airports and time |
|
| 628 | - */ |
|
| 625 | + * Get flight info from flightmapper |
|
| 626 | + * @param String $callsign The callsign |
|
| 627 | + * @return Flight departure and arrival airports and time |
|
| 628 | + */ |
|
| 629 | 629 | public function getFlightMapper($callsign) { |
| 630 | 630 | $Common = new Common(); |
| 631 | 631 | $airline_icao = ''; |
@@ -653,11 +653,11 @@ discard block |
||
| 653 | 653 | $aarr = ''; |
| 654 | 654 | $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
| 655 | 655 | if ($n == 7) { |
| 656 | - $departureTime = $dhour; |
|
| 657 | - $arrivalTime = $ahour; |
|
| 658 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 659 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 660 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 656 | + $departureTime = $dhour; |
|
| 657 | + $arrivalTime = $ahour; |
|
| 658 | + $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 659 | + $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 660 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | } |
@@ -665,10 +665,10 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
| 668 | - * Get flight info from flightaware |
|
| 669 | - * @param String $callsign The callsign |
|
| 670 | - * @return Flight departure and arrival airports and time |
|
| 671 | - */ |
|
| 668 | + * Get flight info from flightaware |
|
| 669 | + * @param String $callsign The callsign |
|
| 670 | + * @return Flight departure and arrival airports and time |
|
| 671 | + */ |
|
| 672 | 672 | public function getFlightAware($callsign) { |
| 673 | 673 | $Common = new Common(); |
| 674 | 674 | /* |
@@ -701,10 +701,10 @@ discard block |
||
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
| 704 | - * Get flight info from CostToTravel |
|
| 705 | - * @param String $callsign The callsign |
|
| 706 | - * @return Flight departure and arrival airports and time |
|
| 707 | - */ |
|
| 704 | + * Get flight info from CostToTravel |
|
| 705 | + * @param String $callsign The callsign |
|
| 706 | + * @return Flight departure and arrival airports and time |
|
| 707 | + */ |
|
| 708 | 708 | public function getCostToTravel($callsign) { |
| 709 | 709 | $Common = new Common(); |
| 710 | 710 | $url= "http://www.costtotravel.com/flight-number/".$callsign; |
@@ -726,11 +726,11 @@ discard block |
||
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | /** |
| 729 | - * Get flight info from Air Canada |
|
| 730 | - * @param String $callsign The callsign |
|
| 731 | - * @param String $date date we want flight number info |
|
| 732 | - * @return Flight departure and arrival airports and time |
|
| 733 | - */ |
|
| 729 | + * Get flight info from Air Canada |
|
| 730 | + * @param String $callsign The callsign |
|
| 731 | + * @param String $date date we want flight number info |
|
| 732 | + * @return Flight departure and arrival airports and time |
|
| 733 | + */ |
|
| 734 | 734 | private function getAirCanada($callsign,$date = 'NOW') { |
| 735 | 735 | $Common = new Common(); |
| 736 | 736 | date_default_timezone_set('UTC'); |
@@ -754,11 +754,11 @@ discard block |
||
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /** |
| 757 | - * Get flight info from Vietnam Airlines |
|
| 758 | - * @param String $callsign The callsign |
|
| 759 | - * @param String $date date we want flight number info |
|
| 760 | - * @return Flight departure and arrival airports and time |
|
| 761 | - */ |
|
| 757 | + * Get flight info from Vietnam Airlines |
|
| 758 | + * @param String $callsign The callsign |
|
| 759 | + * @param String $date date we want flight number info |
|
| 760 | + * @return Flight departure and arrival airports and time |
|
| 761 | + */ |
|
| 762 | 762 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
| 763 | 763 | $Common = new Common(); |
| 764 | 764 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -780,12 +780,12 @@ discard block |
||
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
| 783 | - * Get flight info from Air Berlin |
|
| 784 | - * @param String $callsign The callsign |
|
| 785 | - * @param String $date date we want flight number info |
|
| 786 | - * @param String $carrier airline code |
|
| 787 | - * @return Flight departure and arrival airports and time |
|
| 788 | - */ |
|
| 783 | + * Get flight info from Air Berlin |
|
| 784 | + * @param String $callsign The callsign |
|
| 785 | + * @param String $date date we want flight number info |
|
| 786 | + * @param String $carrier airline code |
|
| 787 | + * @return Flight departure and arrival airports and time |
|
| 788 | + */ |
|
| 789 | 789 | private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
| 790 | 790 | $Common = new Common(); |
| 791 | 791 | date_default_timezone_set('UTC'); |
@@ -814,11 +814,11 @@ discard block |
||
| 814 | 814 | $table = $Common->table2array($data); |
| 815 | 815 | $flight = $table; |
| 816 | 816 | if (isset($flight[5][4])) { |
| 817 | - $arrivalTime = $flight[5][4]; |
|
| 818 | - $arrivalAirport = $flight[5][3]; |
|
| 817 | + $arrivalTime = $flight[5][4]; |
|
| 818 | + $arrivalAirport = $flight[5][3]; |
|
| 819 | 819 | } else { |
| 820 | - $arrivalTime = ''; |
|
| 821 | - $arrivalAirport = ''; |
|
| 820 | + $arrivalTime = ''; |
|
| 821 | + $arrivalAirport = ''; |
|
| 822 | 822 | } |
| 823 | 823 | } else return array(); |
| 824 | 824 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | } |
| 1087 | 1087 | } |
| 1088 | 1088 | } |
| 1089 | - return array(); |
|
| 1089 | + return array(); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | } |
| 1092 | 1092 | |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | / @param String $source source of data |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | - public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
|
| 27 | + public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') { |
|
| 28 | 28 | date_default_timezone_set('UTC'); |
| 29 | - $date = date("Y-m-d H:i:s",time()); |
|
| 29 | + $date = date("Y-m-d H:i:s", time()); |
|
| 30 | 30 | //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
| 31 | 31 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
| 32 | 32 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
@@ -34,69 +34,69 @@ discard block |
||
| 34 | 34 | try { |
| 35 | 35 | $sth = $this->db->prepare($query); |
| 36 | 36 | $sth->execute($query_values); |
| 37 | - } catch(PDOException $e) { |
|
| 37 | + } catch (PDOException $e) { |
|
| 38 | 38 | return "error : ".$e->getMessage(); |
| 39 | 39 | } |
| 40 | 40 | if ($sth->fetchColumn() > 0) { |
| 41 | 41 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 42 | 42 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
| 43 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 43 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao); |
|
| 44 | 44 | } elseif ($arrival_airport_time == '') { |
| 45 | 45 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
| 46 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 46 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao); |
|
| 47 | 47 | } elseif ($departure_airport_time == '') { |
| 48 | 48 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
| 49 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 49 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
| 50 | 50 | } else { |
| 51 | 51 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
| 52 | 52 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
| 53 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 53 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
| 54 | 54 | } |
| 55 | 55 | try { |
| 56 | 56 | $sth = $this->db->prepare($query); |
| 57 | 57 | $sth->execute($query_values); |
| 58 | - } catch(PDOException $e) { |
|
| 58 | + } catch (PDOException $e) { |
|
| 59 | 59 | return "error : ".$e->getMessage(); |
| 60 | 60 | } |
| 61 | 61 | if ($sth->fetchColumn() == 0) { |
| 62 | 62 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
| 63 | 63 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 64 | 64 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 65 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 65 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 66 | 66 | } elseif ($arrival_airport_time == '') { |
| 67 | 67 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 68 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 68 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 69 | 69 | } elseif ($departure_airport_time == '') { |
| 70 | 70 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 71 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 71 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 72 | 72 | } else { |
| 73 | 73 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 74 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 74 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 75 | 75 | } |
| 76 | 76 | try { |
| 77 | 77 | $sth = $this->db->prepare($query); |
| 78 | 78 | $sth->execute($query_values); |
| 79 | - } catch(PDOException $e) { |
|
| 79 | + } catch (PDOException $e) { |
|
| 80 | 80 | return "error : ".$e->getMessage(); |
| 81 | 81 | } |
| 82 | 82 | } else { |
| 83 | 83 | //$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident'; |
| 84 | 84 | $query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident'; |
| 85 | - $query_values = array(':ident' => $ident,':date' => $date); |
|
| 85 | + $query_values = array(':ident' => $ident, ':date' => $date); |
|
| 86 | 86 | try { |
| 87 | 87 | $sth = $this->db->prepare($query); |
| 88 | 88 | $sth->execute($query_values); |
| 89 | - } catch(PDOException $e) { |
|
| 89 | + } catch (PDOException $e) { |
|
| 90 | 90 | return "error : ".$e->getMessage(); |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | } else { |
| 94 | 94 | $query = 'INSERT INTO routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source) VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)'; |
| 95 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 95 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 96 | 96 | try { |
| 97 | 97 | $sth = $this->db->prepare($query); |
| 98 | 98 | $sth->execute($query_values); |
| 99 | - } catch(PDOException $e) { |
|
| 99 | + } catch (PDOException $e) { |
|
| 100 | 100 | return "error : ".$e->getMessage(); |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | public function getSchedule($ident) { |
| 107 | 107 | $Translation = new Translation($this->db); |
| 108 | - $operator = $Translation->checkTranslation($ident,false); |
|
| 108 | + $operator = $Translation->checkTranslation($ident, false); |
|
| 109 | 109 | if ($ident != $operator) { |
| 110 | 110 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1"; |
| 111 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
| 111 | + $query_values = array(':ident' => $ident, 'operator' => $operator); |
|
| 112 | 112 | } else { |
| 113 | 113 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1"; |
| 114 | 114 | $query_values = array(':ident' => $ident); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | try { |
| 117 | 117 | $sth = $this->db->prepare($query); |
| 118 | 118 | $sth->execute($query_values); |
| 119 | - } catch(PDOException $e) { |
|
| 119 | + } catch (PDOException $e) { |
|
| 120 | 120 | return "error : ".$e->getMessage(); |
| 121 | 121 | } |
| 122 | 122 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | try { |
| 140 | 140 | $sth = $this->db->prepare($query); |
| 141 | 141 | $sth->execute($query_values); |
| 142 | - } catch(PDOException $e) { |
|
| 142 | + } catch (PDOException $e) { |
|
| 143 | 143 | return "error : ".$e->getMessage(); |
| 144 | 144 | } |
| 145 | 145 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | * @param String $carrier IATA code |
| 154 | 154 | * @return Flight departure and arrival airports and time |
| 155 | 155 | */ |
| 156 | - private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
|
| 156 | + private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') { |
|
| 157 | 157 | $Common = new Common(); |
| 158 | 158 | $check_date = new Datetime($date); |
| 159 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 160 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 159 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 160 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 161 | 161 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
| 162 | 162 | $json = $Common->getData($url); |
| 163 | 163 | |
| 164 | 164 | $parsed_json = json_decode($json); |
| 165 | - if (property_exists($parsed_json,'errors') === false) { |
|
| 165 | + if (property_exists($parsed_json, 'errors') === false) { |
|
| 166 | 166 | //$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'}; |
| 167 | 167 | $originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'}; |
| 168 | 168 | //$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'}; |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | //$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'}; |
| 173 | 173 | $arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'}; |
| 174 | 174 | |
| 175 | - preg_match('/\((.*?)\)/',$originShort,$originiata); |
|
| 175 | + preg_match('/\((.*?)\)/', $originShort, $originiata); |
|
| 176 | 176 | $DepartureAirportIata = $originiata[1]; |
| 177 | - preg_match('/\((.*?)\)/',$destinationShort,$destinationiata); |
|
| 177 | + preg_match('/\((.*?)\)/', $destinationShort, $destinationiata); |
|
| 178 | 178 | $ArrivalAirportIata = $destinationiata[1]; |
| 179 | 179 | |
| 180 | 180 | /* |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $arrivalTime = gmdate('H:i',strtotime($arrivalTime)); |
| 184 | 184 | */ |
| 185 | 185 | |
| 186 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
|
| 186 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance'); |
|
| 187 | 187 | } else return array(); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | $Common = new Common(); |
| 199 | 199 | date_default_timezone_set($globalTimezone); |
| 200 | 200 | $check_date = new Datetime($date); |
| 201 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 202 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 201 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 202 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 203 | 203 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
| 204 | 204 | $json = $Common->getData($url); |
| 205 | 205 | $parsed_json = json_decode($json); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'}; |
| 212 | 212 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
| 213 | 213 | |
| 214 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
|
| 214 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet'); |
|
| 215 | 215 | } else return array(); |
| 216 | 216 | } |
| 217 | 217 | |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | private function getRyanair($callsign) { |
| 224 | 224 | $Common = new Common(); |
| 225 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 226 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 225 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 226 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 227 | 227 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
| 228 | 228 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
| 229 | - $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
|
| 230 | - $json = $Common->getData($url,'post',$post,$headers); |
|
| 229 | + $headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post)); |
|
| 230 | + $json = $Common->getData($url, 'post', $post, $headers); |
|
| 231 | 231 | $parsed_json = json_decode($json); |
| 232 | 232 | if (isset($parsed_json->{'flightInfo'})) { |
| 233 | 233 | $flights = $parsed_json->{'flightInfo'}; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name |
| 237 | 237 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
| 238 | 238 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
| 239 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
| 239 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
| 240 | 240 | } else return array(); |
| 241 | 241 | } else return array(); |
| 242 | 242 | } |
@@ -248,8 +248,8 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | private function getSwiss($callsign) { |
| 250 | 250 | $Common = new Common(); |
| 251 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 252 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 251 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 252 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 253 | 253 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
| 254 | 254 | $json = $Common->getData($url); |
| 255 | 255 | $parsed_json = json_decode($json); |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | if ($flight->{'no'} == "Vol LX ".$numvol) { |
| 264 | 264 | $DepartureAirportIata = $flight->{'from'}->{'code'}; //city |
| 265 | 265 | $ArrivalAirportIata = $flight->{'to'}->{'code'}; //city |
| 266 | - $departureTime = substr($flight->{'from'}->{'hour'},0,5); |
|
| 267 | - $arrivalTime = substr($flight->{'to'}->{'hour'},0,5); |
|
| 266 | + $departureTime = substr($flight->{'from'}->{'hour'},0, 5); |
|
| 267 | + $arrivalTime = substr($flight->{'to'}->{'hour'},0, 5); |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
| 271 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
|
| 271 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss'); |
|
| 272 | 272 | } else return array(); |
| 273 | 273 | } else return array(); |
| 274 | 274 | } |
@@ -283,21 +283,21 @@ discard block |
||
| 283 | 283 | global $globalBritishAirwaysKey; |
| 284 | 284 | $Common = new Common(); |
| 285 | 285 | $check_date = new Datetime($date); |
| 286 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 287 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 286 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 287 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 288 | 288 | if ($globalBritishAirwaysKey == '') return array(); |
| 289 | 289 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
| 290 | 290 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
| 291 | - $json = $Common->getData($url,'get','',$headers); |
|
| 291 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 292 | 292 | if ($json == '') return array(); |
| 293 | 293 | $parsed_json = json_decode($json); |
| 294 | 294 | $flights = $parsed_json->{'FlightsResponse'}; |
| 295 | 295 | if (count($flights) > 0) { |
| 296 | 296 | $DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'}; |
| 297 | 297 | $ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'}; |
| 298 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
| 299 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
| 300 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
|
| 298 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
| 299 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
| 300 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways'); |
|
| 301 | 301 | } else return array(); |
| 302 | 302 | } |
| 303 | 303 | |
@@ -311,27 +311,27 @@ discard block |
||
| 311 | 311 | global $globalLufthansaKey; |
| 312 | 312 | $Common = new Common(); |
| 313 | 313 | $check_date = new Datetime($date); |
| 314 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 315 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 314 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 315 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 316 | 316 | if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
| 317 | 317 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
| 318 | - $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
|
| 319 | - $data = $Common->getData($url,'post',$post); |
|
| 318 | + $post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials'); |
|
| 319 | + $data = $Common->getData($url, 'post', $post); |
|
| 320 | 320 | $parsed_data = json_decode($data); |
| 321 | 321 | if (!isset($parsed_data->{'access_token'})) return array(); |
| 322 | 322 | $token = $parsed_data->{'access_token'}; |
| 323 | 323 | |
| 324 | 324 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
| 325 | - $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
|
| 326 | - $json = $Common->getData($url,'get','',$headers); |
|
| 325 | + $headers = array('Authorization: Bearer '.$token, 'Accept: application/json'); |
|
| 326 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 327 | 327 | if ($json == '') return array(); |
| 328 | 328 | $parsed_json = json_decode($json); |
| 329 | 329 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
| 330 | 330 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
| 331 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 331 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 332 | 332 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
| 333 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 334 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
|
| 333 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 334 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa'); |
|
| 335 | 335 | } else return array(); |
| 336 | 336 | } |
| 337 | 337 | |
@@ -345,23 +345,23 @@ discard block |
||
| 345 | 345 | global $globalTransaviaKey; |
| 346 | 346 | $Common = new Common(); |
| 347 | 347 | $check_date = new Datetime($date); |
| 348 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 349 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 348 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 349 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 350 | 350 | if ($globalTransaviaKey == '') return array(); |
| 351 | 351 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 352 | 352 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 353 | 353 | $headers = array('apikey: '.$globalTransaviaKey); |
| 354 | - $json = $Common->getData($url,'get','',$headers); |
|
| 354 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 355 | 355 | //echo 'result : '.$json; |
| 356 | 356 | if ($json == '') return array(); |
| 357 | 357 | $parsed_json = json_decode($json); |
| 358 | 358 | |
| 359 | 359 | if (isset($parsed_json->{'data'}[0])) { |
| 360 | 360 | $DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'}; |
| 361 | - $departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
| 361 | + $departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
| 362 | 362 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
| 363 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
| 364 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
|
| 363 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
| 364 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia'); |
|
| 365 | 365 | } else return array(); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -372,14 +372,14 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | public function getTunisair($callsign) { |
| 374 | 374 | $Common = new Common(); |
| 375 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 376 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 375 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 376 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 377 | 377 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
| 378 | 378 | $data = $Common->getData($url); |
| 379 | 379 | $table = $Common->table2array($data); |
| 380 | 380 | foreach ($table as $flight) { |
| 381 | - if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) { |
|
| 382 | - return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair'); |
|
| 381 | + if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) { |
|
| 382 | + return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair'); |
|
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | return array(); |
@@ -390,21 +390,21 @@ discard block |
||
| 390 | 390 | * @param String $callsign The callsign |
| 391 | 391 | * @return Flight departure and arrival airports and time |
| 392 | 392 | */ |
| 393 | - public function getVueling($callsign,$date = 'NOW') { |
|
| 393 | + public function getVueling($callsign, $date = 'NOW') { |
|
| 394 | 394 | $Common = new Common(); |
| 395 | 395 | $check_date = new Datetime($date); |
| 396 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 397 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 398 | - $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
|
| 396 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 397 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 398 | + $final_date = str_replace('/', '%2F', $check_date->format('d/m/Y')); |
|
| 399 | 399 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
| 400 | 400 | $data = $Common->getData($url); |
| 401 | - $data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data)); |
|
| 401 | + $data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data)); |
|
| 402 | 402 | if ($data != '') { |
| 403 | - preg_match('/flightOri=[A-Z]{3}/',$data,$result); |
|
| 404 | - $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
|
| 405 | - preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
|
| 406 | - $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
|
| 407 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 403 | + preg_match('/flightOri=[A-Z]{3}/', $data, $result); |
|
| 404 | + $DepartureAirportIata = str_replace('flightOri=', '', $result[0]); |
|
| 405 | + preg_match('/flightDest=[A-Z]{3}/', $data, $result); |
|
| 406 | + $ArrivalAirportIata = str_replace('flightDest=', '', $result[0]); |
|
| 407 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling'); |
|
| 408 | 408 | else return array(); |
| 409 | 409 | } |
| 410 | 410 | return array(); |
@@ -418,27 +418,27 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | public function getIberia($callsign, $date = 'NOW') { |
| 420 | 420 | $Common = new Common(); |
| 421 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 421 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 422 | 422 | $check_date = new Datetime($date); |
| 423 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 423 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 424 | 424 | $url = "https://www.iberia.com/web/flightDetail.do"; |
| 425 | - $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
|
| 426 | - $data = $Common->getData($url,'post',$post); |
|
| 425 | + $post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB'); |
|
| 426 | + $data = $Common->getData($url, 'post', $post); |
|
| 427 | 427 | if ($data != '') { |
| 428 | 428 | $table = $Common->table2array($data); |
| 429 | 429 | //print_r($table); |
| 430 | 430 | if (count($table) > 0) { |
| 431 | 431 | $flight = $table; |
| 432 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
| 433 | - preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch); |
|
| 432 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
| 433 | + preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch); |
|
| 434 | 434 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 435 | 435 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 436 | - $departureTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[3][2]))),0,5); |
|
| 437 | - $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
|
| 436 | + $departureTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[3][2]))), 0, 5); |
|
| 437 | + $arrivalTime = trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][1]))); |
|
| 438 | 438 | if ($arrivalTime == 'Hora estimada de llegada') { |
| 439 | - $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
|
| 440 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
| 441 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
|
| 439 | + $arrivalTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][2]))), 0, 5); |
|
| 440 | + } else $arrivalTime = substr($arrivalTime, 0, 5); |
|
| 441 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia'); |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | return array(); |
@@ -451,11 +451,11 @@ discard block |
||
| 451 | 451 | * @return Flight departure and arrival airports and time |
| 452 | 452 | */ |
| 453 | 453 | |
| 454 | - private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
|
| 454 | + private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') { |
|
| 455 | 455 | $Common = new Common(); |
| 456 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 456 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 457 | 457 | $check_date = new Datetime($date); |
| 458 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 458 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 459 | 459 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
| 460 | 460 | $data = $Common->getData($url); |
| 461 | 461 | if ($data != '') { |
@@ -464,13 +464,13 @@ discard block |
||
| 464 | 464 | $flight = $table; |
| 465 | 465 | //print_r($table); |
| 466 | 466 | if (isset($flight[25]) && isset($flight[29])) { |
| 467 | - preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch); |
|
| 468 | - preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch); |
|
| 467 | + preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch); |
|
| 468 | + preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch); |
|
| 469 | 469 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 470 | 470 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 471 | - $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
|
| 472 | - $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
|
| 473 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
|
| 471 | + $departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5); |
|
| 472 | + $arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5); |
|
| 473 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance'); |
|
| 474 | 474 | } else return array(); |
| 475 | 475 | } |
| 476 | 476 | |
@@ -488,10 +488,10 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | private function getAlitalia($callsign, $date = 'NOW') { |
| 490 | 490 | $Common = new Common(); |
| 491 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 491 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 492 | 492 | $check_date = new Datetime($date); |
| 493 | - $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
| 494 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 493 | + $url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
| 494 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 495 | 495 | $data = $Common->getData($url); |
| 496 | 496 | if ($data != '') { |
| 497 | 497 | $table = $Common->text2array($data); |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | $ArrivalAirportIata = ''; |
| 500 | 500 | $departureTime = $table[4]; |
| 501 | 501 | $arrivalTime = $table[5]; |
| 502 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia'); |
|
| 502 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia'); |
|
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | |
@@ -511,11 +511,11 @@ discard block |
||
| 511 | 511 | */ |
| 512 | 512 | private function getBrussels($callsign, $date = 'NOW') { |
| 513 | 513 | $Common = new Common(); |
| 514 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 514 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 515 | 515 | $check_date = new Datetime($date); |
| 516 | - $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
| 516 | + $url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
| 517 | 517 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
| 518 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 518 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 519 | 519 | $data = $Common->getData($url); |
| 520 | 520 | if ($data != '') { |
| 521 | 521 | //echo $data; |
@@ -523,9 +523,9 @@ discard block |
||
| 523 | 523 | if (isset($parsed_json[0]->FromAirportCode)) { |
| 524 | 524 | $DepartureAirportIata = $parsed_json[0]->FromAirportCode; |
| 525 | 525 | $ArrivalAirportIata = $parsed_json[0]->ToAirportCode; |
| 526 | - $departureTime = date('H:i',strtotime($parsed_json[0]->ScheduledDepatureDate)); |
|
| 527 | - $arrivalTime = date('H:i',strtotime($parsed_json[0]->ScheduledArrivalDate)); |
|
| 528 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
|
| 526 | + $departureTime = date('H:i', strtotime($parsed_json[0]->ScheduledDepatureDate)); |
|
| 527 | + $arrivalTime = date('H:i', strtotime($parsed_json[0]->ScheduledArrivalDate)); |
|
| 528 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels'); |
|
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | } |
@@ -602,21 +602,21 @@ discard block |
||
| 602 | 602 | */ |
| 603 | 603 | private function getFlyTap($callsign) { |
| 604 | 604 | $Common = new Common(); |
| 605 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 606 | - $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
| 605 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 606 | + $url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
| 607 | 607 | //$check_date = new Datetime($date); |
| 608 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 609 | - $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
|
| 610 | - $data = $Common->getData($url,'post',$post); |
|
| 608 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 609 | + $post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1'); |
|
| 610 | + $data = $Common->getData($url, 'post', $post); |
|
| 611 | 611 | if ($data != '') { |
| 612 | 612 | $table = $Common->table2array($data); |
| 613 | - $departureTime = trim(substr($table[15][0],0,5)); |
|
| 614 | - $arrivalTime = trim(substr($table[35][0],0,5)); |
|
| 615 | - preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch); |
|
| 616 | - preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch); |
|
| 613 | + $departureTime = trim(substr($table[15][0], 0, 5)); |
|
| 614 | + $arrivalTime = trim(substr($table[35][0], 0, 5)); |
|
| 615 | + preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch); |
|
| 616 | + preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch); |
|
| 617 | 617 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 618 | 618 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 619 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap'); |
|
| 619 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap'); |
|
| 620 | 620 | } |
| 621 | 621 | return array(); |
| 622 | 622 | } |
@@ -638,10 +638,10 @@ discard block |
||
| 638 | 638 | } |
| 639 | 639 | } |
| 640 | 640 | if ($airline_icao == '') return array(); |
| 641 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 642 | - $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
| 641 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 642 | + $url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
| 643 | 643 | //$check_date = new Datetime($date); |
| 644 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 644 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 645 | 645 | $data = $Common->getData($url); |
| 646 | 646 | if ($data != '') { |
| 647 | 647 | $table = $Common->table2array($data); |
@@ -651,13 +651,13 @@ discard block |
||
| 651 | 651 | $darr = ''; |
| 652 | 652 | $ahour = ''; |
| 653 | 653 | $aarr = ''; |
| 654 | - $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
|
| 654 | + $n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr); |
|
| 655 | 655 | if ($n == 7) { |
| 656 | 656 | $departureTime = $dhour; |
| 657 | 657 | $arrivalTime = $ahour; |
| 658 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 659 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 660 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 658 | + $DepartureAirportIata = str_replace(array('(', ')'), '', $darr); |
|
| 659 | + $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr); |
|
| 660 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper'); |
|
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | } |
@@ -681,20 +681,20 @@ discard block |
||
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | */ |
| 684 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 685 | - $url= "http://fr.flightaware.com/live/flight/".$callsign; |
|
| 684 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 685 | + $url = "http://fr.flightaware.com/live/flight/".$callsign; |
|
| 686 | 686 | //$check_date = new Datetime($date); |
| 687 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 687 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 688 | 688 | $data = $Common->getData($url); |
| 689 | 689 | if ($data != '') { |
| 690 | 690 | $table = $Common->table2array($data); |
| 691 | 691 | if (isset($table[11][0])) { |
| 692 | - $departureTime = str_replace('h',':',substr($table[5][0],0,5)); |
|
| 693 | - $arrivalTime = str_replace('h',':',substr($table[5][1],0,5)); |
|
| 692 | + $departureTime = str_replace('h', ':', substr($table[5][0], 0, 5)); |
|
| 693 | + $arrivalTime = str_replace('h', ':', substr($table[5][1], 0, 5)); |
|
| 694 | 694 | echo $table[3][0]; |
| 695 | - sscanf($table[3][0],'%*[^(] (%3[A-Z] / %*4[A-Z])',$DepartureAirportIata); |
|
| 696 | - sscanf($table[3][1],'%*[^(] (%3[A-Z] / %*4[A-Z])',$ArrivalAirportIata); |
|
| 697 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightaware'); |
|
| 695 | + sscanf($table[3][0], '%*[^(] (%3[A-Z] / %*4[A-Z])', $DepartureAirportIata); |
|
| 696 | + sscanf($table[3][1], '%*[^(] (%3[A-Z] / %*4[A-Z])', $ArrivalAirportIata); |
|
| 697 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightaware'); |
|
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | return array(); |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | */ |
| 708 | 708 | public function getCostToTravel($callsign) { |
| 709 | 709 | $Common = new Common(); |
| 710 | - $url= "http://www.costtotravel.com/flight-number/".$callsign; |
|
| 710 | + $url = "http://www.costtotravel.com/flight-number/".$callsign; |
|
| 711 | 711 | //$check_date = new Datetime($date); |
| 712 | 712 | //if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
| 713 | 713 | $data = $Common->getData($url); |
@@ -715,11 +715,11 @@ discard block |
||
| 715 | 715 | $table = $Common->table2array($data); |
| 716 | 716 | //print_r($table); |
| 717 | 717 | if (isset($table[11][1])) { |
| 718 | - $departureTime = substr($table[11][1],0,5); |
|
| 719 | - $arrivalTime = substr($table[17][1],0,5); |
|
| 720 | - $DepartureAirportIata = substr($table[13][1],0,3); |
|
| 721 | - $ArrivalAirportIata = substr($table[15][1],0,3); |
|
| 722 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
|
| 718 | + $departureTime = substr($table[11][1], 0, 5); |
|
| 719 | + $arrivalTime = substr($table[17][1], 0, 5); |
|
| 720 | + $DepartureAirportIata = substr($table[13][1], 0, 3); |
|
| 721 | + $ArrivalAirportIata = substr($table[15][1], 0, 3); |
|
| 722 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel'); |
|
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | return array(); |
@@ -731,13 +731,13 @@ discard block |
||
| 731 | 731 | * @param String $date date we want flight number info |
| 732 | 732 | * @return Flight departure and arrival airports and time |
| 733 | 733 | */ |
| 734 | - private function getAirCanada($callsign,$date = 'NOW') { |
|
| 734 | + private function getAirCanada($callsign, $date = 'NOW') { |
|
| 735 | 735 | $Common = new Common(); |
| 736 | 736 | date_default_timezone_set('UTC'); |
| 737 | 737 | $check_date = new Datetime($date); |
| 738 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 739 | - $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
| 740 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 738 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 739 | + $url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
| 740 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 741 | 741 | $data = $Common->getData($url); |
| 742 | 742 | $dom = new DomDocument(); |
| 743 | 743 | $dom->loadXML($data); |
@@ -745,11 +745,11 @@ discard block |
||
| 745 | 745 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
| 746 | 746 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
| 747 | 747 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 748 | - $departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 748 | + $departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 749 | 749 | $arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0); |
| 750 | 750 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 751 | - $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 752 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
|
| 751 | + $arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 752 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada'); |
|
| 753 | 753 | } else return array(); |
| 754 | 754 | } |
| 755 | 755 | |
@@ -761,21 +761,21 @@ discard block |
||
| 761 | 761 | */ |
| 762 | 762 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
| 763 | 763 | $Common = new Common(); |
| 764 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 764 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 765 | 765 | $check_date = new Datetime($date); |
| 766 | - $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
| 767 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 766 | + $url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
| 767 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 768 | 768 | $data = $Common->getData($url); |
| 769 | 769 | if ($data != '') { |
| 770 | 770 | $table = $Common->table2array($data); |
| 771 | 771 | $flight = $table; |
| 772 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
| 773 | - preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch); |
|
| 772 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
| 773 | + preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch); |
|
| 774 | 774 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 775 | 775 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 776 | 776 | $departureTime = $flight[5][1]; |
| 777 | 777 | $arrivalTime = $flight[23][1]; |
| 778 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines'); |
|
| 778 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines'); |
|
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | |
@@ -786,16 +786,16 @@ discard block |
||
| 786 | 786 | * @param String $carrier airline code |
| 787 | 787 | * @return Flight departure and arrival airports and time |
| 788 | 788 | */ |
| 789 | - private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
|
| 789 | + private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') { |
|
| 790 | 790 | $Common = new Common(); |
| 791 | 791 | date_default_timezone_set('UTC'); |
| 792 | 792 | //AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair |
| 793 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 793 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 794 | 794 | $check_date = new Datetime($date); |
| 795 | - $url= "http://www.airberlin.com/en-US/site/aims.php"; |
|
| 796 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 797 | - $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
|
| 798 | - $data = $Common->getData($url,'post',$post); |
|
| 795 | + $url = "http://www.airberlin.com/en-US/site/aims.php"; |
|
| 796 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 797 | + $post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier); |
|
| 798 | + $data = $Common->getData($url, 'post', $post); |
|
| 799 | 799 | //echo $data; |
| 800 | 800 | $DepartureAirportIata = ''; |
| 801 | 801 | $ArrivalAirportIata = ''; |
@@ -808,8 +808,8 @@ discard block |
||
| 808 | 808 | if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
| 809 | 809 | else $departureAirport = ''; |
| 810 | 810 | } else return array(); |
| 811 | - $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
|
| 812 | - $data = $Common->getData($url,'post',$post); |
|
| 811 | + $post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB'); |
|
| 812 | + $data = $Common->getData($url, 'post', $post); |
|
| 813 | 813 | if ($data != '') { |
| 814 | 814 | $table = $Common->table2array($data); |
| 815 | 815 | $flight = $table; |
@@ -837,13 +837,13 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | } |
| 839 | 839 | if (isset($DepartureAirportIata)) { |
| 840 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
|
| 840 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin'); |
|
| 841 | 841 | } else return array(); |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | |
| 845 | 845 | |
| 846 | - public function fetchSchedule($ident,$date = 'NOW') { |
|
| 846 | + public function fetchSchedule($ident, $date = 'NOW') { |
|
| 847 | 847 | global $globalSchedulesSources, $globalSchedulesFetch; |
| 848 | 848 | //$Common = new Common(); |
| 849 | 849 | if (!$globalSchedulesFetch) return array(); |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | // Brussels Airlines |
| 914 | 914 | case "BEL": |
| 915 | 915 | case "SN": |
| 916 | - return $this->getBrussels($ident,$date); |
|
| 916 | + return $this->getBrussels($ident, $date); |
|
| 917 | 917 | /* |
| 918 | 918 | // Copa Airlines |
| 919 | 919 | case "CMP": |
@@ -998,17 +998,17 @@ discard block |
||
| 998 | 998 | // Air France |
| 999 | 999 | case "AF": |
| 1000 | 1000 | case "AFR": |
| 1001 | - return $this->getAirFrance($ident,$date,'AF'); |
|
| 1001 | + return $this->getAirFrance($ident, $date, 'AF'); |
|
| 1002 | 1002 | // HOP |
| 1003 | 1003 | case "A5": |
| 1004 | 1004 | case "HOP": |
| 1005 | - return $this->getAirFrance($ident,$date,'A5'); |
|
| 1005 | + return $this->getAirFrance($ident, $date, 'A5'); |
|
| 1006 | 1006 | // EasyJet |
| 1007 | 1007 | case "U2": |
| 1008 | 1008 | case "DS": |
| 1009 | 1009 | case "EZY": |
| 1010 | 1010 | case "EZS": |
| 1011 | - return $this->getEasyJet($ident,$date); |
|
| 1011 | + return $this->getEasyJet($ident, $date); |
|
| 1012 | 1012 | // Ryanair |
| 1013 | 1013 | case "FR": |
| 1014 | 1014 | case "RYR": |
@@ -1058,25 +1058,25 @@ discard block |
||
| 1058 | 1058 | return $this->getIberia($ident); |
| 1059 | 1059 | // Vietnam Airlines |
| 1060 | 1060 | case "HVN": |
| 1061 | - return $this->getVietnamAirlines($ident,$date); |
|
| 1061 | + return $this->getVietnamAirlines($ident, $date); |
|
| 1062 | 1062 | // Air Berlin |
| 1063 | 1063 | case "AB": |
| 1064 | 1064 | case "BER": |
| 1065 | - return $this->getAirBerlin($ident,$date,'AB'); |
|
| 1065 | + return $this->getAirBerlin($ident, $date, 'AB'); |
|
| 1066 | 1066 | // NIKI |
| 1067 | 1067 | case "HG": |
| 1068 | 1068 | case "NLY": |
| 1069 | - return $this->getAirBerlin($ident,$date,'HG'); |
|
| 1069 | + return $this->getAirBerlin($ident, $date, 'HG'); |
|
| 1070 | 1070 | // BelAir |
| 1071 | 1071 | case "4T": |
| 1072 | 1072 | case "BHP": |
| 1073 | - return $this->getAirBerlin($ident,$date,'4T'); |
|
| 1073 | + return $this->getAirBerlin($ident, $date, '4T'); |
|
| 1074 | 1074 | default: |
| 1075 | 1075 | // Randomly use a generic function to get hours |
| 1076 | 1076 | if (strlen($airline_icao) == 2) { |
| 1077 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1077 | + if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
| 1078 | 1078 | if (count($globalSchedulesSources) > 0) { |
| 1079 | - $rand = mt_rand(0,count($globalSchedulesSources)-1); |
|
| 1079 | + $rand = mt_rand(0, count($globalSchedulesSources) - 1); |
|
| 1080 | 1080 | $source = $globalSchedulesSources[$rand]; |
| 1081 | 1081 | if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
| 1082 | 1082 | elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
@@ -122,7 +122,9 @@ discard block |
||
| 122 | 122 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 123 | 123 | if (count($row) > 0) { |
| 124 | 124 | return $row; |
| 125 | - } else return array(); |
|
| 125 | + } else { |
|
| 126 | + return array(); |
|
| 127 | + } |
|
| 126 | 128 | } |
| 127 | 129 | |
| 128 | 130 | public function checkSchedule($ident) { |
@@ -157,7 +159,9 @@ discard block |
||
| 157 | 159 | $Common = new Common(); |
| 158 | 160 | $check_date = new Datetime($date); |
| 159 | 161 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 160 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 162 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 163 | + return array(); |
|
| 164 | + } |
|
| 161 | 165 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
| 162 | 166 | $json = $Common->getData($url); |
| 163 | 167 | |
@@ -184,7 +188,9 @@ discard block |
||
| 184 | 188 | */ |
| 185 | 189 | |
| 186 | 190 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
| 187 | - } else return array(); |
|
| 191 | + } else { |
|
| 192 | + return array(); |
|
| 193 | + } |
|
| 188 | 194 | } |
| 189 | 195 | |
| 190 | 196 | /** |
@@ -199,7 +205,9 @@ discard block |
||
| 199 | 205 | date_default_timezone_set($globalTimezone); |
| 200 | 206 | $check_date = new Datetime($date); |
| 201 | 207 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 202 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 208 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 209 | + return array(); |
|
| 210 | + } |
|
| 203 | 211 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
| 204 | 212 | $json = $Common->getData($url); |
| 205 | 213 | $parsed_json = json_decode($json); |
@@ -212,7 +220,9 @@ discard block |
||
| 212 | 220 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
| 213 | 221 | |
| 214 | 222 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
| 215 | - } else return array(); |
|
| 223 | + } else { |
|
| 224 | + return array(); |
|
| 225 | + } |
|
| 216 | 226 | } |
| 217 | 227 | |
| 218 | 228 | /** |
@@ -223,7 +233,9 @@ discard block |
||
| 223 | 233 | private function getRyanair($callsign) { |
| 224 | 234 | $Common = new Common(); |
| 225 | 235 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 226 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 236 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 237 | + return array(); |
|
| 238 | + } |
|
| 227 | 239 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
| 228 | 240 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
| 229 | 241 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -237,8 +249,12 @@ discard block |
||
| 237 | 249 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
| 238 | 250 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
| 239 | 251 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
| 240 | - } else return array(); |
|
| 241 | - } else return array(); |
|
| 252 | + } else { |
|
| 253 | + return array(); |
|
| 254 | + } |
|
| 255 | + } else { |
|
| 256 | + return array(); |
|
| 257 | + } |
|
| 242 | 258 | } |
| 243 | 259 | |
| 244 | 260 | /** |
@@ -249,7 +265,9 @@ discard block |
||
| 249 | 265 | private function getSwiss($callsign) { |
| 250 | 266 | $Common = new Common(); |
| 251 | 267 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 252 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 268 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 269 | + return array(); |
|
| 270 | + } |
|
| 253 | 271 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
| 254 | 272 | $json = $Common->getData($url); |
| 255 | 273 | $parsed_json = json_decode($json); |
@@ -269,8 +287,12 @@ discard block |
||
| 269 | 287 | } |
| 270 | 288 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
| 271 | 289 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
| 272 | - } else return array(); |
|
| 273 | - } else return array(); |
|
| 290 | + } else { |
|
| 291 | + return array(); |
|
| 292 | + } |
|
| 293 | + } else { |
|
| 294 | + return array(); |
|
| 295 | + } |
|
| 274 | 296 | } |
| 275 | 297 | |
| 276 | 298 | /** |
@@ -284,12 +306,18 @@ discard block |
||
| 284 | 306 | $Common = new Common(); |
| 285 | 307 | $check_date = new Datetime($date); |
| 286 | 308 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 287 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 288 | - if ($globalBritishAirwaysKey == '') return array(); |
|
| 309 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 310 | + return array(); |
|
| 311 | + } |
|
| 312 | + if ($globalBritishAirwaysKey == '') { |
|
| 313 | + return array(); |
|
| 314 | + } |
|
| 289 | 315 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
| 290 | 316 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
| 291 | 317 | $json = $Common->getData($url,'get','',$headers); |
| 292 | - if ($json == '') return array(); |
|
| 318 | + if ($json == '') { |
|
| 319 | + return array(); |
|
| 320 | + } |
|
| 293 | 321 | $parsed_json = json_decode($json); |
| 294 | 322 | $flights = $parsed_json->{'FlightsResponse'}; |
| 295 | 323 | if (count($flights) > 0) { |
@@ -298,7 +326,9 @@ discard block |
||
| 298 | 326 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
| 299 | 327 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
| 300 | 328 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
| 301 | - } else return array(); |
|
| 329 | + } else { |
|
| 330 | + return array(); |
|
| 331 | + } |
|
| 302 | 332 | } |
| 303 | 333 | |
| 304 | 334 | /** |
@@ -312,19 +342,27 @@ discard block |
||
| 312 | 342 | $Common = new Common(); |
| 313 | 343 | $check_date = new Datetime($date); |
| 314 | 344 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 315 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 316 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
| 345 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 346 | + return array(); |
|
| 347 | + } |
|
| 348 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
| 349 | + return array(); |
|
| 350 | + } |
|
| 317 | 351 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
| 318 | 352 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
| 319 | 353 | $data = $Common->getData($url,'post',$post); |
| 320 | 354 | $parsed_data = json_decode($data); |
| 321 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
| 355 | + if (!isset($parsed_data->{'access_token'})) { |
|
| 356 | + return array(); |
|
| 357 | + } |
|
| 322 | 358 | $token = $parsed_data->{'access_token'}; |
| 323 | 359 | |
| 324 | 360 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
| 325 | 361 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
| 326 | 362 | $json = $Common->getData($url,'get','',$headers); |
| 327 | - if ($json == '') return array(); |
|
| 363 | + if ($json == '') { |
|
| 364 | + return array(); |
|
| 365 | + } |
|
| 328 | 366 | $parsed_json = json_decode($json); |
| 329 | 367 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
| 330 | 368 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -332,7 +370,9 @@ discard block |
||
| 332 | 370 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
| 333 | 371 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
| 334 | 372 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
| 335 | - } else return array(); |
|
| 373 | + } else { |
|
| 374 | + return array(); |
|
| 375 | + } |
|
| 336 | 376 | } |
| 337 | 377 | |
| 338 | 378 | /** |
@@ -346,14 +386,20 @@ discard block |
||
| 346 | 386 | $Common = new Common(); |
| 347 | 387 | $check_date = new Datetime($date); |
| 348 | 388 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 349 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 350 | - if ($globalTransaviaKey == '') return array(); |
|
| 389 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 390 | + return array(); |
|
| 391 | + } |
|
| 392 | + if ($globalTransaviaKey == '') { |
|
| 393 | + return array(); |
|
| 394 | + } |
|
| 351 | 395 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 352 | 396 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 353 | 397 | $headers = array('apikey: '.$globalTransaviaKey); |
| 354 | 398 | $json = $Common->getData($url,'get','',$headers); |
| 355 | 399 | //echo 'result : '.$json; |
| 356 | - if ($json == '') return array(); |
|
| 400 | + if ($json == '') { |
|
| 401 | + return array(); |
|
| 402 | + } |
|
| 357 | 403 | $parsed_json = json_decode($json); |
| 358 | 404 | |
| 359 | 405 | if (isset($parsed_json->{'data'}[0])) { |
@@ -362,7 +408,9 @@ discard block |
||
| 362 | 408 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
| 363 | 409 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
| 364 | 410 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
| 365 | - } else return array(); |
|
| 411 | + } else { |
|
| 412 | + return array(); |
|
| 413 | + } |
|
| 366 | 414 | } |
| 367 | 415 | |
| 368 | 416 | /** |
@@ -373,7 +421,9 @@ discard block |
||
| 373 | 421 | public function getTunisair($callsign) { |
| 374 | 422 | $Common = new Common(); |
| 375 | 423 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 376 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 424 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 425 | + return array(); |
|
| 426 | + } |
|
| 377 | 427 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
| 378 | 428 | $data = $Common->getData($url); |
| 379 | 429 | $table = $Common->table2array($data); |
@@ -394,7 +444,9 @@ discard block |
||
| 394 | 444 | $Common = new Common(); |
| 395 | 445 | $check_date = new Datetime($date); |
| 396 | 446 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 397 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 447 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 448 | + return array(); |
|
| 449 | + } |
|
| 398 | 450 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
| 399 | 451 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
| 400 | 452 | $data = $Common->getData($url); |
@@ -404,8 +456,11 @@ discard block |
||
| 404 | 456 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
| 405 | 457 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
| 406 | 458 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
| 407 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 408 | - else return array(); |
|
| 459 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
| 460 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 461 | + } else { |
|
| 462 | + return array(); |
|
| 463 | + } |
|
| 409 | 464 | } |
| 410 | 465 | return array(); |
| 411 | 466 | } |
@@ -420,7 +475,9 @@ discard block |
||
| 420 | 475 | $Common = new Common(); |
| 421 | 476 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 422 | 477 | $check_date = new Datetime($date); |
| 423 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 478 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 479 | + return array(); |
|
| 480 | + } |
|
| 424 | 481 | $url = "https://www.iberia.com/web/flightDetail.do"; |
| 425 | 482 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
| 426 | 483 | $data = $Common->getData($url,'post',$post); |
@@ -437,7 +494,9 @@ discard block |
||
| 437 | 494 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
| 438 | 495 | if ($arrivalTime == 'Hora estimada de llegada') { |
| 439 | 496 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
| 440 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
| 497 | + } else { |
|
| 498 | + $arrivalTime = substr($arrivalTime,0,5); |
|
| 499 | + } |
|
| 441 | 500 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
| 442 | 501 | } |
| 443 | 502 | } |
@@ -455,7 +514,9 @@ discard block |
||
| 455 | 514 | $Common = new Common(); |
| 456 | 515 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 457 | 516 | $check_date = new Datetime($date); |
| 458 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 517 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 518 | + return array(); |
|
| 519 | + } |
|
| 459 | 520 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
| 460 | 521 | $data = $Common->getData($url); |
| 461 | 522 | if ($data != '') { |
@@ -471,7 +532,9 @@ discard block |
||
| 471 | 532 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
| 472 | 533 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
| 473 | 534 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
| 474 | - } else return array(); |
|
| 535 | + } else { |
|
| 536 | + return array(); |
|
| 537 | + } |
|
| 475 | 538 | } |
| 476 | 539 | |
| 477 | 540 | |
@@ -491,7 +554,9 @@ discard block |
||
| 491 | 554 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 492 | 555 | $check_date = new Datetime($date); |
| 493 | 556 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
| 494 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 557 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 558 | + return array(); |
|
| 559 | + } |
|
| 495 | 560 | $data = $Common->getData($url); |
| 496 | 561 | if ($data != '') { |
| 497 | 562 | $table = $Common->text2array($data); |
@@ -515,7 +580,9 @@ discard block |
||
| 515 | 580 | $check_date = new Datetime($date); |
| 516 | 581 | $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
| 517 | 582 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
| 518 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 583 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 584 | + return array(); |
|
| 585 | + } |
|
| 519 | 586 | $data = $Common->getData($url); |
| 520 | 587 | if ($data != '') { |
| 521 | 588 | //echo $data; |
@@ -605,7 +672,9 @@ discard block |
||
| 605 | 672 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 606 | 673 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
| 607 | 674 | //$check_date = new Datetime($date); |
| 608 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 675 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 676 | + return array(); |
|
| 677 | + } |
|
| 609 | 678 | $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
| 610 | 679 | $data = $Common->getData($url,'post',$post); |
| 611 | 680 | if ($data != '') { |
@@ -637,11 +706,15 @@ discard block |
||
| 637 | 706 | $airline_icao = substr($callsign, 0, 3); |
| 638 | 707 | } |
| 639 | 708 | } |
| 640 | - if ($airline_icao == '') return array(); |
|
| 709 | + if ($airline_icao == '') { |
|
| 710 | + return array(); |
|
| 711 | + } |
|
| 641 | 712 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 642 | 713 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
| 643 | 714 | //$check_date = new Datetime($date); |
| 644 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 715 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 716 | + return array(); |
|
| 717 | + } |
|
| 645 | 718 | $data = $Common->getData($url); |
| 646 | 719 | if ($data != '') { |
| 647 | 720 | $table = $Common->table2array($data); |
@@ -684,7 +757,9 @@ discard block |
||
| 684 | 757 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 685 | 758 | $url= "http://fr.flightaware.com/live/flight/".$callsign; |
| 686 | 759 | //$check_date = new Datetime($date); |
| 687 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 760 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 761 | + return array(); |
|
| 762 | + } |
|
| 688 | 763 | $data = $Common->getData($url); |
| 689 | 764 | if ($data != '') { |
| 690 | 765 | $table = $Common->table2array($data); |
@@ -737,11 +812,15 @@ discard block |
||
| 737 | 812 | $check_date = new Datetime($date); |
| 738 | 813 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 739 | 814 | $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
| 740 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 815 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 816 | + return array(); |
|
| 817 | + } |
|
| 741 | 818 | $data = $Common->getData($url); |
| 742 | 819 | $dom = new DomDocument(); |
| 743 | 820 | $dom->loadXML($data); |
| 744 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
| 821 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
| 822 | + return array(); |
|
| 823 | + } |
|
| 745 | 824 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
| 746 | 825 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
| 747 | 826 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -750,7 +829,9 @@ discard block |
||
| 750 | 829 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 751 | 830 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
| 752 | 831 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
| 753 | - } else return array(); |
|
| 832 | + } else { |
|
| 833 | + return array(); |
|
| 834 | + } |
|
| 754 | 835 | } |
| 755 | 836 | |
| 756 | 837 | /** |
@@ -764,7 +845,9 @@ discard block |
||
| 764 | 845 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 765 | 846 | $check_date = new Datetime($date); |
| 766 | 847 | $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
| 767 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 848 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 849 | + return array(); |
|
| 850 | + } |
|
| 768 | 851 | $data = $Common->getData($url); |
| 769 | 852 | if ($data != '') { |
| 770 | 853 | $table = $Common->table2array($data); |
@@ -793,7 +876,9 @@ discard block |
||
| 793 | 876 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 794 | 877 | $check_date = new Datetime($date); |
| 795 | 878 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
| 796 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 879 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 880 | + return array(); |
|
| 881 | + } |
|
| 797 | 882 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
| 798 | 883 | $data = $Common->getData($url,'post',$post); |
| 799 | 884 | //echo $data; |
@@ -803,11 +888,19 @@ discard block |
||
| 803 | 888 | if ($data != '') { |
| 804 | 889 | $table = $Common->table2array($data); |
| 805 | 890 | $flight = $table; |
| 806 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
| 807 | - else $departureTime = ''; |
|
| 808 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
| 809 | - else $departureAirport = ''; |
|
| 810 | - } else return array(); |
|
| 891 | + if (isset($flight[5][4])) { |
|
| 892 | + $departureTime = $flight[5][4]; |
|
| 893 | + } else { |
|
| 894 | + $departureTime = ''; |
|
| 895 | + } |
|
| 896 | + if (isset($flight[5][2])) { |
|
| 897 | + $departureAirport = $flight[5][2]; |
|
| 898 | + } else { |
|
| 899 | + $departureAirport = ''; |
|
| 900 | + } |
|
| 901 | + } else { |
|
| 902 | + return array(); |
|
| 903 | + } |
|
| 811 | 904 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
| 812 | 905 | $data = $Common->getData($url,'post',$post); |
| 813 | 906 | if ($data != '') { |
@@ -820,10 +913,14 @@ discard block |
||
| 820 | 913 | $arrivalTime = ''; |
| 821 | 914 | $arrivalAirport = ''; |
| 822 | 915 | } |
| 823 | - } else return array(); |
|
| 916 | + } else { |
|
| 917 | + return array(); |
|
| 918 | + } |
|
| 824 | 919 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
| 825 | 920 | $json = $Common->getData($url); |
| 826 | - if ($json == '') return array(); |
|
| 921 | + if ($json == '') { |
|
| 922 | + return array(); |
|
| 923 | + } |
|
| 827 | 924 | $parsed_json = json_decode($json); |
| 828 | 925 | $airports = $parsed_json->{'suggestList'}; |
| 829 | 926 | if (count($airports) > 0) { |
@@ -838,7 +935,9 @@ discard block |
||
| 838 | 935 | } |
| 839 | 936 | if (isset($DepartureAirportIata)) { |
| 840 | 937 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
| 841 | - } else return array(); |
|
| 938 | + } else { |
|
| 939 | + return array(); |
|
| 940 | + } |
|
| 842 | 941 | } |
| 843 | 942 | |
| 844 | 943 | |
@@ -846,7 +945,9 @@ discard block |
||
| 846 | 945 | public function fetchSchedule($ident,$date = 'NOW') { |
| 847 | 946 | global $globalSchedulesSources, $globalSchedulesFetch; |
| 848 | 947 | //$Common = new Common(); |
| 849 | - if (!$globalSchedulesFetch) return array(); |
|
| 948 | + if (!$globalSchedulesFetch) { |
|
| 949 | + return array(); |
|
| 950 | + } |
|
| 850 | 951 | $airline_icao = ''; |
| 851 | 952 | if (!is_numeric(substr($ident, 0, 3))) |
| 852 | 953 | { |
@@ -1074,14 +1175,21 @@ discard block |
||
| 1074 | 1175 | default: |
| 1075 | 1176 | // Randomly use a generic function to get hours |
| 1076 | 1177 | if (strlen($airline_icao) == 2) { |
| 1077 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1178 | + if (!isset($globalSchedulesSources)) { |
|
| 1179 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1180 | + } |
|
| 1078 | 1181 | if (count($globalSchedulesSources) > 0) { |
| 1079 | 1182 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
| 1080 | 1183 | $source = $globalSchedulesSources[$rand]; |
| 1081 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
| 1082 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
| 1184 | + if ($source == 'flightmapper') { |
|
| 1185 | + return $this->getFlightMapper($ident); |
|
| 1186 | + } elseif ($source == 'costtotravel') { |
|
| 1187 | + return $this->getCostToTravel($ident); |
|
| 1188 | + } |
|
| 1083 | 1189 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
| 1084 | - elseif ($source == 'flightaware') return $this->getFlightAware($ident); |
|
| 1190 | + elseif ($source == 'flightaware') { |
|
| 1191 | + return $this->getFlightAware($ident); |
|
| 1192 | + } |
|
| 1085 | 1193 | } |
| 1086 | 1194 | } |
| 1087 | 1195 | } |
@@ -10,6 +10,9 @@ discard block |
||
| 10 | 10 | class update_db { |
| 11 | 11 | public static $db_sqlite; |
| 12 | 12 | |
| 13 | + /** |
|
| 14 | + * @param string $file |
|
| 15 | + */ |
|
| 13 | 16 | public static function download($url, $file, $referer = '') { |
| 14 | 17 | $fp = fopen($file, 'w+'); |
| 15 | 18 | $ch = curl_init(); |
@@ -24,6 +27,9 @@ discard block |
||
| 24 | 27 | fclose($fp); |
| 25 | 28 | } |
| 26 | 29 | |
| 30 | + /** |
|
| 31 | + * @param string $in_file |
|
| 32 | + */ |
|
| 27 | 33 | public static function gunzip($in_file,$out_file_name = '') { |
| 28 | 34 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 29 | 35 | $buffer_size = 4096; // read 4kb at a time |
@@ -45,6 +51,9 @@ discard block |
||
| 45 | 51 | } |
| 46 | 52 | } |
| 47 | 53 | |
| 54 | + /** |
|
| 55 | + * @param string $in_file |
|
| 56 | + */ |
|
| 48 | 57 | public static function unzip($in_file) { |
| 49 | 58 | if ($in_file != '' && file_exists($in_file)) { |
| 50 | 59 | $path = pathinfo(realpath($in_file), PATHINFO_DIRNAME); |
@@ -66,6 +75,9 @@ discard block |
||
| 66 | 75 | } |
| 67 | 76 | } |
| 68 | 77 | |
| 78 | + /** |
|
| 79 | + * @param string $database_file |
|
| 80 | + */ |
|
| 69 | 81 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 70 | 82 | global $globalDebug, $globalTransaction; |
| 71 | 83 | //$query = 'TRUNCATE TABLE routes'; |
@@ -108,6 +120,10 @@ discard block |
||
| 108 | 120 | } |
| 109 | 121 | return ''; |
| 110 | 122 | } |
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @param string $database_file |
|
| 126 | + */ |
|
| 111 | 127 | public static function retrieve_route_oneworld($database_file) { |
| 112 | 128 | global $globalDebug, $globalTransaction; |
| 113 | 129 | //$query = 'TRUNCATE TABLE routes'; |
@@ -147,6 +163,9 @@ discard block |
||
| 147 | 163 | return ''; |
| 148 | 164 | } |
| 149 | 165 | |
| 166 | + /** |
|
| 167 | + * @param string $database_file |
|
| 168 | + */ |
|
| 150 | 169 | public static function retrieve_route_skyteam($database_file) { |
| 151 | 170 | global $globalDebug, $globalTransaction; |
| 152 | 171 | //$query = 'TRUNCATE TABLE routes'; |
@@ -186,6 +205,10 @@ discard block |
||
| 186 | 205 | } |
| 187 | 206 | return ''; |
| 188 | 207 | } |
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * @param string $database_file |
|
| 211 | + */ |
|
| 189 | 212 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 190 | 213 | global $globalTransaction; |
| 191 | 214 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -251,6 +274,9 @@ discard block |
||
| 251 | 274 | return ''; |
| 252 | 275 | } |
| 253 | 276 | |
| 277 | + /** |
|
| 278 | + * @param string $database_file |
|
| 279 | + */ |
|
| 254 | 280 | public static function retrieve_modes_flarmnet($database_file) { |
| 255 | 281 | global $globalTransaction; |
| 256 | 282 | $Common = new Common(); |
@@ -321,6 +347,9 @@ discard block |
||
| 321 | 347 | return ''; |
| 322 | 348 | } |
| 323 | 349 | |
| 350 | + /** |
|
| 351 | + * @param string $database_file |
|
| 352 | + */ |
|
| 324 | 353 | public static function retrieve_modes_ogn($database_file) { |
| 325 | 354 | global $globalTransaction; |
| 326 | 355 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -389,6 +418,9 @@ discard block |
||
| 389 | 418 | return ''; |
| 390 | 419 | } |
| 391 | 420 | |
| 421 | + /** |
|
| 422 | + * @param string $database_file |
|
| 423 | + */ |
|
| 392 | 424 | public static function retrieve_owner($database_file,$country = 'F') { |
| 393 | 425 | global $globalTransaction; |
| 394 | 426 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -939,6 +971,10 @@ discard block |
||
| 939 | 971 | return ''; |
| 940 | 972 | } |
| 941 | 973 | |
| 974 | + /** |
|
| 975 | + * @param string $filename |
|
| 976 | + * @param string $tletype |
|
| 977 | + */ |
|
| 942 | 978 | public static function tle($filename,$tletype) { |
| 943 | 979 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 944 | 980 | global $tmp_dir, $globalTransaction; |
@@ -1071,6 +1107,9 @@ discard block |
||
| 1071 | 1107 | |
| 1072 | 1108 | } |
| 1073 | 1109 | */ |
| 1110 | + /** |
|
| 1111 | + * @param string $filename |
|
| 1112 | + */ |
|
| 1074 | 1113 | public static function waypoints($filename) { |
| 1075 | 1114 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1076 | 1115 | global $tmp_dir, $globalTransaction; |
@@ -1118,6 +1157,9 @@ discard block |
||
| 1118 | 1157 | return ''; |
| 1119 | 1158 | } |
| 1120 | 1159 | |
| 1160 | + /** |
|
| 1161 | + * @param string $filename |
|
| 1162 | + */ |
|
| 1121 | 1163 | public static function ivao_airlines($filename) { |
| 1122 | 1164 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1123 | 1165 | global $tmp_dir, $globalTransaction; |
@@ -75,38 +75,38 @@ discard block |
||
| 75 | 75 | try { |
| 76 | 76 | //$Connection = new Connection(); |
| 77 | 77 | $sth = $Connection->db->prepare($query); |
| 78 | - $sth->execute(array(':source' => $database_file)); |
|
| 79 | - } catch(PDOException $e) { |
|
| 80 | - return "error : ".$e->getMessage(); |
|
| 81 | - } |
|
| 78 | + $sth->execute(array(':source' => $database_file)); |
|
| 79 | + } catch(PDOException $e) { |
|
| 80 | + return "error : ".$e->getMessage(); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 84 | - update_db::connect_sqlite($database_file); |
|
| 83 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 84 | + update_db::connect_sqlite($database_file); |
|
| 85 | 85 | //$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 | 86 | $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"; |
| 87 | 87 | try { |
| 88 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 89 | - $sth->execute(); |
|
| 90 | - } catch(PDOException $e) { |
|
| 91 | - return "error : ".$e->getMessage(); |
|
| 92 | - } |
|
| 88 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 89 | + $sth->execute(); |
|
| 90 | + } catch(PDOException $e) { |
|
| 91 | + return "error : ".$e->getMessage(); |
|
| 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)'; |
| 94 | 94 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 95 | 95 | $Connection = new Connection(); |
| 96 | 96 | $sth_dest = $Connection->db->prepare($query_dest); |
| 97 | 97 | try { |
| 98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 99 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 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 | 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 | 105 | } catch(PDOException $e) { |
| 106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
| 107 | 107 | return "error : ".$e->getMessage(); |
| 108 | 108 | } |
| 109 | - return ''; |
|
| 109 | + return ''; |
|
| 110 | 110 | } |
| 111 | 111 | public static function retrieve_route_oneworld($database_file) { |
| 112 | 112 | global $globalDebug, $globalTransaction; |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | try { |
| 118 | 118 | //$Connection = new Connection(); |
| 119 | 119 | $sth = $Connection->db->prepare($query); |
| 120 | - $sth->execute(array(':source' => 'oneworld')); |
|
| 121 | - } catch(PDOException $e) { |
|
| 122 | - return "error : ".$e->getMessage(); |
|
| 123 | - } |
|
| 120 | + $sth->execute(array(':source' => 'oneworld')); |
|
| 121 | + } catch(PDOException $e) { |
|
| 122 | + return "error : ".$e->getMessage(); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 125 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 127 | 127 | $Spotter = new Spotter(); |
| 128 | 128 | if ($fh = fopen($database_file,"r")) { |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | if ($globalTransaction) $Connection->db->commit(); |
| 148 | 148 | } |
| 149 | - return ''; |
|
| 149 | + return ''; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public static function retrieve_route_skyteam($database_file) { |
@@ -158,12 +158,12 @@ discard block |
||
| 158 | 158 | try { |
| 159 | 159 | //$Connection = new Connection(); |
| 160 | 160 | $sth = $Connection->db->prepare($query); |
| 161 | - $sth->execute(array(':source' => 'skyteam')); |
|
| 162 | - } catch(PDOException $e) { |
|
| 163 | - return "error : ".$e->getMessage(); |
|
| 164 | - } |
|
| 161 | + $sth->execute(array(':source' => 'skyteam')); |
|
| 162 | + } catch(PDOException $e) { |
|
| 163 | + return "error : ".$e->getMessage(); |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 166 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 167 | 167 | |
| 168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 169 | 169 | $Spotter = new Spotter(); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | return "error : ".$e->getMessage(); |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - return ''; |
|
| 192 | + return ''; |
|
| 193 | 193 | } |
| 194 | 194 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 195 | 195 | global $globalTransaction; |
@@ -198,27 +198,27 @@ discard block |
||
| 198 | 198 | try { |
| 199 | 199 | $Connection = new Connection(); |
| 200 | 200 | $sth = $Connection->db->prepare($query); |
| 201 | - $sth->execute(array(':source' => $database_file)); |
|
| 202 | - } catch(PDOException $e) { |
|
| 203 | - return "error : ".$e->getMessage(); |
|
| 204 | - } |
|
| 201 | + $sth->execute(array(':source' => $database_file)); |
|
| 202 | + } catch(PDOException $e) { |
|
| 203 | + return "error : ".$e->getMessage(); |
|
| 204 | + } |
|
| 205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
| 206 | 206 | try { |
| 207 | 207 | $Connection = new Connection(); |
| 208 | 208 | $sth = $Connection->db->prepare($query); |
| 209 | - $sth->execute(array(':source' => $database_file)); |
|
| 210 | - } catch(PDOException $e) { |
|
| 211 | - return "error : ".$e->getMessage(); |
|
| 212 | - } |
|
| 209 | + $sth->execute(array(':source' => $database_file)); |
|
| 210 | + } catch(PDOException $e) { |
|
| 211 | + return "error : ".$e->getMessage(); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - update_db::connect_sqlite($database_file); |
|
| 214 | + update_db::connect_sqlite($database_file); |
|
| 215 | 215 | $query = 'select * from Aircraft'; |
| 216 | 216 | try { |
| 217 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 218 | - $sth->execute(); |
|
| 219 | - } catch(PDOException $e) { |
|
| 220 | - return "error : ".$e->getMessage(); |
|
| 221 | - } |
|
| 217 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 218 | + $sth->execute(); |
|
| 219 | + } catch(PDOException $e) { |
|
| 220 | + return "error : ".$e->getMessage(); |
|
| 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)'; |
| 223 | 223 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
| 224 | 224 | |
@@ -229,17 +229,17 @@ discard block |
||
| 229 | 229 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 230 | 230 | try { |
| 231 | 231 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 232 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 232 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 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 | 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']); |
|
| 240 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
| 239 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 240 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
| 241 | 241 | } |
| 242 | - } |
|
| 242 | + } |
|
| 243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
| 244 | 244 | } catch(PDOException $e) { |
| 245 | 245 | return "error : ".$e->getMessage(); |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | try { |
| 250 | 250 | $Connection = new Connection(); |
| 251 | 251 | $sth = $Connection->db->prepare($query); |
| 252 | - $sth->execute(array(':source' => $database_file)); |
|
| 253 | - } catch(PDOException $e) { |
|
| 254 | - return "error : ".$e->getMessage(); |
|
| 255 | - } |
|
| 252 | + $sth->execute(array(':source' => $database_file)); |
|
| 253 | + } catch(PDOException $e) { |
|
| 254 | + return "error : ".$e->getMessage(); |
|
| 255 | + } |
|
| 256 | 256 | return ''; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -264,10 +264,10 @@ discard block |
||
| 264 | 264 | try { |
| 265 | 265 | $Connection = new Connection(); |
| 266 | 266 | $sth = $Connection->db->prepare($query); |
| 267 | - $sth->execute(array(':source' => $database_file)); |
|
| 268 | - } catch(PDOException $e) { |
|
| 269 | - return "error : ".$e->getMessage(); |
|
| 270 | - } |
|
| 267 | + $sth->execute(array(':source' => $database_file)); |
|
| 268 | + } catch(PDOException $e) { |
|
| 269 | + return "error : ".$e->getMessage(); |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | 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)'; |
@@ -277,26 +277,26 @@ discard block |
||
| 277 | 277 | $sth_dest = $Connection->db->prepare($query_dest); |
| 278 | 278 | try { |
| 279 | 279 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 280 | - while (!feof($fh)) { |
|
| 281 | - $values = array(); |
|
| 282 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 280 | + while (!feof($fh)) { |
|
| 281 | + $values = array(); |
|
| 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)); |
|
| 287 | - // Check if we can find ICAO, else set it to GLID |
|
| 288 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 289 | - $search_more = ''; |
|
| 290 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 291 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 292 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 284 | + $values['ModeS'] = substr($line,0,6); |
|
| 285 | + $values['Registration'] = trim(substr($line,69,6)); |
|
| 286 | + $aircraft_name = trim(substr($line,48,6)); |
|
| 287 | + // Check if we can find ICAO, else set it to GLID |
|
| 288 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 289 | + $search_more = ''; |
|
| 290 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 291 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 292 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 293 | 293 | try { |
| 294 | - $sth_search->execute(); |
|
| 295 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 296 | - //if (count($result) > 0) { |
|
| 297 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
| 298 | - $values['ICAOTypeCode'] = $result['icao']; |
|
| 299 | - } |
|
| 294 | + $sth_search->execute(); |
|
| 295 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 296 | + //if (count($result) > 0) { |
|
| 297 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 298 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 299 | + } |
|
| 300 | 300 | } catch(PDOException $e) { |
| 301 | 301 | return "error : ".$e->getMessage(); |
| 302 | 302 | } |
@@ -319,10 +319,10 @@ discard block |
||
| 319 | 319 | try { |
| 320 | 320 | $Connection = new Connection(); |
| 321 | 321 | $sth = $Connection->db->prepare($query); |
| 322 | - $sth->execute(array(':source' => $database_file)); |
|
| 323 | - } catch(PDOException $e) { |
|
| 324 | - return "error : ".$e->getMessage(); |
|
| 325 | - } |
|
| 322 | + $sth->execute(array(':source' => $database_file)); |
|
| 323 | + } catch(PDOException $e) { |
|
| 324 | + return "error : ".$e->getMessage(); |
|
| 325 | + } |
|
| 326 | 326 | return ''; |
| 327 | 327 | } |
| 328 | 328 | |
@@ -333,10 +333,10 @@ discard block |
||
| 333 | 333 | try { |
| 334 | 334 | $Connection = new Connection(); |
| 335 | 335 | $sth = $Connection->db->prepare($query); |
| 336 | - $sth->execute(array(':source' => $database_file)); |
|
| 337 | - } catch(PDOException $e) { |
|
| 338 | - return "error : ".$e->getMessage(); |
|
| 339 | - } |
|
| 336 | + $sth->execute(array(':source' => $database_file)); |
|
| 337 | + } catch(PDOException $e) { |
|
| 338 | + return "error : ".$e->getMessage(); |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | 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)'; |
@@ -347,24 +347,24 @@ discard block |
||
| 347 | 347 | try { |
| 348 | 348 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 349 | 349 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 350 | - while (!feof($fh)) { |
|
| 351 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 350 | + while (!feof($fh)) { |
|
| 351 | + $line = fgetcsv($fh,9999,',',"'"); |
|
| 352 | 352 | |
| 353 | 353 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 354 | 354 | //print_r($line); |
| 355 | - $values['ModeS'] = $line[1]; |
|
| 356 | - $values['Registration'] = $line[3]; |
|
| 357 | - $aircraft_name = $line[2]; |
|
| 358 | - // Check if we can find ICAO, else set it to GLID |
|
| 359 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 360 | - $search_more = ''; |
|
| 361 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 362 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 363 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 355 | + $values['ModeS'] = $line[1]; |
|
| 356 | + $values['Registration'] = $line[3]; |
|
| 357 | + $aircraft_name = $line[2]; |
|
| 358 | + // Check if we can find ICAO, else set it to GLID |
|
| 359 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 360 | + $search_more = ''; |
|
| 361 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 362 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 363 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 364 | 364 | try { |
| 365 | - $sth_search->execute(); |
|
| 366 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 367 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 365 | + $sth_search->execute(); |
|
| 366 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 367 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 368 | 368 | } catch(PDOException $e) { |
| 369 | 369 | return "error : ".$e->getMessage(); |
| 370 | 370 | } |
@@ -387,10 +387,10 @@ discard block |
||
| 387 | 387 | try { |
| 388 | 388 | $Connection = new Connection(); |
| 389 | 389 | $sth = $Connection->db->prepare($query); |
| 390 | - $sth->execute(array(':source' => $database_file)); |
|
| 391 | - } catch(PDOException $e) { |
|
| 392 | - return "error : ".$e->getMessage(); |
|
| 393 | - } |
|
| 390 | + $sth->execute(array(':source' => $database_file)); |
|
| 391 | + } catch(PDOException $e) { |
|
| 392 | + return "error : ".$e->getMessage(); |
|
| 393 | + } |
|
| 394 | 394 | return ''; |
| 395 | 395 | } |
| 396 | 396 | |
@@ -401,10 +401,10 @@ discard block |
||
| 401 | 401 | try { |
| 402 | 402 | $Connection = new Connection(); |
| 403 | 403 | $sth = $Connection->db->prepare($query); |
| 404 | - $sth->execute(array(':source' => $database_file)); |
|
| 405 | - } catch(PDOException $e) { |
|
| 406 | - return "error : ".$e->getMessage(); |
|
| 407 | - } |
|
| 404 | + $sth->execute(array(':source' => $database_file)); |
|
| 405 | + } catch(PDOException $e) { |
|
| 406 | + return "error : ".$e->getMessage(); |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | 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)'; |
@@ -415,95 +415,95 @@ discard block |
||
| 415 | 415 | try { |
| 416 | 416 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 417 | 417 | $tmp = fgetcsv($fh,9999,',','"'); |
| 418 | - while (!feof($fh)) { |
|
| 419 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 420 | - $values = array(); |
|
| 421 | - //print_r($line); |
|
| 422 | - if ($country == 'F') { |
|
| 423 | - $values['registration'] = $line[0]; |
|
| 424 | - $values['base'] = $line[4]; |
|
| 425 | - $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])); |
|
| 428 | - $values['cancel'] = $line[7]; |
|
| 418 | + while (!feof($fh)) { |
|
| 419 | + $line = fgetcsv($fh,9999,',','"'); |
|
| 420 | + $values = array(); |
|
| 421 | + //print_r($line); |
|
| 422 | + if ($country == 'F') { |
|
| 423 | + $values['registration'] = $line[0]; |
|
| 424 | + $values['base'] = $line[4]; |
|
| 425 | + $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])); |
|
| 428 | + $values['cancel'] = $line[7]; |
|
| 429 | 429 | } elseif ($country == 'EI') { |
| 430 | - // TODO : add modeS & reg to aircraft_modes |
|
| 431 | - $values['registration'] = $line[0]; |
|
| 432 | - $values['base'] = $line[3]; |
|
| 433 | - $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])); |
|
| 436 | - $values['cancel'] = ''; |
|
| 430 | + // TODO : add modeS & reg to aircraft_modes |
|
| 431 | + $values['registration'] = $line[0]; |
|
| 432 | + $values['base'] = $line[3]; |
|
| 433 | + $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])); |
|
| 436 | + $values['cancel'] = ''; |
|
| 437 | 437 | } elseif ($country == 'HB') { |
| 438 | - // TODO : add modeS & reg to aircraft_modes |
|
| 439 | - $values['registration'] = $line[0]; |
|
| 440 | - $values['base'] = null; |
|
| 441 | - $values['owner'] = $line[5]; |
|
| 442 | - $values['date_first_reg'] = null; |
|
| 443 | - $values['cancel'] = ''; |
|
| 438 | + // TODO : add modeS & reg to aircraft_modes |
|
| 439 | + $values['registration'] = $line[0]; |
|
| 440 | + $values['base'] = null; |
|
| 441 | + $values['owner'] = $line[5]; |
|
| 442 | + $values['date_first_reg'] = null; |
|
| 443 | + $values['cancel'] = ''; |
|
| 444 | 444 | } elseif ($country == 'OK') { |
| 445 | - // TODO : add modeS & reg to aircraft_modes |
|
| 446 | - $values['registration'] = $line[3]; |
|
| 447 | - $values['base'] = null; |
|
| 448 | - $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])); |
|
| 451 | - $values['cancel'] = ''; |
|
| 445 | + // TODO : add modeS & reg to aircraft_modes |
|
| 446 | + $values['registration'] = $line[3]; |
|
| 447 | + $values['base'] = null; |
|
| 448 | + $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])); |
|
| 451 | + $values['cancel'] = ''; |
|
| 452 | 452 | } elseif ($country == 'VH') { |
| 453 | - // TODO : add modeS & reg to aircraft_modes |
|
| 454 | - $values['registration'] = $line[0]; |
|
| 455 | - $values['base'] = null; |
|
| 456 | - $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])); |
|
| 459 | - |
|
| 460 | - $values['cancel'] = $line[39]; |
|
| 453 | + // TODO : add modeS & reg to aircraft_modes |
|
| 454 | + $values['registration'] = $line[0]; |
|
| 455 | + $values['base'] = null; |
|
| 456 | + $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])); |
|
| 459 | + |
|
| 460 | + $values['cancel'] = $line[39]; |
|
| 461 | 461 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
| 462 | - $values['registration'] = $line[0]; |
|
| 463 | - $values['base'] = null; |
|
| 464 | - $values['owner'] = $line[4]; |
|
| 465 | - $values['date_first_reg'] = null; |
|
| 466 | - $values['cancel'] = ''; |
|
| 462 | + $values['registration'] = $line[0]; |
|
| 463 | + $values['base'] = null; |
|
| 464 | + $values['owner'] = $line[4]; |
|
| 465 | + $values['date_first_reg'] = null; |
|
| 466 | + $values['cancel'] = ''; |
|
| 467 | 467 | } elseif ($country == 'CC') { |
| 468 | - $values['registration'] = $line[0]; |
|
| 469 | - $values['base'] = null; |
|
| 470 | - $values['owner'] = $line[6]; |
|
| 471 | - $values['date_first_reg'] = null; |
|
| 472 | - $values['cancel'] = ''; |
|
| 468 | + $values['registration'] = $line[0]; |
|
| 469 | + $values['base'] = null; |
|
| 470 | + $values['owner'] = $line[6]; |
|
| 471 | + $values['date_first_reg'] = null; |
|
| 472 | + $values['cancel'] = ''; |
|
| 473 | 473 | } elseif ($country == 'HJ') { |
| 474 | - $values['registration'] = $line[0]; |
|
| 475 | - $values['base'] = null; |
|
| 476 | - $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])); |
|
| 479 | - $values['cancel'] = ''; |
|
| 474 | + $values['registration'] = $line[0]; |
|
| 475 | + $values['base'] = null; |
|
| 476 | + $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])); |
|
| 479 | + $values['cancel'] = ''; |
|
| 480 | 480 | } elseif ($country == 'PP') { |
| 481 | - $values['registration'] = $line[0]; |
|
| 482 | - $values['base'] = null; |
|
| 483 | - $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])); |
|
| 486 | - $values['cancel'] = $line[7]; |
|
| 481 | + $values['registration'] = $line[0]; |
|
| 482 | + $values['base'] = null; |
|
| 483 | + $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])); |
|
| 486 | + $values['cancel'] = $line[7]; |
|
| 487 | 487 | } elseif ($country == 'E7') { |
| 488 | - $values['registration'] = $line[0]; |
|
| 489 | - $values['base'] = null; |
|
| 490 | - $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])); |
|
| 493 | - $values['cancel'] = ''; |
|
| 488 | + $values['registration'] = $line[0]; |
|
| 489 | + $values['base'] = null; |
|
| 490 | + $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])); |
|
| 493 | + $values['cancel'] = ''; |
|
| 494 | 494 | } elseif ($country == '8Q') { |
| 495 | - $values['registration'] = $line[0]; |
|
| 496 | - $values['base'] = null; |
|
| 497 | - $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])); |
|
| 500 | - $values['cancel'] = ''; |
|
| 495 | + $values['registration'] = $line[0]; |
|
| 496 | + $values['base'] = null; |
|
| 497 | + $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])); |
|
| 500 | + $values['cancel'] = ''; |
|
| 501 | 501 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 502 | - $values['registration'] = $line[0]; |
|
| 503 | - $values['base'] = null; |
|
| 504 | - $values['owner'] = $line[3]; |
|
| 505 | - $values['date_first_reg'] = null; |
|
| 506 | - $values['cancel'] = ''; |
|
| 502 | + $values['registration'] = $line[0]; |
|
| 503 | + $values['base'] = null; |
|
| 504 | + $values['owner'] = $line[3]; |
|
| 505 | + $values['date_first_reg'] = null; |
|
| 506 | + $values['cancel'] = ''; |
|
| 507 | 507 | } |
| 508 | 508 | if ($values['cancel'] == '' && $values['registration'] != null) { |
| 509 | 509 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -625,20 +625,20 @@ discard block |
||
| 625 | 625 | try { |
| 626 | 626 | $Connection = new Connection(); |
| 627 | 627 | $sth = $Connection->db->prepare($query); |
| 628 | - $sth->execute(); |
|
| 629 | - } catch(PDOException $e) { |
|
| 630 | - return "error : ".$e->getMessage(); |
|
| 631 | - } |
|
| 628 | + $sth->execute(); |
|
| 629 | + } catch(PDOException $e) { |
|
| 630 | + return "error : ".$e->getMessage(); |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | 633 | |
| 634 | 634 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
| 635 | 635 | try { |
| 636 | 636 | $Connection = new Connection(); |
| 637 | 637 | $sth = $Connection->db->prepare($query); |
| 638 | - $sth->execute(); |
|
| 639 | - } catch(PDOException $e) { |
|
| 640 | - return "error : ".$e->getMessage(); |
|
| 641 | - } |
|
| 638 | + $sth->execute(); |
|
| 639 | + } catch(PDOException $e) { |
|
| 640 | + return "error : ".$e->getMessage(); |
|
| 641 | + } |
|
| 642 | 642 | |
| 643 | 643 | $query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) |
| 644 | 644 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
@@ -704,10 +704,10 @@ discard block |
||
| 704 | 704 | try { |
| 705 | 705 | $Connection = new Connection(); |
| 706 | 706 | $sth = $Connection->db->prepare($query); |
| 707 | - $sth->execute(); |
|
| 708 | - } catch(PDOException $e) { |
|
| 709 | - return "error : ".$e->getMessage(); |
|
| 710 | - } |
|
| 707 | + $sth->execute(); |
|
| 708 | + } catch(PDOException $e) { |
|
| 709 | + return "error : ".$e->getMessage(); |
|
| 710 | + } |
|
| 711 | 711 | |
| 712 | 712 | |
| 713 | 713 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
@@ -717,10 +717,10 @@ discard block |
||
| 717 | 717 | try { |
| 718 | 718 | $Connection = new Connection(); |
| 719 | 719 | $sth = $Connection->db->prepare($query); |
| 720 | - $sth->execute($query_values); |
|
| 721 | - } catch(PDOException $e) { |
|
| 722 | - return "error : ".$e->getMessage(); |
|
| 723 | - } |
|
| 720 | + $sth->execute($query_values); |
|
| 721 | + } catch(PDOException $e) { |
|
| 722 | + return "error : ".$e->getMessage(); |
|
| 723 | + } |
|
| 724 | 724 | $i++; |
| 725 | 725 | /* |
| 726 | 726 | $query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | |
| 835 | 835 | |
| 836 | 836 | |
| 837 | - return "success"; |
|
| 837 | + return "success"; |
|
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | public static function translation() { |
@@ -850,10 +850,10 @@ discard block |
||
| 850 | 850 | try { |
| 851 | 851 | $Connection = new Connection(); |
| 852 | 852 | $sth = $Connection->db->prepare($query); |
| 853 | - $sth->execute(array(':source' => 'translation.csv')); |
|
| 854 | - } catch(PDOException $e) { |
|
| 855 | - return "error : ".$e->getMessage(); |
|
| 856 | - } |
|
| 853 | + $sth->execute(array(':source' => 'translation.csv')); |
|
| 854 | + } catch(PDOException $e) { |
|
| 855 | + return "error : ".$e->getMessage(); |
|
| 856 | + } |
|
| 857 | 857 | |
| 858 | 858 | |
| 859 | 859 | //update_db::unzip($out_file); |
@@ -872,21 +872,21 @@ discard block |
||
| 872 | 872 | $data = $row; |
| 873 | 873 | $operator = $data[2]; |
| 874 | 874 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
| 875 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 876 | - //echo substr($operator, 0, 2)."\n";; |
|
| 877 | - if (count($airline_array) > 0) { |
|
| 875 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 876 | + //echo substr($operator, 0, 2)."\n";; |
|
| 877 | + if (count($airline_array) > 0) { |
|
| 878 | 878 | //print_r($airline_array); |
| 879 | 879 | $operator = $airline_array[0]['icao'].substr($operator,2); |
| 880 | - } |
|
| 881 | - } |
|
| 880 | + } |
|
| 881 | + } |
|
| 882 | 882 | |
| 883 | 883 | $operator_correct = $data[3]; |
| 884 | 884 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 885 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 886 | - if (count($airline_array) > 0) { |
|
| 887 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 888 | - } |
|
| 889 | - } |
|
| 885 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 886 | + if (count($airline_array) > 0) { |
|
| 887 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 888 | + } |
|
| 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); |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | //$Connection->db->commit(); |
| 901 | 901 | } |
| 902 | 902 | return ''; |
| 903 | - } |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | 905 | public static function translation_fam() { |
| 906 | 906 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -910,10 +910,10 @@ discard block |
||
| 910 | 910 | try { |
| 911 | 911 | $Connection = new Connection(); |
| 912 | 912 | $sth = $Connection->db->prepare($query); |
| 913 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 914 | - } catch(PDOException $e) { |
|
| 915 | - return "error : ".$e->getMessage(); |
|
| 916 | - } |
|
| 913 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 914 | + } catch(PDOException $e) { |
|
| 915 | + return "error : ".$e->getMessage(); |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | 918 | |
| 919 | 919 | //update_db::unzip($out_file); |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | //$Connection->db->commit(); |
| 943 | 943 | } |
| 944 | 944 | return ''; |
| 945 | - } |
|
| 945 | + } |
|
| 946 | 946 | |
| 947 | 947 | public static function tle($filename,$tletype) { |
| 948 | 948 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -953,10 +953,10 @@ discard block |
||
| 953 | 953 | try { |
| 954 | 954 | $Connection = new Connection(); |
| 955 | 955 | $sth = $Connection->db->prepare($query); |
| 956 | - $sth->execute(array(':source' => $filename)); |
|
| 957 | - } catch(PDOException $e) { |
|
| 958 | - return "error : ".$e->getMessage(); |
|
| 959 | - } |
|
| 956 | + $sth->execute(array(':source' => $filename)); |
|
| 957 | + } catch(PDOException $e) { |
|
| 958 | + return "error : ".$e->getMessage(); |
|
| 959 | + } |
|
| 960 | 960 | |
| 961 | 961 | $Connection = new Connection(); |
| 962 | 962 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -991,54 +991,54 @@ discard block |
||
| 991 | 991 | //$Connection->db->commit(); |
| 992 | 992 | } |
| 993 | 993 | return ''; |
| 994 | - } |
|
| 994 | + } |
|
| 995 | 995 | |
| 996 | 996 | /** |
| 997 | - * Convert a HTML table to an array |
|
| 998 | - * @param String $data HTML page |
|
| 999 | - * @return Array array of the tables in HTML page |
|
| 1000 | - */ |
|
| 1001 | - private static function table2array($data) { |
|
| 1002 | - $html = str_get_html($data); |
|
| 1003 | - $tabledata=array(); |
|
| 1004 | - foreach($html->find('tr') as $element) |
|
| 1005 | - { |
|
| 1006 | - $td = array(); |
|
| 1007 | - foreach( $element->find('th') as $row) |
|
| 1008 | - { |
|
| 1009 | - $td [] = trim($row->plaintext); |
|
| 1010 | - } |
|
| 1011 | - $td=array_filter($td); |
|
| 1012 | - $tabledata[] = $td; |
|
| 1013 | - |
|
| 1014 | - $td = array(); |
|
| 1015 | - $tdi = array(); |
|
| 1016 | - foreach( $element->find('td') as $row) |
|
| 1017 | - { |
|
| 1018 | - $td [] = trim($row->plaintext); |
|
| 1019 | - $tdi [] = trim($row->innertext); |
|
| 1020 | - } |
|
| 1021 | - $td=array_filter($td); |
|
| 1022 | - $tdi=array_filter($tdi); |
|
| 1023 | - // $tabledata[]=array_merge($td,$tdi); |
|
| 1024 | - $tabledata[]=$td; |
|
| 1025 | - } |
|
| 1026 | - return(array_filter($tabledata)); |
|
| 1027 | - } |
|
| 1028 | - |
|
| 1029 | - /** |
|
| 1030 | - * Get data from form result |
|
| 1031 | - * @param String $url form URL |
|
| 1032 | - * @return String the result |
|
| 1033 | - */ |
|
| 1034 | - private static function getData($url) { |
|
| 1035 | - $ch = curl_init(); |
|
| 1036 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1037 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 1038 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 1039 | - 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'); |
|
| 1040 | - return curl_exec($ch); |
|
| 1041 | - } |
|
| 997 | + * Convert a HTML table to an array |
|
| 998 | + * @param String $data HTML page |
|
| 999 | + * @return Array array of the tables in HTML page |
|
| 1000 | + */ |
|
| 1001 | + private static function table2array($data) { |
|
| 1002 | + $html = str_get_html($data); |
|
| 1003 | + $tabledata=array(); |
|
| 1004 | + foreach($html->find('tr') as $element) |
|
| 1005 | + { |
|
| 1006 | + $td = array(); |
|
| 1007 | + foreach( $element->find('th') as $row) |
|
| 1008 | + { |
|
| 1009 | + $td [] = trim($row->plaintext); |
|
| 1010 | + } |
|
| 1011 | + $td=array_filter($td); |
|
| 1012 | + $tabledata[] = $td; |
|
| 1013 | + |
|
| 1014 | + $td = array(); |
|
| 1015 | + $tdi = array(); |
|
| 1016 | + foreach( $element->find('td') as $row) |
|
| 1017 | + { |
|
| 1018 | + $td [] = trim($row->plaintext); |
|
| 1019 | + $tdi [] = trim($row->innertext); |
|
| 1020 | + } |
|
| 1021 | + $td=array_filter($td); |
|
| 1022 | + $tdi=array_filter($tdi); |
|
| 1023 | + // $tabledata[]=array_merge($td,$tdi); |
|
| 1024 | + $tabledata[]=$td; |
|
| 1025 | + } |
|
| 1026 | + return(array_filter($tabledata)); |
|
| 1027 | + } |
|
| 1028 | + |
|
| 1029 | + /** |
|
| 1030 | + * Get data from form result |
|
| 1031 | + * @param String $url form URL |
|
| 1032 | + * @return String the result |
|
| 1033 | + */ |
|
| 1034 | + private static function getData($url) { |
|
| 1035 | + $ch = curl_init(); |
|
| 1036 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1037 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 1038 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 1039 | + 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'); |
|
| 1040 | + return curl_exec($ch); |
|
| 1041 | + } |
|
| 1042 | 1042 | /* |
| 1043 | 1043 | public static function waypoints() { |
| 1044 | 1044 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | if ($globalTransaction) $Connection->db->commit(); |
| 1122 | 1122 | } |
| 1123 | 1123 | return ''; |
| 1124 | - } |
|
| 1124 | + } |
|
| 1125 | 1125 | |
| 1126 | 1126 | public static function ivao_airlines($filename) { |
| 1127 | 1127 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1131,10 +1131,10 @@ discard block |
||
| 1131 | 1131 | try { |
| 1132 | 1132 | $Connection = new Connection(); |
| 1133 | 1133 | $sth = $Connection->db->prepare($query); |
| 1134 | - $sth->execute(); |
|
| 1135 | - } catch(PDOException $e) { |
|
| 1136 | - return "error : ".$e->getMessage(); |
|
| 1137 | - } |
|
| 1134 | + $sth->execute(); |
|
| 1135 | + } catch(PDOException $e) { |
|
| 1136 | + return "error : ".$e->getMessage(); |
|
| 1137 | + } |
|
| 1138 | 1138 | |
| 1139 | 1139 | $header = NULL; |
| 1140 | 1140 | $delimiter = ':'; |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | if ($globalTransaction) $Connection->db->commit(); |
| 1159 | 1159 | } |
| 1160 | 1160 | return ''; |
| 1161 | - } |
|
| 1161 | + } |
|
| 1162 | 1162 | |
| 1163 | 1163 | public static function update_airspace() { |
| 1164 | 1164 | global $tmp_dir, $globalDBdriver; |
@@ -1168,11 +1168,11 @@ discard block |
||
| 1168 | 1168 | $query = 'DROP TABLE airspace'; |
| 1169 | 1169 | try { |
| 1170 | 1170 | $sth = $Connection->db->prepare($query); |
| 1171 | - $sth->execute(); |
|
| 1172 | - } catch(PDOException $e) { |
|
| 1171 | + $sth->execute(); |
|
| 1172 | + } catch(PDOException $e) { |
|
| 1173 | 1173 | return "error : ".$e->getMessage(); |
| 1174 | - } |
|
| 1175 | - } |
|
| 1174 | + } |
|
| 1175 | + } |
|
| 1176 | 1176 | |
| 1177 | 1177 | |
| 1178 | 1178 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1227,10 +1227,10 @@ discard block |
||
| 1227 | 1227 | $query = 'DROP TABLE countries'; |
| 1228 | 1228 | try { |
| 1229 | 1229 | $sth = $Connection->db->prepare($query); |
| 1230 | - $sth->execute(); |
|
| 1231 | - } catch(PDOException $e) { |
|
| 1232 | - echo "error : ".$e->getMessage(); |
|
| 1233 | - } |
|
| 1230 | + $sth->execute(); |
|
| 1231 | + } catch(PDOException $e) { |
|
| 1232 | + echo "error : ".$e->getMessage(); |
|
| 1233 | + } |
|
| 1234 | 1234 | } |
| 1235 | 1235 | if ($globalDBdriver == 'mysql') { |
| 1236 | 1236 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -1619,11 +1619,11 @@ discard block |
||
| 1619 | 1619 | $query = 'DROP TABLE airspace'; |
| 1620 | 1620 | try { |
| 1621 | 1621 | $sth = $Connection->db->prepare($query); |
| 1622 | - $sth->execute(); |
|
| 1623 | - } catch(PDOException $e) { |
|
| 1622 | + $sth->execute(); |
|
| 1623 | + } catch(PDOException $e) { |
|
| 1624 | 1624 | return "error : ".$e->getMessage(); |
| 1625 | - } |
|
| 1626 | - } |
|
| 1625 | + } |
|
| 1626 | + } |
|
| 1627 | 1627 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 1628 | 1628 | update_db::insert_airspace_version($airspace_md5); |
| 1629 | 1629 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -1743,12 +1743,12 @@ discard block |
||
| 1743 | 1743 | echo $data; |
| 1744 | 1744 | */ |
| 1745 | 1745 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 1746 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 1747 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1748 | - $result = fread($fh,100000000); |
|
| 1749 | - //echo $result; |
|
| 1750 | - //var_dump(str_get_html($result)); |
|
| 1751 | - //print_r(self::table2array($result)); |
|
| 1746 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 1747 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1748 | + $result = fread($fh,100000000); |
|
| 1749 | + //echo $result; |
|
| 1750 | + //var_dump(str_get_html($result)); |
|
| 1751 | + //print_r(self::table2array($result)); |
|
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | 1754 | } |
@@ -1762,10 +1762,10 @@ discard block |
||
| 1762 | 1762 | try { |
| 1763 | 1763 | $Connection = new Connection(); |
| 1764 | 1764 | $sth = $Connection->db->prepare($query); |
| 1765 | - $sth->execute(); |
|
| 1766 | - } catch(PDOException $e) { |
|
| 1767 | - return "error : ".$e->getMessage(); |
|
| 1768 | - } |
|
| 1765 | + $sth->execute(); |
|
| 1766 | + } catch(PDOException $e) { |
|
| 1767 | + return "error : ".$e->getMessage(); |
|
| 1768 | + } |
|
| 1769 | 1769 | |
| 1770 | 1770 | $error = ''; |
| 1771 | 1771 | if ($globalDebug) echo "Notam : Download..."; |
@@ -1821,8 +1821,8 @@ discard block |
||
| 1821 | 1821 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
| 1822 | 1822 | $data['permanent'] = 0; |
| 1823 | 1823 | } else { |
| 1824 | - $data['date_end'] = NULL; |
|
| 1825 | - $data['permanent'] = 1; |
|
| 1824 | + $data['date_end'] = NULL; |
|
| 1825 | + $data['permanent'] = 1; |
|
| 1826 | 1826 | } |
| 1827 | 1827 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 1828 | 1828 | $NOTAM = new NOTAM(); |
@@ -1881,13 +1881,13 @@ discard block |
||
| 1881 | 1881 | try { |
| 1882 | 1882 | $Connection = new Connection(); |
| 1883 | 1883 | $sth = $Connection->db->prepare($query); |
| 1884 | - $sth->execute(); |
|
| 1885 | - } catch(PDOException $e) { |
|
| 1886 | - return "error : ".$e->getMessage(); |
|
| 1887 | - } |
|
| 1888 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1889 | - if ($row['nb'] > 0) return false; |
|
| 1890 | - else return true; |
|
| 1884 | + $sth->execute(); |
|
| 1885 | + } catch(PDOException $e) { |
|
| 1886 | + return "error : ".$e->getMessage(); |
|
| 1887 | + } |
|
| 1888 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1889 | + if ($row['nb'] > 0) return false; |
|
| 1890 | + else return true; |
|
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | public static function insert_last_update() { |
@@ -1896,10 +1896,10 @@ discard block |
||
| 1896 | 1896 | try { |
| 1897 | 1897 | $Connection = new Connection(); |
| 1898 | 1898 | $sth = $Connection->db->prepare($query); |
| 1899 | - $sth->execute(); |
|
| 1900 | - } catch(PDOException $e) { |
|
| 1901 | - return "error : ".$e->getMessage(); |
|
| 1902 | - } |
|
| 1899 | + $sth->execute(); |
|
| 1900 | + } catch(PDOException $e) { |
|
| 1901 | + return "error : ".$e->getMessage(); |
|
| 1902 | + } |
|
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | 1905 | public static function check_airspace_version($version) { |
@@ -1907,13 +1907,13 @@ discard block |
||
| 1907 | 1907 | try { |
| 1908 | 1908 | $Connection = new Connection(); |
| 1909 | 1909 | $sth = $Connection->db->prepare($query); |
| 1910 | - $sth->execute(array(':version' => $version)); |
|
| 1911 | - } catch(PDOException $e) { |
|
| 1912 | - return "error : ".$e->getMessage(); |
|
| 1913 | - } |
|
| 1914 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1915 | - if ($row['nb'] > 0) return true; |
|
| 1916 | - else return false; |
|
| 1910 | + $sth->execute(array(':version' => $version)); |
|
| 1911 | + } catch(PDOException $e) { |
|
| 1912 | + return "error : ".$e->getMessage(); |
|
| 1913 | + } |
|
| 1914 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1915 | + if ($row['nb'] > 0) return true; |
|
| 1916 | + else return false; |
|
| 1917 | 1917 | } |
| 1918 | 1918 | |
| 1919 | 1919 | |
@@ -1923,10 +1923,10 @@ discard block |
||
| 1923 | 1923 | try { |
| 1924 | 1924 | $Connection = new Connection(); |
| 1925 | 1925 | $sth = $Connection->db->prepare($query); |
| 1926 | - $sth->execute(array(':version' => $version)); |
|
| 1927 | - } catch(PDOException $e) { |
|
| 1928 | - return "error : ".$e->getMessage(); |
|
| 1929 | - } |
|
| 1926 | + $sth->execute(array(':version' => $version)); |
|
| 1927 | + } catch(PDOException $e) { |
|
| 1928 | + return "error : ".$e->getMessage(); |
|
| 1929 | + } |
|
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | 1932 | public static function check_last_notam_update() { |
@@ -1939,13 +1939,13 @@ discard block |
||
| 1939 | 1939 | try { |
| 1940 | 1940 | $Connection = new Connection(); |
| 1941 | 1941 | $sth = $Connection->db->prepare($query); |
| 1942 | - $sth->execute(); |
|
| 1943 | - } catch(PDOException $e) { |
|
| 1944 | - return "error : ".$e->getMessage(); |
|
| 1945 | - } |
|
| 1946 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1947 | - if ($row['nb'] > 0) return false; |
|
| 1948 | - else return true; |
|
| 1942 | + $sth->execute(); |
|
| 1943 | + } catch(PDOException $e) { |
|
| 1944 | + return "error : ".$e->getMessage(); |
|
| 1945 | + } |
|
| 1946 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1947 | + if ($row['nb'] > 0) return false; |
|
| 1948 | + else return true; |
|
| 1949 | 1949 | } |
| 1950 | 1950 | |
| 1951 | 1951 | public static function insert_last_notam_update() { |
@@ -1954,10 +1954,10 @@ discard block |
||
| 1954 | 1954 | try { |
| 1955 | 1955 | $Connection = new Connection(); |
| 1956 | 1956 | $sth = $Connection->db->prepare($query); |
| 1957 | - $sth->execute(); |
|
| 1958 | - } catch(PDOException $e) { |
|
| 1959 | - return "error : ".$e->getMessage(); |
|
| 1960 | - } |
|
| 1957 | + $sth->execute(); |
|
| 1958 | + } catch(PDOException $e) { |
|
| 1959 | + return "error : ".$e->getMessage(); |
|
| 1960 | + } |
|
| 1961 | 1961 | } |
| 1962 | 1962 | public static function check_last_airspace_update() { |
| 1963 | 1963 | global $globalDBdriver; |
@@ -1969,13 +1969,13 @@ discard block |
||
| 1969 | 1969 | try { |
| 1970 | 1970 | $Connection = new Connection(); |
| 1971 | 1971 | $sth = $Connection->db->prepare($query); |
| 1972 | - $sth->execute(); |
|
| 1973 | - } catch(PDOException $e) { |
|
| 1974 | - return "error : ".$e->getMessage(); |
|
| 1975 | - } |
|
| 1976 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1977 | - if ($row['nb'] > 0) return false; |
|
| 1978 | - else return true; |
|
| 1972 | + $sth->execute(); |
|
| 1973 | + } catch(PDOException $e) { |
|
| 1974 | + return "error : ".$e->getMessage(); |
|
| 1975 | + } |
|
| 1976 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1977 | + if ($row['nb'] > 0) return false; |
|
| 1978 | + else return true; |
|
| 1979 | 1979 | } |
| 1980 | 1980 | |
| 1981 | 1981 | public static function insert_last_airspace_update() { |
@@ -1984,10 +1984,10 @@ discard block |
||
| 1984 | 1984 | try { |
| 1985 | 1985 | $Connection = new Connection(); |
| 1986 | 1986 | $sth = $Connection->db->prepare($query); |
| 1987 | - $sth->execute(); |
|
| 1988 | - } catch(PDOException $e) { |
|
| 1989 | - return "error : ".$e->getMessage(); |
|
| 1990 | - } |
|
| 1987 | + $sth->execute(); |
|
| 1988 | + } catch(PDOException $e) { |
|
| 1989 | + return "error : ".$e->getMessage(); |
|
| 1990 | + } |
|
| 1991 | 1991 | } |
| 1992 | 1992 | |
| 1993 | 1993 | public static function check_last_owner_update() { |
@@ -2000,13 +2000,13 @@ discard block |
||
| 2000 | 2000 | try { |
| 2001 | 2001 | $Connection = new Connection(); |
| 2002 | 2002 | $sth = $Connection->db->prepare($query); |
| 2003 | - $sth->execute(); |
|
| 2004 | - } catch(PDOException $e) { |
|
| 2005 | - return "error : ".$e->getMessage(); |
|
| 2006 | - } |
|
| 2007 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2008 | - if ($row['nb'] > 0) return false; |
|
| 2009 | - else return true; |
|
| 2003 | + $sth->execute(); |
|
| 2004 | + } catch(PDOException $e) { |
|
| 2005 | + return "error : ".$e->getMessage(); |
|
| 2006 | + } |
|
| 2007 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2008 | + if ($row['nb'] > 0) return false; |
|
| 2009 | + else return true; |
|
| 2010 | 2010 | } |
| 2011 | 2011 | |
| 2012 | 2012 | public static function insert_last_owner_update() { |
@@ -2015,10 +2015,10 @@ discard block |
||
| 2015 | 2015 | try { |
| 2016 | 2016 | $Connection = new Connection(); |
| 2017 | 2017 | $sth = $Connection->db->prepare($query); |
| 2018 | - $sth->execute(); |
|
| 2019 | - } catch(PDOException $e) { |
|
| 2020 | - return "error : ".$e->getMessage(); |
|
| 2021 | - } |
|
| 2018 | + $sth->execute(); |
|
| 2019 | + } catch(PDOException $e) { |
|
| 2020 | + return "error : ".$e->getMessage(); |
|
| 2021 | + } |
|
| 2022 | 2022 | } |
| 2023 | 2023 | public static function check_last_schedules_update() { |
| 2024 | 2024 | global $globalDBdriver; |
@@ -2030,13 +2030,13 @@ discard block |
||
| 2030 | 2030 | try { |
| 2031 | 2031 | $Connection = new Connection(); |
| 2032 | 2032 | $sth = $Connection->db->prepare($query); |
| 2033 | - $sth->execute(); |
|
| 2034 | - } catch(PDOException $e) { |
|
| 2035 | - return "error : ".$e->getMessage(); |
|
| 2036 | - } |
|
| 2037 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2038 | - if ($row['nb'] > 0) return false; |
|
| 2039 | - else return true; |
|
| 2033 | + $sth->execute(); |
|
| 2034 | + } catch(PDOException $e) { |
|
| 2035 | + return "error : ".$e->getMessage(); |
|
| 2036 | + } |
|
| 2037 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2038 | + if ($row['nb'] > 0) return false; |
|
| 2039 | + else return true; |
|
| 2040 | 2040 | } |
| 2041 | 2041 | |
| 2042 | 2042 | public static function insert_last_schedules_update() { |
@@ -2045,10 +2045,10 @@ discard block |
||
| 2045 | 2045 | try { |
| 2046 | 2046 | $Connection = new Connection(); |
| 2047 | 2047 | $sth = $Connection->db->prepare($query); |
| 2048 | - $sth->execute(); |
|
| 2049 | - } catch(PDOException $e) { |
|
| 2050 | - return "error : ".$e->getMessage(); |
|
| 2051 | - } |
|
| 2048 | + $sth->execute(); |
|
| 2049 | + } catch(PDOException $e) { |
|
| 2050 | + return "error : ".$e->getMessage(); |
|
| 2051 | + } |
|
| 2052 | 2052 | } |
| 2053 | 2053 | public static function check_last_tle_update() { |
| 2054 | 2054 | global $globalDBdriver; |
@@ -2060,13 +2060,13 @@ discard block |
||
| 2060 | 2060 | try { |
| 2061 | 2061 | $Connection = new Connection(); |
| 2062 | 2062 | $sth = $Connection->db->prepare($query); |
| 2063 | - $sth->execute(); |
|
| 2064 | - } catch(PDOException $e) { |
|
| 2065 | - return "error : ".$e->getMessage(); |
|
| 2066 | - } |
|
| 2067 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2068 | - if ($row['nb'] > 0) return false; |
|
| 2069 | - else return true; |
|
| 2063 | + $sth->execute(); |
|
| 2064 | + } catch(PDOException $e) { |
|
| 2065 | + return "error : ".$e->getMessage(); |
|
| 2066 | + } |
|
| 2067 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2068 | + if ($row['nb'] > 0) return false; |
|
| 2069 | + else return true; |
|
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | public static function insert_last_tle_update() { |
@@ -2075,10 +2075,10 @@ discard block |
||
| 2075 | 2075 | try { |
| 2076 | 2076 | $Connection = new Connection(); |
| 2077 | 2077 | $sth = $Connection->db->prepare($query); |
| 2078 | - $sth->execute(); |
|
| 2079 | - } catch(PDOException $e) { |
|
| 2080 | - return "error : ".$e->getMessage(); |
|
| 2081 | - } |
|
| 2078 | + $sth->execute(); |
|
| 2079 | + } catch(PDOException $e) { |
|
| 2080 | + return "error : ".$e->getMessage(); |
|
| 2081 | + } |
|
| 2082 | 2082 | } |
| 2083 | 2083 | |
| 2084 | 2084 | public static function update_all() { |
@@ -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 | 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'); |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | } elseif ($globalDebug) echo "Done\n"; |
| 1341 | 1341 | */ |
| 1342 | 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'); |
|
| 1343 | + update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip', $tmp_dir.'basestation_latest.zip', 'http://planebase.biz/bstnsqb'); |
|
| 1344 | 1344 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1345 | 1345 | if ($globalDebug) echo "Unzip..."; |
| 1346 | 1346 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
@@ -1356,7 +1356,7 @@ discard block |
||
| 1356 | 1356 | public static function update_ModeS_flarm() { |
| 1357 | 1357 | global $tmp_dir, $globalDebug; |
| 1358 | 1358 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
| 1359 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
| 1359 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
| 1360 | 1360 | if (file_exists($tmp_dir.'data.fln')) { |
| 1361 | 1361 | if ($globalDebug) echo "Add to DB..."; |
| 1362 | 1362 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1370,7 +1370,7 @@ discard block |
||
| 1370 | 1370 | public static function update_ModeS_ogn() { |
| 1371 | 1371 | global $tmp_dir, $globalDebug; |
| 1372 | 1372 | if ($globalDebug) echo "Modes OGN: Download..."; |
| 1373 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
| 1373 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
| 1374 | 1374 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1375 | 1375 | if ($globalDebug) echo "Add to DB..."; |
| 1376 | 1376 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1385,173 +1385,173 @@ discard block |
||
| 1385 | 1385 | global $tmp_dir, $globalDebug; |
| 1386 | 1386 | |
| 1387 | 1387 | if ($globalDebug) echo "Owner France: Download..."; |
| 1388 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
| 1388 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
| 1389 | 1389 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1390 | 1390 | if ($globalDebug) echo "Add to DB..."; |
| 1391 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
| 1391 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
| 1392 | 1392 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
| 1393 | 1393 | if ($error != '') { |
| 1394 | 1394 | return $error; |
| 1395 | 1395 | } elseif ($globalDebug) echo "Done\n"; |
| 1396 | 1396 | |
| 1397 | 1397 | if ($globalDebug) echo "Owner Ireland: Download..."; |
| 1398 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
| 1398 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
| 1399 | 1399 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1400 | 1400 | if ($globalDebug) echo "Add to DB..."; |
| 1401 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
| 1401 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
| 1402 | 1402 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
| 1403 | 1403 | if ($error != '') { |
| 1404 | 1404 | return $error; |
| 1405 | 1405 | } elseif ($globalDebug) echo "Done\n"; |
| 1406 | 1406 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
| 1407 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
| 1407 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
| 1408 | 1408 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1409 | 1409 | if ($globalDebug) echo "Add to DB..."; |
| 1410 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
| 1410 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
| 1411 | 1411 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
| 1412 | 1412 | if ($error != '') { |
| 1413 | 1413 | return $error; |
| 1414 | 1414 | } elseif ($globalDebug) echo "Done\n"; |
| 1415 | 1415 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
| 1416 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
| 1416 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
| 1417 | 1417 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1418 | 1418 | if ($globalDebug) echo "Add to DB..."; |
| 1419 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
| 1419 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
| 1420 | 1420 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
| 1421 | 1421 | if ($error != '') { |
| 1422 | 1422 | return $error; |
| 1423 | 1423 | } elseif ($globalDebug) echo "Done\n"; |
| 1424 | 1424 | if ($globalDebug) echo "Owner Australia: Download..."; |
| 1425 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
| 1425 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
| 1426 | 1426 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1427 | 1427 | if ($globalDebug) echo "Add to DB..."; |
| 1428 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
| 1428 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
| 1429 | 1429 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
| 1430 | 1430 | if ($error != '') { |
| 1431 | 1431 | return $error; |
| 1432 | 1432 | } elseif ($globalDebug) echo "Done\n"; |
| 1433 | 1433 | if ($globalDebug) echo "Owner Austria: Download..."; |
| 1434 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
| 1434 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
| 1435 | 1435 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1436 | 1436 | if ($globalDebug) echo "Add to DB..."; |
| 1437 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
| 1437 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
| 1438 | 1438 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
| 1439 | 1439 | if ($error != '') { |
| 1440 | 1440 | return $error; |
| 1441 | 1441 | } elseif ($globalDebug) echo "Done\n"; |
| 1442 | 1442 | if ($globalDebug) echo "Owner Chile: Download..."; |
| 1443 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
| 1443 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
| 1444 | 1444 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1445 | 1445 | if ($globalDebug) echo "Add to DB..."; |
| 1446 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
| 1446 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
| 1447 | 1447 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
| 1448 | 1448 | if ($error != '') { |
| 1449 | 1449 | return $error; |
| 1450 | 1450 | } elseif ($globalDebug) echo "Done\n"; |
| 1451 | 1451 | if ($globalDebug) echo "Owner Colombia: Download..."; |
| 1452 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
| 1452 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
| 1453 | 1453 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1454 | 1454 | if ($globalDebug) echo "Add to DB..."; |
| 1455 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
| 1455 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
| 1456 | 1456 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
| 1457 | 1457 | if ($error != '') { |
| 1458 | 1458 | return $error; |
| 1459 | 1459 | } elseif ($globalDebug) echo "Done\n"; |
| 1460 | 1460 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
| 1461 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
| 1461 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
| 1462 | 1462 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1463 | 1463 | if ($globalDebug) echo "Add to DB..."; |
| 1464 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
| 1464 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
| 1465 | 1465 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
| 1466 | 1466 | if ($error != '') { |
| 1467 | 1467 | return $error; |
| 1468 | 1468 | } elseif ($globalDebug) echo "Done\n"; |
| 1469 | 1469 | if ($globalDebug) echo "Owner Brazil: Download..."; |
| 1470 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
| 1470 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
| 1471 | 1471 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1472 | 1472 | if ($globalDebug) echo "Add to DB..."; |
| 1473 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
| 1473 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
| 1474 | 1474 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
| 1475 | 1475 | if ($error != '') { |
| 1476 | 1476 | return $error; |
| 1477 | 1477 | } elseif ($globalDebug) echo "Done\n"; |
| 1478 | 1478 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
| 1479 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
| 1479 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
| 1480 | 1480 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1481 | 1481 | if ($globalDebug) echo "Add to DB..."; |
| 1482 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
| 1482 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
| 1483 | 1483 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
| 1484 | 1484 | if ($error != '') { |
| 1485 | 1485 | return $error; |
| 1486 | 1486 | } elseif ($globalDebug) echo "Done\n"; |
| 1487 | 1487 | if ($globalDebug) echo "Owner Croatia: Download..."; |
| 1488 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
| 1488 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
| 1489 | 1489 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1490 | 1490 | if ($globalDebug) echo "Add to DB..."; |
| 1491 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
| 1491 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
| 1492 | 1492 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
| 1493 | 1493 | if ($error != '') { |
| 1494 | 1494 | return $error; |
| 1495 | 1495 | } elseif ($globalDebug) echo "Done\n"; |
| 1496 | 1496 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
| 1497 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
| 1497 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
| 1498 | 1498 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1499 | 1499 | if ($globalDebug) echo "Add to DB..."; |
| 1500 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
| 1500 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
| 1501 | 1501 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
| 1502 | 1502 | if ($error != '') { |
| 1503 | 1503 | return $error; |
| 1504 | 1504 | } elseif ($globalDebug) echo "Done\n"; |
| 1505 | 1505 | if ($globalDebug) echo "Owner Maldives: Download..."; |
| 1506 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
| 1506 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
| 1507 | 1507 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1508 | 1508 | if ($globalDebug) echo "Add to DB..."; |
| 1509 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
| 1509 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
| 1510 | 1510 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
| 1511 | 1511 | if ($error != '') { |
| 1512 | 1512 | return $error; |
| 1513 | 1513 | } elseif ($globalDebug) echo "Done\n"; |
| 1514 | 1514 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
| 1515 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
| 1515 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
| 1516 | 1516 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1517 | 1517 | if ($globalDebug) echo "Add to DB..."; |
| 1518 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
| 1518 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
| 1519 | 1519 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
| 1520 | 1520 | if ($error != '') { |
| 1521 | 1521 | return $error; |
| 1522 | 1522 | } elseif ($globalDebug) echo "Done\n"; |
| 1523 | 1523 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
| 1524 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
| 1524 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
| 1525 | 1525 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1526 | 1526 | if ($globalDebug) echo "Add to DB..."; |
| 1527 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
| 1527 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
| 1528 | 1528 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
| 1529 | 1529 | if ($error != '') { |
| 1530 | 1530 | return $error; |
| 1531 | 1531 | } elseif ($globalDebug) echo "Done\n"; |
| 1532 | 1532 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
| 1533 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
| 1533 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
| 1534 | 1534 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1535 | 1535 | if ($globalDebug) echo "Add to DB..."; |
| 1536 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
| 1536 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
| 1537 | 1537 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
| 1538 | 1538 | if ($error != '') { |
| 1539 | 1539 | return $error; |
| 1540 | 1540 | } elseif ($globalDebug) echo "Done\n"; |
| 1541 | 1541 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
| 1542 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
| 1542 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
| 1543 | 1543 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1544 | 1544 | if ($globalDebug) echo "Add to DB..."; |
| 1545 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
| 1545 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
| 1546 | 1546 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
| 1547 | 1547 | if ($error != '') { |
| 1548 | 1548 | return $error; |
| 1549 | 1549 | } elseif ($globalDebug) echo "Done\n"; |
| 1550 | 1550 | if ($globalDebug) echo "Owner Iceland: Download..."; |
| 1551 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
| 1551 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
| 1552 | 1552 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1553 | 1553 | if ($globalDebug) echo "Add to DB..."; |
| 1554 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
| 1554 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
| 1555 | 1555 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
| 1556 | 1556 | if ($error != '') { |
| 1557 | 1557 | return $error; |
@@ -1563,7 +1563,7 @@ discard block |
||
| 1563 | 1563 | global $tmp_dir, $globalDebug; |
| 1564 | 1564 | $error = ''; |
| 1565 | 1565 | if ($globalDebug) echo "Translation : Download..."; |
| 1566 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
| 1566 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
| 1567 | 1567 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1568 | 1568 | if ($globalDebug) echo "Unzip..."; |
| 1569 | 1569 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | public static function update_translation_fam() { |
| 1580 | 1580 | global $tmp_dir, $globalDebug; |
| 1581 | 1581 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
| 1582 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
| 1582 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
| 1583 | 1583 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1584 | 1584 | if ($globalDebug) echo "Gunzip..."; |
| 1585 | 1585 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1597,18 +1597,18 @@ discard block |
||
| 1597 | 1597 | include_once('class.create_db.php'); |
| 1598 | 1598 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
| 1599 | 1599 | if ($globalDBdriver == 'mysql') { |
| 1600 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 1600 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 1601 | 1601 | } else { |
| 1602 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 1602 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 1603 | 1603 | } |
| 1604 | 1604 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
| 1605 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 1605 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 1606 | 1606 | $airspace_md5 = $airspace_md5_file[0]; |
| 1607 | 1607 | if (!update_db::check_airspace_version($airspace_md5)) { |
| 1608 | 1608 | if ($globalDBdriver == 'mysql') { |
| 1609 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 1609 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 1610 | 1610 | } else { |
| 1611 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 1611 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 1612 | 1612 | } |
| 1613 | 1613 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 1614 | 1614 | if ($globalDebug) echo "Gunzip..."; |
@@ -1620,7 +1620,7 @@ discard block |
||
| 1620 | 1620 | try { |
| 1621 | 1621 | $sth = $Connection->db->prepare($query); |
| 1622 | 1622 | $sth->execute(); |
| 1623 | - } catch(PDOException $e) { |
|
| 1623 | + } catch (PDOException $e) { |
|
| 1624 | 1624 | return "error : ".$e->getMessage(); |
| 1625 | 1625 | } |
| 1626 | 1626 | } |
@@ -1638,15 +1638,15 @@ discard block |
||
| 1638 | 1638 | public static function update_tle() { |
| 1639 | 1639 | global $tmp_dir, $globalDebug; |
| 1640 | 1640 | if ($globalDebug) echo "Download TLE : Download..."; |
| 1641 | - $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', |
|
| 1642 | - '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', |
|
| 1643 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
| 1641 | + $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', |
|
| 1642 | + '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', |
|
| 1643 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
| 1644 | 1644 | foreach ($alltle as $filename) { |
| 1645 | 1645 | if ($globalDebug) echo "downloading ".$filename.'...'; |
| 1646 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
| 1646 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
| 1647 | 1647 | if (file_exists($tmp_dir.$filename)) { |
| 1648 | 1648 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
| 1649 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
| 1649 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
| 1650 | 1650 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
| 1651 | 1651 | if ($error != '') { |
| 1652 | 1652 | echo $error."\n"; |
@@ -1659,32 +1659,32 @@ discard block |
||
| 1659 | 1659 | global $tmp_dir, $globalDebug; |
| 1660 | 1660 | $error = ''; |
| 1661 | 1661 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
| 1662 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
| 1662 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
| 1663 | 1663 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 1664 | 1664 | if ($globalDebug) echo "Check files...\n"; |
| 1665 | 1665 | $newmodelsdb = array(); |
| 1666 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
| 1667 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1666 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
| 1667 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1668 | 1668 | $model = trim($row[2]); |
| 1669 | 1669 | $newmodelsdb[$model] = trim($row[0]); |
| 1670 | 1670 | } |
| 1671 | 1671 | } |
| 1672 | 1672 | $modelsdb = array(); |
| 1673 | 1673 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
| 1674 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
| 1675 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1674 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
| 1675 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1676 | 1676 | $model = trim($row[2]); |
| 1677 | 1677 | $modelsdb[$model] = trim($row[0]); |
| 1678 | 1678 | } |
| 1679 | 1679 | } |
| 1680 | 1680 | } |
| 1681 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 1681 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 1682 | 1682 | foreach ($diff as $key => $value) { |
| 1683 | 1683 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
| 1684 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
| 1684 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
| 1685 | 1685 | |
| 1686 | 1686 | } |
| 1687 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
| 1687 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
| 1688 | 1688 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 1689 | 1689 | if ($error != '') { |
| 1690 | 1690 | return $error; |
@@ -1696,32 +1696,32 @@ discard block |
||
| 1696 | 1696 | global $tmp_dir, $globalDebug; |
| 1697 | 1697 | $error = ''; |
| 1698 | 1698 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
| 1699 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
| 1699 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
| 1700 | 1700 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 1701 | 1701 | if ($globalDebug) echo "Check files...\n"; |
| 1702 | 1702 | $newmodelsdb = array(); |
| 1703 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
| 1704 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1703 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
| 1704 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1705 | 1705 | $model = trim($row[2]); |
| 1706 | 1706 | $newmodelsdb[$model] = trim($row[0]); |
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| 1709 | 1709 | $modelsdb = array(); |
| 1710 | 1710 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
| 1711 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
| 1712 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1711 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
| 1712 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1713 | 1713 | $model = trim($row[2]); |
| 1714 | 1714 | $modelsdb[$model] = trim($row[0]); |
| 1715 | 1715 | } |
| 1716 | 1716 | } |
| 1717 | 1717 | } |
| 1718 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 1718 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 1719 | 1719 | foreach ($diff as $key => $value) { |
| 1720 | 1720 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
| 1721 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
| 1721 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
| 1722 | 1722 | |
| 1723 | 1723 | } |
| 1724 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 1724 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 1725 | 1725 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 1726 | 1726 | if ($error != '') { |
| 1727 | 1727 | return $error; |
@@ -1744,8 +1744,8 @@ discard block |
||
| 1744 | 1744 | */ |
| 1745 | 1745 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 1746 | 1746 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
| 1747 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1748 | - $result = fread($fh,100000000); |
|
| 1747 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
| 1748 | + $result = fread($fh, 100000000); |
|
| 1749 | 1749 | //echo $result; |
| 1750 | 1750 | //var_dump(str_get_html($result)); |
| 1751 | 1751 | //print_r(self::table2array($result)); |
@@ -1763,23 +1763,23 @@ discard block |
||
| 1763 | 1763 | $Connection = new Connection(); |
| 1764 | 1764 | $sth = $Connection->db->prepare($query); |
| 1765 | 1765 | $sth->execute(); |
| 1766 | - } catch(PDOException $e) { |
|
| 1766 | + } catch (PDOException $e) { |
|
| 1767 | 1767 | return "error : ".$e->getMessage(); |
| 1768 | 1768 | } |
| 1769 | 1769 | |
| 1770 | 1770 | $error = ''; |
| 1771 | 1771 | if ($globalDebug) echo "Notam : Download..."; |
| 1772 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
| 1772 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
| 1773 | 1773 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1774 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
| 1774 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
| 1775 | 1775 | foreach ($notams['channel']['item'] as $notam) { |
| 1776 | - $title = explode(':',$notam['title']); |
|
| 1776 | + $title = explode(':', $notam['title']); |
|
| 1777 | 1777 | $data['ref'] = trim($title[0]); |
| 1778 | 1778 | unset($title[0]); |
| 1779 | - $data['title'] = trim(implode(':',$title)); |
|
| 1780 | - $description = strip_tags($notam['description'],'<pre>'); |
|
| 1781 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
| 1782 | - $q = explode('/',$match[1]); |
|
| 1779 | + $data['title'] = trim(implode(':', $title)); |
|
| 1780 | + $description = strip_tags($notam['description'], '<pre>'); |
|
| 1781 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
| 1782 | + $q = explode('/', $match[1]); |
|
| 1783 | 1783 | $data['fir'] = $q[0]; |
| 1784 | 1784 | $data['code'] = $q[1]; |
| 1785 | 1785 | $ifrvfr = $q[2]; |
@@ -1795,30 +1795,30 @@ discard block |
||
| 1795 | 1795 | $data['lower_limit'] = $q[5]; |
| 1796 | 1796 | $data['upper_limit'] = $q[6]; |
| 1797 | 1797 | $latlonrad = $q[7]; |
| 1798 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
| 1799 | - $latitude = $Common->convertDec($las,'latitude'); |
|
| 1800 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
| 1798 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
| 1799 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
| 1800 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
| 1801 | 1801 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 1802 | 1802 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 1803 | 1803 | $data['center_latitude'] = $latitude; |
| 1804 | 1804 | $data['center_longitude'] = $longitude; |
| 1805 | 1805 | $data['radius'] = intval($radius); |
| 1806 | 1806 | |
| 1807 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
| 1807 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
| 1808 | 1808 | $data['text'] = $match[1]; |
| 1809 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
| 1809 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
| 1810 | 1810 | $fromto = $match[1]; |
| 1811 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
| 1811 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
| 1812 | 1812 | $fromall = trim($match[1]); |
| 1813 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
| 1813 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
| 1814 | 1814 | $from = trim($match[1]); |
| 1815 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
| 1816 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
| 1815 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
| 1816 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
| 1817 | 1817 | $toall = trim($match[1]); |
| 1818 | - if (!preg_match(':Permanent:',$toall)) { |
|
| 1819 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
| 1818 | + if (!preg_match(':Permanent:', $toall)) { |
|
| 1819 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
| 1820 | 1820 | $to = trim($match[1]); |
| 1821 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
| 1821 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
| 1822 | 1822 | $data['permanent'] = 0; |
| 1823 | 1823 | } else { |
| 1824 | 1824 | $data['date_end'] = NULL; |
@@ -1826,7 +1826,7 @@ discard block |
||
| 1826 | 1826 | } |
| 1827 | 1827 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 1828 | 1828 | $NOTAM = new NOTAM(); |
| 1829 | - $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']); |
|
| 1829 | + $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']); |
|
| 1830 | 1830 | unset($data); |
| 1831 | 1831 | } |
| 1832 | 1832 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -1849,16 +1849,16 @@ discard block |
||
| 1849 | 1849 | $Connection = new Connection(); |
| 1850 | 1850 | $sth = $Connection->db->prepare($query); |
| 1851 | 1851 | $sth->execute(); |
| 1852 | - } catch(PDOException $e) { |
|
| 1852 | + } catch (PDOException $e) { |
|
| 1853 | 1853 | return "error : ".$e->getMessage(); |
| 1854 | 1854 | } |
| 1855 | 1855 | } |
| 1856 | 1856 | $Common = new Common(); |
| 1857 | 1857 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 1858 | - $airspace_json = json_decode($airspace_lst,true); |
|
| 1858 | + $airspace_json = json_decode($airspace_lst, true); |
|
| 1859 | 1859 | foreach ($airspace_json['records'] as $airspace) { |
| 1860 | 1860 | if ($globalDebug) echo $airspace['name']."...\n"; |
| 1861 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
| 1861 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
| 1862 | 1862 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 1863 | 1863 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
| 1864 | 1864 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -1882,7 +1882,7 @@ discard block |
||
| 1882 | 1882 | $Connection = new Connection(); |
| 1883 | 1883 | $sth = $Connection->db->prepare($query); |
| 1884 | 1884 | $sth->execute(); |
| 1885 | - } catch(PDOException $e) { |
|
| 1885 | + } catch (PDOException $e) { |
|
| 1886 | 1886 | return "error : ".$e->getMessage(); |
| 1887 | 1887 | } |
| 1888 | 1888 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1897,7 +1897,7 @@ discard block |
||
| 1897 | 1897 | $Connection = new Connection(); |
| 1898 | 1898 | $sth = $Connection->db->prepare($query); |
| 1899 | 1899 | $sth->execute(); |
| 1900 | - } catch(PDOException $e) { |
|
| 1900 | + } catch (PDOException $e) { |
|
| 1901 | 1901 | return "error : ".$e->getMessage(); |
| 1902 | 1902 | } |
| 1903 | 1903 | } |
@@ -1908,7 +1908,7 @@ discard block |
||
| 1908 | 1908 | $Connection = new Connection(); |
| 1909 | 1909 | $sth = $Connection->db->prepare($query); |
| 1910 | 1910 | $sth->execute(array(':version' => $version)); |
| 1911 | - } catch(PDOException $e) { |
|
| 1911 | + } catch (PDOException $e) { |
|
| 1912 | 1912 | return "error : ".$e->getMessage(); |
| 1913 | 1913 | } |
| 1914 | 1914 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1924,7 +1924,7 @@ discard block |
||
| 1924 | 1924 | $Connection = new Connection(); |
| 1925 | 1925 | $sth = $Connection->db->prepare($query); |
| 1926 | 1926 | $sth->execute(array(':version' => $version)); |
| 1927 | - } catch(PDOException $e) { |
|
| 1927 | + } catch (PDOException $e) { |
|
| 1928 | 1928 | return "error : ".$e->getMessage(); |
| 1929 | 1929 | } |
| 1930 | 1930 | } |
@@ -1940,7 +1940,7 @@ discard block |
||
| 1940 | 1940 | $Connection = new Connection(); |
| 1941 | 1941 | $sth = $Connection->db->prepare($query); |
| 1942 | 1942 | $sth->execute(); |
| 1943 | - } catch(PDOException $e) { |
|
| 1943 | + } catch (PDOException $e) { |
|
| 1944 | 1944 | return "error : ".$e->getMessage(); |
| 1945 | 1945 | } |
| 1946 | 1946 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1955,7 +1955,7 @@ discard block |
||
| 1955 | 1955 | $Connection = new Connection(); |
| 1956 | 1956 | $sth = $Connection->db->prepare($query); |
| 1957 | 1957 | $sth->execute(); |
| 1958 | - } catch(PDOException $e) { |
|
| 1958 | + } catch (PDOException $e) { |
|
| 1959 | 1959 | return "error : ".$e->getMessage(); |
| 1960 | 1960 | } |
| 1961 | 1961 | } |
@@ -1970,7 +1970,7 @@ discard block |
||
| 1970 | 1970 | $Connection = new Connection(); |
| 1971 | 1971 | $sth = $Connection->db->prepare($query); |
| 1972 | 1972 | $sth->execute(); |
| 1973 | - } catch(PDOException $e) { |
|
| 1973 | + } catch (PDOException $e) { |
|
| 1974 | 1974 | return "error : ".$e->getMessage(); |
| 1975 | 1975 | } |
| 1976 | 1976 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1985,7 +1985,7 @@ discard block |
||
| 1985 | 1985 | $Connection = new Connection(); |
| 1986 | 1986 | $sth = $Connection->db->prepare($query); |
| 1987 | 1987 | $sth->execute(); |
| 1988 | - } catch(PDOException $e) { |
|
| 1988 | + } catch (PDOException $e) { |
|
| 1989 | 1989 | return "error : ".$e->getMessage(); |
| 1990 | 1990 | } |
| 1991 | 1991 | } |
@@ -2001,7 +2001,7 @@ discard block |
||
| 2001 | 2001 | $Connection = new Connection(); |
| 2002 | 2002 | $sth = $Connection->db->prepare($query); |
| 2003 | 2003 | $sth->execute(); |
| 2004 | - } catch(PDOException $e) { |
|
| 2004 | + } catch (PDOException $e) { |
|
| 2005 | 2005 | return "error : ".$e->getMessage(); |
| 2006 | 2006 | } |
| 2007 | 2007 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2016,7 +2016,7 @@ discard block |
||
| 2016 | 2016 | $Connection = new Connection(); |
| 2017 | 2017 | $sth = $Connection->db->prepare($query); |
| 2018 | 2018 | $sth->execute(); |
| 2019 | - } catch(PDOException $e) { |
|
| 2019 | + } catch (PDOException $e) { |
|
| 2020 | 2020 | return "error : ".$e->getMessage(); |
| 2021 | 2021 | } |
| 2022 | 2022 | } |
@@ -2031,7 +2031,7 @@ discard block |
||
| 2031 | 2031 | $Connection = new Connection(); |
| 2032 | 2032 | $sth = $Connection->db->prepare($query); |
| 2033 | 2033 | $sth->execute(); |
| 2034 | - } catch(PDOException $e) { |
|
| 2034 | + } catch (PDOException $e) { |
|
| 2035 | 2035 | return "error : ".$e->getMessage(); |
| 2036 | 2036 | } |
| 2037 | 2037 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2046,7 +2046,7 @@ discard block |
||
| 2046 | 2046 | $Connection = new Connection(); |
| 2047 | 2047 | $sth = $Connection->db->prepare($query); |
| 2048 | 2048 | $sth->execute(); |
| 2049 | - } catch(PDOException $e) { |
|
| 2049 | + } catch (PDOException $e) { |
|
| 2050 | 2050 | return "error : ".$e->getMessage(); |
| 2051 | 2051 | } |
| 2052 | 2052 | } |
@@ -2061,7 +2061,7 @@ discard block |
||
| 2061 | 2061 | $Connection = new Connection(); |
| 2062 | 2062 | $sth = $Connection->db->prepare($query); |
| 2063 | 2063 | $sth->execute(); |
| 2064 | - } catch(PDOException $e) { |
|
| 2064 | + } catch (PDOException $e) { |
|
| 2065 | 2065 | return "error : ".$e->getMessage(); |
| 2066 | 2066 | } |
| 2067 | 2067 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2076,7 +2076,7 @@ discard block |
||
| 2076 | 2076 | $Connection = new Connection(); |
| 2077 | 2077 | $sth = $Connection->db->prepare($query); |
| 2078 | 2078 | $sth->execute(); |
| 2079 | - } catch(PDOException $e) { |
|
| 2079 | + } catch (PDOException $e) { |
|
| 2080 | 2080 | return "error : ".$e->getMessage(); |
| 2081 | 2081 | } |
| 2082 | 2082 | } |
@@ -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,263 +1523,463 @@ discard block |
||
| 1339 | 1523 | exit; |
| 1340 | 1524 | } elseif ($globalDebug) echo "Done\n"; |
| 1341 | 1525 | */ |
| 1342 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 1526 | + if ($globalDebug) { |
|
| 1527 | + echo "Modes : Download..."; |
|
| 1528 | + } |
|
| 1343 | 1529 | update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 1344 | 1530 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1345 | - if ($globalDebug) echo "Unzip..."; |
|
| 1531 | + if ($globalDebug) { |
|
| 1532 | + echo "Unzip..."; |
|
| 1533 | + } |
|
| 1346 | 1534 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
| 1347 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1535 | + if ($globalDebug) { |
|
| 1536 | + echo "Add to DB..."; |
|
| 1537 | + } |
|
| 1348 | 1538 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 1349 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1539 | + } else { |
|
| 1540 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1541 | + } |
|
| 1350 | 1542 | if ($error != '') { |
| 1351 | 1543 | return $error; |
| 1352 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1544 | + } elseif ($globalDebug) { |
|
| 1545 | + echo "Done\n"; |
|
| 1546 | + } |
|
| 1353 | 1547 | return ''; |
| 1354 | 1548 | } |
| 1355 | 1549 | |
| 1356 | 1550 | public static function update_ModeS_flarm() { |
| 1357 | 1551 | global $tmp_dir, $globalDebug; |
| 1358 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 1552 | + if ($globalDebug) { |
|
| 1553 | + echo "Modes Flarmnet: Download..."; |
|
| 1554 | + } |
|
| 1359 | 1555 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 1360 | 1556 | if (file_exists($tmp_dir.'data.fln')) { |
| 1361 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1557 | + if ($globalDebug) { |
|
| 1558 | + echo "Add to DB..."; |
|
| 1559 | + } |
|
| 1362 | 1560 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 1363 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1561 | + } else { |
|
| 1562 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1563 | + } |
|
| 1364 | 1564 | if ($error != '') { |
| 1365 | 1565 | return $error; |
| 1366 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1566 | + } elseif ($globalDebug) { |
|
| 1567 | + echo "Done\n"; |
|
| 1568 | + } |
|
| 1367 | 1569 | return ''; |
| 1368 | 1570 | } |
| 1369 | 1571 | |
| 1370 | 1572 | public static function update_ModeS_ogn() { |
| 1371 | 1573 | global $tmp_dir, $globalDebug; |
| 1372 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 1574 | + if ($globalDebug) { |
|
| 1575 | + echo "Modes OGN: Download..."; |
|
| 1576 | + } |
|
| 1373 | 1577 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 1374 | 1578 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1375 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1579 | + if ($globalDebug) { |
|
| 1580 | + echo "Add to DB..."; |
|
| 1581 | + } |
|
| 1376 | 1582 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 1377 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1583 | + } else { |
|
| 1584 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1585 | + } |
|
| 1378 | 1586 | if ($error != '') { |
| 1379 | 1587 | return $error; |
| 1380 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1588 | + } elseif ($globalDebug) { |
|
| 1589 | + echo "Done\n"; |
|
| 1590 | + } |
|
| 1381 | 1591 | return ''; |
| 1382 | 1592 | } |
| 1383 | 1593 | |
| 1384 | 1594 | public static function update_owner() { |
| 1385 | 1595 | global $tmp_dir, $globalDebug; |
| 1386 | 1596 | |
| 1387 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 1597 | + if ($globalDebug) { |
|
| 1598 | + echo "Owner France: Download..."; |
|
| 1599 | + } |
|
| 1388 | 1600 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 1389 | 1601 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1390 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1602 | + if ($globalDebug) { |
|
| 1603 | + echo "Add to DB..."; |
|
| 1604 | + } |
|
| 1391 | 1605 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 1392 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1606 | + } else { |
|
| 1607 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1608 | + } |
|
| 1393 | 1609 | if ($error != '') { |
| 1394 | 1610 | return $error; |
| 1395 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1611 | + } elseif ($globalDebug) { |
|
| 1612 | + echo "Done\n"; |
|
| 1613 | + } |
|
| 1396 | 1614 | |
| 1397 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 1615 | + if ($globalDebug) { |
|
| 1616 | + echo "Owner Ireland: Download..."; |
|
| 1617 | + } |
|
| 1398 | 1618 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 1399 | 1619 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1400 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1620 | + if ($globalDebug) { |
|
| 1621 | + echo "Add to DB..."; |
|
| 1622 | + } |
|
| 1401 | 1623 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 1402 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1624 | + } else { |
|
| 1625 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1626 | + } |
|
| 1403 | 1627 | if ($error != '') { |
| 1404 | 1628 | return $error; |
| 1405 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1406 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 1629 | + } elseif ($globalDebug) { |
|
| 1630 | + echo "Done\n"; |
|
| 1631 | + } |
|
| 1632 | + if ($globalDebug) { |
|
| 1633 | + echo "Owner Switzerland: Download..."; |
|
| 1634 | + } |
|
| 1407 | 1635 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 1408 | 1636 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1409 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1637 | + if ($globalDebug) { |
|
| 1638 | + echo "Add to DB..."; |
|
| 1639 | + } |
|
| 1410 | 1640 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 1411 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1641 | + } else { |
|
| 1642 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1643 | + } |
|
| 1412 | 1644 | if ($error != '') { |
| 1413 | 1645 | return $error; |
| 1414 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1415 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 1646 | + } elseif ($globalDebug) { |
|
| 1647 | + echo "Done\n"; |
|
| 1648 | + } |
|
| 1649 | + if ($globalDebug) { |
|
| 1650 | + echo "Owner Czech Republic: Download..."; |
|
| 1651 | + } |
|
| 1416 | 1652 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 1417 | 1653 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1418 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1654 | + if ($globalDebug) { |
|
| 1655 | + echo "Add to DB..."; |
|
| 1656 | + } |
|
| 1419 | 1657 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 1420 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1658 | + } else { |
|
| 1659 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1660 | + } |
|
| 1421 | 1661 | if ($error != '') { |
| 1422 | 1662 | return $error; |
| 1423 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1424 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 1663 | + } elseif ($globalDebug) { |
|
| 1664 | + echo "Done\n"; |
|
| 1665 | + } |
|
| 1666 | + if ($globalDebug) { |
|
| 1667 | + echo "Owner Australia: Download..."; |
|
| 1668 | + } |
|
| 1425 | 1669 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 1426 | 1670 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1427 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1671 | + if ($globalDebug) { |
|
| 1672 | + echo "Add to DB..."; |
|
| 1673 | + } |
|
| 1428 | 1674 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 1429 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1675 | + } else { |
|
| 1676 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1677 | + } |
|
| 1430 | 1678 | if ($error != '') { |
| 1431 | 1679 | return $error; |
| 1432 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1433 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 1680 | + } elseif ($globalDebug) { |
|
| 1681 | + echo "Done\n"; |
|
| 1682 | + } |
|
| 1683 | + if ($globalDebug) { |
|
| 1684 | + echo "Owner Austria: Download..."; |
|
| 1685 | + } |
|
| 1434 | 1686 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 1435 | 1687 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1436 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1688 | + if ($globalDebug) { |
|
| 1689 | + echo "Add to DB..."; |
|
| 1690 | + } |
|
| 1437 | 1691 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 1438 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1692 | + } else { |
|
| 1693 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1694 | + } |
|
| 1439 | 1695 | if ($error != '') { |
| 1440 | 1696 | return $error; |
| 1441 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1442 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 1697 | + } elseif ($globalDebug) { |
|
| 1698 | + echo "Done\n"; |
|
| 1699 | + } |
|
| 1700 | + if ($globalDebug) { |
|
| 1701 | + echo "Owner Chile: Download..."; |
|
| 1702 | + } |
|
| 1443 | 1703 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 1444 | 1704 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1445 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1705 | + if ($globalDebug) { |
|
| 1706 | + echo "Add to DB..."; |
|
| 1707 | + } |
|
| 1446 | 1708 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 1447 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1709 | + } else { |
|
| 1710 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1711 | + } |
|
| 1448 | 1712 | if ($error != '') { |
| 1449 | 1713 | return $error; |
| 1450 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1451 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 1714 | + } elseif ($globalDebug) { |
|
| 1715 | + echo "Done\n"; |
|
| 1716 | + } |
|
| 1717 | + if ($globalDebug) { |
|
| 1718 | + echo "Owner Colombia: Download..."; |
|
| 1719 | + } |
|
| 1452 | 1720 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 1453 | 1721 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1454 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1722 | + if ($globalDebug) { |
|
| 1723 | + echo "Add to DB..."; |
|
| 1724 | + } |
|
| 1455 | 1725 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 1456 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1726 | + } else { |
|
| 1727 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1728 | + } |
|
| 1457 | 1729 | if ($error != '') { |
| 1458 | 1730 | return $error; |
| 1459 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1460 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1731 | + } elseif ($globalDebug) { |
|
| 1732 | + echo "Done\n"; |
|
| 1733 | + } |
|
| 1734 | + if ($globalDebug) { |
|
| 1735 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1736 | + } |
|
| 1461 | 1737 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 1462 | 1738 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1463 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1739 | + if ($globalDebug) { |
|
| 1740 | + echo "Add to DB..."; |
|
| 1741 | + } |
|
| 1464 | 1742 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 1465 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1743 | + } else { |
|
| 1744 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1745 | + } |
|
| 1466 | 1746 | if ($error != '') { |
| 1467 | 1747 | return $error; |
| 1468 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1469 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 1748 | + } elseif ($globalDebug) { |
|
| 1749 | + echo "Done\n"; |
|
| 1750 | + } |
|
| 1751 | + if ($globalDebug) { |
|
| 1752 | + echo "Owner Brazil: Download..."; |
|
| 1753 | + } |
|
| 1470 | 1754 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 1471 | 1755 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1472 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1756 | + if ($globalDebug) { |
|
| 1757 | + echo "Add to DB..."; |
|
| 1758 | + } |
|
| 1473 | 1759 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 1474 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1760 | + } else { |
|
| 1761 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1762 | + } |
|
| 1475 | 1763 | if ($error != '') { |
| 1476 | 1764 | return $error; |
| 1477 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1478 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 1765 | + } elseif ($globalDebug) { |
|
| 1766 | + echo "Done\n"; |
|
| 1767 | + } |
|
| 1768 | + if ($globalDebug) { |
|
| 1769 | + echo "Owner Cayman Islands: Download..."; |
|
| 1770 | + } |
|
| 1479 | 1771 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 1480 | 1772 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1481 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1773 | + if ($globalDebug) { |
|
| 1774 | + echo "Add to DB..."; |
|
| 1775 | + } |
|
| 1482 | 1776 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 1483 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1777 | + } else { |
|
| 1778 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1779 | + } |
|
| 1484 | 1780 | if ($error != '') { |
| 1485 | 1781 | return $error; |
| 1486 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1487 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 1782 | + } elseif ($globalDebug) { |
|
| 1783 | + echo "Done\n"; |
|
| 1784 | + } |
|
| 1785 | + if ($globalDebug) { |
|
| 1786 | + echo "Owner Croatia: Download..."; |
|
| 1787 | + } |
|
| 1488 | 1788 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 1489 | 1789 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1490 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1790 | + if ($globalDebug) { |
|
| 1791 | + echo "Add to DB..."; |
|
| 1792 | + } |
|
| 1491 | 1793 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 1492 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1794 | + } else { |
|
| 1795 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1796 | + } |
|
| 1493 | 1797 | if ($error != '') { |
| 1494 | 1798 | return $error; |
| 1495 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1496 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 1799 | + } elseif ($globalDebug) { |
|
| 1800 | + echo "Done\n"; |
|
| 1801 | + } |
|
| 1802 | + if ($globalDebug) { |
|
| 1803 | + echo "Owner Luxembourg: Download..."; |
|
| 1804 | + } |
|
| 1497 | 1805 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 1498 | 1806 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1499 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1807 | + if ($globalDebug) { |
|
| 1808 | + echo "Add to DB..."; |
|
| 1809 | + } |
|
| 1500 | 1810 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 1501 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1811 | + } else { |
|
| 1812 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1813 | + } |
|
| 1502 | 1814 | if ($error != '') { |
| 1503 | 1815 | return $error; |
| 1504 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1505 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 1816 | + } elseif ($globalDebug) { |
|
| 1817 | + echo "Done\n"; |
|
| 1818 | + } |
|
| 1819 | + if ($globalDebug) { |
|
| 1820 | + echo "Owner Maldives: Download..."; |
|
| 1821 | + } |
|
| 1506 | 1822 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 1507 | 1823 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1508 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1824 | + if ($globalDebug) { |
|
| 1825 | + echo "Add to DB..."; |
|
| 1826 | + } |
|
| 1509 | 1827 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 1510 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1828 | + } else { |
|
| 1829 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1830 | + } |
|
| 1511 | 1831 | if ($error != '') { |
| 1512 | 1832 | return $error; |
| 1513 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1514 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 1833 | + } elseif ($globalDebug) { |
|
| 1834 | + echo "Done\n"; |
|
| 1835 | + } |
|
| 1836 | + if ($globalDebug) { |
|
| 1837 | + echo "Owner New Zealand: Download..."; |
|
| 1838 | + } |
|
| 1515 | 1839 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 1516 | 1840 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1517 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1841 | + if ($globalDebug) { |
|
| 1842 | + echo "Add to DB..."; |
|
| 1843 | + } |
|
| 1518 | 1844 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 1519 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1845 | + } else { |
|
| 1846 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1847 | + } |
|
| 1520 | 1848 | if ($error != '') { |
| 1521 | 1849 | return $error; |
| 1522 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1523 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 1850 | + } elseif ($globalDebug) { |
|
| 1851 | + echo "Done\n"; |
|
| 1852 | + } |
|
| 1853 | + if ($globalDebug) { |
|
| 1854 | + echo "Owner Papua New Guinea: Download..."; |
|
| 1855 | + } |
|
| 1524 | 1856 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 1525 | 1857 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1526 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1858 | + if ($globalDebug) { |
|
| 1859 | + echo "Add to DB..."; |
|
| 1860 | + } |
|
| 1527 | 1861 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 1528 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1862 | + } else { |
|
| 1863 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1864 | + } |
|
| 1529 | 1865 | if ($error != '') { |
| 1530 | 1866 | return $error; |
| 1531 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1532 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 1867 | + } elseif ($globalDebug) { |
|
| 1868 | + echo "Done\n"; |
|
| 1869 | + } |
|
| 1870 | + if ($globalDebug) { |
|
| 1871 | + echo "Owner Slovakia: Download..."; |
|
| 1872 | + } |
|
| 1533 | 1873 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 1534 | 1874 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1535 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1875 | + if ($globalDebug) { |
|
| 1876 | + echo "Add to DB..."; |
|
| 1877 | + } |
|
| 1536 | 1878 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 1537 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1879 | + } else { |
|
| 1880 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1881 | + } |
|
| 1538 | 1882 | if ($error != '') { |
| 1539 | 1883 | return $error; |
| 1540 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1541 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 1884 | + } elseif ($globalDebug) { |
|
| 1885 | + echo "Done\n"; |
|
| 1886 | + } |
|
| 1887 | + if ($globalDebug) { |
|
| 1888 | + echo "Owner Ecuador: Download..."; |
|
| 1889 | + } |
|
| 1542 | 1890 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 1543 | 1891 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1544 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1892 | + if ($globalDebug) { |
|
| 1893 | + echo "Add to DB..."; |
|
| 1894 | + } |
|
| 1545 | 1895 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 1546 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1896 | + } else { |
|
| 1897 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1898 | + } |
|
| 1547 | 1899 | if ($error != '') { |
| 1548 | 1900 | return $error; |
| 1549 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1550 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 1901 | + } elseif ($globalDebug) { |
|
| 1902 | + echo "Done\n"; |
|
| 1903 | + } |
|
| 1904 | + if ($globalDebug) { |
|
| 1905 | + echo "Owner Iceland: Download..."; |
|
| 1906 | + } |
|
| 1551 | 1907 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 1552 | 1908 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1553 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1909 | + if ($globalDebug) { |
|
| 1910 | + echo "Add to DB..."; |
|
| 1911 | + } |
|
| 1554 | 1912 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 1555 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1913 | + } else { |
|
| 1914 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1915 | + } |
|
| 1556 | 1916 | if ($error != '') { |
| 1557 | 1917 | return $error; |
| 1558 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1918 | + } elseif ($globalDebug) { |
|
| 1919 | + echo "Done\n"; |
|
| 1920 | + } |
|
| 1559 | 1921 | return ''; |
| 1560 | 1922 | } |
| 1561 | 1923 | |
| 1562 | 1924 | public static function update_translation() { |
| 1563 | 1925 | global $tmp_dir, $globalDebug; |
| 1564 | 1926 | $error = ''; |
| 1565 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 1927 | + if ($globalDebug) { |
|
| 1928 | + echo "Translation : Download..."; |
|
| 1929 | + } |
|
| 1566 | 1930 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 1567 | 1931 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1568 | - if ($globalDebug) echo "Unzip..."; |
|
| 1932 | + if ($globalDebug) { |
|
| 1933 | + echo "Unzip..."; |
|
| 1934 | + } |
|
| 1569 | 1935 | update_db::unzip($tmp_dir.'translation.zip'); |
| 1570 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1936 | + if ($globalDebug) { |
|
| 1937 | + echo "Add to DB..."; |
|
| 1938 | + } |
|
| 1571 | 1939 | $error = update_db::translation(); |
| 1572 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1940 | + } else { |
|
| 1941 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1942 | + } |
|
| 1573 | 1943 | if ($error != '') { |
| 1574 | 1944 | return $error; |
| 1575 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1945 | + } elseif ($globalDebug) { |
|
| 1946 | + echo "Done\n"; |
|
| 1947 | + } |
|
| 1576 | 1948 | return ''; |
| 1577 | 1949 | } |
| 1578 | 1950 | |
| 1579 | 1951 | public static function update_translation_fam() { |
| 1580 | 1952 | global $tmp_dir, $globalDebug; |
| 1581 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 1953 | + if ($globalDebug) { |
|
| 1954 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 1955 | + } |
|
| 1582 | 1956 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 1583 | 1957 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1584 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1958 | + if ($globalDebug) { |
|
| 1959 | + echo "Gunzip..."; |
|
| 1960 | + } |
|
| 1585 | 1961 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 1586 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1962 | + if ($globalDebug) { |
|
| 1963 | + echo "Add to DB..."; |
|
| 1964 | + } |
|
| 1587 | 1965 | $error = update_db::translation_fam(); |
| 1588 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1966 | + } else { |
|
| 1967 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1968 | + } |
|
| 1589 | 1969 | if ($error != '') { |
| 1590 | 1970 | return $error; |
| 1591 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1971 | + } elseif ($globalDebug) { |
|
| 1972 | + echo "Done\n"; |
|
| 1973 | + } |
|
| 1592 | 1974 | return ''; |
| 1593 | 1975 | } |
| 1594 | 1976 | |
| 1595 | 1977 | public static function update_airspace_fam() { |
| 1596 | 1978 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 1597 | 1979 | include_once('class.create_db.php'); |
| 1598 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 1980 | + if ($globalDebug) { |
|
| 1981 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 1982 | + } |
|
| 1599 | 1983 | if ($globalDBdriver == 'mysql') { |
| 1600 | 1984 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 1601 | 1985 | } else { |
@@ -1611,9 +1995,13 @@ discard block |
||
| 1611 | 1995 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
| 1612 | 1996 | } |
| 1613 | 1997 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 1614 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1998 | + if ($globalDebug) { |
|
| 1999 | + echo "Gunzip..."; |
|
| 2000 | + } |
|
| 1615 | 2001 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 1616 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2002 | + if ($globalDebug) { |
|
| 2003 | + echo "Add to DB..."; |
|
| 2004 | + } |
|
| 1617 | 2005 | $Connection = new Connection(); |
| 1618 | 2006 | if ($Connection->tableExists('airspace')) { |
| 1619 | 2007 | $query = 'DROP TABLE airspace'; |
@@ -1626,31 +2014,47 @@ discard block |
||
| 1626 | 2014 | } |
| 1627 | 2015 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 1628 | 2016 | update_db::insert_airspace_version($airspace_md5); |
| 1629 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2017 | + } else { |
|
| 2018 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2019 | + } |
|
| 1630 | 2020 | } |
| 1631 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2021 | + } else { |
|
| 2022 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2023 | + } |
|
| 1632 | 2024 | if ($error != '') { |
| 1633 | 2025 | return $error; |
| 1634 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2026 | + } elseif ($globalDebug) { |
|
| 2027 | + echo "Done\n"; |
|
| 2028 | + } |
|
| 1635 | 2029 | return ''; |
| 1636 | 2030 | } |
| 1637 | 2031 | |
| 1638 | 2032 | public static function update_tle() { |
| 1639 | 2033 | global $tmp_dir, $globalDebug; |
| 1640 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 2034 | + if ($globalDebug) { |
|
| 2035 | + echo "Download TLE : Download..."; |
|
| 2036 | + } |
|
| 1641 | 2037 | $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', |
| 1642 | 2038 | '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', |
| 1643 | 2039 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
| 1644 | 2040 | foreach ($alltle as $filename) { |
| 1645 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 2041 | + if ($globalDebug) { |
|
| 2042 | + echo "downloading ".$filename.'...'; |
|
| 2043 | + } |
|
| 1646 | 2044 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 1647 | 2045 | if (file_exists($tmp_dir.$filename)) { |
| 1648 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 2046 | + if ($globalDebug) { |
|
| 2047 | + echo "Add to DB ".$filename."..."; |
|
| 2048 | + } |
|
| 1649 | 2049 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 1650 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2050 | + } else { |
|
| 2051 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2052 | + } |
|
| 1651 | 2053 | if ($error != '') { |
| 1652 | 2054 | echo $error."\n"; |
| 1653 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2055 | + } elseif ($globalDebug) { |
|
| 2056 | + echo "Done\n"; |
|
| 2057 | + } |
|
| 1654 | 2058 | } |
| 1655 | 2059 | return ''; |
| 1656 | 2060 | } |
@@ -1658,10 +2062,14 @@ discard block |
||
| 1658 | 2062 | public static function update_models() { |
| 1659 | 2063 | global $tmp_dir, $globalDebug; |
| 1660 | 2064 | $error = ''; |
| 1661 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 2065 | + if ($globalDebug) { |
|
| 2066 | + echo "Models from FlightAirMap website : Download..."; |
|
| 2067 | + } |
|
| 1662 | 2068 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 1663 | 2069 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 1664 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2070 | + if ($globalDebug) { |
|
| 2071 | + echo "Check files...\n"; |
|
| 2072 | + } |
|
| 1665 | 2073 | $newmodelsdb = array(); |
| 1666 | 2074 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 1667 | 2075 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1680,25 +2088,35 @@ discard block |
||
| 1680 | 2088 | } |
| 1681 | 2089 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 1682 | 2090 | foreach ($diff as $key => $value) { |
| 1683 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2091 | + if ($globalDebug) { |
|
| 2092 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2093 | + } |
|
| 1684 | 2094 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 1685 | 2095 | |
| 1686 | 2096 | } |
| 1687 | 2097 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 1688 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2098 | + } else { |
|
| 2099 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2100 | + } |
|
| 1689 | 2101 | if ($error != '') { |
| 1690 | 2102 | return $error; |
| 1691 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2103 | + } elseif ($globalDebug) { |
|
| 2104 | + echo "Done\n"; |
|
| 2105 | + } |
|
| 1692 | 2106 | return ''; |
| 1693 | 2107 | } |
| 1694 | 2108 | |
| 1695 | 2109 | public static function update_space_models() { |
| 1696 | 2110 | global $tmp_dir, $globalDebug; |
| 1697 | 2111 | $error = ''; |
| 1698 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 2112 | + if ($globalDebug) { |
|
| 2113 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 2114 | + } |
|
| 1699 | 2115 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 1700 | 2116 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 1701 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2117 | + if ($globalDebug) { |
|
| 2118 | + echo "Check files...\n"; |
|
| 2119 | + } |
|
| 1702 | 2120 | $newmodelsdb = array(); |
| 1703 | 2121 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 1704 | 2122 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1717,15 +2135,21 @@ discard block |
||
| 1717 | 2135 | } |
| 1718 | 2136 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 1719 | 2137 | foreach ($diff as $key => $value) { |
| 1720 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2138 | + if ($globalDebug) { |
|
| 2139 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2140 | + } |
|
| 1721 | 2141 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 1722 | 2142 | |
| 1723 | 2143 | } |
| 1724 | 2144 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 1725 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2145 | + } else { |
|
| 2146 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2147 | + } |
|
| 1726 | 2148 | if ($error != '') { |
| 1727 | 2149 | return $error; |
| 1728 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2150 | + } elseif ($globalDebug) { |
|
| 2151 | + echo "Done\n"; |
|
| 2152 | + } |
|
| 1729 | 2153 | return ''; |
| 1730 | 2154 | } |
| 1731 | 2155 | |
@@ -1768,7 +2192,9 @@ discard block |
||
| 1768 | 2192 | } |
| 1769 | 2193 | |
| 1770 | 2194 | $error = ''; |
| 1771 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 2195 | + if ($globalDebug) { |
|
| 2196 | + echo "Notam : Download..."; |
|
| 2197 | + } |
|
| 1772 | 2198 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 1773 | 2199 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1774 | 2200 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1783,14 +2209,30 @@ discard block |
||
| 1783 | 2209 | $data['fir'] = $q[0]; |
| 1784 | 2210 | $data['code'] = $q[1]; |
| 1785 | 2211 | $ifrvfr = $q[2]; |
| 1786 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 1787 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 1788 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 1789 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 1790 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 1791 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 1792 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 1793 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 2212 | + if ($ifrvfr == 'IV') { |
|
| 2213 | + $data['rules'] = 'IFR/VFR'; |
|
| 2214 | + } |
|
| 2215 | + if ($ifrvfr == 'I') { |
|
| 2216 | + $data['rules'] = 'IFR'; |
|
| 2217 | + } |
|
| 2218 | + if ($ifrvfr == 'V') { |
|
| 2219 | + $data['rules'] = 'VFR'; |
|
| 2220 | + } |
|
| 2221 | + if ($q[4] == 'A') { |
|
| 2222 | + $data['scope'] = 'Airport warning'; |
|
| 2223 | + } |
|
| 2224 | + if ($q[4] == 'E') { |
|
| 2225 | + $data['scope'] = 'Enroute warning'; |
|
| 2226 | + } |
|
| 2227 | + if ($q[4] == 'W') { |
|
| 2228 | + $data['scope'] = 'Navigation warning'; |
|
| 2229 | + } |
|
| 2230 | + if ($q[4] == 'AE') { |
|
| 2231 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 2232 | + } |
|
| 2233 | + if ($q[4] == 'AW') { |
|
| 2234 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 2235 | + } |
|
| 1794 | 2236 | //$data['scope'] = $q[4]; |
| 1795 | 2237 | $data['lower_limit'] = $q[5]; |
| 1796 | 2238 | $data['upper_limit'] = $q[6]; |
@@ -1798,8 +2240,12 @@ discard block |
||
| 1798 | 2240 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 1799 | 2241 | $latitude = $Common->convertDec($las,'latitude'); |
| 1800 | 2242 | $longitude = $Common->convertDec($lns,'longitude'); |
| 1801 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 1802 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 2243 | + if ($lac == 'S') { |
|
| 2244 | + $latitude = '-'.$latitude; |
|
| 2245 | + } |
|
| 2246 | + if ($lnc == 'W') { |
|
| 2247 | + $longitude = '-'.$longitude; |
|
| 2248 | + } |
|
| 1803 | 2249 | $data['center_latitude'] = $latitude; |
| 1804 | 2250 | $data['center_longitude'] = $longitude; |
| 1805 | 2251 | $data['radius'] = intval($radius); |
@@ -1829,10 +2275,14 @@ discard block |
||
| 1829 | 2275 | $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']); |
| 1830 | 2276 | unset($data); |
| 1831 | 2277 | } |
| 1832 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2278 | + } else { |
|
| 2279 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2280 | + } |
|
| 1833 | 2281 | if ($error != '') { |
| 1834 | 2282 | return $error; |
| 1835 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2283 | + } elseif ($globalDebug) { |
|
| 2284 | + echo "Done\n"; |
|
| 2285 | + } |
|
| 1836 | 2286 | return ''; |
| 1837 | 2287 | } |
| 1838 | 2288 | |
@@ -1857,7 +2307,9 @@ discard block |
||
| 1857 | 2307 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 1858 | 2308 | $airspace_json = json_decode($airspace_lst,true); |
| 1859 | 2309 | foreach ($airspace_json['records'] as $airspace) { |
| 1860 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 2310 | + if ($globalDebug) { |
|
| 2311 | + echo $airspace['name']."...\n"; |
|
| 2312 | + } |
|
| 1861 | 2313 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 1862 | 2314 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 1863 | 2315 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -1886,8 +2338,11 @@ discard block |
||
| 1886 | 2338 | return "error : ".$e->getMessage(); |
| 1887 | 2339 | } |
| 1888 | 2340 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1889 | - if ($row['nb'] > 0) return false; |
|
| 1890 | - else return true; |
|
| 2341 | + if ($row['nb'] > 0) { |
|
| 2342 | + return false; |
|
| 2343 | + } else { |
|
| 2344 | + return true; |
|
| 2345 | + } |
|
| 1891 | 2346 | } |
| 1892 | 2347 | |
| 1893 | 2348 | public static function insert_last_update() { |
@@ -1912,8 +2367,11 @@ discard block |
||
| 1912 | 2367 | return "error : ".$e->getMessage(); |
| 1913 | 2368 | } |
| 1914 | 2369 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1915 | - if ($row['nb'] > 0) return true; |
|
| 1916 | - else return false; |
|
| 2370 | + if ($row['nb'] > 0) { |
|
| 2371 | + return true; |
|
| 2372 | + } else { |
|
| 2373 | + return false; |
|
| 2374 | + } |
|
| 1917 | 2375 | } |
| 1918 | 2376 | |
| 1919 | 2377 | |
@@ -1944,8 +2402,11 @@ discard block |
||
| 1944 | 2402 | return "error : ".$e->getMessage(); |
| 1945 | 2403 | } |
| 1946 | 2404 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1947 | - if ($row['nb'] > 0) return false; |
|
| 1948 | - else return true; |
|
| 2405 | + if ($row['nb'] > 0) { |
|
| 2406 | + return false; |
|
| 2407 | + } else { |
|
| 2408 | + return true; |
|
| 2409 | + } |
|
| 1949 | 2410 | } |
| 1950 | 2411 | |
| 1951 | 2412 | public static function insert_last_notam_update() { |
@@ -1974,8 +2435,11 @@ discard block |
||
| 1974 | 2435 | return "error : ".$e->getMessage(); |
| 1975 | 2436 | } |
| 1976 | 2437 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1977 | - if ($row['nb'] > 0) return false; |
|
| 1978 | - else return true; |
|
| 2438 | + if ($row['nb'] > 0) { |
|
| 2439 | + return false; |
|
| 2440 | + } else { |
|
| 2441 | + return true; |
|
| 2442 | + } |
|
| 1979 | 2443 | } |
| 1980 | 2444 | |
| 1981 | 2445 | public static function insert_last_airspace_update() { |
@@ -2005,8 +2469,11 @@ discard block |
||
| 2005 | 2469 | return "error : ".$e->getMessage(); |
| 2006 | 2470 | } |
| 2007 | 2471 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2008 | - if ($row['nb'] > 0) return false; |
|
| 2009 | - else return true; |
|
| 2472 | + if ($row['nb'] > 0) { |
|
| 2473 | + return false; |
|
| 2474 | + } else { |
|
| 2475 | + return true; |
|
| 2476 | + } |
|
| 2010 | 2477 | } |
| 2011 | 2478 | |
| 2012 | 2479 | public static function insert_last_owner_update() { |
@@ -2035,8 +2502,11 @@ discard block |
||
| 2035 | 2502 | return "error : ".$e->getMessage(); |
| 2036 | 2503 | } |
| 2037 | 2504 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2038 | - if ($row['nb'] > 0) return false; |
|
| 2039 | - else return true; |
|
| 2505 | + if ($row['nb'] > 0) { |
|
| 2506 | + return false; |
|
| 2507 | + } else { |
|
| 2508 | + return true; |
|
| 2509 | + } |
|
| 2040 | 2510 | } |
| 2041 | 2511 | |
| 2042 | 2512 | public static function insert_last_schedules_update() { |
@@ -2065,8 +2535,11 @@ discard block |
||
| 2065 | 2535 | return "error : ".$e->getMessage(); |
| 2066 | 2536 | } |
| 2067 | 2537 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2068 | - if ($row['nb'] > 0) return false; |
|
| 2069 | - else return true; |
|
| 2538 | + if ($row['nb'] > 0) { |
|
| 2539 | + return false; |
|
| 2540 | + } else { |
|
| 2541 | + return true; |
|
| 2542 | + } |
|
| 2070 | 2543 | } |
| 2071 | 2544 | |
| 2072 | 2545 | public static function insert_last_tle_update() { |
@@ -146,20 +146,6 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | /** Predict first pass after a certain time. |
| 148 | 148 | * |
| 149 | - * @param Predict_Sat $sat The satellite data. |
|
| 150 | - * @param Predict_QTH $qth The observer's location data. |
|
| 151 | - * @param float $start Starting time. |
|
| 152 | - * @param int $maxdt The maximum number of days to look ahead (0 for no limit). |
|
| 153 | - * |
|
| 154 | - * @return Predict_Pass or NULL if there was an error. |
|
| 155 | - * |
|
| 156 | - * This function will find the first upcoming pass with AOS no earlier than |
|
| 157 | - * t = start and no later than t = (start+maxdt). |
|
| 158 | - * |
|
| 159 | - * note For no time limit use maxdt = 0.0 |
|
| 160 | - * |
|
| 161 | - * note the data in sat will be corrupt (future) and must be refreshed |
|
| 162 | - * by the caller, if the caller will need it later on |
|
| 163 | 149 | */ |
| 164 | 150 | public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt) |
| 165 | 151 | { |
@@ -407,7 +393,7 @@ discard block |
||
| 407 | 393 | * @param Predict_QTH $qth The observer's location (QTH) data. |
| 408 | 394 | * @param float $start The julian date where calculation should start. |
| 409 | 395 | * @param int $maxdt The upper time limit in days (0.0 = no limit) |
| 410 | - * @return The julain date of the next AOS or 0.0 if the satellite has no AOS. |
|
| 396 | + * @return double julain date of the next AOS or 0.0 if the satellite has no AOS. |
|
| 411 | 397 | * |
| 412 | 398 | * This function finds the time of AOS for the first coming pass taking place |
| 413 | 399 | * no earlier that start. |
@@ -563,7 +549,7 @@ discard block |
||
| 563 | 549 | * @param Predict_QTH $qth The QTH observer location data. |
| 564 | 550 | * @param float $start The time where calculation should start. (Julian Date) |
| 565 | 551 | * @param int $maxdt The upper time limit in days (0.0 = no limit) |
| 566 | - * @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS. |
|
| 552 | + * @return double time (julian date) of the next LOS or 0.0 if the satellite has no LOS. |
|
| 567 | 553 | * |
| 568 | 554 | * This function finds the time of LOS for the first coming pass taking place |
| 569 | 555 | * no earlier that start. |
@@ -648,7 +634,7 @@ discard block |
||
| 648 | 634 | * @param Predict_Sat $sat The satellite to find AOS for. |
| 649 | 635 | * @param Predict_QTH $qth The ground station. |
| 650 | 636 | * @param float $start Start time, prefereably now. |
| 651 | - * @return The time of the previous AOS or 0.0 if the satellite has no AOS. |
|
| 637 | + * @return double time of the previous AOS or 0.0 if the satellite has no AOS. |
|
| 652 | 638 | * |
| 653 | 639 | * This function can be used to find the AOS time in the past of the |
| 654 | 640 | * current pass. |
@@ -52,824 +52,824 @@ |
||
| 52 | 52 | */ |
| 53 | 53 | class Predict |
| 54 | 54 | { |
| 55 | - const de2ra = 1.74532925E-2; /* Degrees to Radians */ |
|
| 56 | - const pi = 3.1415926535898; /* Pi */ |
|
| 57 | - const pio2 = 1.5707963267949; /* Pi/2 */ |
|
| 58 | - const x3pio2 = 4.71238898; /* 3*Pi/2 */ |
|
| 59 | - const twopi = 6.2831853071796; /* 2*Pi */ |
|
| 60 | - const e6a = 1.0E-6; |
|
| 61 | - const tothrd = 6.6666667E-1; /* 2/3 */ |
|
| 62 | - const xj2 = 1.0826158E-3; /* J2 Harmonic */ |
|
| 63 | - const xj3 = -2.53881E-6; /* J3 Harmonic */ |
|
| 64 | - const xj4 = -1.65597E-6; /* J4 Harmonic */ |
|
| 65 | - const xke = 7.43669161E-2; |
|
| 66 | - const xkmper = 6.378135E3; /* Earth radius km */ |
|
| 67 | - const xmnpda = 1.44E3; /* Minutes per day */ |
|
| 68 | - const km2mi = 0.621371; /* Kilometers per Mile */ |
|
| 69 | - const ae = 1.0; |
|
| 70 | - const ck2 = 5.413079E-4; |
|
| 71 | - const ck4 = 6.209887E-7; |
|
| 72 | - const __f = 3.352779E-3; |
|
| 73 | - const ge = 3.986008E5; |
|
| 74 | - const __s__ = 1.012229; |
|
| 75 | - const qoms2t = 1.880279E-09; |
|
| 76 | - const secday = 8.6400E4; /* Seconds per day */ |
|
| 77 | - const omega_E = 1.0027379; |
|
| 78 | - const omega_ER = 6.3003879; |
|
| 79 | - const zns = 1.19459E-5; |
|
| 80 | - const c1ss = 2.9864797E-6; |
|
| 81 | - const zes = 1.675E-2; |
|
| 82 | - const znl = 1.5835218E-4; |
|
| 83 | - const c1l = 4.7968065E-7; |
|
| 84 | - const zel = 5.490E-2; |
|
| 85 | - const zcosis = 9.1744867E-1; |
|
| 86 | - const zsinis = 3.9785416E-1; |
|
| 87 | - const zsings = -9.8088458E-1; |
|
| 88 | - const zcosgs = 1.945905E-1; |
|
| 89 | - const zcoshs = 1; |
|
| 90 | - const zsinhs = 0; |
|
| 91 | - const q22 = 1.7891679E-6; |
|
| 92 | - const q31 = 2.1460748E-6; |
|
| 93 | - const q33 = 2.2123015E-7; |
|
| 94 | - const g22 = 5.7686396; |
|
| 95 | - const g32 = 9.5240898E-1; |
|
| 96 | - const g44 = 1.8014998; |
|
| 97 | - const g52 = 1.0508330; |
|
| 98 | - const g54 = 4.4108898; |
|
| 99 | - const root22 = 1.7891679E-6; |
|
| 100 | - const root32 = 3.7393792E-7; |
|
| 101 | - const root44 = 7.3636953E-9; |
|
| 102 | - const root52 = 1.1428639E-7; |
|
| 103 | - const root54 = 2.1765803E-9; |
|
| 104 | - const thdt = 4.3752691E-3; |
|
| 105 | - const rho = 1.5696615E-1; |
|
| 106 | - const mfactor = 7.292115E-5; |
|
| 107 | - const __sr__ = 6.96000E5; /*Solar radius - kilometers (IAU 76)*/ |
|
| 108 | - const AU = 1.49597870E8; /*Astronomical unit - kilometers (IAU 76)*/ |
|
| 109 | - |
|
| 110 | - /* visibility constants */ |
|
| 111 | - const SAT_VIS_NONE = 0; |
|
| 112 | - const SAT_VIS_VISIBLE = 1; |
|
| 113 | - const SAT_VIS_DAYLIGHT = 2; |
|
| 114 | - const SAT_VIS_ECLIPSED = 3; |
|
| 115 | - |
|
| 116 | - /* preferences */ |
|
| 117 | - public $minEle = 10; // Minimum elevation |
|
| 118 | - public $timeRes = 10; // Pass details: time resolution |
|
| 119 | - public $numEntries = 20; // Pass details: number of entries |
|
| 120 | - public $threshold = -6; // Twilight threshold |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Predict the next pass. |
|
| 124 | - * |
|
| 125 | - * This function simply wraps the get_pass function using the current time |
|
| 126 | - * as parameter. |
|
| 127 | - * |
|
| 128 | - * Note: the data in sat will be corrupt (future) and must be refreshed |
|
| 129 | - * by the caller, if the caller will need it later on (eg. if the caller |
|
| 130 | - * is GtkSatList). |
|
| 131 | - * |
|
| 132 | - * @param Predict_Sat $sat The satellite data. |
|
| 133 | - * @param Predict_QTH $qth The observer data. |
|
| 134 | - * @param int $maxdt The maximum number of days to look ahead. |
|
| 135 | - * |
|
| 136 | - * @return Predict_Pass Pointer instance or NULL if no pass can be |
|
| 137 | - * found. |
|
| 138 | - */ |
|
| 139 | - public function get_next_pass(Predict_Sat $sat, Predict_QTH $qth, $maxdt) |
|
| 140 | - { |
|
| 141 | - /* get the current time and call the get_pass function */ |
|
| 142 | - $now = Predict_Time::get_current_daynum(); |
|
| 143 | - |
|
| 144 | - return $this->get_pass($sat, $qth, $now, $maxdt); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** Predict first pass after a certain time. |
|
| 148 | - * |
|
| 149 | - * @param Predict_Sat $sat The satellite data. |
|
| 150 | - * @param Predict_QTH $qth The observer's location data. |
|
| 151 | - * @param float $start Starting time. |
|
| 152 | - * @param int $maxdt The maximum number of days to look ahead (0 for no limit). |
|
| 153 | - * |
|
| 154 | - * @return Predict_Pass or NULL if there was an error. |
|
| 155 | - * |
|
| 156 | - * This function will find the first upcoming pass with AOS no earlier than |
|
| 157 | - * t = start and no later than t = (start+maxdt). |
|
| 158 | - * |
|
| 159 | - * note For no time limit use maxdt = 0.0 |
|
| 160 | - * |
|
| 161 | - * note the data in sat will be corrupt (future) and must be refreshed |
|
| 162 | - * by the caller, if the caller will need it later on |
|
| 163 | - */ |
|
| 164 | - public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt) |
|
| 165 | - { |
|
| 166 | - $aos = 0.0; /* time of AOS */ |
|
| 167 | - $tca = 0.0; /* time of TCA */ |
|
| 168 | - $los = 0.0; /* time of LOS */ |
|
| 169 | - $dt = 0.0; /* time diff */ |
|
| 170 | - $step = 0.0; /* time step */ |
|
| 171 | - $t0 = $start; |
|
| 172 | - $tres = 0.0; /* required time resolution */ |
|
| 173 | - $max_el = 0.0; /* maximum elevation */ |
|
| 174 | - $pass = null; |
|
| 175 | - $detail = null; |
|
| 176 | - $done = false; |
|
| 177 | - $iter = 0; /* number of iterations */ |
|
| 178 | - /* FIXME: watchdog */ |
|
| 179 | - |
|
| 180 | - /*copy sat_in to a working structure*/ |
|
| 181 | - $sat = clone $sat_in; |
|
| 182 | - $sat_working = clone $sat_in; |
|
| 183 | - |
|
| 184 | - /* get time resolution; sat-cfg stores it in seconds */ |
|
| 185 | - $tres = $this->timeRes / 86400.0; |
|
| 186 | - |
|
| 187 | - /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL |
|
| 55 | + const de2ra = 1.74532925E-2; /* Degrees to Radians */ |
|
| 56 | + const pi = 3.1415926535898; /* Pi */ |
|
| 57 | + const pio2 = 1.5707963267949; /* Pi/2 */ |
|
| 58 | + const x3pio2 = 4.71238898; /* 3*Pi/2 */ |
|
| 59 | + const twopi = 6.2831853071796; /* 2*Pi */ |
|
| 60 | + const e6a = 1.0E-6; |
|
| 61 | + const tothrd = 6.6666667E-1; /* 2/3 */ |
|
| 62 | + const xj2 = 1.0826158E-3; /* J2 Harmonic */ |
|
| 63 | + const xj3 = -2.53881E-6; /* J3 Harmonic */ |
|
| 64 | + const xj4 = -1.65597E-6; /* J4 Harmonic */ |
|
| 65 | + const xke = 7.43669161E-2; |
|
| 66 | + const xkmper = 6.378135E3; /* Earth radius km */ |
|
| 67 | + const xmnpda = 1.44E3; /* Minutes per day */ |
|
| 68 | + const km2mi = 0.621371; /* Kilometers per Mile */ |
|
| 69 | + const ae = 1.0; |
|
| 70 | + const ck2 = 5.413079E-4; |
|
| 71 | + const ck4 = 6.209887E-7; |
|
| 72 | + const __f = 3.352779E-3; |
|
| 73 | + const ge = 3.986008E5; |
|
| 74 | + const __s__ = 1.012229; |
|
| 75 | + const qoms2t = 1.880279E-09; |
|
| 76 | + const secday = 8.6400E4; /* Seconds per day */ |
|
| 77 | + const omega_E = 1.0027379; |
|
| 78 | + const omega_ER = 6.3003879; |
|
| 79 | + const zns = 1.19459E-5; |
|
| 80 | + const c1ss = 2.9864797E-6; |
|
| 81 | + const zes = 1.675E-2; |
|
| 82 | + const znl = 1.5835218E-4; |
|
| 83 | + const c1l = 4.7968065E-7; |
|
| 84 | + const zel = 5.490E-2; |
|
| 85 | + const zcosis = 9.1744867E-1; |
|
| 86 | + const zsinis = 3.9785416E-1; |
|
| 87 | + const zsings = -9.8088458E-1; |
|
| 88 | + const zcosgs = 1.945905E-1; |
|
| 89 | + const zcoshs = 1; |
|
| 90 | + const zsinhs = 0; |
|
| 91 | + const q22 = 1.7891679E-6; |
|
| 92 | + const q31 = 2.1460748E-6; |
|
| 93 | + const q33 = 2.2123015E-7; |
|
| 94 | + const g22 = 5.7686396; |
|
| 95 | + const g32 = 9.5240898E-1; |
|
| 96 | + const g44 = 1.8014998; |
|
| 97 | + const g52 = 1.0508330; |
|
| 98 | + const g54 = 4.4108898; |
|
| 99 | + const root22 = 1.7891679E-6; |
|
| 100 | + const root32 = 3.7393792E-7; |
|
| 101 | + const root44 = 7.3636953E-9; |
|
| 102 | + const root52 = 1.1428639E-7; |
|
| 103 | + const root54 = 2.1765803E-9; |
|
| 104 | + const thdt = 4.3752691E-3; |
|
| 105 | + const rho = 1.5696615E-1; |
|
| 106 | + const mfactor = 7.292115E-5; |
|
| 107 | + const __sr__ = 6.96000E5; /*Solar radius - kilometers (IAU 76)*/ |
|
| 108 | + const AU = 1.49597870E8; /*Astronomical unit - kilometers (IAU 76)*/ |
|
| 109 | + |
|
| 110 | + /* visibility constants */ |
|
| 111 | + const SAT_VIS_NONE = 0; |
|
| 112 | + const SAT_VIS_VISIBLE = 1; |
|
| 113 | + const SAT_VIS_DAYLIGHT = 2; |
|
| 114 | + const SAT_VIS_ECLIPSED = 3; |
|
| 115 | + |
|
| 116 | + /* preferences */ |
|
| 117 | + public $minEle = 10; // Minimum elevation |
|
| 118 | + public $timeRes = 10; // Pass details: time resolution |
|
| 119 | + public $numEntries = 20; // Pass details: number of entries |
|
| 120 | + public $threshold = -6; // Twilight threshold |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Predict the next pass. |
|
| 124 | + * |
|
| 125 | + * This function simply wraps the get_pass function using the current time |
|
| 126 | + * as parameter. |
|
| 127 | + * |
|
| 128 | + * Note: the data in sat will be corrupt (future) and must be refreshed |
|
| 129 | + * by the caller, if the caller will need it later on (eg. if the caller |
|
| 130 | + * is GtkSatList). |
|
| 131 | + * |
|
| 132 | + * @param Predict_Sat $sat The satellite data. |
|
| 133 | + * @param Predict_QTH $qth The observer data. |
|
| 134 | + * @param int $maxdt The maximum number of days to look ahead. |
|
| 135 | + * |
|
| 136 | + * @return Predict_Pass Pointer instance or NULL if no pass can be |
|
| 137 | + * found. |
|
| 138 | + */ |
|
| 139 | + public function get_next_pass(Predict_Sat $sat, Predict_QTH $qth, $maxdt) |
|
| 140 | + { |
|
| 141 | + /* get the current time and call the get_pass function */ |
|
| 142 | + $now = Predict_Time::get_current_daynum(); |
|
| 143 | + |
|
| 144 | + return $this->get_pass($sat, $qth, $now, $maxdt); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** Predict first pass after a certain time. |
|
| 148 | + * |
|
| 149 | + * @param Predict_Sat $sat The satellite data. |
|
| 150 | + * @param Predict_QTH $qth The observer's location data. |
|
| 151 | + * @param float $start Starting time. |
|
| 152 | + * @param int $maxdt The maximum number of days to look ahead (0 for no limit). |
|
| 153 | + * |
|
| 154 | + * @return Predict_Pass or NULL if there was an error. |
|
| 155 | + * |
|
| 156 | + * This function will find the first upcoming pass with AOS no earlier than |
|
| 157 | + * t = start and no later than t = (start+maxdt). |
|
| 158 | + * |
|
| 159 | + * note For no time limit use maxdt = 0.0 |
|
| 160 | + * |
|
| 161 | + * note the data in sat will be corrupt (future) and must be refreshed |
|
| 162 | + * by the caller, if the caller will need it later on |
|
| 163 | + */ |
|
| 164 | + public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt) |
|
| 165 | + { |
|
| 166 | + $aos = 0.0; /* time of AOS */ |
|
| 167 | + $tca = 0.0; /* time of TCA */ |
|
| 168 | + $los = 0.0; /* time of LOS */ |
|
| 169 | + $dt = 0.0; /* time diff */ |
|
| 170 | + $step = 0.0; /* time step */ |
|
| 171 | + $t0 = $start; |
|
| 172 | + $tres = 0.0; /* required time resolution */ |
|
| 173 | + $max_el = 0.0; /* maximum elevation */ |
|
| 174 | + $pass = null; |
|
| 175 | + $detail = null; |
|
| 176 | + $done = false; |
|
| 177 | + $iter = 0; /* number of iterations */ |
|
| 178 | + /* FIXME: watchdog */ |
|
| 179 | + |
|
| 180 | + /*copy sat_in to a working structure*/ |
|
| 181 | + $sat = clone $sat_in; |
|
| 182 | + $sat_working = clone $sat_in; |
|
| 183 | + |
|
| 184 | + /* get time resolution; sat-cfg stores it in seconds */ |
|
| 185 | + $tres = $this->timeRes / 86400.0; |
|
| 186 | + |
|
| 187 | + /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL |
|
| 188 | 188 | or we run out of time |
| 189 | 189 | FIXME: we should have a safety break |
| 190 | 190 | */ |
| 191 | - while (!$done) { |
|
| 192 | - /* Find los of next pass or of current pass */ |
|
| 193 | - $los = $this->find_los($sat, $qth, $t0, $maxdt); // See if a pass is ongoing |
|
| 194 | - $aos = $this->find_aos($sat, $qth, $t0, $maxdt); |
|
| 195 | - /* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */ |
|
| 196 | - /* __FILE__, */ |
|
| 197 | - /* __FUNCTION__, */ |
|
| 198 | - /* __LINE__, */ |
|
| 199 | - /* aos, */ |
|
| 200 | - /* los, */ |
|
| 201 | - /* t0); */ |
|
| 202 | - if ($aos > $los) { |
|
| 203 | - // los is from an currently happening pass, find previous aos |
|
| 204 | - $aos = $this->find_prev_aos($sat, $qth, $t0); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /* aos = 0.0 means no aos */ |
|
| 208 | - if ($aos == 0.0) { |
|
| 209 | - $done = true; |
|
| 210 | - } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) { |
|
| 211 | - /* check whether we are within time limits; |
|
| 191 | + while (!$done) { |
|
| 192 | + /* Find los of next pass or of current pass */ |
|
| 193 | + $los = $this->find_los($sat, $qth, $t0, $maxdt); // See if a pass is ongoing |
|
| 194 | + $aos = $this->find_aos($sat, $qth, $t0, $maxdt); |
|
| 195 | + /* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */ |
|
| 196 | + /* __FILE__, */ |
|
| 197 | + /* __FUNCTION__, */ |
|
| 198 | + /* __LINE__, */ |
|
| 199 | + /* aos, */ |
|
| 200 | + /* los, */ |
|
| 201 | + /* t0); */ |
|
| 202 | + if ($aos > $los) { |
|
| 203 | + // los is from an currently happening pass, find previous aos |
|
| 204 | + $aos = $this->find_prev_aos($sat, $qth, $t0); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /* aos = 0.0 means no aos */ |
|
| 208 | + if ($aos == 0.0) { |
|
| 209 | + $done = true; |
|
| 210 | + } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) { |
|
| 211 | + /* check whether we are within time limits; |
|
| 212 | 212 | maxdt = 0 mean no time limit. |
| 213 | 213 | */ |
| 214 | - $done = true; |
|
| 215 | - } else { |
|
| 216 | - //los = find_los (sat, qth, aos + 0.001, maxdt); // +1.5 min later |
|
| 217 | - $dt = $los - $aos; |
|
| 214 | + $done = true; |
|
| 215 | + } else { |
|
| 216 | + //los = find_los (sat, qth, aos + 0.001, maxdt); // +1.5 min later |
|
| 217 | + $dt = $los - $aos; |
|
| 218 | 218 | |
| 219 | - /* get time step, which will give us the max number of entries */ |
|
| 220 | - $step = $dt / $this->numEntries; |
|
| 219 | + /* get time step, which will give us the max number of entries */ |
|
| 220 | + $step = $dt / $this->numEntries; |
|
| 221 | 221 | |
| 222 | - /* but if this is smaller than the required resolution |
|
| 222 | + /* but if this is smaller than the required resolution |
|
| 223 | 223 | we go with the resolution |
| 224 | 224 | */ |
| 225 | - if ($step < $tres) { |
|
| 226 | - $step = $tres; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /* create a pass_t entry; FIXME: g_try_new in 2.8 */ |
|
| 230 | - $pass = new Predict_Pass(); |
|
| 231 | - |
|
| 232 | - $pass->aos = $aos; |
|
| 233 | - $pass->los = $los; |
|
| 234 | - $pass->max_el = 0.0; |
|
| 235 | - $pass->aos_az = 0.0; |
|
| 236 | - $pass->los_az = 0.0; |
|
| 237 | - $pass->maxel_az = 0.0; |
|
| 238 | - $pass->vis = '---'; |
|
| 239 | - $pass->satname = $sat->nickname; |
|
| 240 | - $pass->details = array(); |
|
| 241 | - |
|
| 242 | - /* iterate over each time step */ |
|
| 243 | - for ($t = $pass->aos; $t <= $pass->los; $t += $step) { |
|
| 244 | - |
|
| 245 | - /* calculate satellite data */ |
|
| 246 | - $this->predict_calc($sat, $qth, $t); |
|
| 247 | - |
|
| 248 | - /* in the first iter we want to store |
|
| 225 | + if ($step < $tres) { |
|
| 226 | + $step = $tres; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /* create a pass_t entry; FIXME: g_try_new in 2.8 */ |
|
| 230 | + $pass = new Predict_Pass(); |
|
| 231 | + |
|
| 232 | + $pass->aos = $aos; |
|
| 233 | + $pass->los = $los; |
|
| 234 | + $pass->max_el = 0.0; |
|
| 235 | + $pass->aos_az = 0.0; |
|
| 236 | + $pass->los_az = 0.0; |
|
| 237 | + $pass->maxel_az = 0.0; |
|
| 238 | + $pass->vis = '---'; |
|
| 239 | + $pass->satname = $sat->nickname; |
|
| 240 | + $pass->details = array(); |
|
| 241 | + |
|
| 242 | + /* iterate over each time step */ |
|
| 243 | + for ($t = $pass->aos; $t <= $pass->los; $t += $step) { |
|
| 244 | + |
|
| 245 | + /* calculate satellite data */ |
|
| 246 | + $this->predict_calc($sat, $qth, $t); |
|
| 247 | + |
|
| 248 | + /* in the first iter we want to store |
|
| 249 | 249 | pass->aos_az |
| 250 | 250 | */ |
| 251 | - if ($t == $pass->aos) { |
|
| 252 | - $pass->aos_az = $sat->az; |
|
| 253 | - $pass->orbit = $sat->orbit; |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - /* append details to sat->details */ |
|
| 257 | - $detail = new Predict_PassDetail(); |
|
| 258 | - $detail->time = $t; |
|
| 259 | - $detail->pos->x = $sat->pos->x; |
|
| 260 | - $detail->pos->y = $sat->pos->y; |
|
| 261 | - $detail->pos->z = $sat->pos->z; |
|
| 262 | - $detail->pos->w = $sat->pos->w; |
|
| 263 | - $detail->vel->x = $sat->vel->x; |
|
| 264 | - $detail->vel->y = $sat->vel->y; |
|
| 265 | - $detail->vel->z = $sat->vel->z; |
|
| 266 | - $detail->vel->w = $sat->vel->w; |
|
| 267 | - $detail->velo = $sat->velo; |
|
| 268 | - $detail->az = $sat->az; |
|
| 269 | - $detail->el = $sat->el; |
|
| 270 | - $detail->range = $sat->range; |
|
| 271 | - $detail->range_rate = $sat->range_rate; |
|
| 272 | - $detail->lat = $sat->ssplat; |
|
| 273 | - $detail->lon = $sat->ssplon; |
|
| 274 | - $detail->alt = $sat->alt; |
|
| 275 | - $detail->ma = $sat->ma; |
|
| 276 | - $detail->phase = $sat->phase; |
|
| 277 | - $detail->footprint = $sat->footprint; |
|
| 278 | - $detail->orbit = $sat->orbit; |
|
| 279 | - $detail->vis = $this->get_sat_vis($sat, $qth, $t); |
|
| 280 | - |
|
| 281 | - /* also store visibility "bit" */ |
|
| 282 | - switch ($detail->vis) { |
|
| 283 | - case self::SAT_VIS_VISIBLE: |
|
| 284 | - $pass->vis[0] = 'V'; |
|
| 285 | - break; |
|
| 286 | - case self::SAT_VIS_DAYLIGHT: |
|
| 287 | - $pass->vis[1] = 'D'; |
|
| 288 | - break; |
|
| 289 | - case self::SAT_VIS_ECLIPSED: |
|
| 290 | - $pass->vis[2] = 'E'; |
|
| 291 | - break; |
|
| 292 | - default: |
|
| 293 | - break; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - // Using an array, no need to prepend and reverse the list |
|
| 297 | - // as gpredict does |
|
| 298 | - $pass->details[] = $detail; |
|
| 299 | - |
|
| 300 | - // Look up apparent magnitude if this is a visible pass |
|
| 301 | - if ($detail->vis === self::SAT_VIS_VISIBLE) { |
|
| 302 | - $apmag = $sat->calculateApparentMagnitude($t, $qth); |
|
| 303 | - if ($pass->max_apparent_magnitude === null || $apmag < $pass->max_apparent_magnitude) { |
|
| 304 | - $pass->max_apparent_magnitude = $apmag; |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - /* store elevation if greater than the |
|
| 251 | + if ($t == $pass->aos) { |
|
| 252 | + $pass->aos_az = $sat->az; |
|
| 253 | + $pass->orbit = $sat->orbit; |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + /* append details to sat->details */ |
|
| 257 | + $detail = new Predict_PassDetail(); |
|
| 258 | + $detail->time = $t; |
|
| 259 | + $detail->pos->x = $sat->pos->x; |
|
| 260 | + $detail->pos->y = $sat->pos->y; |
|
| 261 | + $detail->pos->z = $sat->pos->z; |
|
| 262 | + $detail->pos->w = $sat->pos->w; |
|
| 263 | + $detail->vel->x = $sat->vel->x; |
|
| 264 | + $detail->vel->y = $sat->vel->y; |
|
| 265 | + $detail->vel->z = $sat->vel->z; |
|
| 266 | + $detail->vel->w = $sat->vel->w; |
|
| 267 | + $detail->velo = $sat->velo; |
|
| 268 | + $detail->az = $sat->az; |
|
| 269 | + $detail->el = $sat->el; |
|
| 270 | + $detail->range = $sat->range; |
|
| 271 | + $detail->range_rate = $sat->range_rate; |
|
| 272 | + $detail->lat = $sat->ssplat; |
|
| 273 | + $detail->lon = $sat->ssplon; |
|
| 274 | + $detail->alt = $sat->alt; |
|
| 275 | + $detail->ma = $sat->ma; |
|
| 276 | + $detail->phase = $sat->phase; |
|
| 277 | + $detail->footprint = $sat->footprint; |
|
| 278 | + $detail->orbit = $sat->orbit; |
|
| 279 | + $detail->vis = $this->get_sat_vis($sat, $qth, $t); |
|
| 280 | + |
|
| 281 | + /* also store visibility "bit" */ |
|
| 282 | + switch ($detail->vis) { |
|
| 283 | + case self::SAT_VIS_VISIBLE: |
|
| 284 | + $pass->vis[0] = 'V'; |
|
| 285 | + break; |
|
| 286 | + case self::SAT_VIS_DAYLIGHT: |
|
| 287 | + $pass->vis[1] = 'D'; |
|
| 288 | + break; |
|
| 289 | + case self::SAT_VIS_ECLIPSED: |
|
| 290 | + $pass->vis[2] = 'E'; |
|
| 291 | + break; |
|
| 292 | + default: |
|
| 293 | + break; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + // Using an array, no need to prepend and reverse the list |
|
| 297 | + // as gpredict does |
|
| 298 | + $pass->details[] = $detail; |
|
| 299 | + |
|
| 300 | + // Look up apparent magnitude if this is a visible pass |
|
| 301 | + if ($detail->vis === self::SAT_VIS_VISIBLE) { |
|
| 302 | + $apmag = $sat->calculateApparentMagnitude($t, $qth); |
|
| 303 | + if ($pass->max_apparent_magnitude === null || $apmag < $pass->max_apparent_magnitude) { |
|
| 304 | + $pass->max_apparent_magnitude = $apmag; |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + /* store elevation if greater than the |
|
| 309 | 309 | previously stored one |
| 310 | 310 | */ |
| 311 | - if ($sat->el > $max_el) { |
|
| 312 | - $max_el = $sat->el; |
|
| 313 | - $tca = $t; |
|
| 314 | - $pass->maxel_az = $sat->az; |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /* g_print ("TIME: %f\tAZ: %f\tEL: %f (MAX: %f)\n", */ |
|
| 318 | - /* t, sat->az, sat->el, max_el); */ |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - /* calculate satellite data */ |
|
| 322 | - $this->predict_calc($sat, $qth, $pass->los); |
|
| 323 | - /* store los_az, max_el and tca */ |
|
| 324 | - $pass->los_az = $sat->az; |
|
| 325 | - $pass->max_el = $max_el; |
|
| 326 | - $pass->tca = $tca; |
|
| 327 | - |
|
| 328 | - /* check whether this pass is good */ |
|
| 329 | - if ($max_el >= $this->minEle) { |
|
| 330 | - $done = true; |
|
| 331 | - } else { |
|
| 332 | - $done = false; |
|
| 333 | - $t0 = $los + 0.014; // +20 min |
|
| 334 | - $pass = null; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - $iter++; |
|
| 338 | - } |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - return $pass; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * Calculate satellite visibility. |
|
| 346 | - * |
|
| 347 | - * @param Predict_Sat $sat The satellite structure. |
|
| 348 | - * @param Predict_QTH $qth The QTH |
|
| 349 | - * @param float $jul_utc The time at which the visibility should be calculated. |
|
| 350 | - * |
|
| 351 | - * @return int The visiblity constant, 0, 1, 2, or 3 (see above) |
|
| 352 | - */ |
|
| 353 | - public function get_sat_vis(Predict_Sat $sat, Predict_QTH $qth, $jul_utc) |
|
| 354 | - { |
|
| 355 | - /* gboolean sat_sun_status; |
|
| 311 | + if ($sat->el > $max_el) { |
|
| 312 | + $max_el = $sat->el; |
|
| 313 | + $tca = $t; |
|
| 314 | + $pass->maxel_az = $sat->az; |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /* g_print ("TIME: %f\tAZ: %f\tEL: %f (MAX: %f)\n", */ |
|
| 318 | + /* t, sat->az, sat->el, max_el); */ |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + /* calculate satellite data */ |
|
| 322 | + $this->predict_calc($sat, $qth, $pass->los); |
|
| 323 | + /* store los_az, max_el and tca */ |
|
| 324 | + $pass->los_az = $sat->az; |
|
| 325 | + $pass->max_el = $max_el; |
|
| 326 | + $pass->tca = $tca; |
|
| 327 | + |
|
| 328 | + /* check whether this pass is good */ |
|
| 329 | + if ($max_el >= $this->minEle) { |
|
| 330 | + $done = true; |
|
| 331 | + } else { |
|
| 332 | + $done = false; |
|
| 333 | + $t0 = $los + 0.014; // +20 min |
|
| 334 | + $pass = null; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + $iter++; |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + return $pass; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * Calculate satellite visibility. |
|
| 346 | + * |
|
| 347 | + * @param Predict_Sat $sat The satellite structure. |
|
| 348 | + * @param Predict_QTH $qth The QTH |
|
| 349 | + * @param float $jul_utc The time at which the visibility should be calculated. |
|
| 350 | + * |
|
| 351 | + * @return int The visiblity constant, 0, 1, 2, or 3 (see above) |
|
| 352 | + */ |
|
| 353 | + public function get_sat_vis(Predict_Sat $sat, Predict_QTH $qth, $jul_utc) |
|
| 354 | + { |
|
| 355 | + /* gboolean sat_sun_status; |
|
| 356 | 356 | gdouble sun_el; |
| 357 | 357 | gdouble threshold; |
| 358 | 358 | gdouble eclipse_depth; |
| 359 | 359 | sat_vis_t vis = SAT_VIS_NONE; */ |
| 360 | 360 | |
| 361 | - $eclipse_depth = 0.0; |
|
| 362 | - $zero_vector = new Predict_Vector(); |
|
| 363 | - $obs_geodetic = new Predict_Geodetic(); |
|
| 364 | - |
|
| 365 | - /* Solar ECI position vector */ |
|
| 366 | - $solar_vector = new Predict_Vector(); |
|
| 367 | - |
|
| 368 | - /* Solar observed az and el vector */ |
|
| 369 | - $solar_set = new Predict_ObsSet(); |
|
| 370 | - |
|
| 371 | - /* FIXME: could be passed as parameter */ |
|
| 372 | - $obs_geodetic->lon = $qth->lon * self::de2ra; |
|
| 373 | - $obs_geodetic->lat = $qth->lat * self::de2ra; |
|
| 374 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 375 | - $obs_geodetic->theta = 0; |
|
| 376 | - |
|
| 377 | - Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector); |
|
| 378 | - Predict_SGPObs::Calculate_Obs($jul_utc, $solar_vector, $zero_vector, $obs_geodetic, $solar_set); |
|
| 379 | - |
|
| 380 | - if (Predict_Solar::Sat_Eclipsed($sat->pos, $solar_vector, $eclipse_depth)) { |
|
| 381 | - /* satellite is eclipsed */ |
|
| 382 | - $sat_sun_status = false; |
|
| 383 | - } else { |
|
| 384 | - /* satellite in sunlight => may be visible */ |
|
| 385 | - $sat_sun_status = true; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - if ($sat_sun_status) { |
|
| 389 | - $sun_el = Predict_Math::Degrees($solar_set->el); |
|
| 390 | - |
|
| 391 | - if ($sun_el <= $this->threshold && $sat->el >= 0.0) { |
|
| 392 | - $vis = self::SAT_VIS_VISIBLE; |
|
| 393 | - } else { |
|
| 394 | - $vis = self::SAT_VIS_DAYLIGHT; |
|
| 395 | - } |
|
| 396 | - } else { |
|
| 397 | - $vis = self::SAT_VIS_ECLIPSED; |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - return $vis; |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - /** Find the AOS time of the next pass. |
|
| 404 | - * @author Alexandru Csete, OZ9AEC |
|
| 405 | - * @author John A. Magliacane, KD2BD |
|
| 406 | - * @param Predict_Sat $sat The satellite data. |
|
| 407 | - * @param Predict_QTH $qth The observer's location (QTH) data. |
|
| 408 | - * @param float $start The julian date where calculation should start. |
|
| 409 | - * @param int $maxdt The upper time limit in days (0.0 = no limit) |
|
| 410 | - * @return The julain date of the next AOS or 0.0 if the satellite has no AOS. |
|
| 411 | - * |
|
| 412 | - * This function finds the time of AOS for the first coming pass taking place |
|
| 413 | - * no earlier that start. |
|
| 414 | - * If the satellite is currently within range, the function first calls |
|
| 415 | - * find_los to get the next LOS time. Then the calculations are done using |
|
| 416 | - * the new start time. |
|
| 417 | - * |
|
| 418 | - */ |
|
| 419 | - public function find_aos(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt) |
|
| 420 | - { |
|
| 421 | - $t = $start; |
|
| 422 | - $aostime = 0.0; |
|
| 423 | - |
|
| 424 | - |
|
| 425 | - /* make sure current sat values are |
|
| 361 | + $eclipse_depth = 0.0; |
|
| 362 | + $zero_vector = new Predict_Vector(); |
|
| 363 | + $obs_geodetic = new Predict_Geodetic(); |
|
| 364 | + |
|
| 365 | + /* Solar ECI position vector */ |
|
| 366 | + $solar_vector = new Predict_Vector(); |
|
| 367 | + |
|
| 368 | + /* Solar observed az and el vector */ |
|
| 369 | + $solar_set = new Predict_ObsSet(); |
|
| 370 | + |
|
| 371 | + /* FIXME: could be passed as parameter */ |
|
| 372 | + $obs_geodetic->lon = $qth->lon * self::de2ra; |
|
| 373 | + $obs_geodetic->lat = $qth->lat * self::de2ra; |
|
| 374 | + $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 375 | + $obs_geodetic->theta = 0; |
|
| 376 | + |
|
| 377 | + Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector); |
|
| 378 | + Predict_SGPObs::Calculate_Obs($jul_utc, $solar_vector, $zero_vector, $obs_geodetic, $solar_set); |
|
| 379 | + |
|
| 380 | + if (Predict_Solar::Sat_Eclipsed($sat->pos, $solar_vector, $eclipse_depth)) { |
|
| 381 | + /* satellite is eclipsed */ |
|
| 382 | + $sat_sun_status = false; |
|
| 383 | + } else { |
|
| 384 | + /* satellite in sunlight => may be visible */ |
|
| 385 | + $sat_sun_status = true; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + if ($sat_sun_status) { |
|
| 389 | + $sun_el = Predict_Math::Degrees($solar_set->el); |
|
| 390 | + |
|
| 391 | + if ($sun_el <= $this->threshold && $sat->el >= 0.0) { |
|
| 392 | + $vis = self::SAT_VIS_VISIBLE; |
|
| 393 | + } else { |
|
| 394 | + $vis = self::SAT_VIS_DAYLIGHT; |
|
| 395 | + } |
|
| 396 | + } else { |
|
| 397 | + $vis = self::SAT_VIS_ECLIPSED; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + return $vis; |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + /** Find the AOS time of the next pass. |
|
| 404 | + * @author Alexandru Csete, OZ9AEC |
|
| 405 | + * @author John A. Magliacane, KD2BD |
|
| 406 | + * @param Predict_Sat $sat The satellite data. |
|
| 407 | + * @param Predict_QTH $qth The observer's location (QTH) data. |
|
| 408 | + * @param float $start The julian date where calculation should start. |
|
| 409 | + * @param int $maxdt The upper time limit in days (0.0 = no limit) |
|
| 410 | + * @return The julain date of the next AOS or 0.0 if the satellite has no AOS. |
|
| 411 | + * |
|
| 412 | + * This function finds the time of AOS for the first coming pass taking place |
|
| 413 | + * no earlier that start. |
|
| 414 | + * If the satellite is currently within range, the function first calls |
|
| 415 | + * find_los to get the next LOS time. Then the calculations are done using |
|
| 416 | + * the new start time. |
|
| 417 | + * |
|
| 418 | + */ |
|
| 419 | + public function find_aos(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt) |
|
| 420 | + { |
|
| 421 | + $t = $start; |
|
| 422 | + $aostime = 0.0; |
|
| 423 | + |
|
| 424 | + |
|
| 425 | + /* make sure current sat values are |
|
| 426 | 426 | in sync with the time |
| 427 | 427 | */ |
| 428 | - $this->predict_calc($sat, $qth, $start); |
|
| 429 | - |
|
| 430 | - /* check whether satellite has aos */ |
|
| 431 | - if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 432 | - ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 433 | - !$this->has_aos($sat, $qth)) { |
|
| 434 | - |
|
| 435 | - return 0.0; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - if ($sat->el > 0.0) { |
|
| 439 | - $t = $this->find_los($sat, $qth, $start, $maxdt) + 0.014; // +20 min |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - /* invalid time (potentially returned by find_los) */ |
|
| 443 | - if ($t < 0.1) { |
|
| 444 | - return 0.0; |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - /* update satellite data */ |
|
| 448 | - $this->predict_calc($sat, $qth, $t); |
|
| 449 | - |
|
| 450 | - /* use upper time limit */ |
|
| 451 | - if ($maxdt > 0.0) { |
|
| 452 | - |
|
| 453 | - /* coarse time steps */ |
|
| 454 | - while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) { |
|
| 455 | - $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 456 | - $this->predict_calc($sat, $qth, $t); |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - /* fine steps */ |
|
| 460 | - while (($aostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 461 | - |
|
| 462 | - if (abs($sat->el) < 0.005) { |
|
| 463 | - $aostime = $t; |
|
| 464 | - } else { |
|
| 465 | - $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 466 | - $this->predict_calc($sat, $qth, $t); |
|
| 467 | - } |
|
| 468 | - } |
|
| 469 | - } else { |
|
| 470 | - /* don't use upper time limit */ |
|
| 471 | - |
|
| 472 | - /* coarse time steps */ |
|
| 473 | - while ($sat->el < -1.0) { |
|
| 474 | - |
|
| 475 | - $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 476 | - $this->predict_calc($sat, $qth, $t); |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - /* fine steps */ |
|
| 480 | - while ($aostime == 0.0) { |
|
| 481 | - |
|
| 482 | - if (abs($sat->el) < 0.005) { |
|
| 483 | - $aostime = $t; |
|
| 484 | - } else { |
|
| 485 | - $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 486 | - $this->predict_calc($sat, $qth, $t); |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - return $aostime; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - /** SGP4SDP4 driver for doing AOS/LOS calculations. |
|
| 496 | - * @param Predict_Sat $sat The satellite data. |
|
| 497 | - * @param Predict_QTH $qth The QTH observer location data. |
|
| 498 | - * @param float $t The time for calculation (Julian Date) |
|
| 499 | - * |
|
| 500 | - */ |
|
| 501 | - public function predict_calc(Predict_Sat $sat, Predict_QTH $qth, $t) |
|
| 502 | - { |
|
| 503 | - $obs_set = new Predict_ObsSet(); |
|
| 504 | - $sat_geodetic = new Predict_Geodetic(); |
|
| 505 | - $obs_geodetic = new Predict_Geodetic(); |
|
| 506 | - |
|
| 507 | - $obs_geodetic->lon = $qth->lon * self::de2ra; |
|
| 508 | - $obs_geodetic->lat = $qth->lat * self::de2ra; |
|
| 509 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 510 | - $obs_geodetic->theta = 0; |
|
| 511 | - |
|
| 512 | - $sat->jul_utc = $t; |
|
| 513 | - $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda; |
|
| 514 | - |
|
| 515 | - /* call the norad routines according to the deep-space flag */ |
|
| 516 | - $sgpsdp = Predict_SGPSDP::getInstance($sat); |
|
| 517 | - if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 518 | - $sgpsdp->SDP4($sat, $sat->tsince); |
|
| 519 | - } else { |
|
| 520 | - $sgpsdp->SGP4($sat, $sat->tsince); |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
|
| 524 | - |
|
| 525 | - /* get the velocity of the satellite */ |
|
| 526 | - $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 527 | - $sat->velo = $sat->vel->w; |
|
| 528 | - Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
|
| 529 | - Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic); |
|
| 530 | - |
|
| 531 | - while ($sat_geodetic->lon < -self::pi) { |
|
| 532 | - $sat_geodetic->lon += self::twopi; |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - while ($sat_geodetic->lon > (self::pi)) { |
|
| 536 | - $sat_geodetic->lon -= self::twopi; |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - $sat->az = Predict_Math::Degrees($obs_set->az); |
|
| 540 | - $sat->el = Predict_Math::Degrees($obs_set->el); |
|
| 541 | - $sat->range = $obs_set->range; |
|
| 542 | - $sat->range_rate = $obs_set->range_rate; |
|
| 543 | - $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); |
|
| 544 | - $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
|
| 545 | - $sat->alt = $sat_geodetic->alt; |
|
| 546 | - $sat->ma = Predict_Math::Degrees($sat->phase); |
|
| 547 | - $sat->ma *= 256.0 / 360.0; |
|
| 548 | - $sat->phase = Predict_Math::Degrees($sat->phase); |
|
| 549 | - |
|
| 550 | - /* same formulas, but the one from predict is nicer */ |
|
| 551 | - //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); |
|
| 552 | - $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt)); |
|
| 553 | - $age = $sat->jul_utc - $sat->jul_epoch; |
|
| 554 | - $sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi + |
|
| 555 | - $age * $sat->tle->bstar * self::ae) * $age + |
|
| 556 | - $sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1; |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - /** Find the LOS time of the next pass. |
|
| 560 | - * @author Alexandru Csete, OZ9AEC |
|
| 561 | - * @author John A. Magliacane, KD2BD |
|
| 562 | - * @param Predict_Sat $sat The satellite data. |
|
| 563 | - * @param Predict_QTH $qth The QTH observer location data. |
|
| 564 | - * @param float $start The time where calculation should start. (Julian Date) |
|
| 565 | - * @param int $maxdt The upper time limit in days (0.0 = no limit) |
|
| 566 | - * @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS. |
|
| 567 | - * |
|
| 568 | - * This function finds the time of LOS for the first coming pass taking place |
|
| 569 | - * no earlier that start. |
|
| 570 | - * If the satellite is currently out of range, the function first calls |
|
| 571 | - * find_aos to get the next AOS time. Then the calculations are done using |
|
| 572 | - * the new start time. |
|
| 573 | - * The function has a built-in watchdog to ensure that we don't end up in |
|
| 574 | - * lengthy loops. |
|
| 575 | - * |
|
| 576 | - */ |
|
| 577 | - public function find_los(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt) |
|
| 578 | - { |
|
| 579 | - $t = $start; |
|
| 580 | - $lostime = 0.0; |
|
| 581 | - |
|
| 582 | - |
|
| 583 | - $this->predict_calc($sat, $qth, $start); |
|
| 584 | - |
|
| 585 | - /* check whether satellite has aos */ |
|
| 586 | - if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 587 | - ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 588 | - !$this->has_aos ($sat, $qth)) { |
|
| 589 | - |
|
| 590 | - return 0.0; |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - if ($sat->el < 0.0) { |
|
| 594 | - $t = $this->find_aos($sat, $qth, $start, $maxdt) + 0.001; // +1.5 min |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - /* invalid time (potentially returned by find_aos) */ |
|
| 598 | - if ($t < 0.01) { |
|
| 599 | - return 0.0; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - /* update satellite data */ |
|
| 603 | - $this->predict_calc($sat, $qth, $t); |
|
| 604 | - |
|
| 605 | - /* use upper time limit */ |
|
| 606 | - if ($maxdt > 0.0) { |
|
| 607 | - |
|
| 608 | - /* coarse steps */ |
|
| 609 | - while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) { |
|
| 610 | - $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 611 | - $this->predict_calc($sat, $qth, $t); |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - /* fine steps */ |
|
| 615 | - while (($lostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 616 | - |
|
| 617 | - $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 618 | - $this->predict_calc($sat, $qth, $t); |
|
| 619 | - |
|
| 620 | - if (abs($sat->el) < 0.005) { |
|
| 621 | - $lostime = $t; |
|
| 622 | - } |
|
| 623 | - } |
|
| 624 | - } else { |
|
| 625 | - /* don't use upper limit */ |
|
| 626 | - |
|
| 627 | - /* coarse steps */ |
|
| 628 | - while ($sat->el >= 1.0) { |
|
| 629 | - $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 630 | - $this->predict_calc($sat, $qth, $t); |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - /* fine steps */ |
|
| 634 | - while ($lostime == 0.0) { |
|
| 635 | - |
|
| 636 | - $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 637 | - $this->predict_calc($sat, $qth, $t); |
|
| 638 | - |
|
| 639 | - if (abs($sat->el) < 0.005) |
|
| 640 | - $lostime = $t; |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - |
|
| 644 | - return $lostime; |
|
| 645 | - } |
|
| 646 | - |
|
| 647 | - /** Find AOS time of current pass. |
|
| 648 | - * @param Predict_Sat $sat The satellite to find AOS for. |
|
| 649 | - * @param Predict_QTH $qth The ground station. |
|
| 650 | - * @param float $start Start time, prefereably now. |
|
| 651 | - * @return The time of the previous AOS or 0.0 if the satellite has no AOS. |
|
| 652 | - * |
|
| 653 | - * This function can be used to find the AOS time in the past of the |
|
| 654 | - * current pass. |
|
| 655 | - */ |
|
| 656 | - public function find_prev_aos(Predict_Sat $sat, Predict_QTH $qth, $start) |
|
| 657 | - { |
|
| 658 | - $aostime = $start; |
|
| 659 | - |
|
| 660 | - /* make sure current sat values are |
|
| 428 | + $this->predict_calc($sat, $qth, $start); |
|
| 429 | + |
|
| 430 | + /* check whether satellite has aos */ |
|
| 431 | + if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 432 | + ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 433 | + !$this->has_aos($sat, $qth)) { |
|
| 434 | + |
|
| 435 | + return 0.0; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + if ($sat->el > 0.0) { |
|
| 439 | + $t = $this->find_los($sat, $qth, $start, $maxdt) + 0.014; // +20 min |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + /* invalid time (potentially returned by find_los) */ |
|
| 443 | + if ($t < 0.1) { |
|
| 444 | + return 0.0; |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + /* update satellite data */ |
|
| 448 | + $this->predict_calc($sat, $qth, $t); |
|
| 449 | + |
|
| 450 | + /* use upper time limit */ |
|
| 451 | + if ($maxdt > 0.0) { |
|
| 452 | + |
|
| 453 | + /* coarse time steps */ |
|
| 454 | + while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) { |
|
| 455 | + $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 456 | + $this->predict_calc($sat, $qth, $t); |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + /* fine steps */ |
|
| 460 | + while (($aostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 461 | + |
|
| 462 | + if (abs($sat->el) < 0.005) { |
|
| 463 | + $aostime = $t; |
|
| 464 | + } else { |
|
| 465 | + $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 466 | + $this->predict_calc($sat, $qth, $t); |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + } else { |
|
| 470 | + /* don't use upper time limit */ |
|
| 471 | + |
|
| 472 | + /* coarse time steps */ |
|
| 473 | + while ($sat->el < -1.0) { |
|
| 474 | + |
|
| 475 | + $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 476 | + $this->predict_calc($sat, $qth, $t); |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + /* fine steps */ |
|
| 480 | + while ($aostime == 0.0) { |
|
| 481 | + |
|
| 482 | + if (abs($sat->el) < 0.005) { |
|
| 483 | + $aostime = $t; |
|
| 484 | + } else { |
|
| 485 | + $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 486 | + $this->predict_calc($sat, $qth, $t); |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + return $aostime; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + /** SGP4SDP4 driver for doing AOS/LOS calculations. |
|
| 496 | + * @param Predict_Sat $sat The satellite data. |
|
| 497 | + * @param Predict_QTH $qth The QTH observer location data. |
|
| 498 | + * @param float $t The time for calculation (Julian Date) |
|
| 499 | + * |
|
| 500 | + */ |
|
| 501 | + public function predict_calc(Predict_Sat $sat, Predict_QTH $qth, $t) |
|
| 502 | + { |
|
| 503 | + $obs_set = new Predict_ObsSet(); |
|
| 504 | + $sat_geodetic = new Predict_Geodetic(); |
|
| 505 | + $obs_geodetic = new Predict_Geodetic(); |
|
| 506 | + |
|
| 507 | + $obs_geodetic->lon = $qth->lon * self::de2ra; |
|
| 508 | + $obs_geodetic->lat = $qth->lat * self::de2ra; |
|
| 509 | + $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 510 | + $obs_geodetic->theta = 0; |
|
| 511 | + |
|
| 512 | + $sat->jul_utc = $t; |
|
| 513 | + $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda; |
|
| 514 | + |
|
| 515 | + /* call the norad routines according to the deep-space flag */ |
|
| 516 | + $sgpsdp = Predict_SGPSDP::getInstance($sat); |
|
| 517 | + if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 518 | + $sgpsdp->SDP4($sat, $sat->tsince); |
|
| 519 | + } else { |
|
| 520 | + $sgpsdp->SGP4($sat, $sat->tsince); |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
|
| 524 | + |
|
| 525 | + /* get the velocity of the satellite */ |
|
| 526 | + $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 527 | + $sat->velo = $sat->vel->w; |
|
| 528 | + Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
|
| 529 | + Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic); |
|
| 530 | + |
|
| 531 | + while ($sat_geodetic->lon < -self::pi) { |
|
| 532 | + $sat_geodetic->lon += self::twopi; |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + while ($sat_geodetic->lon > (self::pi)) { |
|
| 536 | + $sat_geodetic->lon -= self::twopi; |
|
| 537 | + } |
|
| 538 | + |
|
| 539 | + $sat->az = Predict_Math::Degrees($obs_set->az); |
|
| 540 | + $sat->el = Predict_Math::Degrees($obs_set->el); |
|
| 541 | + $sat->range = $obs_set->range; |
|
| 542 | + $sat->range_rate = $obs_set->range_rate; |
|
| 543 | + $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); |
|
| 544 | + $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
|
| 545 | + $sat->alt = $sat_geodetic->alt; |
|
| 546 | + $sat->ma = Predict_Math::Degrees($sat->phase); |
|
| 547 | + $sat->ma *= 256.0 / 360.0; |
|
| 548 | + $sat->phase = Predict_Math::Degrees($sat->phase); |
|
| 549 | + |
|
| 550 | + /* same formulas, but the one from predict is nicer */ |
|
| 551 | + //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); |
|
| 552 | + $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt)); |
|
| 553 | + $age = $sat->jul_utc - $sat->jul_epoch; |
|
| 554 | + $sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi + |
|
| 555 | + $age * $sat->tle->bstar * self::ae) * $age + |
|
| 556 | + $sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1; |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + /** Find the LOS time of the next pass. |
|
| 560 | + * @author Alexandru Csete, OZ9AEC |
|
| 561 | + * @author John A. Magliacane, KD2BD |
|
| 562 | + * @param Predict_Sat $sat The satellite data. |
|
| 563 | + * @param Predict_QTH $qth The QTH observer location data. |
|
| 564 | + * @param float $start The time where calculation should start. (Julian Date) |
|
| 565 | + * @param int $maxdt The upper time limit in days (0.0 = no limit) |
|
| 566 | + * @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS. |
|
| 567 | + * |
|
| 568 | + * This function finds the time of LOS for the first coming pass taking place |
|
| 569 | + * no earlier that start. |
|
| 570 | + * If the satellite is currently out of range, the function first calls |
|
| 571 | + * find_aos to get the next AOS time. Then the calculations are done using |
|
| 572 | + * the new start time. |
|
| 573 | + * The function has a built-in watchdog to ensure that we don't end up in |
|
| 574 | + * lengthy loops. |
|
| 575 | + * |
|
| 576 | + */ |
|
| 577 | + public function find_los(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt) |
|
| 578 | + { |
|
| 579 | + $t = $start; |
|
| 580 | + $lostime = 0.0; |
|
| 581 | + |
|
| 582 | + |
|
| 583 | + $this->predict_calc($sat, $qth, $start); |
|
| 584 | + |
|
| 585 | + /* check whether satellite has aos */ |
|
| 586 | + if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 587 | + ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 588 | + !$this->has_aos ($sat, $qth)) { |
|
| 589 | + |
|
| 590 | + return 0.0; |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + if ($sat->el < 0.0) { |
|
| 594 | + $t = $this->find_aos($sat, $qth, $start, $maxdt) + 0.001; // +1.5 min |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + /* invalid time (potentially returned by find_aos) */ |
|
| 598 | + if ($t < 0.01) { |
|
| 599 | + return 0.0; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + /* update satellite data */ |
|
| 603 | + $this->predict_calc($sat, $qth, $t); |
|
| 604 | + |
|
| 605 | + /* use upper time limit */ |
|
| 606 | + if ($maxdt > 0.0) { |
|
| 607 | + |
|
| 608 | + /* coarse steps */ |
|
| 609 | + while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) { |
|
| 610 | + $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 611 | + $this->predict_calc($sat, $qth, $t); |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + /* fine steps */ |
|
| 615 | + while (($lostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 616 | + |
|
| 617 | + $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 618 | + $this->predict_calc($sat, $qth, $t); |
|
| 619 | + |
|
| 620 | + if (abs($sat->el) < 0.005) { |
|
| 621 | + $lostime = $t; |
|
| 622 | + } |
|
| 623 | + } |
|
| 624 | + } else { |
|
| 625 | + /* don't use upper limit */ |
|
| 626 | + |
|
| 627 | + /* coarse steps */ |
|
| 628 | + while ($sat->el >= 1.0) { |
|
| 629 | + $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 630 | + $this->predict_calc($sat, $qth, $t); |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + /* fine steps */ |
|
| 634 | + while ($lostime == 0.0) { |
|
| 635 | + |
|
| 636 | + $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 637 | + $this->predict_calc($sat, $qth, $t); |
|
| 638 | + |
|
| 639 | + if (abs($sat->el) < 0.005) |
|
| 640 | + $lostime = $t; |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + |
|
| 644 | + return $lostime; |
|
| 645 | + } |
|
| 646 | + |
|
| 647 | + /** Find AOS time of current pass. |
|
| 648 | + * @param Predict_Sat $sat The satellite to find AOS for. |
|
| 649 | + * @param Predict_QTH $qth The ground station. |
|
| 650 | + * @param float $start Start time, prefereably now. |
|
| 651 | + * @return The time of the previous AOS or 0.0 if the satellite has no AOS. |
|
| 652 | + * |
|
| 653 | + * This function can be used to find the AOS time in the past of the |
|
| 654 | + * current pass. |
|
| 655 | + */ |
|
| 656 | + public function find_prev_aos(Predict_Sat $sat, Predict_QTH $qth, $start) |
|
| 657 | + { |
|
| 658 | + $aostime = $start; |
|
| 659 | + |
|
| 660 | + /* make sure current sat values are |
|
| 661 | 661 | in sync with the time |
| 662 | 662 | */ |
| 663 | - $this->predict_calc($sat, $qth, $start); |
|
| 664 | - |
|
| 665 | - /* check whether satellite has aos */ |
|
| 666 | - if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 667 | - ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 668 | - !$this->has_aos($sat, $qth)) { |
|
| 669 | - |
|
| 670 | - return 0.0; |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - while ($sat->el >= 0.0) { |
|
| 674 | - $aostime -= 0.0005; // 0.75 min |
|
| 675 | - $this->predict_calc($sat, $qth, $aostime); |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - return $aostime; |
|
| 679 | - } |
|
| 680 | - |
|
| 681 | - /** Determine whether satellite ever reaches AOS. |
|
| 682 | - * @author John A. Magliacane, KD2BD |
|
| 683 | - * @author Alexandru Csete, OZ9AEC |
|
| 684 | - * @param Predict_Sat $sat The satellite data. |
|
| 685 | - * @param Predict_QTH $qth The observer's location data |
|
| 686 | - * @return bool true if the satellite will reach AOS, false otherwise. |
|
| 687 | - * |
|
| 688 | - */ |
|
| 689 | - public function has_aos(Predict_Sat $sat, Predict_QTH $qth) |
|
| 690 | - { |
|
| 691 | - $retcode = false; |
|
| 692 | - |
|
| 693 | - /* FIXME */ |
|
| 694 | - if ($sat->meanmo == 0.0) { |
|
| 695 | - $retcode = false; |
|
| 696 | - } else { |
|
| 697 | - |
|
| 698 | - /* xincl is already in RAD by select_ephemeris */ |
|
| 699 | - $lin = $sat->tle->xincl; |
|
| 700 | - if ($lin >= self::pio2) { |
|
| 701 | - $lin = self::pi - $lin; |
|
| 702 | - } |
|
| 703 | - |
|
| 704 | - $sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0)); |
|
| 705 | - $apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper; |
|
| 706 | - |
|
| 707 | - if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) { |
|
| 708 | - $retcode = true; |
|
| 709 | - } else { |
|
| 710 | - $retcode = false; |
|
| 711 | - } |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - return $retcode; |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - /** Predict passes after a certain time. |
|
| 718 | - * |
|
| 719 | - * |
|
| 720 | - * This function calculates num upcoming passes with AOS no earlier |
|
| 721 | - * than t = start and not later that t = (start+maxdt). The function will |
|
| 722 | - * repeatedly call get_pass until |
|
| 723 | - * the number of predicted passes is equal to num, the time has reached |
|
| 724 | - * limit or the get_pass function returns NULL. |
|
| 725 | - * |
|
| 726 | - * note For no time limit use maxdt = 0.0 |
|
| 727 | - * |
|
| 728 | - * note the data in sat will be corrupt (future) and must be refreshed |
|
| 729 | - * by the caller, if the caller will need it later on (eg. if the caller |
|
| 730 | - * is GtkSatList). |
|
| 731 | - * |
|
| 732 | - * note Prepending to a singly linked list is much faster than appending. |
|
| 733 | - * Therefore, the elements are prepended whereafter the GSList is |
|
| 734 | - * reversed |
|
| 735 | - * |
|
| 736 | - * |
|
| 737 | - * @param Predict_Sat $sat The satellite data |
|
| 738 | - * @param Predict_QTH $qth The observer's location data |
|
| 739 | - * @param float $start The start julian date |
|
| 740 | - * @param int $maxdt The max # of days to look |
|
| 741 | - * @param int $num The max # of passes to get |
|
| 742 | - * @return array of Predict_Pass instances if found, empty array otherwise |
|
| 743 | - */ |
|
| 744 | - public function get_passes(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt, $num = 0) |
|
| 745 | - { |
|
| 746 | - $passes = array(); |
|
| 747 | - |
|
| 748 | - /* if no number has been specified |
|
| 663 | + $this->predict_calc($sat, $qth, $start); |
|
| 664 | + |
|
| 665 | + /* check whether satellite has aos */ |
|
| 666 | + if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 667 | + ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 668 | + !$this->has_aos($sat, $qth)) { |
|
| 669 | + |
|
| 670 | + return 0.0; |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + while ($sat->el >= 0.0) { |
|
| 674 | + $aostime -= 0.0005; // 0.75 min |
|
| 675 | + $this->predict_calc($sat, $qth, $aostime); |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + return $aostime; |
|
| 679 | + } |
|
| 680 | + |
|
| 681 | + /** Determine whether satellite ever reaches AOS. |
|
| 682 | + * @author John A. Magliacane, KD2BD |
|
| 683 | + * @author Alexandru Csete, OZ9AEC |
|
| 684 | + * @param Predict_Sat $sat The satellite data. |
|
| 685 | + * @param Predict_QTH $qth The observer's location data |
|
| 686 | + * @return bool true if the satellite will reach AOS, false otherwise. |
|
| 687 | + * |
|
| 688 | + */ |
|
| 689 | + public function has_aos(Predict_Sat $sat, Predict_QTH $qth) |
|
| 690 | + { |
|
| 691 | + $retcode = false; |
|
| 692 | + |
|
| 693 | + /* FIXME */ |
|
| 694 | + if ($sat->meanmo == 0.0) { |
|
| 695 | + $retcode = false; |
|
| 696 | + } else { |
|
| 697 | + |
|
| 698 | + /* xincl is already in RAD by select_ephemeris */ |
|
| 699 | + $lin = $sat->tle->xincl; |
|
| 700 | + if ($lin >= self::pio2) { |
|
| 701 | + $lin = self::pi - $lin; |
|
| 702 | + } |
|
| 703 | + |
|
| 704 | + $sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0)); |
|
| 705 | + $apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper; |
|
| 706 | + |
|
| 707 | + if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) { |
|
| 708 | + $retcode = true; |
|
| 709 | + } else { |
|
| 710 | + $retcode = false; |
|
| 711 | + } |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + return $retcode; |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + /** Predict passes after a certain time. |
|
| 718 | + * |
|
| 719 | + * |
|
| 720 | + * This function calculates num upcoming passes with AOS no earlier |
|
| 721 | + * than t = start and not later that t = (start+maxdt). The function will |
|
| 722 | + * repeatedly call get_pass until |
|
| 723 | + * the number of predicted passes is equal to num, the time has reached |
|
| 724 | + * limit or the get_pass function returns NULL. |
|
| 725 | + * |
|
| 726 | + * note For no time limit use maxdt = 0.0 |
|
| 727 | + * |
|
| 728 | + * note the data in sat will be corrupt (future) and must be refreshed |
|
| 729 | + * by the caller, if the caller will need it later on (eg. if the caller |
|
| 730 | + * is GtkSatList). |
|
| 731 | + * |
|
| 732 | + * note Prepending to a singly linked list is much faster than appending. |
|
| 733 | + * Therefore, the elements are prepended whereafter the GSList is |
|
| 734 | + * reversed |
|
| 735 | + * |
|
| 736 | + * |
|
| 737 | + * @param Predict_Sat $sat The satellite data |
|
| 738 | + * @param Predict_QTH $qth The observer's location data |
|
| 739 | + * @param float $start The start julian date |
|
| 740 | + * @param int $maxdt The max # of days to look |
|
| 741 | + * @param int $num The max # of passes to get |
|
| 742 | + * @return array of Predict_Pass instances if found, empty array otherwise |
|
| 743 | + */ |
|
| 744 | + public function get_passes(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt, $num = 0) |
|
| 745 | + { |
|
| 746 | + $passes = array(); |
|
| 747 | + |
|
| 748 | + /* if no number has been specified |
|
| 749 | 749 | set it to something big */ |
| 750 | - if ($num == 0) { |
|
| 751 | - $num = 100; |
|
| 752 | - } |
|
| 750 | + if ($num == 0) { |
|
| 751 | + $num = 100; |
|
| 752 | + } |
|
| 753 | 753 | |
| 754 | - $t = $start; |
|
| 754 | + $t = $start; |
|
| 755 | 755 | |
| 756 | - for ($i = 0; $i < $num; $i++) { |
|
| 757 | - $pass = $this->get_pass($sat, $qth, $t, $maxdt); |
|
| 756 | + for ($i = 0; $i < $num; $i++) { |
|
| 757 | + $pass = $this->get_pass($sat, $qth, $t, $maxdt); |
|
| 758 | 758 | |
| 759 | - if ($pass != null) { |
|
| 760 | - $passes[] = $pass; |
|
| 761 | - $t = $pass->los + 0.014; // +20 min |
|
| 759 | + if ($pass != null) { |
|
| 760 | + $passes[] = $pass; |
|
| 761 | + $t = $pass->los + 0.014; // +20 min |
|
| 762 | 762 | |
| 763 | - /* if maxdt > 0.0 check whether we have reached t = start+maxdt |
|
| 763 | + /* if maxdt > 0.0 check whether we have reached t = start+maxdt |
|
| 764 | 764 | if yes finish predictions |
| 765 | 765 | */ |
| 766 | - if (($maxdt > 0.0) && ($t >= ($start + $maxdt))) { |
|
| 767 | - $i = $num; |
|
| 768 | - } |
|
| 769 | - } else { |
|
| 770 | - /* we can't get any more passes */ |
|
| 771 | - $i = $num; |
|
| 772 | - } |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - return $passes; |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - /** |
|
| 779 | - * Filters out visible passes and adds the visible aos, tca, los, and |
|
| 780 | - * corresponding az and ele for each. |
|
| 781 | - * |
|
| 782 | - * @param array $passes The passes returned from get_passes() |
|
| 783 | - * |
|
| 784 | - * @author Bill Shupp |
|
| 785 | - * @return array |
|
| 786 | - */ |
|
| 787 | - public function filterVisiblePasses(array $passes) |
|
| 788 | - { |
|
| 789 | - $filtered = array(); |
|
| 790 | - |
|
| 791 | - foreach ($passes as $result) { |
|
| 792 | - // Dummy check |
|
| 793 | - if ($result->vis[0] != 'V') { |
|
| 794 | - continue; |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - $aos = false; |
|
| 798 | - $aos_az = false; |
|
| 799 | - $aos = false; |
|
| 800 | - $tca = false; |
|
| 801 | - $los_az = false; |
|
| 802 | - $max_el = 0; |
|
| 803 | - |
|
| 804 | - foreach ($result->details as $detail) { |
|
| 805 | - if ($detail->vis != Predict::SAT_VIS_VISIBLE) { |
|
| 806 | - continue; |
|
| 807 | - } |
|
| 808 | - if ($detail->el < $this->minEle) { |
|
| 809 | - continue; |
|
| 810 | - } |
|
| 811 | - |
|
| 812 | - if ($aos == false) { |
|
| 813 | - $aos = $detail->time; |
|
| 814 | - $aos_az = $detail->az; |
|
| 815 | - $aos_el = $detail->el; |
|
| 816 | - $tca = $detail->time; |
|
| 817 | - $los = $detail->time; |
|
| 818 | - $los_az = $detail->az; |
|
| 819 | - $los_el = $detail->el; |
|
| 820 | - $max_el = $detail->el; |
|
| 821 | - $max_el_az = $detail->el; |
|
| 822 | - continue; |
|
| 823 | - } |
|
| 824 | - $los = $detail->time; |
|
| 825 | - $los_az = $detail->az; |
|
| 826 | - $los_el = $detail->el; |
|
| 827 | - |
|
| 828 | - if ($detail->el > $max_el) { |
|
| 829 | - $tca = $detail->time; |
|
| 830 | - $max_el = $detail->el; |
|
| 831 | - $max_el_az = $detail->az; |
|
| 832 | - } |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - if ($aos === false) { |
|
| 836 | - // Does not reach minimum elevation, skip |
|
| 837 | - continue; |
|
| 838 | - } |
|
| 839 | - |
|
| 840 | - $result->visible_aos = $aos; |
|
| 841 | - $result->visible_aos_az = $aos_az; |
|
| 842 | - $result->visible_aos_el = $aos_el; |
|
| 843 | - $result->visible_tca = $tca; |
|
| 844 | - $result->visible_max_el = $max_el; |
|
| 845 | - $result->visible_max_el_az = $max_el_az; |
|
| 846 | - $result->visible_los = $los; |
|
| 847 | - $result->visible_los_az = $los_az; |
|
| 848 | - $result->visible_los_el = $los_el; |
|
| 849 | - |
|
| 850 | - $filtered[] = $result; |
|
| 851 | - } |
|
| 852 | - |
|
| 853 | - return $filtered; |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - /** |
|
| 857 | - * Translates aziumuth degrees to compass direction: |
|
| 858 | - * |
|
| 859 | - * N (0°), NNE (22.5°), NE (45°), ENE (67.5°), E (90°), ESE (112.5°), |
|
| 860 | - * SE (135°), SSE (157.5°), S (180°), SSW (202.5°), SW (225°), |
|
| 861 | - * WSW (247.5°), W (270°), WNW (292.5°), NW (315°), NNW (337.5°) |
|
| 862 | - * |
|
| 863 | - * @param int $az The azimuth in degrees, defaults to 0 |
|
| 864 | - * |
|
| 865 | - * @return string |
|
| 866 | - */ |
|
| 867 | - public function azDegreesToDirection($az = 0) |
|
| 868 | - { |
|
| 869 | - $i = floor($az / 22.5); |
|
| 870 | - $m = (22.5 * (2 * $i + 1)) / 2; |
|
| 871 | - $i = ($az >= $m) ? $i + 1 : $i; |
|
| 872 | - |
|
| 873 | - return trim(substr('N NNENE ENEE ESESE SSES SSWSW WSWW WNWNW NNWN ', $i * 3, 3)); |
|
| 874 | - } |
|
| 766 | + if (($maxdt > 0.0) && ($t >= ($start + $maxdt))) { |
|
| 767 | + $i = $num; |
|
| 768 | + } |
|
| 769 | + } else { |
|
| 770 | + /* we can't get any more passes */ |
|
| 771 | + $i = $num; |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + return $passes; |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + /** |
|
| 779 | + * Filters out visible passes and adds the visible aos, tca, los, and |
|
| 780 | + * corresponding az and ele for each. |
|
| 781 | + * |
|
| 782 | + * @param array $passes The passes returned from get_passes() |
|
| 783 | + * |
|
| 784 | + * @author Bill Shupp |
|
| 785 | + * @return array |
|
| 786 | + */ |
|
| 787 | + public function filterVisiblePasses(array $passes) |
|
| 788 | + { |
|
| 789 | + $filtered = array(); |
|
| 790 | + |
|
| 791 | + foreach ($passes as $result) { |
|
| 792 | + // Dummy check |
|
| 793 | + if ($result->vis[0] != 'V') { |
|
| 794 | + continue; |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + $aos = false; |
|
| 798 | + $aos_az = false; |
|
| 799 | + $aos = false; |
|
| 800 | + $tca = false; |
|
| 801 | + $los_az = false; |
|
| 802 | + $max_el = 0; |
|
| 803 | + |
|
| 804 | + foreach ($result->details as $detail) { |
|
| 805 | + if ($detail->vis != Predict::SAT_VIS_VISIBLE) { |
|
| 806 | + continue; |
|
| 807 | + } |
|
| 808 | + if ($detail->el < $this->minEle) { |
|
| 809 | + continue; |
|
| 810 | + } |
|
| 811 | + |
|
| 812 | + if ($aos == false) { |
|
| 813 | + $aos = $detail->time; |
|
| 814 | + $aos_az = $detail->az; |
|
| 815 | + $aos_el = $detail->el; |
|
| 816 | + $tca = $detail->time; |
|
| 817 | + $los = $detail->time; |
|
| 818 | + $los_az = $detail->az; |
|
| 819 | + $los_el = $detail->el; |
|
| 820 | + $max_el = $detail->el; |
|
| 821 | + $max_el_az = $detail->el; |
|
| 822 | + continue; |
|
| 823 | + } |
|
| 824 | + $los = $detail->time; |
|
| 825 | + $los_az = $detail->az; |
|
| 826 | + $los_el = $detail->el; |
|
| 827 | + |
|
| 828 | + if ($detail->el > $max_el) { |
|
| 829 | + $tca = $detail->time; |
|
| 830 | + $max_el = $detail->el; |
|
| 831 | + $max_el_az = $detail->az; |
|
| 832 | + } |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + if ($aos === false) { |
|
| 836 | + // Does not reach minimum elevation, skip |
|
| 837 | + continue; |
|
| 838 | + } |
|
| 839 | + |
|
| 840 | + $result->visible_aos = $aos; |
|
| 841 | + $result->visible_aos_az = $aos_az; |
|
| 842 | + $result->visible_aos_el = $aos_el; |
|
| 843 | + $result->visible_tca = $tca; |
|
| 844 | + $result->visible_max_el = $max_el; |
|
| 845 | + $result->visible_max_el_az = $max_el_az; |
|
| 846 | + $result->visible_los = $los; |
|
| 847 | + $result->visible_los_az = $los_az; |
|
| 848 | + $result->visible_los_el = $los_el; |
|
| 849 | + |
|
| 850 | + $filtered[] = $result; |
|
| 851 | + } |
|
| 852 | + |
|
| 853 | + return $filtered; |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + /** |
|
| 857 | + * Translates aziumuth degrees to compass direction: |
|
| 858 | + * |
|
| 859 | + * N (0°), NNE (22.5°), NE (45°), ENE (67.5°), E (90°), ESE (112.5°), |
|
| 860 | + * SE (135°), SSE (157.5°), S (180°), SSW (202.5°), SW (225°), |
|
| 861 | + * WSW (247.5°), W (270°), WNW (292.5°), NW (315°), NNW (337.5°) |
|
| 862 | + * |
|
| 863 | + * @param int $az The azimuth in degrees, defaults to 0 |
|
| 864 | + * |
|
| 865 | + * @return string |
|
| 866 | + */ |
|
| 867 | + public function azDegreesToDirection($az = 0) |
|
| 868 | + { |
|
| 869 | + $i = floor($az / 22.5); |
|
| 870 | + $m = (22.5 * (2 * $i + 1)) / 2; |
|
| 871 | + $i = ($az >= $m) ? $i + 1 : $i; |
|
| 872 | + |
|
| 873 | + return trim(substr('N NNENE ENEE ESESE SSES SSWSW WSWW WNWNW NNWN ', $i * 3, 3)); |
|
| 874 | + } |
|
| 875 | 875 | } |
@@ -52,60 +52,60 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | class Predict |
| 54 | 54 | { |
| 55 | - const de2ra = 1.74532925E-2; /* Degrees to Radians */ |
|
| 56 | - const pi = 3.1415926535898; /* Pi */ |
|
| 57 | - const pio2 = 1.5707963267949; /* Pi/2 */ |
|
| 58 | - const x3pio2 = 4.71238898; /* 3*Pi/2 */ |
|
| 59 | - const twopi = 6.2831853071796; /* 2*Pi */ |
|
| 60 | - const e6a = 1.0E-6; |
|
| 61 | - const tothrd = 6.6666667E-1; /* 2/3 */ |
|
| 62 | - const xj2 = 1.0826158E-3; /* J2 Harmonic */ |
|
| 63 | - const xj3 = -2.53881E-6; /* J3 Harmonic */ |
|
| 64 | - const xj4 = -1.65597E-6; /* J4 Harmonic */ |
|
| 65 | - const xke = 7.43669161E-2; |
|
| 66 | - const xkmper = 6.378135E3; /* Earth radius km */ |
|
| 67 | - const xmnpda = 1.44E3; /* Minutes per day */ |
|
| 68 | - const km2mi = 0.621371; /* Kilometers per Mile */ |
|
| 69 | - const ae = 1.0; |
|
| 70 | - const ck2 = 5.413079E-4; |
|
| 71 | - const ck4 = 6.209887E-7; |
|
| 72 | - const __f = 3.352779E-3; |
|
| 73 | - const ge = 3.986008E5; |
|
| 74 | - const __s__ = 1.012229; |
|
| 75 | - const qoms2t = 1.880279E-09; |
|
| 76 | - const secday = 8.6400E4; /* Seconds per day */ |
|
| 77 | - const omega_E = 1.0027379; |
|
| 78 | - const omega_ER = 6.3003879; |
|
| 79 | - const zns = 1.19459E-5; |
|
| 80 | - const c1ss = 2.9864797E-6; |
|
| 81 | - const zes = 1.675E-2; |
|
| 82 | - const znl = 1.5835218E-4; |
|
| 83 | - const c1l = 4.7968065E-7; |
|
| 84 | - const zel = 5.490E-2; |
|
| 85 | - const zcosis = 9.1744867E-1; |
|
| 86 | - const zsinis = 3.9785416E-1; |
|
| 55 | + const de2ra = 1.74532925E-2; /* Degrees to Radians */ |
|
| 56 | + const pi = 3.1415926535898; /* Pi */ |
|
| 57 | + const pio2 = 1.5707963267949; /* Pi/2 */ |
|
| 58 | + const x3pio2 = 4.71238898; /* 3*Pi/2 */ |
|
| 59 | + const twopi = 6.2831853071796; /* 2*Pi */ |
|
| 60 | + const e6a = 1.0E-6; |
|
| 61 | + const tothrd = 6.6666667E-1; /* 2/3 */ |
|
| 62 | + const xj2 = 1.0826158E-3; /* J2 Harmonic */ |
|
| 63 | + const xj3 = -2.53881E-6; /* J3 Harmonic */ |
|
| 64 | + const xj4 = -1.65597E-6; /* J4 Harmonic */ |
|
| 65 | + const xke = 7.43669161E-2; |
|
| 66 | + const xkmper = 6.378135E3; /* Earth radius km */ |
|
| 67 | + const xmnpda = 1.44E3; /* Minutes per day */ |
|
| 68 | + const km2mi = 0.621371; /* Kilometers per Mile */ |
|
| 69 | + const ae = 1.0; |
|
| 70 | + const ck2 = 5.413079E-4; |
|
| 71 | + const ck4 = 6.209887E-7; |
|
| 72 | + const __f = 3.352779E-3; |
|
| 73 | + const ge = 3.986008E5; |
|
| 74 | + const __s__ = 1.012229; |
|
| 75 | + const qoms2t = 1.880279E-09; |
|
| 76 | + const secday = 8.6400E4; /* Seconds per day */ |
|
| 77 | + const omega_E = 1.0027379; |
|
| 78 | + const omega_ER = 6.3003879; |
|
| 79 | + const zns = 1.19459E-5; |
|
| 80 | + const c1ss = 2.9864797E-6; |
|
| 81 | + const zes = 1.675E-2; |
|
| 82 | + const znl = 1.5835218E-4; |
|
| 83 | + const c1l = 4.7968065E-7; |
|
| 84 | + const zel = 5.490E-2; |
|
| 85 | + const zcosis = 9.1744867E-1; |
|
| 86 | + const zsinis = 3.9785416E-1; |
|
| 87 | 87 | const zsings = -9.8088458E-1; |
| 88 | - const zcosgs = 1.945905E-1; |
|
| 89 | - const zcoshs = 1; |
|
| 90 | - const zsinhs = 0; |
|
| 91 | - const q22 = 1.7891679E-6; |
|
| 92 | - const q31 = 2.1460748E-6; |
|
| 93 | - const q33 = 2.2123015E-7; |
|
| 94 | - const g22 = 5.7686396; |
|
| 95 | - const g32 = 9.5240898E-1; |
|
| 96 | - const g44 = 1.8014998; |
|
| 97 | - const g52 = 1.0508330; |
|
| 98 | - const g54 = 4.4108898; |
|
| 99 | - const root22 = 1.7891679E-6; |
|
| 100 | - const root32 = 3.7393792E-7; |
|
| 101 | - const root44 = 7.3636953E-9; |
|
| 102 | - const root52 = 1.1428639E-7; |
|
| 103 | - const root54 = 2.1765803E-9; |
|
| 104 | - const thdt = 4.3752691E-3; |
|
| 105 | - const rho = 1.5696615E-1; |
|
| 106 | - const mfactor = 7.292115E-5; |
|
| 107 | - const __sr__ = 6.96000E5; /*Solar radius - kilometers (IAU 76)*/ |
|
| 108 | - const AU = 1.49597870E8; /*Astronomical unit - kilometers (IAU 76)*/ |
|
| 88 | + const zcosgs = 1.945905E-1; |
|
| 89 | + const zcoshs = 1; |
|
| 90 | + const zsinhs = 0; |
|
| 91 | + const q22 = 1.7891679E-6; |
|
| 92 | + const q31 = 2.1460748E-6; |
|
| 93 | + const q33 = 2.2123015E-7; |
|
| 94 | + const g22 = 5.7686396; |
|
| 95 | + const g32 = 9.5240898E-1; |
|
| 96 | + const g44 = 1.8014998; |
|
| 97 | + const g52 = 1.0508330; |
|
| 98 | + const g54 = 4.4108898; |
|
| 99 | + const root22 = 1.7891679E-6; |
|
| 100 | + const root32 = 3.7393792E-7; |
|
| 101 | + const root44 = 7.3636953E-9; |
|
| 102 | + const root52 = 1.1428639E-7; |
|
| 103 | + const root54 = 2.1765803E-9; |
|
| 104 | + const thdt = 4.3752691E-3; |
|
| 105 | + const rho = 1.5696615E-1; |
|
| 106 | + const mfactor = 7.292115E-5; |
|
| 107 | + const __sr__ = 6.96000E5; /*Solar radius - kilometers (IAU 76)*/ |
|
| 108 | + const AU = 1.49597870E8; /*Astronomical unit - kilometers (IAU 76)*/ |
|
| 109 | 109 | |
| 110 | 110 | /* visibility constants */ |
| 111 | 111 | const SAT_VIS_NONE = 0; |
@@ -163,18 +163,18 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt) |
| 165 | 165 | { |
| 166 | - $aos = 0.0; /* time of AOS */ |
|
| 167 | - $tca = 0.0; /* time of TCA */ |
|
| 168 | - $los = 0.0; /* time of LOS */ |
|
| 169 | - $dt = 0.0; /* time diff */ |
|
| 170 | - $step = 0.0; /* time step */ |
|
| 166 | + $aos = 0.0; /* time of AOS */ |
|
| 167 | + $tca = 0.0; /* time of TCA */ |
|
| 168 | + $los = 0.0; /* time of LOS */ |
|
| 169 | + $dt = 0.0; /* time diff */ |
|
| 170 | + $step = 0.0; /* time step */ |
|
| 171 | 171 | $t0 = $start; |
| 172 | - $tres = 0.0; /* required time resolution */ |
|
| 172 | + $tres = 0.0; /* required time resolution */ |
|
| 173 | 173 | $max_el = 0.0; /* maximum elevation */ |
| 174 | 174 | $pass = null; |
| 175 | 175 | $detail = null; |
| 176 | 176 | $done = false; |
| 177 | - $iter = 0; /* number of iterations */ |
|
| 177 | + $iter = 0; /* number of iterations */ |
|
| 178 | 178 | /* FIXME: watchdog */ |
| 179 | 179 | |
| 180 | 180 | /*copy sat_in to a working structure*/ |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $sat_working = clone $sat_in; |
| 183 | 183 | |
| 184 | 184 | /* get time resolution; sat-cfg stores it in seconds */ |
| 185 | - $tres = $this->timeRes / 86400.0; |
|
| 185 | + $tres = $this->timeRes/86400.0; |
|
| 186 | 186 | |
| 187 | 187 | /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL |
| 188 | 188 | or we run out of time |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | /* aos = 0.0 means no aos */ |
| 208 | 208 | if ($aos == 0.0) { |
| 209 | 209 | $done = true; |
| 210 | - } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) { |
|
| 210 | + } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt))) { |
|
| 211 | 211 | /* check whether we are within time limits; |
| 212 | 212 | maxdt = 0 mean no time limit. |
| 213 | 213 | */ |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $dt = $los - $aos; |
| 218 | 218 | |
| 219 | 219 | /* get time step, which will give us the max number of entries */ |
| 220 | - $step = $dt / $this->numEntries; |
|
| 220 | + $step = $dt/$this->numEntries; |
|
| 221 | 221 | |
| 222 | 222 | /* but if this is smaller than the required resolution |
| 223 | 223 | we go with the resolution |
@@ -369,9 +369,9 @@ discard block |
||
| 369 | 369 | $solar_set = new Predict_ObsSet(); |
| 370 | 370 | |
| 371 | 371 | /* FIXME: could be passed as parameter */ |
| 372 | - $obs_geodetic->lon = $qth->lon * self::de2ra; |
|
| 373 | - $obs_geodetic->lat = $qth->lat * self::de2ra; |
|
| 374 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 372 | + $obs_geodetic->lon = $qth->lon*self::de2ra; |
|
| 373 | + $obs_geodetic->lat = $qth->lat*self::de2ra; |
|
| 374 | + $obs_geodetic->alt = $qth->alt/1000.0; |
|
| 375 | 375 | $obs_geodetic->theta = 0; |
| 376 | 376 | |
| 377 | 377 | Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector); |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | |
| 453 | 453 | /* coarse time steps */ |
| 454 | 454 | while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) { |
| 455 | - $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 455 | + $t -= 0.00035*($sat->el*(($sat->alt/8400.0) + 0.46) - 2.0); |
|
| 456 | 456 | $this->predict_calc($sat, $qth, $t); |
| 457 | 457 | } |
| 458 | 458 | |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | if (abs($sat->el) < 0.005) { |
| 463 | 463 | $aostime = $t; |
| 464 | 464 | } else { |
| 465 | - $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 465 | + $t -= $sat->el*sqrt($sat->alt)/530000.0; |
|
| 466 | 466 | $this->predict_calc($sat, $qth, $t); |
| 467 | 467 | } |
| 468 | 468 | } |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | /* coarse time steps */ |
| 473 | 473 | while ($sat->el < -1.0) { |
| 474 | 474 | |
| 475 | - $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 475 | + $t -= 0.00035*($sat->el*(($sat->alt/8400.0) + 0.46) - 2.0); |
|
| 476 | 476 | $this->predict_calc($sat, $qth, $t); |
| 477 | 477 | } |
| 478 | 478 | |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | if (abs($sat->el) < 0.005) { |
| 483 | 483 | $aostime = $t; |
| 484 | 484 | } else { |
| 485 | - $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 485 | + $t -= $sat->el*sqrt($sat->alt)/530000.0; |
|
| 486 | 486 | $this->predict_calc($sat, $qth, $t); |
| 487 | 487 | } |
| 488 | 488 | |
@@ -504,17 +504,17 @@ discard block |
||
| 504 | 504 | $sat_geodetic = new Predict_Geodetic(); |
| 505 | 505 | $obs_geodetic = new Predict_Geodetic(); |
| 506 | 506 | |
| 507 | - $obs_geodetic->lon = $qth->lon * self::de2ra; |
|
| 508 | - $obs_geodetic->lat = $qth->lat * self::de2ra; |
|
| 509 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 507 | + $obs_geodetic->lon = $qth->lon*self::de2ra; |
|
| 508 | + $obs_geodetic->lat = $qth->lat*self::de2ra; |
|
| 509 | + $obs_geodetic->alt = $qth->alt/1000.0; |
|
| 510 | 510 | $obs_geodetic->theta = 0; |
| 511 | 511 | |
| 512 | 512 | $sat->jul_utc = $t; |
| 513 | - $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda; |
|
| 513 | + $sat->tsince = ($sat->jul_utc - $sat->jul_epoch)*self::xmnpda; |
|
| 514 | 514 | |
| 515 | 515 | /* call the norad routines according to the deep-space flag */ |
| 516 | 516 | $sgpsdp = Predict_SGPSDP::getInstance($sat); |
| 517 | - if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 517 | + if ($sat->flags&Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 518 | 518 | $sgpsdp->SDP4($sat, $sat->tsince); |
| 519 | 519 | } else { |
| 520 | 520 | $sgpsdp->SGP4($sat, $sat->tsince); |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
| 524 | 524 | |
| 525 | 525 | /* get the velocity of the satellite */ |
| 526 | - $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 526 | + $sat->vel->w = sqrt($sat->vel->x*$sat->vel->x + $sat->vel->y*$sat->vel->y + $sat->vel->z*$sat->vel->z); |
|
| 527 | 527 | $sat->velo = $sat->vel->w; |
| 528 | 528 | Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
| 529 | 529 | Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic); |
@@ -544,16 +544,16 @@ discard block |
||
| 544 | 544 | $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
| 545 | 545 | $sat->alt = $sat_geodetic->alt; |
| 546 | 546 | $sat->ma = Predict_Math::Degrees($sat->phase); |
| 547 | - $sat->ma *= 256.0 / 360.0; |
|
| 547 | + $sat->ma *= 256.0/360.0; |
|
| 548 | 548 | $sat->phase = Predict_Math::Degrees($sat->phase); |
| 549 | 549 | |
| 550 | 550 | /* same formulas, but the one from predict is nicer */ |
| 551 | 551 | //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); |
| 552 | - $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt)); |
|
| 552 | + $sat->footprint = 12756.33*acos(self::xkmper/(self::xkmper + $sat->alt)); |
|
| 553 | 553 | $age = $sat->jul_utc - $sat->jul_epoch; |
| 554 | - $sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi + |
|
| 555 | - $age * $sat->tle->bstar * self::ae) * $age + |
|
| 556 | - $sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1; |
|
| 554 | + $sat->orbit = floor(($sat->tle->xno*self::xmnpda/self::twopi + |
|
| 555 | + $age*$sat->tle->bstar*self::ae)*$age + |
|
| 556 | + $sat->tle->xmo/self::twopi) + $sat->tle->revnum - 1; |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | /** Find the LOS time of the next pass. |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | /* check whether satellite has aos */ |
| 586 | 586 | if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
| 587 | 587 | ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
| 588 | - !$this->has_aos ($sat, $qth)) { |
|
| 588 | + !$this->has_aos($sat, $qth)) { |
|
| 589 | 589 | |
| 590 | 590 | return 0.0; |
| 591 | 591 | } |
@@ -607,14 +607,14 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | /* coarse steps */ |
| 609 | 609 | while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) { |
| 610 | - $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 610 | + $t += cos(($sat->el - 1.0)*self::de2ra)*sqrt($sat->alt)/25000.0; |
|
| 611 | 611 | $this->predict_calc($sat, $qth, $t); |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /* fine steps */ |
| 615 | - while (($lostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 615 | + while (($lostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 616 | 616 | |
| 617 | - $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 617 | + $t += $sat->el*sqrt($sat->alt)/502500.0; |
|
| 618 | 618 | $this->predict_calc($sat, $qth, $t); |
| 619 | 619 | |
| 620 | 620 | if (abs($sat->el) < 0.005) { |
@@ -626,14 +626,14 @@ discard block |
||
| 626 | 626 | |
| 627 | 627 | /* coarse steps */ |
| 628 | 628 | while ($sat->el >= 1.0) { |
| 629 | - $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 629 | + $t += cos(($sat->el - 1.0)*self::de2ra)*sqrt($sat->alt)/25000.0; |
|
| 630 | 630 | $this->predict_calc($sat, $qth, $t); |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | /* fine steps */ |
| 634 | 634 | while ($lostime == 0.0) { |
| 635 | 635 | |
| 636 | - $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 636 | + $t += $sat->el*sqrt($sat->alt)/502500.0; |
|
| 637 | 637 | $this->predict_calc($sat, $qth, $t); |
| 638 | 638 | |
| 639 | 639 | if (abs($sat->el) < 0.005) |
@@ -701,10 +701,10 @@ discard block |
||
| 701 | 701 | $lin = self::pi - $lin; |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - $sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0)); |
|
| 705 | - $apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper; |
|
| 704 | + $sma = 331.25*exp(log(1440.0/$sat->meanmo)*(2.0/3.0)); |
|
| 705 | + $apogee = $sma*(1.0 + $sat->tle->eo) - self::xkmper; |
|
| 706 | 706 | |
| 707 | - if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) { |
|
| 707 | + if ((acos(self::xkmper/($apogee + self::xkmper)) + ($lin)) > abs($qth->lat*self::de2ra)) { |
|
| 708 | 708 | $retcode = true; |
| 709 | 709 | } else { |
| 710 | 710 | $retcode = false; |
@@ -866,10 +866,10 @@ discard block |
||
| 866 | 866 | */ |
| 867 | 867 | public function azDegreesToDirection($az = 0) |
| 868 | 868 | { |
| 869 | - $i = floor($az / 22.5); |
|
| 870 | - $m = (22.5 * (2 * $i + 1)) / 2; |
|
| 869 | + $i = floor($az/22.5); |
|
| 870 | + $m = (22.5*(2*$i + 1))/2; |
|
| 871 | 871 | $i = ($az >= $m) ? $i + 1 : $i; |
| 872 | 872 | |
| 873 | - return trim(substr('N NNENE ENEE ESESE SSES SSWSW WSWW WNWNW NNWN ', $i * 3, 3)); |
|
| 873 | + return trim(substr('N NNENE ENEE ESESE SSES SSWSW WSWW WNWNW NNWN ', $i*3, 3)); |
|
| 874 | 874 | } |
| 875 | 875 | } |
@@ -636,8 +636,9 @@ |
||
| 636 | 636 | $t += $sat->el * sqrt($sat->alt) / 502500.0; |
| 637 | 637 | $this->predict_calc($sat, $qth, $t); |
| 638 | 638 | |
| 639 | - if (abs($sat->el) < 0.005) |
|
| 640 | - $lostime = $t; |
|
| 639 | + if (abs($sat->el) < 0.005) { |
|
| 640 | + $lostime = $t; |
|
| 641 | + } |
|
| 641 | 642 | } |
| 642 | 643 | } |
| 643 | 644 | |
@@ -42,6 +42,10 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /* Returns arccosine of rgument */ |
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @param double $arg |
|
| 48 | + */ |
|
| 45 | 49 | public static function ArcCos($arg) |
| 46 | 50 | { |
| 47 | 51 | return Predict::pio2 - self::ArcSin($arg); |
@@ -68,6 +72,10 @@ discard block |
||
| 68 | 72 | } |
| 69 | 73 | |
| 70 | 74 | /* Multiplies the vector v1 by the scalar k to produce the vector v2 */ |
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param integer $k |
|
| 78 | + */ |
|
| 71 | 79 | public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2) |
| 72 | 80 | { |
| 73 | 81 | $v2->x = $k * $v1->x; |
@@ -155,6 +163,10 @@ discard block |
||
| 155 | 163 | } |
| 156 | 164 | |
| 157 | 165 | /* Returns arg1 mod arg2 */ |
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * @param double $arg1 |
|
| 169 | + */ |
|
| 158 | 170 | public static function Modulus($arg1, $arg2) |
| 159 | 171 | { |
| 160 | 172 | $ret_val = $arg1; |
@@ -169,6 +181,10 @@ discard block |
||
| 169 | 181 | } |
| 170 | 182 | |
| 171 | 183 | /* Returns fractional part of double argument */ |
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * @param double $arg |
|
| 187 | + */ |
|
| 172 | 188 | public static function Frac($arg) |
| 173 | 189 | { |
| 174 | 190 | return $arg - floor($arg); |
@@ -19,178 +19,178 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Predict_Math |
| 21 | 21 | { |
| 22 | - /* Returns sign of a float */ |
|
| 23 | - public static function Sign($arg) |
|
| 24 | - { |
|
| 25 | - if ($arg > 0 ) { |
|
| 26 | - return 1; |
|
| 27 | - } else if ($arg < 0 ) { |
|
| 28 | - return -1; |
|
| 29 | - } else { |
|
| 30 | - return 0; |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /* Returns the arcsine of the argument */ |
|
| 35 | - public static function ArcSin($arg) |
|
| 36 | - { |
|
| 37 | - if (abs($arg) >= 1 ) { |
|
| 38 | - return (self::Sign($arg) * Predict::pio2); |
|
| 39 | - } else { |
|
| 40 | - return(atan($arg / sqrt(1 - $arg * $arg))); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /* Returns arccosine of rgument */ |
|
| 45 | - public static function ArcCos($arg) |
|
| 46 | - { |
|
| 47 | - return Predict::pio2 - self::ArcSin($arg); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /* Adds vectors v1 and v2 together to produce v3 */ |
|
| 51 | - public static function Vec_Add(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3) |
|
| 52 | - { |
|
| 53 | - $v3->x = $v1->x + $v2->x; |
|
| 54 | - $v3->y = $v1->y + $v2->y; |
|
| 55 | - $v3->z = $v1->z + $v2->z; |
|
| 56 | - |
|
| 57 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /* Subtracts vector v2 from v1 to produce v3 */ |
|
| 61 | - public static function Vec_Sub(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3) |
|
| 62 | - { |
|
| 63 | - $v3->x = $v1->x - $v2->x; |
|
| 64 | - $v3->y = $v1->y - $v2->y; |
|
| 65 | - $v3->z = $v1->z - $v2->z; |
|
| 66 | - |
|
| 67 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /* Multiplies the vector v1 by the scalar k to produce the vector v2 */ |
|
| 71 | - public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2) |
|
| 72 | - { |
|
| 73 | - $v2->x = $k * $v1->x; |
|
| 74 | - $v2->y = $k * $v1->y; |
|
| 75 | - $v2->z = $k * $v1->z; |
|
| 76 | - $v2->w = abs($k) * $v1->w; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /* Multiplies the vector v1 by the scalar k */ |
|
| 80 | - public static function Scale_Vector($k, Predict_Vector $v) |
|
| 81 | - { |
|
| 82 | - $v->x *= $k; |
|
| 83 | - $v->y *= $k; |
|
| 84 | - $v->z *= $k; |
|
| 85 | - |
|
| 86 | - $v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /* Returns the dot product of two vectors */ |
|
| 90 | - public static function Dot(Predict_Vector $v1, Predict_Vector $v2) |
|
| 91 | - { |
|
| 92 | - return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /* Calculates the angle between vectors v1 and v2 */ |
|
| 96 | - public static function Angle(Predict_Vector $v1, Predict_Vector $v2) |
|
| 97 | - { |
|
| 98 | - $v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z); |
|
| 99 | - $v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z); |
|
| 100 | - return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w))); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /* Produces cross product of v1 and v2, and returns in v3 */ |
|
| 104 | - public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3) |
|
| 105 | - { |
|
| 106 | - $v3->x = $v1->y * $v2->z - $v1->z * $v2->y; |
|
| 107 | - $v3->y = $v1->z * $v2->x - $v1->x * $v2->z; |
|
| 108 | - $v3->z = $v1->x * $v2->y - $v1->y * $v2->x; |
|
| 109 | - |
|
| 110 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /* Normalizes a vector */ |
|
| 114 | - public static function Normalize(Predict_Vector $v ) |
|
| 115 | - { |
|
| 116 | - $v->x /= $v->w; |
|
| 117 | - $v->y /= $v->w; |
|
| 118 | - $v->z /= $v->w; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /* Four-quadrant arctan function */ |
|
| 122 | - public static function AcTan($sinx, $cosx) |
|
| 123 | - { |
|
| 124 | - if ($cosx == 0) { |
|
| 125 | - if ($sinx > 0) { |
|
| 126 | - return Predict::pio2; |
|
| 127 | - } else { |
|
| 128 | - return Predict::x3pio2; |
|
| 129 | - } |
|
| 130 | - } else { |
|
| 131 | - if ($cosx > 0) { |
|
| 132 | - if ($sinx > 0) { |
|
| 133 | - return atan($sinx / $cosx); |
|
| 134 | - } else { |
|
| 135 | - return Predict::twopi + atan($sinx / $cosx); |
|
| 136 | - } |
|
| 137 | - } else { |
|
| 138 | - return Predict::pi + atan($sinx / $cosx); |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /* Returns mod 2pi of argument */ |
|
| 144 | - public static function FMod2p($x) |
|
| 145 | - { |
|
| 146 | - $ret_val = $x; |
|
| 147 | - $i = (int) ($ret_val / Predict::twopi); |
|
| 148 | - $ret_val -= $i * Predict::twopi; |
|
| 149 | - |
|
| 150 | - if ($ret_val < 0) { |
|
| 151 | - $ret_val += Predict::twopi; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return $ret_val; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /* Returns arg1 mod arg2 */ |
|
| 158 | - public static function Modulus($arg1, $arg2) |
|
| 159 | - { |
|
| 160 | - $ret_val = $arg1; |
|
| 161 | - $i = (int) ($ret_val / $arg2); |
|
| 162 | - $ret_val -= $i * $arg2; |
|
| 163 | - |
|
| 164 | - if ($ret_val < 0) { |
|
| 165 | - $ret_val += $arg2; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - return $ret_val; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /* Returns fractional part of double argument */ |
|
| 172 | - public static function Frac($arg) |
|
| 173 | - { |
|
| 174 | - return $arg - floor($arg); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /* Converts the satellite's position and velocity */ |
|
| 178 | - /* vectors from normalised values to km and km/sec */ |
|
| 179 | - public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel) |
|
| 180 | - { |
|
| 181 | - self::Scale_Vector(Predict::xkmper, $pos); |
|
| 182 | - self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /* Returns angle in radians from arg in degrees */ |
|
| 186 | - public static function Radians($arg) |
|
| 187 | - { |
|
| 188 | - return $arg * Predict::de2ra; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /* Returns angle in degrees from arg in rads */ |
|
| 192 | - public static function Degrees($arg) |
|
| 193 | - { |
|
| 194 | - return $arg / Predict::de2ra; |
|
| 195 | - } |
|
| 22 | + /* Returns sign of a float */ |
|
| 23 | + public static function Sign($arg) |
|
| 24 | + { |
|
| 25 | + if ($arg > 0 ) { |
|
| 26 | + return 1; |
|
| 27 | + } else if ($arg < 0 ) { |
|
| 28 | + return -1; |
|
| 29 | + } else { |
|
| 30 | + return 0; |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /* Returns the arcsine of the argument */ |
|
| 35 | + public static function ArcSin($arg) |
|
| 36 | + { |
|
| 37 | + if (abs($arg) >= 1 ) { |
|
| 38 | + return (self::Sign($arg) * Predict::pio2); |
|
| 39 | + } else { |
|
| 40 | + return(atan($arg / sqrt(1 - $arg * $arg))); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /* Returns arccosine of rgument */ |
|
| 45 | + public static function ArcCos($arg) |
|
| 46 | + { |
|
| 47 | + return Predict::pio2 - self::ArcSin($arg); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /* Adds vectors v1 and v2 together to produce v3 */ |
|
| 51 | + public static function Vec_Add(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3) |
|
| 52 | + { |
|
| 53 | + $v3->x = $v1->x + $v2->x; |
|
| 54 | + $v3->y = $v1->y + $v2->y; |
|
| 55 | + $v3->z = $v1->z + $v2->z; |
|
| 56 | + |
|
| 57 | + $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /* Subtracts vector v2 from v1 to produce v3 */ |
|
| 61 | + public static function Vec_Sub(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3) |
|
| 62 | + { |
|
| 63 | + $v3->x = $v1->x - $v2->x; |
|
| 64 | + $v3->y = $v1->y - $v2->y; |
|
| 65 | + $v3->z = $v1->z - $v2->z; |
|
| 66 | + |
|
| 67 | + $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /* Multiplies the vector v1 by the scalar k to produce the vector v2 */ |
|
| 71 | + public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2) |
|
| 72 | + { |
|
| 73 | + $v2->x = $k * $v1->x; |
|
| 74 | + $v2->y = $k * $v1->y; |
|
| 75 | + $v2->z = $k * $v1->z; |
|
| 76 | + $v2->w = abs($k) * $v1->w; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /* Multiplies the vector v1 by the scalar k */ |
|
| 80 | + public static function Scale_Vector($k, Predict_Vector $v) |
|
| 81 | + { |
|
| 82 | + $v->x *= $k; |
|
| 83 | + $v->y *= $k; |
|
| 84 | + $v->z *= $k; |
|
| 85 | + |
|
| 86 | + $v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /* Returns the dot product of two vectors */ |
|
| 90 | + public static function Dot(Predict_Vector $v1, Predict_Vector $v2) |
|
| 91 | + { |
|
| 92 | + return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /* Calculates the angle between vectors v1 and v2 */ |
|
| 96 | + public static function Angle(Predict_Vector $v1, Predict_Vector $v2) |
|
| 97 | + { |
|
| 98 | + $v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z); |
|
| 99 | + $v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z); |
|
| 100 | + return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w))); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /* Produces cross product of v1 and v2, and returns in v3 */ |
|
| 104 | + public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3) |
|
| 105 | + { |
|
| 106 | + $v3->x = $v1->y * $v2->z - $v1->z * $v2->y; |
|
| 107 | + $v3->y = $v1->z * $v2->x - $v1->x * $v2->z; |
|
| 108 | + $v3->z = $v1->x * $v2->y - $v1->y * $v2->x; |
|
| 109 | + |
|
| 110 | + $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /* Normalizes a vector */ |
|
| 114 | + public static function Normalize(Predict_Vector $v ) |
|
| 115 | + { |
|
| 116 | + $v->x /= $v->w; |
|
| 117 | + $v->y /= $v->w; |
|
| 118 | + $v->z /= $v->w; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /* Four-quadrant arctan function */ |
|
| 122 | + public static function AcTan($sinx, $cosx) |
|
| 123 | + { |
|
| 124 | + if ($cosx == 0) { |
|
| 125 | + if ($sinx > 0) { |
|
| 126 | + return Predict::pio2; |
|
| 127 | + } else { |
|
| 128 | + return Predict::x3pio2; |
|
| 129 | + } |
|
| 130 | + } else { |
|
| 131 | + if ($cosx > 0) { |
|
| 132 | + if ($sinx > 0) { |
|
| 133 | + return atan($sinx / $cosx); |
|
| 134 | + } else { |
|
| 135 | + return Predict::twopi + atan($sinx / $cosx); |
|
| 136 | + } |
|
| 137 | + } else { |
|
| 138 | + return Predict::pi + atan($sinx / $cosx); |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /* Returns mod 2pi of argument */ |
|
| 144 | + public static function FMod2p($x) |
|
| 145 | + { |
|
| 146 | + $ret_val = $x; |
|
| 147 | + $i = (int) ($ret_val / Predict::twopi); |
|
| 148 | + $ret_val -= $i * Predict::twopi; |
|
| 149 | + |
|
| 150 | + if ($ret_val < 0) { |
|
| 151 | + $ret_val += Predict::twopi; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + return $ret_val; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /* Returns arg1 mod arg2 */ |
|
| 158 | + public static function Modulus($arg1, $arg2) |
|
| 159 | + { |
|
| 160 | + $ret_val = $arg1; |
|
| 161 | + $i = (int) ($ret_val / $arg2); |
|
| 162 | + $ret_val -= $i * $arg2; |
|
| 163 | + |
|
| 164 | + if ($ret_val < 0) { |
|
| 165 | + $ret_val += $arg2; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + return $ret_val; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /* Returns fractional part of double argument */ |
|
| 172 | + public static function Frac($arg) |
|
| 173 | + { |
|
| 174 | + return $arg - floor($arg); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /* Converts the satellite's position and velocity */ |
|
| 178 | + /* vectors from normalised values to km and km/sec */ |
|
| 179 | + public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel) |
|
| 180 | + { |
|
| 181 | + self::Scale_Vector(Predict::xkmper, $pos); |
|
| 182 | + self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /* Returns angle in radians from arg in degrees */ |
|
| 186 | + public static function Radians($arg) |
|
| 187 | + { |
|
| 188 | + return $arg * Predict::de2ra; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /* Returns angle in degrees from arg in rads */ |
|
| 192 | + public static function Degrees($arg) |
|
| 193 | + { |
|
| 194 | + return $arg / Predict::de2ra; |
|
| 195 | + } |
|
| 196 | 196 | } |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | /* Returns sign of a float */ |
| 23 | 23 | public static function Sign($arg) |
| 24 | 24 | { |
| 25 | - if ($arg > 0 ) { |
|
| 25 | + if ($arg > 0) { |
|
| 26 | 26 | return 1; |
| 27 | - } else if ($arg < 0 ) { |
|
| 27 | + } else if ($arg < 0) { |
|
| 28 | 28 | return -1; |
| 29 | 29 | } else { |
| 30 | 30 | return 0; |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | /* Returns the arcsine of the argument */ |
| 35 | 35 | public static function ArcSin($arg) |
| 36 | 36 | { |
| 37 | - if (abs($arg) >= 1 ) { |
|
| 38 | - return (self::Sign($arg) * Predict::pio2); |
|
| 37 | + if (abs($arg) >= 1) { |
|
| 38 | + return (self::Sign($arg)*Predict::pio2); |
|
| 39 | 39 | } else { |
| 40 | - return(atan($arg / sqrt(1 - $arg * $arg))); |
|
| 40 | + return(atan($arg/sqrt(1 - $arg*$arg))); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $v3->y = $v1->y + $v2->y; |
| 55 | 55 | $v3->z = $v1->z + $v2->z; |
| 56 | 56 | |
| 57 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 57 | + $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /* Subtracts vector v2 from v1 to produce v3 */ |
@@ -64,16 +64,16 @@ discard block |
||
| 64 | 64 | $v3->y = $v1->y - $v2->y; |
| 65 | 65 | $v3->z = $v1->z - $v2->z; |
| 66 | 66 | |
| 67 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 67 | + $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /* Multiplies the vector v1 by the scalar k to produce the vector v2 */ |
| 71 | 71 | public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2) |
| 72 | 72 | { |
| 73 | - $v2->x = $k * $v1->x; |
|
| 74 | - $v2->y = $k * $v1->y; |
|
| 75 | - $v2->z = $k * $v1->z; |
|
| 76 | - $v2->w = abs($k) * $v1->w; |
|
| 73 | + $v2->x = $k*$v1->x; |
|
| 74 | + $v2->y = $k*$v1->y; |
|
| 75 | + $v2->z = $k*$v1->z; |
|
| 76 | + $v2->w = abs($k)*$v1->w; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /* Multiplies the vector v1 by the scalar k */ |
@@ -83,35 +83,35 @@ discard block |
||
| 83 | 83 | $v->y *= $k; |
| 84 | 84 | $v->z *= $k; |
| 85 | 85 | |
| 86 | - $v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z); |
|
| 86 | + $v->w = sqrt($v->x*$v->x + $v->y*$v->y + $v->z*$v->z); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /* Returns the dot product of two vectors */ |
| 90 | 90 | public static function Dot(Predict_Vector $v1, Predict_Vector $v2) |
| 91 | 91 | { |
| 92 | - return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z); |
|
| 92 | + return ($v1->x*$v2->x + $v1->y*$v2->y + $v1->z*$v2->z); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /* Calculates the angle between vectors v1 and v2 */ |
| 96 | 96 | public static function Angle(Predict_Vector $v1, Predict_Vector $v2) |
| 97 | 97 | { |
| 98 | - $v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z); |
|
| 99 | - $v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z); |
|
| 100 | - return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w))); |
|
| 98 | + $v1->w = sqrt($v1->x*$v1->x + $v1->y*$v1->y + $v1->z*$v1->z); |
|
| 99 | + $v2->w = sqrt($v2->x*$v2->x + $v2->y*$v2->y + $v2->z*$v2->z); |
|
| 100 | + return (self::ArcCos(self::Dot($v1, $v2)/($v1->w*$v2->w))); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /* Produces cross product of v1 and v2, and returns in v3 */ |
| 104 | - public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3) |
|
| 104 | + public static function Cross(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3) |
|
| 105 | 105 | { |
| 106 | - $v3->x = $v1->y * $v2->z - $v1->z * $v2->y; |
|
| 107 | - $v3->y = $v1->z * $v2->x - $v1->x * $v2->z; |
|
| 108 | - $v3->z = $v1->x * $v2->y - $v1->y * $v2->x; |
|
| 106 | + $v3->x = $v1->y*$v2->z - $v1->z*$v2->y; |
|
| 107 | + $v3->y = $v1->z*$v2->x - $v1->x*$v2->z; |
|
| 108 | + $v3->z = $v1->x*$v2->y - $v1->y*$v2->x; |
|
| 109 | 109 | |
| 110 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 110 | + $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /* Normalizes a vector */ |
| 114 | - public static function Normalize(Predict_Vector $v ) |
|
| 114 | + public static function Normalize(Predict_Vector $v) |
|
| 115 | 115 | { |
| 116 | 116 | $v->x /= $v->w; |
| 117 | 117 | $v->y /= $v->w; |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | } else { |
| 131 | 131 | if ($cosx > 0) { |
| 132 | 132 | if ($sinx > 0) { |
| 133 | - return atan($sinx / $cosx); |
|
| 133 | + return atan($sinx/$cosx); |
|
| 134 | 134 | } else { |
| 135 | - return Predict::twopi + atan($sinx / $cosx); |
|
| 135 | + return Predict::twopi + atan($sinx/$cosx); |
|
| 136 | 136 | } |
| 137 | 137 | } else { |
| 138 | - return Predict::pi + atan($sinx / $cosx); |
|
| 138 | + return Predict::pi + atan($sinx/$cosx); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | public static function FMod2p($x) |
| 145 | 145 | { |
| 146 | 146 | $ret_val = $x; |
| 147 | - $i = (int) ($ret_val / Predict::twopi); |
|
| 148 | - $ret_val -= $i * Predict::twopi; |
|
| 147 | + $i = (int) ($ret_val/Predict::twopi); |
|
| 148 | + $ret_val -= $i*Predict::twopi; |
|
| 149 | 149 | |
| 150 | 150 | if ($ret_val < 0) { |
| 151 | 151 | $ret_val += Predict::twopi; |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | public static function Modulus($arg1, $arg2) |
| 159 | 159 | { |
| 160 | 160 | $ret_val = $arg1; |
| 161 | - $i = (int) ($ret_val / $arg2); |
|
| 162 | - $ret_val -= $i * $arg2; |
|
| 161 | + $i = (int) ($ret_val/$arg2); |
|
| 162 | + $ret_val -= $i*$arg2; |
|
| 163 | 163 | |
| 164 | 164 | if ($ret_val < 0) { |
| 165 | 165 | $ret_val += $arg2; |
@@ -179,18 +179,18 @@ discard block |
||
| 179 | 179 | public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel) |
| 180 | 180 | { |
| 181 | 181 | self::Scale_Vector(Predict::xkmper, $pos); |
| 182 | - self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel); |
|
| 182 | + self::Scale_Vector(Predict::xkmper*Predict::xmnpda/Predict::secday, $vel); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /* Returns angle in radians from arg in degrees */ |
| 186 | 186 | public static function Radians($arg) |
| 187 | 187 | { |
| 188 | - return $arg * Predict::de2ra; |
|
| 188 | + return $arg*Predict::de2ra; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /* Returns angle in degrees from arg in rads */ |
| 192 | 192 | public static function Degrees($arg) |
| 193 | 193 | { |
| 194 | - return $arg / Predict::de2ra; |
|
| 194 | + return $arg/Predict::de2ra; |
|
| 195 | 195 | } |
| 196 | 196 | } |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** Initialise satellite data. |
| 127 | - * @param sat The satellite to initialise. |
|
| 128 | - * @param qth Optional QTH info, use (0,0) if NULL. |
|
| 127 | + * @param sat Predict_Sat satellite to initialise. |
|
| 128 | + * @param qth Predict_QTH QTH info, use (0,0) if NULL. |
|
| 129 | 129 | * |
| 130 | 130 | * This function calculates the satellite data at t = 0, ie. epoch time |
| 131 | 131 | * The function is called automatically by gtk_sat_data_read_sat. |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | /** Determinte whether satellite is in geostationary orbit. |
| 218 | 218 | * @author John A. Magliacane, KD2BD |
| 219 | - * @param sat Pointer to satellite data. |
|
| 220 | - * @return TRUE if the satellite appears to be in geostationary orbit, |
|
| 219 | + * @param sat Predict_Sat to satellite data. |
|
| 220 | + * @return boolean if the satellite appears to be in geostationary orbit, |
|
| 221 | 221 | * FALSE otherwise. |
| 222 | 222 | * |
| 223 | 223 | * A satellite is in geostationary orbit if |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | /** Determine whether satellite has decayed. |
| 240 | 240 | * @author John A. Magliacane, KD2BD |
| 241 | 241 | * @author Alexandru Csete, OZ9AEC |
| 242 | - * @param sat Pointer to satellite data. |
|
| 243 | - * @return TRUE if the satellite appears to have decayed, FALSE otherwise. |
|
| 242 | + * @param sat Predict_Sat to satellite data. |
|
| 243 | + * @return boolean if the satellite appears to have decayed, FALSE otherwise. |
|
| 244 | 244 | * @bug Modified version of the predict code but it is not tested. |
| 245 | 245 | * |
| 246 | 246 | * A satellite is decayed if |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @param float $time The daynum the satellite is calculated for |
| 274 | 274 | * @param Predict_QTH $qth The observer location |
| 275 | 275 | * |
| 276 | - * @return null on failure, float otherwise |
|
| 276 | + * @return null|double on failure, float otherwise |
|
| 277 | 277 | */ |
| 278 | 278 | public function calculateApparentMagnitude($time, Predict_QTH $qth) |
| 279 | 279 | { |
@@ -22,304 +22,304 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Predict_Sat |
| 24 | 24 | { |
| 25 | - // Fifth root of a hundred, used for magnitude calculation |
|
| 26 | - const POGSONS_RATIO = 2.5118864315096; |
|
| 27 | - |
|
| 28 | - public $name = null; |
|
| 29 | - public $nickname = null; |
|
| 30 | - public $website = null; |
|
| 31 | - |
|
| 32 | - public $tle = null; /*!< Keplerian elements */ |
|
| 33 | - public $flags = 0; /*!< Flags for algo ctrl */ |
|
| 34 | - public $sgps = null; |
|
| 35 | - public $dps = null; |
|
| 36 | - public $deep_arg = null; |
|
| 37 | - public $pos = null; /*!< Raw position and range */ |
|
| 38 | - public $vel = null; /*!< Raw velocity */ |
|
| 39 | - |
|
| 40 | - /*** FIXME: REMOVE */ |
|
| 41 | - public $bearing = null; /*!< Az, El, range and vel */ |
|
| 42 | - public $astro = null; /*!< Ra and Decl */ |
|
| 43 | - /*** END */ |
|
| 44 | - |
|
| 45 | - /* time keeping fields */ |
|
| 46 | - public $jul_epoch = null; |
|
| 47 | - public $jul_utc = null; |
|
| 48 | - public $tsince = null; |
|
| 49 | - public $aos = null; /*!< Next AOS. */ |
|
| 50 | - public $los = null; /*!< Next LOS */ |
|
| 51 | - |
|
| 52 | - public $az = null; /*!< Azimuth [deg] */ |
|
| 53 | - public $el = null; /*!< Elevation [deg] */ |
|
| 54 | - public $range = null; /*!< Range [km] */ |
|
| 55 | - public $range_rate = null; /*!< Range Rate [km/sec] */ |
|
| 56 | - public $ra = null; /*!< Right Ascension [deg] */ |
|
| 57 | - public $dec = null; /*!< Declination [deg] */ |
|
| 58 | - public $ssplat = null; /*!< SSP latitude [deg] */ |
|
| 59 | - public $ssplon = null; /*!< SSP longitude [deg] */ |
|
| 60 | - public $alt = null; /*!< altitude [km] */ |
|
| 61 | - public $velo = null; /*!< velocity [km/s] */ |
|
| 62 | - public $ma = null; /*!< mean anomaly */ |
|
| 63 | - public $footprint = null; /*!< footprint */ |
|
| 64 | - public $phase = null; /*!< orbit phase */ |
|
| 65 | - public $meanmo = null; /*!< mean motion kept in rev/day */ |
|
| 66 | - public $orbit = null; /*!< orbit number */ |
|
| 67 | - public $otype = null; /*!< orbit type. */ |
|
| 68 | - |
|
| 69 | - public function __construct(Predict_TLE $tle) |
|
| 70 | - { |
|
| 71 | - $headerParts = explode(' ', $tle->header); |
|
| 72 | - $this->name = $headerParts[0]; |
|
| 73 | - $this->nickname = $this->name; |
|
| 74 | - $this->tle = $tle; |
|
| 75 | - $this->pos = new Predict_Vector(); |
|
| 76 | - $this->vel = new Predict_Vector(); |
|
| 77 | - $this->sgps = new Predict_SGSDPStatic(); |
|
| 78 | - $this->deep_arg = new Predict_DeepArg(); |
|
| 79 | - $this->dps = new Predict_DeepStatic(); |
|
| 80 | - |
|
| 81 | - $this->select_ephemeris(); |
|
| 82 | - $this->sat_data_init_sat($this); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /* Selects the apropriate ephemeris type to be used */ |
|
| 86 | - /* for predictions according to the data in the TLE */ |
|
| 87 | - /* It also processes values in the tle set so that */ |
|
| 88 | - /* they are apropriate for the sgp4/sdp4 routines */ |
|
| 89 | - public function select_ephemeris() |
|
| 90 | - { |
|
| 91 | - /* Preprocess tle set */ |
|
| 92 | - $this->tle->xnodeo *= Predict::de2ra; |
|
| 93 | - $this->tle->omegao *= Predict::de2ra; |
|
| 94 | - $this->tle->xmo *= Predict::de2ra; |
|
| 95 | - $this->tle->xincl *= Predict::de2ra; |
|
| 96 | - $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda; |
|
| 97 | - |
|
| 98 | - /* store mean motion before conversion */ |
|
| 99 | - $this->meanmo = $this->tle->xno; |
|
| 100 | - $this->tle->xno = $this->tle->xno * $temp * Predict::xmnpda; |
|
| 101 | - $this->tle->xndt2o *= $temp; |
|
| 102 | - $this->tle->xndd6o = $this->tle->xndd6o * $temp / Predict::xmnpda; |
|
| 103 | - $this->tle->bstar /= Predict::ae; |
|
| 104 | - |
|
| 105 | - /* Period > 225 minutes is deep space */ |
|
| 106 | - $dd1 = Predict::xke / $this->tle->xno; |
|
| 107 | - $dd2 = Predict::tothrd; |
|
| 108 | - $a1 = pow($dd1, $dd2); |
|
| 109 | - $r1 = cos($this->tle->xincl); |
|
| 110 | - $dd1 = 1.0 - $this->tle->eo * $this->tle->eo; |
|
| 111 | - $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5); |
|
| 112 | - $del1 = $temp / ($a1 * $a1); |
|
| 113 | - $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 * |
|
| 114 | - ($del1 * 1.654320987654321 + 1.0))); |
|
| 115 | - $delo = $temp / ($ao * $ao); |
|
| 116 | - $xnodp = $this->tle->xno / ($delo + 1.0); |
|
| 117 | - |
|
| 118 | - /* Select a deep-space/near-earth ephemeris */ |
|
| 119 | - if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) { |
|
| 120 | - $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
| 121 | - } else { |
|
| 122 | - $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** Initialise satellite data. |
|
| 127 | - * @param sat The satellite to initialise. |
|
| 128 | - * @param qth Optional QTH info, use (0,0) if NULL. |
|
| 129 | - * |
|
| 130 | - * This function calculates the satellite data at t = 0, ie. epoch time |
|
| 131 | - * The function is called automatically by gtk_sat_data_read_sat. |
|
| 132 | - */ |
|
| 133 | - public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null) |
|
| 134 | - { |
|
| 135 | - $obs_geodetic = new Predict_Geodetic(); |
|
| 136 | - $obs_set = new Predict_ObsSet(); |
|
| 137 | - $sat_geodetic = new Predict_Geodetic(); |
|
| 138 | - /* double jul_utc, age; */ |
|
| 139 | - |
|
| 140 | - $jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0 |
|
| 141 | - $sat->jul_epoch = $jul_utc; |
|
| 142 | - |
|
| 143 | - /* initialise observer location */ |
|
| 144 | - if ($qth != null) { |
|
| 145 | - $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
| 146 | - $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
| 147 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 148 | - $obs_geodetic->theta = 0; |
|
| 149 | - } |
|
| 150 | - else { |
|
| 151 | - $obs_geodetic->lon = 0.0; |
|
| 152 | - $obs_geodetic->lat = 0.0; |
|
| 153 | - $obs_geodetic->alt = 0.0; |
|
| 154 | - $obs_geodetic->theta = 0; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /* execute computations */ |
|
| 158 | - $sdpsgp = Predict_SGPSDP::getInstance($sat); |
|
| 159 | - if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 160 | - $sdpsgp->SDP4($sat, 0.0); |
|
| 161 | - } else { |
|
| 162 | - $sdpsgp->SGP4($sat, 0.0); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /* scale position and velocity to km and km/sec */ |
|
| 166 | - Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
|
| 167 | - |
|
| 168 | - /* get the velocity of the satellite */ |
|
| 169 | - $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 170 | - $sat->velo = $sat->vel->w; |
|
| 171 | - Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
|
| 172 | - Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic); |
|
| 173 | - |
|
| 174 | - while ($sat_geodetic->lon < -Predict::pi) { |
|
| 175 | - $sat_geodetic->lon += Predict::twopi; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - while ($sat_geodetic->lon > Predict::pi) { |
|
| 179 | - $sat_geodetic->lon -= Predict::twopi; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - $sat->az = Predict_Math::Degrees($obs_set->az); |
|
| 183 | - $sat->el = Predict_Math::Degrees($obs_set->el); |
|
| 184 | - $sat->range = $obs_set->range; |
|
| 185 | - $sat->range_rate = $obs_set->range_rate; |
|
| 186 | - $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); |
|
| 187 | - $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
|
| 188 | - $sat->alt = $sat_geodetic->alt; |
|
| 189 | - $sat->ma = Predict_Math::Degrees($sat->phase); |
|
| 190 | - $sat->ma *= 256.0 / 360.0; |
|
| 191 | - $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w); |
|
| 192 | - $age = 0.0; |
|
| 193 | - $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi + |
|
| 194 | - $age * $sat->tle->bstar * Predict::ae) * $age + |
|
| 195 | - $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1; |
|
| 196 | - |
|
| 197 | - /* orbit type */ |
|
| 198 | - $sat->otype = $sat->get_orbit_type($sat); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - public function get_orbit_type(Predict_Sat $sat) |
|
| 202 | - { |
|
| 203 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
| 204 | - |
|
| 205 | - if ($this->geostationary($sat)) { |
|
| 206 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_GEO; |
|
| 207 | - } else if ($this->decayed($sat)) { |
|
| 208 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_DECAYED; |
|
| 209 | - } else { |
|
| 210 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - return $orbit; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - /** Determinte whether satellite is in geostationary orbit. |
|
| 218 | - * @author John A. Magliacane, KD2BD |
|
| 219 | - * @param sat Pointer to satellite data. |
|
| 220 | - * @return TRUE if the satellite appears to be in geostationary orbit, |
|
| 221 | - * FALSE otherwise. |
|
| 222 | - * |
|
| 223 | - * A satellite is in geostationary orbit if |
|
| 224 | - * |
|
| 225 | - * fabs (sat.meanmotion - 1.0027) < 0.0002 |
|
| 226 | - * |
|
| 227 | - * Note: Appearantly, the mean motion can deviate much more from 1.0027 than 0.0002 |
|
| 228 | - */ |
|
| 229 | - public function geostationary(Predict_Sat $sat) |
|
| 230 | - { |
|
| 231 | - if (abs($sat->meanmo - 1.0027) < 0.0002) { |
|
| 232 | - return true; |
|
| 233 | - } else { |
|
| 234 | - return false; |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** Determine whether satellite has decayed. |
|
| 240 | - * @author John A. Magliacane, KD2BD |
|
| 241 | - * @author Alexandru Csete, OZ9AEC |
|
| 242 | - * @param sat Pointer to satellite data. |
|
| 243 | - * @return TRUE if the satellite appears to have decayed, FALSE otherwise. |
|
| 244 | - * @bug Modified version of the predict code but it is not tested. |
|
| 245 | - * |
|
| 246 | - * A satellite is decayed if |
|
| 247 | - * |
|
| 248 | - * satepoch + ((16.666666 - sat.meanmo) / (10.0*fabs(sat.drag))) < "now" |
|
| 249 | - * |
|
| 250 | - */ |
|
| 251 | - public function decayed(Predict_Sat $sat) |
|
| 252 | - { |
|
| 253 | - /* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the |
|
| 25 | + // Fifth root of a hundred, used for magnitude calculation |
|
| 26 | + const POGSONS_RATIO = 2.5118864315096; |
|
| 27 | + |
|
| 28 | + public $name = null; |
|
| 29 | + public $nickname = null; |
|
| 30 | + public $website = null; |
|
| 31 | + |
|
| 32 | + public $tle = null; /*!< Keplerian elements */ |
|
| 33 | + public $flags = 0; /*!< Flags for algo ctrl */ |
|
| 34 | + public $sgps = null; |
|
| 35 | + public $dps = null; |
|
| 36 | + public $deep_arg = null; |
|
| 37 | + public $pos = null; /*!< Raw position and range */ |
|
| 38 | + public $vel = null; /*!< Raw velocity */ |
|
| 39 | + |
|
| 40 | + /*** FIXME: REMOVE */ |
|
| 41 | + public $bearing = null; /*!< Az, El, range and vel */ |
|
| 42 | + public $astro = null; /*!< Ra and Decl */ |
|
| 43 | + /*** END */ |
|
| 44 | + |
|
| 45 | + /* time keeping fields */ |
|
| 46 | + public $jul_epoch = null; |
|
| 47 | + public $jul_utc = null; |
|
| 48 | + public $tsince = null; |
|
| 49 | + public $aos = null; /*!< Next AOS. */ |
|
| 50 | + public $los = null; /*!< Next LOS */ |
|
| 51 | + |
|
| 52 | + public $az = null; /*!< Azimuth [deg] */ |
|
| 53 | + public $el = null; /*!< Elevation [deg] */ |
|
| 54 | + public $range = null; /*!< Range [km] */ |
|
| 55 | + public $range_rate = null; /*!< Range Rate [km/sec] */ |
|
| 56 | + public $ra = null; /*!< Right Ascension [deg] */ |
|
| 57 | + public $dec = null; /*!< Declination [deg] */ |
|
| 58 | + public $ssplat = null; /*!< SSP latitude [deg] */ |
|
| 59 | + public $ssplon = null; /*!< SSP longitude [deg] */ |
|
| 60 | + public $alt = null; /*!< altitude [km] */ |
|
| 61 | + public $velo = null; /*!< velocity [km/s] */ |
|
| 62 | + public $ma = null; /*!< mean anomaly */ |
|
| 63 | + public $footprint = null; /*!< footprint */ |
|
| 64 | + public $phase = null; /*!< orbit phase */ |
|
| 65 | + public $meanmo = null; /*!< mean motion kept in rev/day */ |
|
| 66 | + public $orbit = null; /*!< orbit number */ |
|
| 67 | + public $otype = null; /*!< orbit type. */ |
|
| 68 | + |
|
| 69 | + public function __construct(Predict_TLE $tle) |
|
| 70 | + { |
|
| 71 | + $headerParts = explode(' ', $tle->header); |
|
| 72 | + $this->name = $headerParts[0]; |
|
| 73 | + $this->nickname = $this->name; |
|
| 74 | + $this->tle = $tle; |
|
| 75 | + $this->pos = new Predict_Vector(); |
|
| 76 | + $this->vel = new Predict_Vector(); |
|
| 77 | + $this->sgps = new Predict_SGSDPStatic(); |
|
| 78 | + $this->deep_arg = new Predict_DeepArg(); |
|
| 79 | + $this->dps = new Predict_DeepStatic(); |
|
| 80 | + |
|
| 81 | + $this->select_ephemeris(); |
|
| 82 | + $this->sat_data_init_sat($this); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /* Selects the apropriate ephemeris type to be used */ |
|
| 86 | + /* for predictions according to the data in the TLE */ |
|
| 87 | + /* It also processes values in the tle set so that */ |
|
| 88 | + /* they are apropriate for the sgp4/sdp4 routines */ |
|
| 89 | + public function select_ephemeris() |
|
| 90 | + { |
|
| 91 | + /* Preprocess tle set */ |
|
| 92 | + $this->tle->xnodeo *= Predict::de2ra; |
|
| 93 | + $this->tle->omegao *= Predict::de2ra; |
|
| 94 | + $this->tle->xmo *= Predict::de2ra; |
|
| 95 | + $this->tle->xincl *= Predict::de2ra; |
|
| 96 | + $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda; |
|
| 97 | + |
|
| 98 | + /* store mean motion before conversion */ |
|
| 99 | + $this->meanmo = $this->tle->xno; |
|
| 100 | + $this->tle->xno = $this->tle->xno * $temp * Predict::xmnpda; |
|
| 101 | + $this->tle->xndt2o *= $temp; |
|
| 102 | + $this->tle->xndd6o = $this->tle->xndd6o * $temp / Predict::xmnpda; |
|
| 103 | + $this->tle->bstar /= Predict::ae; |
|
| 104 | + |
|
| 105 | + /* Period > 225 minutes is deep space */ |
|
| 106 | + $dd1 = Predict::xke / $this->tle->xno; |
|
| 107 | + $dd2 = Predict::tothrd; |
|
| 108 | + $a1 = pow($dd1, $dd2); |
|
| 109 | + $r1 = cos($this->tle->xincl); |
|
| 110 | + $dd1 = 1.0 - $this->tle->eo * $this->tle->eo; |
|
| 111 | + $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5); |
|
| 112 | + $del1 = $temp / ($a1 * $a1); |
|
| 113 | + $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 * |
|
| 114 | + ($del1 * 1.654320987654321 + 1.0))); |
|
| 115 | + $delo = $temp / ($ao * $ao); |
|
| 116 | + $xnodp = $this->tle->xno / ($delo + 1.0); |
|
| 117 | + |
|
| 118 | + /* Select a deep-space/near-earth ephemeris */ |
|
| 119 | + if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) { |
|
| 120 | + $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
| 121 | + } else { |
|
| 122 | + $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** Initialise satellite data. |
|
| 127 | + * @param sat The satellite to initialise. |
|
| 128 | + * @param qth Optional QTH info, use (0,0) if NULL. |
|
| 129 | + * |
|
| 130 | + * This function calculates the satellite data at t = 0, ie. epoch time |
|
| 131 | + * The function is called automatically by gtk_sat_data_read_sat. |
|
| 132 | + */ |
|
| 133 | + public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null) |
|
| 134 | + { |
|
| 135 | + $obs_geodetic = new Predict_Geodetic(); |
|
| 136 | + $obs_set = new Predict_ObsSet(); |
|
| 137 | + $sat_geodetic = new Predict_Geodetic(); |
|
| 138 | + /* double jul_utc, age; */ |
|
| 139 | + |
|
| 140 | + $jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0 |
|
| 141 | + $sat->jul_epoch = $jul_utc; |
|
| 142 | + |
|
| 143 | + /* initialise observer location */ |
|
| 144 | + if ($qth != null) { |
|
| 145 | + $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
| 146 | + $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
| 147 | + $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 148 | + $obs_geodetic->theta = 0; |
|
| 149 | + } |
|
| 150 | + else { |
|
| 151 | + $obs_geodetic->lon = 0.0; |
|
| 152 | + $obs_geodetic->lat = 0.0; |
|
| 153 | + $obs_geodetic->alt = 0.0; |
|
| 154 | + $obs_geodetic->theta = 0; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /* execute computations */ |
|
| 158 | + $sdpsgp = Predict_SGPSDP::getInstance($sat); |
|
| 159 | + if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 160 | + $sdpsgp->SDP4($sat, 0.0); |
|
| 161 | + } else { |
|
| 162 | + $sdpsgp->SGP4($sat, 0.0); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /* scale position and velocity to km and km/sec */ |
|
| 166 | + Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
|
| 167 | + |
|
| 168 | + /* get the velocity of the satellite */ |
|
| 169 | + $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 170 | + $sat->velo = $sat->vel->w; |
|
| 171 | + Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
|
| 172 | + Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic); |
|
| 173 | + |
|
| 174 | + while ($sat_geodetic->lon < -Predict::pi) { |
|
| 175 | + $sat_geodetic->lon += Predict::twopi; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + while ($sat_geodetic->lon > Predict::pi) { |
|
| 179 | + $sat_geodetic->lon -= Predict::twopi; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + $sat->az = Predict_Math::Degrees($obs_set->az); |
|
| 183 | + $sat->el = Predict_Math::Degrees($obs_set->el); |
|
| 184 | + $sat->range = $obs_set->range; |
|
| 185 | + $sat->range_rate = $obs_set->range_rate; |
|
| 186 | + $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); |
|
| 187 | + $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
|
| 188 | + $sat->alt = $sat_geodetic->alt; |
|
| 189 | + $sat->ma = Predict_Math::Degrees($sat->phase); |
|
| 190 | + $sat->ma *= 256.0 / 360.0; |
|
| 191 | + $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w); |
|
| 192 | + $age = 0.0; |
|
| 193 | + $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi + |
|
| 194 | + $age * $sat->tle->bstar * Predict::ae) * $age + |
|
| 195 | + $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1; |
|
| 196 | + |
|
| 197 | + /* orbit type */ |
|
| 198 | + $sat->otype = $sat->get_orbit_type($sat); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + public function get_orbit_type(Predict_Sat $sat) |
|
| 202 | + { |
|
| 203 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
| 204 | + |
|
| 205 | + if ($this->geostationary($sat)) { |
|
| 206 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_GEO; |
|
| 207 | + } else if ($this->decayed($sat)) { |
|
| 208 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_DECAYED; |
|
| 209 | + } else { |
|
| 210 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + return $orbit; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + /** Determinte whether satellite is in geostationary orbit. |
|
| 218 | + * @author John A. Magliacane, KD2BD |
|
| 219 | + * @param sat Pointer to satellite data. |
|
| 220 | + * @return TRUE if the satellite appears to be in geostationary orbit, |
|
| 221 | + * FALSE otherwise. |
|
| 222 | + * |
|
| 223 | + * A satellite is in geostationary orbit if |
|
| 224 | + * |
|
| 225 | + * fabs (sat.meanmotion - 1.0027) < 0.0002 |
|
| 226 | + * |
|
| 227 | + * Note: Appearantly, the mean motion can deviate much more from 1.0027 than 0.0002 |
|
| 228 | + */ |
|
| 229 | + public function geostationary(Predict_Sat $sat) |
|
| 230 | + { |
|
| 231 | + if (abs($sat->meanmo - 1.0027) < 0.0002) { |
|
| 232 | + return true; |
|
| 233 | + } else { |
|
| 234 | + return false; |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** Determine whether satellite has decayed. |
|
| 240 | + * @author John A. Magliacane, KD2BD |
|
| 241 | + * @author Alexandru Csete, OZ9AEC |
|
| 242 | + * @param sat Pointer to satellite data. |
|
| 243 | + * @return TRUE if the satellite appears to have decayed, FALSE otherwise. |
|
| 244 | + * @bug Modified version of the predict code but it is not tested. |
|
| 245 | + * |
|
| 246 | + * A satellite is decayed if |
|
| 247 | + * |
|
| 248 | + * satepoch + ((16.666666 - sat.meanmo) / (10.0*fabs(sat.drag))) < "now" |
|
| 249 | + * |
|
| 250 | + */ |
|
| 251 | + public function decayed(Predict_Sat $sat) |
|
| 252 | + { |
|
| 253 | + /* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the |
|
| 254 | 254 | value matches up with the value in predict 2.2.3 */ |
| 255 | - /*** FIXME decayed is treated as a static quantity. |
|
| 255 | + /*** FIXME decayed is treated as a static quantity. |
|
| 256 | 256 | It is time dependent. Also sat->jul_utc is often zero |
| 257 | 257 | when this function is called |
| 258 | 258 | ***/ |
| 259 | - if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) { |
|
| 260 | - return true; |
|
| 261 | - } elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) / |
|
| 262 | - (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) { |
|
| 263 | - return true; |
|
| 264 | - } else { |
|
| 265 | - return false; |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Experimental attempt at calculating apparent magnitude. Known intrinsic |
|
| 271 | - * magnitudes are listed inside the function for now. |
|
| 272 | - * |
|
| 273 | - * @param float $time The daynum the satellite is calculated for |
|
| 274 | - * @param Predict_QTH $qth The observer location |
|
| 275 | - * |
|
| 276 | - * @return null on failure, float otherwise |
|
| 277 | - */ |
|
| 278 | - public function calculateApparentMagnitude($time, Predict_QTH $qth) |
|
| 279 | - { |
|
| 280 | - // Recorded intrinsic magnitudes and their respective |
|
| 281 | - // illumination and distance from heavens-above.com |
|
| 282 | - static $intrinsicMagnitudes = array( |
|
| 283 | - '25544' => array( |
|
| 284 | - 'mag' => -1.3, |
|
| 285 | - 'illum' => .5, |
|
| 286 | - 'distance' => 1000, |
|
| 287 | - ) |
|
| 288 | - ); |
|
| 289 | - |
|
| 290 | - // Return null if we don't have a record of the intrinsic mag |
|
| 291 | - if (!isset($intrinsicMagnitudes[$this->tle->catnr])) { |
|
| 292 | - return null; |
|
| 293 | - } |
|
| 294 | - $imag = $intrinsicMagnitudes[$this->tle->catnr]; |
|
| 295 | - |
|
| 296 | - // Convert the observer's geodetic info to radians and km so |
|
| 297 | - // we can compare vectors |
|
| 298 | - $observerGeo = new Predict_Geodetic(); |
|
| 299 | - $observerGeo->lat = Predict_Math::Radians($qth->lat); |
|
| 300 | - $observerGeo->lon = Predict_Math::Radians($qth->lon); |
|
| 301 | - $observerGeo->alt = $qth->alt * 1000; |
|
| 302 | - |
|
| 303 | - // Now determine the sun and observer positions |
|
| 304 | - $observerPos = new Predict_Vector(); |
|
| 305 | - $observerVel = new Predict_Vector(); |
|
| 306 | - $solarVector = new Predict_Vector(); |
|
| 307 | - Predict_Solar::Calculate_Solar_Position($time, $solarVector); |
|
| 308 | - Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel); |
|
| 309 | - |
|
| 310 | - // Determine the solar phase and and thus the percent illumination |
|
| 311 | - $observerSatPos = new Predict_Vector(); |
|
| 312 | - Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos); |
|
| 313 | - $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos)); |
|
| 314 | - $illum = $phaseAngle / 180; |
|
| 315 | - |
|
| 316 | - $illuminationChange = $illum / $imag['illum']; |
|
| 317 | - $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2); |
|
| 318 | - $changeInMagnitude = log( |
|
| 319 | - $illuminationChange * $inverseSquareOfDistanceChange, |
|
| 320 | - self::POGSONS_RATIO |
|
| 321 | - ); |
|
| 322 | - |
|
| 323 | - return $imag['mag'] - $changeInMagnitude; |
|
| 324 | - } |
|
| 259 | + if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) { |
|
| 260 | + return true; |
|
| 261 | + } elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) / |
|
| 262 | + (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) { |
|
| 263 | + return true; |
|
| 264 | + } else { |
|
| 265 | + return false; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Experimental attempt at calculating apparent magnitude. Known intrinsic |
|
| 271 | + * magnitudes are listed inside the function for now. |
|
| 272 | + * |
|
| 273 | + * @param float $time The daynum the satellite is calculated for |
|
| 274 | + * @param Predict_QTH $qth The observer location |
|
| 275 | + * |
|
| 276 | + * @return null on failure, float otherwise |
|
| 277 | + */ |
|
| 278 | + public function calculateApparentMagnitude($time, Predict_QTH $qth) |
|
| 279 | + { |
|
| 280 | + // Recorded intrinsic magnitudes and their respective |
|
| 281 | + // illumination and distance from heavens-above.com |
|
| 282 | + static $intrinsicMagnitudes = array( |
|
| 283 | + '25544' => array( |
|
| 284 | + 'mag' => -1.3, |
|
| 285 | + 'illum' => .5, |
|
| 286 | + 'distance' => 1000, |
|
| 287 | + ) |
|
| 288 | + ); |
|
| 289 | + |
|
| 290 | + // Return null if we don't have a record of the intrinsic mag |
|
| 291 | + if (!isset($intrinsicMagnitudes[$this->tle->catnr])) { |
|
| 292 | + return null; |
|
| 293 | + } |
|
| 294 | + $imag = $intrinsicMagnitudes[$this->tle->catnr]; |
|
| 295 | + |
|
| 296 | + // Convert the observer's geodetic info to radians and km so |
|
| 297 | + // we can compare vectors |
|
| 298 | + $observerGeo = new Predict_Geodetic(); |
|
| 299 | + $observerGeo->lat = Predict_Math::Radians($qth->lat); |
|
| 300 | + $observerGeo->lon = Predict_Math::Radians($qth->lon); |
|
| 301 | + $observerGeo->alt = $qth->alt * 1000; |
|
| 302 | + |
|
| 303 | + // Now determine the sun and observer positions |
|
| 304 | + $observerPos = new Predict_Vector(); |
|
| 305 | + $observerVel = new Predict_Vector(); |
|
| 306 | + $solarVector = new Predict_Vector(); |
|
| 307 | + Predict_Solar::Calculate_Solar_Position($time, $solarVector); |
|
| 308 | + Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel); |
|
| 309 | + |
|
| 310 | + // Determine the solar phase and and thus the percent illumination |
|
| 311 | + $observerSatPos = new Predict_Vector(); |
|
| 312 | + Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos); |
|
| 313 | + $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos)); |
|
| 314 | + $illum = $phaseAngle / 180; |
|
| 315 | + |
|
| 316 | + $illuminationChange = $illum / $imag['illum']; |
|
| 317 | + $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2); |
|
| 318 | + $changeInMagnitude = log( |
|
| 319 | + $illuminationChange * $inverseSquareOfDistanceChange, |
|
| 320 | + self::POGSONS_RATIO |
|
| 321 | + ); |
|
| 322 | + |
|
| 323 | + return $imag['mag'] - $changeInMagnitude; |
|
| 324 | + } |
|
| 325 | 325 | } |
@@ -29,42 +29,42 @@ discard block |
||
| 29 | 29 | public $nickname = null; |
| 30 | 30 | public $website = null; |
| 31 | 31 | |
| 32 | - public $tle = null; /*!< Keplerian elements */ |
|
| 33 | - public $flags = 0; /*!< Flags for algo ctrl */ |
|
| 32 | + public $tle = null; /*!< Keplerian elements */ |
|
| 33 | + public $flags = 0; /*!< Flags for algo ctrl */ |
|
| 34 | 34 | public $sgps = null; |
| 35 | 35 | public $dps = null; |
| 36 | 36 | public $deep_arg = null; |
| 37 | - public $pos = null; /*!< Raw position and range */ |
|
| 38 | - public $vel = null; /*!< Raw velocity */ |
|
| 37 | + public $pos = null; /*!< Raw position and range */ |
|
| 38 | + public $vel = null; /*!< Raw velocity */ |
|
| 39 | 39 | |
| 40 | 40 | /*** FIXME: REMOVE */ |
| 41 | - public $bearing = null; /*!< Az, El, range and vel */ |
|
| 42 | - public $astro = null; /*!< Ra and Decl */ |
|
| 41 | + public $bearing = null; /*!< Az, El, range and vel */ |
|
| 42 | + public $astro = null; /*!< Ra and Decl */ |
|
| 43 | 43 | /*** END */ |
| 44 | 44 | |
| 45 | 45 | /* time keeping fields */ |
| 46 | 46 | public $jul_epoch = null; |
| 47 | 47 | public $jul_utc = null; |
| 48 | 48 | public $tsince = null; |
| 49 | - public $aos = null; /*!< Next AOS. */ |
|
| 50 | - public $los = null; /*!< Next LOS */ |
|
| 51 | - |
|
| 52 | - public $az = null; /*!< Azimuth [deg] */ |
|
| 53 | - public $el = null; /*!< Elevation [deg] */ |
|
| 54 | - public $range = null; /*!< Range [km] */ |
|
| 55 | - public $range_rate = null; /*!< Range Rate [km/sec] */ |
|
| 56 | - public $ra = null; /*!< Right Ascension [deg] */ |
|
| 57 | - public $dec = null; /*!< Declination [deg] */ |
|
| 58 | - public $ssplat = null; /*!< SSP latitude [deg] */ |
|
| 59 | - public $ssplon = null; /*!< SSP longitude [deg] */ |
|
| 60 | - public $alt = null; /*!< altitude [km] */ |
|
| 61 | - public $velo = null; /*!< velocity [km/s] */ |
|
| 62 | - public $ma = null; /*!< mean anomaly */ |
|
| 63 | - public $footprint = null; /*!< footprint */ |
|
| 64 | - public $phase = null; /*!< orbit phase */ |
|
| 65 | - public $meanmo = null; /*!< mean motion kept in rev/day */ |
|
| 66 | - public $orbit = null; /*!< orbit number */ |
|
| 67 | - public $otype = null; /*!< orbit type. */ |
|
| 49 | + public $aos = null; /*!< Next AOS. */ |
|
| 50 | + public $los = null; /*!< Next LOS */ |
|
| 51 | + |
|
| 52 | + public $az = null; /*!< Azimuth [deg] */ |
|
| 53 | + public $el = null; /*!< Elevation [deg] */ |
|
| 54 | + public $range = null; /*!< Range [km] */ |
|
| 55 | + public $range_rate = null; /*!< Range Rate [km/sec] */ |
|
| 56 | + public $ra = null; /*!< Right Ascension [deg] */ |
|
| 57 | + public $dec = null; /*!< Declination [deg] */ |
|
| 58 | + public $ssplat = null; /*!< SSP latitude [deg] */ |
|
| 59 | + public $ssplon = null; /*!< SSP longitude [deg] */ |
|
| 60 | + public $alt = null; /*!< altitude [km] */ |
|
| 61 | + public $velo = null; /*!< velocity [km/s] */ |
|
| 62 | + public $ma = null; /*!< mean anomaly */ |
|
| 63 | + public $footprint = null; /*!< footprint */ |
|
| 64 | + public $phase = null; /*!< orbit phase */ |
|
| 65 | + public $meanmo = null; /*!< mean motion kept in rev/day */ |
|
| 66 | + public $orbit = null; /*!< orbit number */ |
|
| 67 | + public $otype = null; /*!< orbit type. */ |
|
| 68 | 68 | |
| 69 | 69 | public function __construct(Predict_TLE $tle) |
| 70 | 70 | { |
@@ -93,30 +93,30 @@ discard block |
||
| 93 | 93 | $this->tle->omegao *= Predict::de2ra; |
| 94 | 94 | $this->tle->xmo *= Predict::de2ra; |
| 95 | 95 | $this->tle->xincl *= Predict::de2ra; |
| 96 | - $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda; |
|
| 96 | + $temp = Predict::twopi/Predict::xmnpda/Predict::xmnpda; |
|
| 97 | 97 | |
| 98 | 98 | /* store mean motion before conversion */ |
| 99 | 99 | $this->meanmo = $this->tle->xno; |
| 100 | - $this->tle->xno = $this->tle->xno * $temp * Predict::xmnpda; |
|
| 100 | + $this->tle->xno = $this->tle->xno*$temp*Predict::xmnpda; |
|
| 101 | 101 | $this->tle->xndt2o *= $temp; |
| 102 | - $this->tle->xndd6o = $this->tle->xndd6o * $temp / Predict::xmnpda; |
|
| 102 | + $this->tle->xndd6o = $this->tle->xndd6o*$temp/Predict::xmnpda; |
|
| 103 | 103 | $this->tle->bstar /= Predict::ae; |
| 104 | 104 | |
| 105 | 105 | /* Period > 225 minutes is deep space */ |
| 106 | - $dd1 = Predict::xke / $this->tle->xno; |
|
| 106 | + $dd1 = Predict::xke/$this->tle->xno; |
|
| 107 | 107 | $dd2 = Predict::tothrd; |
| 108 | 108 | $a1 = pow($dd1, $dd2); |
| 109 | 109 | $r1 = cos($this->tle->xincl); |
| 110 | - $dd1 = 1.0 - $this->tle->eo * $this->tle->eo; |
|
| 111 | - $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5); |
|
| 112 | - $del1 = $temp / ($a1 * $a1); |
|
| 113 | - $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 * |
|
| 114 | - ($del1 * 1.654320987654321 + 1.0))); |
|
| 115 | - $delo = $temp / ($ao * $ao); |
|
| 116 | - $xnodp = $this->tle->xno / ($delo + 1.0); |
|
| 110 | + $dd1 = 1.0 - $this->tle->eo*$this->tle->eo; |
|
| 111 | + $temp = Predict::ck2*1.5*($r1*$r1*3.0 - 1.0)/pow($dd1, 1.5); |
|
| 112 | + $del1 = $temp/($a1*$a1); |
|
| 113 | + $ao = $a1*(1.0 - $del1*(Predict::tothrd*0.5 + $del1* |
|
| 114 | + ($del1*1.654320987654321 + 1.0))); |
|
| 115 | + $delo = $temp/($ao*$ao); |
|
| 116 | + $xnodp = $this->tle->xno/($delo + 1.0); |
|
| 117 | 117 | |
| 118 | 118 | /* Select a deep-space/near-earth ephemeris */ |
| 119 | - if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) { |
|
| 119 | + if (Predict::twopi/$xnodp/Predict::xmnpda >= .15625) { |
|
| 120 | 120 | $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
| 121 | 121 | } else { |
| 122 | 122 | $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | /* initialise observer location */ |
| 144 | 144 | if ($qth != null) { |
| 145 | - $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
| 146 | - $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
| 147 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 145 | + $obs_geodetic->lon = $qth->lon*Predict::de2ra; |
|
| 146 | + $obs_geodetic->lat = $qth->lat*Predict::de2ra; |
|
| 147 | + $obs_geodetic->alt = $qth->alt/1000.0; |
|
| 148 | 148 | $obs_geodetic->theta = 0; |
| 149 | 149 | } |
| 150 | 150 | else { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | /* execute computations */ |
| 158 | 158 | $sdpsgp = Predict_SGPSDP::getInstance($sat); |
| 159 | - if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 159 | + if ($sat->flags&Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 160 | 160 | $sdpsgp->SDP4($sat, 0.0); |
| 161 | 161 | } else { |
| 162 | 162 | $sdpsgp->SGP4($sat, 0.0); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
| 167 | 167 | |
| 168 | 168 | /* get the velocity of the satellite */ |
| 169 | - $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 169 | + $sat->vel->w = sqrt($sat->vel->x*$sat->vel->x + $sat->vel->y*$sat->vel->y + $sat->vel->z*$sat->vel->z); |
|
| 170 | 170 | $sat->velo = $sat->vel->w; |
| 171 | 171 | Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
| 172 | 172 | Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic); |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
| 188 | 188 | $sat->alt = $sat_geodetic->alt; |
| 189 | 189 | $sat->ma = Predict_Math::Degrees($sat->phase); |
| 190 | - $sat->ma *= 256.0 / 360.0; |
|
| 191 | - $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w); |
|
| 190 | + $sat->ma *= 256.0/360.0; |
|
| 191 | + $sat->footprint = 2.0*Predict::xkmper*acos(Predict::xkmper/$sat->pos->w); |
|
| 192 | 192 | $age = 0.0; |
| 193 | - $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi + |
|
| 194 | - $age * $sat->tle->bstar * Predict::ae) * $age + |
|
| 195 | - $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1; |
|
| 193 | + $sat->orbit = floor(($sat->tle->xno*Predict::xmnpda/Predict::twopi + |
|
| 194 | + $age*$sat->tle->bstar*Predict::ae)*$age + |
|
| 195 | + $sat->tle->xmo/Predict::twopi) + $sat->tle->revnum - 1; |
|
| 196 | 196 | |
| 197 | 197 | /* orbit type */ |
| 198 | 198 | $sat->otype = $sat->get_orbit_type($sat); |
@@ -256,10 +256,10 @@ discard block |
||
| 256 | 256 | It is time dependent. Also sat->jul_utc is often zero |
| 257 | 257 | when this function is called |
| 258 | 258 | ***/ |
| 259 | - if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) { |
|
| 259 | + if ((10.0*abs($sat->tle->xndt2o/(Predict::twopi/Predict::xmnpda/Predict::xmnpda))) == 0) { |
|
| 260 | 260 | return true; |
| 261 | - } elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) / |
|
| 262 | - (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) { |
|
| 261 | + } elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo)/ |
|
| 262 | + (10.0*abs($sat->tle->xndt2o/(Predict::twopi/Predict::xmnpda/Predict::xmnpda)))) < $sat->jul_utc) { |
|
| 263 | 263 | return true; |
| 264 | 264 | } else { |
| 265 | 265 | return false; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | $observerGeo = new Predict_Geodetic(); |
| 299 | 299 | $observerGeo->lat = Predict_Math::Radians($qth->lat); |
| 300 | 300 | $observerGeo->lon = Predict_Math::Radians($qth->lon); |
| 301 | - $observerGeo->alt = $qth->alt * 1000; |
|
| 301 | + $observerGeo->alt = $qth->alt*1000; |
|
| 302 | 302 | |
| 303 | 303 | // Now determine the sun and observer positions |
| 304 | 304 | $observerPos = new Predict_Vector(); |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | $observerSatPos = new Predict_Vector(); |
| 312 | 312 | Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos); |
| 313 | 313 | $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos)); |
| 314 | - $illum = $phaseAngle / 180; |
|
| 314 | + $illum = $phaseAngle/180; |
|
| 315 | 315 | |
| 316 | - $illuminationChange = $illum / $imag['illum']; |
|
| 317 | - $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2); |
|
| 316 | + $illuminationChange = $illum/$imag['illum']; |
|
| 317 | + $inverseSquareOfDistanceChange = pow(($imag['distance']/$this->range), 2); |
|
| 318 | 318 | $changeInMagnitude = log( |
| 319 | - $illuminationChange * $inverseSquareOfDistanceChange, |
|
| 319 | + $illuminationChange*$inverseSquareOfDistanceChange, |
|
| 320 | 320 | self::POGSONS_RATIO |
| 321 | 321 | ); |
| 322 | 322 | |
@@ -146,8 +146,7 @@ |
||
| 146 | 146 | $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
| 147 | 147 | $obs_geodetic->alt = $qth->alt / 1000.0; |
| 148 | 148 | $obs_geodetic->theta = 0; |
| 149 | - } |
|
| 150 | - else { |
|
| 149 | + } else { |
|
| 151 | 150 | $obs_geodetic->lon = 0.0; |
| 152 | 151 | $obs_geodetic->lat = 0.0; |
| 153 | 152 | $obs_geodetic->alt = 0.0; |