@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | //waypoint plotting |
| 93 | - /* |
|
| 93 | + /* |
|
| 94 | 94 | $output .= '{'; |
| 95 | 95 | $output .= '"type": "Feature",'; |
| 96 | 96 | $output .= '"properties": {'; |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | $output_time .= (strtotime($spotter_history['date'])*1000).','; |
| 270 | 270 | } |
| 271 | 271 | if (isset($output_time)) { |
| 272 | - $output_time = substr($output_time, 0, -1); |
|
| 273 | - $output .= '"time": ['.$output_time.'],'; |
|
| 272 | + $output_time = substr($output_time, 0, -1); |
|
| 273 | + $output .= '"time": ['.$output_time.'],'; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | $output .= '"coordinates": ['; |
| 285 | 285 | |
| 286 | 286 | if (isset($output_history)) { |
| 287 | - $output_history = substr($output_history, 0, -1); |
|
| 288 | - $output .= $output_history; |
|
| 287 | + $output_history = substr($output_history, 0, -1); |
|
| 288 | + $output .= $output_history; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | $output .= ']'; |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | ?> |
| 250 | 250 | <div class="more"> |
| 251 | 251 | <?php |
| 252 | - /* |
|
| 252 | + /* |
|
| 253 | 253 | if ($year != '' && $month != '') { |
| 254 | 254 | ?> |
| 255 | 255 | <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | <?php |
| 261 | 261 | } |
| 262 | 262 | */ |
| 263 | - ?> |
|
| 263 | + ?> |
|
| 264 | 264 | </div> |
| 265 | 265 | </div> |
| 266 | 266 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | ?> |
| 295 | 295 | <div class="more"> |
| 296 | 296 | <?php |
| 297 | - /* |
|
| 297 | + /* |
|
| 298 | 298 | if ($year != '' && $month != '') { |
| 299 | 299 | ?> |
| 300 | 300 | <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | <?php |
| 306 | 306 | } |
| 307 | 307 | */ |
| 308 | - ?> |
|
| 308 | + ?> |
|
| 309 | 309 | </div> |
| 310 | 310 | </div> |
| 311 | 311 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -404,17 +404,17 @@ discard block |
||
| 404 | 404 | } |
| 405 | 405 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 406 | 406 | } else $all = array(); |
| 407 | - if (empty($all)) { |
|
| 408 | - $Spotter = new Spotter($this->db); |
|
| 409 | - $filters = array(); |
|
| 407 | + if (empty($all)) { |
|
| 408 | + $Spotter = new Spotter($this->db); |
|
| 409 | + $filters = array(); |
|
| 410 | 410 | $filters = array('year' => $year,'month' => $month); |
| 411 | - if ($filter_name != '') { |
|
| 412 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 411 | + if ($filter_name != '') { |
|
| 412 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 413 | 413 | } |
| 414 | 414 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
| 415 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
| 416 | - } |
|
| 417 | - return $all; |
|
| 415 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
| 416 | + } |
|
| 417 | + return $all; |
|
| 418 | 418 | } |
| 419 | 419 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 420 | 420 | global $globalStatsFilters; |
@@ -1611,7 +1611,7 @@ discard block |
||
| 1611 | 1611 | return "error : ".$e->getMessage(); |
| 1612 | 1612 | } |
| 1613 | 1613 | } |
| 1614 | - /* |
|
| 1614 | + /* |
|
| 1615 | 1615 | public function getStatsSource($date,$stats_type = '') { |
| 1616 | 1616 | if ($stats_type == '') { |
| 1617 | 1617 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -7,35 +7,35 @@ discard block |
||
| 7 | 7 | public $latest_schema = 46; |
| 8 | 8 | |
| 9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
| 10 | - global $globalNoDB; |
|
| 11 | - if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
| 10 | + global $globalNoDB; |
|
| 11 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
| 12 | 12 | $this->db = null; |
| 13 | - } else { |
|
| 13 | + } else { |
|
| 14 | 14 | if ($dbc === null) { |
| 15 | - if ($this->db === null && $dbname === null) { |
|
| 15 | + if ($this->db === null && $dbname === null) { |
|
| 16 | 16 | if ($user === null && $pass === null) { |
| 17 | - $this->createDBConnection(); |
|
| 17 | + $this->createDBConnection(); |
|
| 18 | 18 | } else { |
| 19 | - $this->createDBConnection(null,$user,$pass); |
|
| 19 | + $this->createDBConnection(null,$user,$pass); |
|
| 20 | 20 | } |
| 21 | - } else { |
|
| 21 | + } else { |
|
| 22 | 22 | $this->createDBConnection($dbname); |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | } elseif ($dbname === null || $dbname === 'default') { |
| 25 | - $this->db = $dbc; |
|
| 26 | - if ($this->connectionExists() === false) { |
|
| 25 | + $this->db = $dbc; |
|
| 26 | + if ($this->connectionExists() === false) { |
|
| 27 | 27 | /* |
| 28 | 28 | echo 'Restart Connection !!!'."\n"; |
| 29 | 29 | $e = new \Exception; |
| 30 | 30 | var_dump($e->getTraceAsString()); |
| 31 | 31 | */ |
| 32 | 32 | $this->createDBConnection(); |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | } else { |
| 35 | - //$this->connectionExists(); |
|
| 36 | - $this->dbs[$dbname] = $dbc; |
|
| 35 | + //$this->connectionExists(); |
|
| 36 | + $this->dbs[$dbname] = $dbc; |
|
| 37 | + } |
|
| 37 | 38 | } |
| 38 | - } |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function db() { |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * Creates the database connection |
|
| 60 | - * |
|
| 61 | - * @return Boolean of the database connection |
|
| 62 | - * |
|
| 63 | - */ |
|
| 59 | + * Creates the database connection |
|
| 60 | + * |
|
| 61 | + * @return Boolean of the database connection |
|
| 62 | + * |
|
| 63 | + */ |
|
| 64 | 64 | |
| 65 | 65 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
| 66 | 66 | { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | return false; |
| 159 | 159 | } |
| 160 | 160 | if($results->rowCount()>0) { |
| 161 | - return true; |
|
| 161 | + return true; |
|
| 162 | 162 | } |
| 163 | 163 | else return false; |
| 164 | 164 | } |
@@ -176,14 +176,14 @@ discard block |
||
| 176 | 176 | $sum = $sum->fetchColumn(0); |
| 177 | 177 | } else $sum = 0; |
| 178 | 178 | if (intval($sum) !== 2) { |
| 179 | - return false; |
|
| 179 | + return false; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | } catch(PDOException $e) { |
| 183 | 183 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
| 184 | - throw $e; |
|
| 185 | - } |
|
| 186 | - //echo 'error ! '.$e->getMessage(); |
|
| 184 | + throw $e; |
|
| 185 | + } |
|
| 186 | + //echo 'error ! '.$e->getMessage(); |
|
| 187 | 187 | return false; |
| 188 | 188 | } |
| 189 | 189 | return true; |
@@ -287,8 +287,8 @@ discard block |
||
| 287 | 287 | $version = 0; |
| 288 | 288 | if ($this->tableExists('aircraft')) { |
| 289 | 289 | if (!$this->tableExists('config')) { |
| 290 | - $version = '1'; |
|
| 291 | - return $version; |
|
| 290 | + $version = '1'; |
|
| 291 | + return $version; |
|
| 292 | 292 | } else { |
| 293 | 293 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
| 294 | 294 | try { |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | * @return Boolean if latest version or not |
| 310 | 310 | */ |
| 311 | 311 | public function latest() { |
| 312 | - global $globalNoDB; |
|
| 313 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 314 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 315 | - else return false; |
|
| 312 | + global $globalNoDB; |
|
| 313 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 314 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 315 | + else return false; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | } |
@@ -124,11 +124,11 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | - * Gets all launch site |
|
| 128 | - * |
|
| 129 | - * @return Array the launch site list |
|
| 130 | - * |
|
| 131 | - */ |
|
| 127 | + * Gets all launch site |
|
| 128 | + * |
|
| 129 | + * @return Array the launch site list |
|
| 130 | + * |
|
| 131 | + */ |
|
| 132 | 132 | public function countAllLaunchSite($limit = true, $filters = array()) |
| 133 | 133 | { |
| 134 | 134 | global $globalDBdriver; |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | - * Gets all owners |
|
| 157 | - * |
|
| 158 | - * @return Array the owners list |
|
| 159 | - * |
|
| 160 | - */ |
|
| 156 | + * Gets all owners |
|
| 157 | + * |
|
| 158 | + * @return Array the owners list |
|
| 159 | + * |
|
| 160 | + */ |
|
| 161 | 161 | public function countAllOwners($limit = true, $filters = array()) |
| 162 | 162 | { |
| 163 | 163 | global $globalDBdriver; |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | - * Gets all countries owners |
|
| 186 | - * |
|
| 187 | - * @return Array the countries list |
|
| 188 | - * |
|
| 189 | - */ |
|
| 185 | + * Gets all countries owners |
|
| 186 | + * |
|
| 187 | + * @return Array the countries list |
|
| 188 | + * |
|
| 189 | + */ |
|
| 190 | 190 | public function countAllCountriesOwners($limit = true, $filters = array()) |
| 191 | 191 | { |
| 192 | 192 | global $globalDBdriver; |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | - * Counts all launch dates during the last year |
|
| 215 | - * |
|
| 216 | - * @return Array the launch date list |
|
| 217 | - * |
|
| 218 | - */ |
|
| 214 | + * Counts all launch dates during the last year |
|
| 215 | + * |
|
| 216 | + * @return Array the launch date list |
|
| 217 | + * |
|
| 218 | + */ |
|
| 219 | 219 | public function countAllMonthsLastYear($filters = array(), $sincedate = '') |
| 220 | 220 | { |
| 221 | 221 | global $globalTimezone, $globalDBdriver; |
@@ -256,11 +256,11 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | - * Counts all dates during the last 10 years |
|
| 260 | - * |
|
| 261 | - * @return Array the date list |
|
| 262 | - * |
|
| 263 | - */ |
|
| 259 | + * Counts all dates during the last 10 years |
|
| 260 | + * |
|
| 261 | + * @return Array the date list |
|
| 262 | + * |
|
| 263 | + */ |
|
| 264 | 264 | public function countAllYears($filters = array(), $sincedate = '') |
| 265 | 265 | { |
| 266 | 266 | global $globalTimezone, $globalDBdriver; |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 18 | 18 | if (isset($globalMarine) && $globalMarine) { |
| 19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,46 +25,46 @@ discard block |
||
| 25 | 25 | // Check if schema is at latest version |
| 26 | 26 | $Connection = new Connection(); |
| 27 | 27 | if ($Connection->connectionExists() === false) { |
| 28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 29 | - exit(); |
|
| 28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 29 | + exit(); |
|
| 30 | 30 | } |
| 31 | 31 | if ($Connection->latest() === false) { |
| 32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 33 | - exit(); |
|
| 32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 33 | + exit(); |
|
| 34 | 34 | } |
| 35 | 35 | if (PHP_SAPI != 'cli') { |
| 36 | - echo "This script MUST be called from console, not a web browser."; |
|
| 36 | + echo "This script MUST be called from console, not a web browser."; |
|
| 37 | 37 | // exit(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // This is to be compatible with old version of settings.php |
| 41 | 41 | if (!isset($globalSources)) { |
| 42 | - if (isset($globalSBS1Hosts)) { |
|
| 43 | - //$hosts = $globalSBS1Hosts; |
|
| 44 | - foreach ($globalSBS1Hosts as $host) { |
|
| 45 | - $globalSources[] = array('host' => $host); |
|
| 46 | - } |
|
| 47 | - } else { |
|
| 48 | - if (!isset($globalSBS1Host)) { |
|
| 49 | - echo '$globalSources MUST be defined !'; |
|
| 50 | - die; |
|
| 42 | + if (isset($globalSBS1Hosts)) { |
|
| 43 | + //$hosts = $globalSBS1Hosts; |
|
| 44 | + foreach ($globalSBS1Hosts as $host) { |
|
| 45 | + $globalSources[] = array('host' => $host); |
|
| 46 | + } |
|
| 47 | + } else { |
|
| 48 | + if (!isset($globalSBS1Host)) { |
|
| 49 | + echo '$globalSources MUST be defined !'; |
|
| 50 | + die; |
|
| 51 | 51 | } |
| 52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
| 58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 60 | 60 | if (isset($options['s'])) { |
| 61 | - $globalSources = array(); |
|
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['s']); |
|
| 61 | + $globalSources = array(); |
|
| 62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | + else $globalSources[] = array('host' => $options['s']); |
|
| 64 | 64 | } elseif (isset($options['source'])) { |
| 65 | - $globalSources = array(); |
|
| 66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | - else $globalSources[] = array('host' => $options['source']); |
|
| 65 | + $globalSources = array(); |
|
| 66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | + else $globalSources[] = array('host' => $options['source']); |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($options['aprsserverhost'])) { |
| 70 | 70 | $globalServerAPRS = TRUE; |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 80 | 80 | else $id_source = 1; |
| 81 | 81 | if (isset($globalServer) && $globalServer) { |
| 82 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 83 | - $SI=new SpotterServer(); |
|
| 82 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 83 | + $SI=new SpotterServer(); |
|
| 84 | 84 | /* |
| 85 | 85 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 86 | 86 | $SI = new adsb2aprs(); |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | } else $SI=new SpotterImport($Connection->db); |
| 90 | 90 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 91 | 91 | if (isset($globalMarine) && $globalMarine) { |
| 92 | - $AIS = new AIS(); |
|
| 93 | - $MI = new MarineImport($Connection->db); |
|
| 92 | + $AIS = new AIS(); |
|
| 93 | + $MI = new MarineImport($Connection->db); |
|
| 94 | 94 | } |
| 95 | 95 | //$APRS=new APRS($Connection->db); |
| 96 | 96 | $SBS=new SBS(); |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | //$servertz = system('date +%Z'); |
| 102 | 102 | // signal handler - playing nice with sockets and dump1090 |
| 103 | 103 | if (function_exists('pcntl_fork')) { |
| 104 | - pcntl_signal(SIGINT, function() { |
|
| 105 | - global $sockets; |
|
| 106 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 107 | - die("Bye!\n"); |
|
| 108 | - }); |
|
| 109 | - pcntl_signal_dispatch(); |
|
| 104 | + pcntl_signal(SIGINT, function() { |
|
| 105 | + global $sockets; |
|
| 106 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 107 | + die("Bye!\n"); |
|
| 108 | + }); |
|
| 109 | + pcntl_signal_dispatch(); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // let's try and connect |
@@ -116,36 +116,36 @@ discard block |
||
| 116 | 116 | $reset = 0; |
| 117 | 117 | |
| 118 | 118 | function connect_all($hosts) { |
| 119 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 120 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 121 | - $reset++; |
|
| 122 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 123 | - foreach ($hosts as $id => $value) { |
|
| 119 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 120 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 121 | + $reset++; |
|
| 122 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 123 | + foreach ($hosts as $id => $value) { |
|
| 124 | 124 | $host = $value['host']; |
| 125 | 125 | $globalSources[$id]['last_exec'] = 0; |
| 126 | 126 | // Here we check type of source(s) |
| 127 | 127 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 128 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 129 | - //$formats[$id] = 'deltadbtxt'; |
|
| 130 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 131 | - //$last_exec['deltadbtxt'] = 0; |
|
| 132 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 133 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 134 | - //$formats[$id] = 'vatsimtxt'; |
|
| 135 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 136 | - //$last_exec['vatsimtxt'] = 0; |
|
| 137 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 138 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 139 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 140 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 141 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 142 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 143 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 144 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 145 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 146 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 147 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 148 | - /* |
|
| 128 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 129 | + //$formats[$id] = 'deltadbtxt'; |
|
| 130 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 131 | + //$last_exec['deltadbtxt'] = 0; |
|
| 132 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 133 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 134 | + //$formats[$id] = 'vatsimtxt'; |
|
| 135 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 136 | + //$last_exec['vatsimtxt'] = 0; |
|
| 137 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 138 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 139 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 140 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 141 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 142 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 143 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 144 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 145 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 146 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 147 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 148 | + /* |
|
| 149 | 149 | // Disabled for now, site change source format |
| 150 | 150 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
| 151 | 151 | //$formats[$id] = 'radarvirtueljson'; |
@@ -157,121 +157,121 @@ discard block |
||
| 157 | 157 | exit(0); |
| 158 | 158 | } |
| 159 | 159 | */ |
| 160 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 161 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 162 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 163 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 164 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 165 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 166 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 167 | - exit(0); |
|
| 168 | - } |
|
| 169 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 170 | - //$formats[$id] = 'phpvmacars'; |
|
| 171 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 172 | - //$last_exec['phpvmacars'] = 0; |
|
| 173 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 174 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 175 | - //$formats[$id] = 'phpvmacars'; |
|
| 176 | - $globalSources[$id]['format'] = 'vam'; |
|
| 177 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 178 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 179 | - //$formats[$id] = 'whazzup'; |
|
| 180 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 181 | - //$last_exec['whazzup'] = 0; |
|
| 182 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 183 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
| 184 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
| 185 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 186 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 187 | - $globalSources[$id]['format'] = 'airwhere'; |
|
| 188 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 189 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 190 | - //$formats[$id] = 'pirepsjson'; |
|
| 191 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 192 | - //$last_exec['pirepsjson'] = 0; |
|
| 193 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 194 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 195 | - //$formats[$id] = 'fr24json'; |
|
| 196 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 197 | - //$last_exec['fr24json'] = 0; |
|
| 198 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 199 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 200 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 201 | - exit(0); |
|
| 202 | - } |
|
| 203 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 204 | - //$formats[$id] = 'fr24json'; |
|
| 205 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 206 | - //$last_exec['fr24json'] = 0; |
|
| 207 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 208 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 209 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 210 | - exit(0); |
|
| 211 | - } |
|
| 212 | - //} else if (preg_match('/10001/',$host)) { |
|
| 213 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 214 | - //$formats[$id] = 'tsv'; |
|
| 215 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 216 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 217 | - } |
|
| 218 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 219 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 220 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 221 | - if ($idf !== false) { |
|
| 222 | - $httpfeeds[$id] = $idf; |
|
| 223 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 224 | - } |
|
| 225 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 226 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 227 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 228 | - $hostport = explode(':',$host); |
|
| 229 | - if (isset($hostport[1])) { |
|
| 160 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 161 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 162 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 163 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 164 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 165 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 166 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 167 | + exit(0); |
|
| 168 | + } |
|
| 169 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 170 | + //$formats[$id] = 'phpvmacars'; |
|
| 171 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 172 | + //$last_exec['phpvmacars'] = 0; |
|
| 173 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 174 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 175 | + //$formats[$id] = 'phpvmacars'; |
|
| 176 | + $globalSources[$id]['format'] = 'vam'; |
|
| 177 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 178 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 179 | + //$formats[$id] = 'whazzup'; |
|
| 180 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 181 | + //$last_exec['whazzup'] = 0; |
|
| 182 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 183 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
| 184 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
| 185 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 186 | + } else if (preg_match('/airwhere/i',$host)) { |
|
| 187 | + $globalSources[$id]['format'] = 'airwhere'; |
|
| 188 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 189 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 190 | + //$formats[$id] = 'pirepsjson'; |
|
| 191 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 192 | + //$last_exec['pirepsjson'] = 0; |
|
| 193 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 194 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 195 | + //$formats[$id] = 'fr24json'; |
|
| 196 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 197 | + //$last_exec['fr24json'] = 0; |
|
| 198 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 199 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 200 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 201 | + exit(0); |
|
| 202 | + } |
|
| 203 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 204 | + //$formats[$id] = 'fr24json'; |
|
| 205 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 206 | + //$last_exec['fr24json'] = 0; |
|
| 207 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 208 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 209 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 210 | + exit(0); |
|
| 211 | + } |
|
| 212 | + //} else if (preg_match('/10001/',$host)) { |
|
| 213 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 214 | + //$formats[$id] = 'tsv'; |
|
| 215 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 216 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 217 | + } |
|
| 218 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 219 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 220 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 221 | + if ($idf !== false) { |
|
| 222 | + $httpfeeds[$id] = $idf; |
|
| 223 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 224 | + } |
|
| 225 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 226 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 227 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 228 | + $hostport = explode(':',$host); |
|
| 229 | + if (isset($hostport[1])) { |
|
| 230 | 230 | $port = $hostport[1]; |
| 231 | 231 | $hostn = $hostport[0]; |
| 232 | - } else { |
|
| 232 | + } else { |
|
| 233 | 233 | $port = $globalSources[$id]['port']; |
| 234 | 234 | $hostn = $globalSources[$id]['host']; |
| 235 | - } |
|
| 236 | - $Common = new Common(); |
|
| 237 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 238 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 239 | - } else { |
|
| 240 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 241 | - } |
|
| 242 | - if ($s) { |
|
| 243 | - $sockets[$id] = $s; |
|
| 244 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 245 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 235 | + } |
|
| 236 | + $Common = new Common(); |
|
| 237 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 238 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 239 | + } else { |
|
| 240 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 241 | + } |
|
| 242 | + if ($s) { |
|
| 243 | + $sockets[$id] = $s; |
|
| 244 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 245 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 246 | 246 | //$formats[$id] = 'aprs'; |
| 247 | 247 | $globalSources[$id]['format'] = 'aprs'; |
| 248 | 248 | //$aprs_connect = 0; |
| 249 | 249 | //$use_aprs = true; |
| 250 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 250 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 251 | 251 | $globalSources[$id]['format'] = 'vrstcp'; |
| 252 | - } elseif ($port == '10001') { |
|
| 253 | - //$formats[$id] = 'tsv'; |
|
| 254 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 255 | - } elseif ($port == '30002') { |
|
| 256 | - //$formats[$id] = 'raw'; |
|
| 257 | - $globalSources[$id]['format'] = 'raw'; |
|
| 258 | - } elseif ($port == '5001') { |
|
| 259 | - //$formats[$id] = 'raw'; |
|
| 260 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 261 | - } elseif ($port == '30005') { |
|
| 252 | + } elseif ($port == '10001') { |
|
| 253 | + //$formats[$id] = 'tsv'; |
|
| 254 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 255 | + } elseif ($port == '30002') { |
|
| 256 | + //$formats[$id] = 'raw'; |
|
| 257 | + $globalSources[$id]['format'] = 'raw'; |
|
| 258 | + } elseif ($port == '5001') { |
|
| 259 | + //$formats[$id] = 'raw'; |
|
| 260 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 261 | + } elseif ($port == '30005') { |
|
| 262 | 262 | // Not yet supported |
| 263 | - //$formats[$id] = 'beast'; |
|
| 264 | - $globalSources[$id]['format'] = 'beast'; |
|
| 265 | - //} else $formats[$id] = 'sbs'; |
|
| 266 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 267 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 263 | + //$formats[$id] = 'beast'; |
|
| 264 | + $globalSources[$id]['format'] = 'beast'; |
|
| 265 | + //} else $formats[$id] = 'sbs'; |
|
| 266 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 267 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 268 | 268 | } |
| 269 | 269 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 270 | - } else { |
|
| 270 | + } else { |
|
| 271 | 271 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 272 | - } |
|
| 273 | - } |
|
| 274 | - } |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | 275 | } |
| 276 | 276 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 277 | 277 | |
@@ -294,9 +294,9 @@ discard block |
||
| 294 | 294 | //connect_all($globalSources); |
| 295 | 295 | |
| 296 | 296 | if (isset($globalProxy) && $globalProxy) { |
| 297 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 297 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 298 | 298 | } else { |
| 299 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 299 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // APRS Configuration |
@@ -305,21 +305,21 @@ discard block |
||
| 305 | 305 | die; |
| 306 | 306 | } |
| 307 | 307 | foreach ($globalSources as $key => $source) { |
| 308 | - if (!isset($source['format'])) { |
|
| 309 | - $globalSources[$key]['format'] = 'auto'; |
|
| 310 | - } |
|
| 311 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 312 | - unset($globalSources[$key]); |
|
| 313 | - } |
|
| 308 | + if (!isset($source['format'])) { |
|
| 309 | + $globalSources[$key]['format'] = 'auto'; |
|
| 310 | + } |
|
| 311 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 312 | + unset($globalSources[$key]); |
|
| 313 | + } |
|
| 314 | 314 | } |
| 315 | 315 | connect_all($globalSources); |
| 316 | 316 | foreach ($globalSources as $key => $source) { |
| 317 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 317 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 318 | 318 | $aprs_connect = 0; |
| 319 | 319 | $use_aprs = true; |
| 320 | 320 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 321 | 321 | break; |
| 322 | - } |
|
| 322 | + } |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | if ($use_aprs) { |
@@ -360,126 +360,126 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 362 | 362 | while ($i > 0) { |
| 363 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 364 | - // Delete old ATC |
|
| 365 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 363 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 364 | + // Delete old ATC |
|
| 365 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 366 | 366 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 367 | - $ATC->deleteOldATC(); |
|
| 368 | - } |
|
| 367 | + $ATC->deleteOldATC(); |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - if (count($last_exec) == count($globalSources)) { |
|
| 370 | + if (count($last_exec) == count($globalSources)) { |
|
| 371 | 371 | $max = $globalMinFetch; |
| 372 | 372 | foreach ($last_exec as $last) { |
| 373 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 373 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 374 | 374 | } |
| 375 | 375 | if ($max != $globalMinFetch) { |
| 376 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 377 | - sleep($globalMinFetch-$max+2); |
|
| 376 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 377 | + sleep($globalMinFetch-$max+2); |
|
| 378 | + } |
|
| 378 | 379 | } |
| 379 | - } |
|
| 380 | 380 | |
| 381 | 381 | |
| 382 | - //foreach ($formats as $id => $value) { |
|
| 383 | - foreach ($globalSources as $id => $value) { |
|
| 382 | + //foreach ($formats as $id => $value) { |
|
| 383 | + foreach ($globalSources as $id => $value) { |
|
| 384 | 384 | date_default_timezone_set('UTC'); |
| 385 | 385 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 386 | 386 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 387 | 387 | if ($value['format'] == 'deltadbtxt' && |
| 388 | - ( |
|
| 388 | + ( |
|
| 389 | 389 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 390 | 390 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 391 | - ) |
|
| 391 | + ) |
|
| 392 | 392 | ) { |
| 393 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 394 | - $buffer = $Common->getData($value['host']); |
|
| 395 | - if ($buffer != '') $reset = 0; |
|
| 396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 397 | - $buffer = explode('\n',$buffer); |
|
| 398 | - foreach ($buffer as $line) { |
|
| 399 | - if ($line != '' && count($line) > 7) { |
|
| 400 | - $line = explode(',', $line); |
|
| 401 | - $data = array(); |
|
| 402 | - $data['hex'] = $line[1]; // hex |
|
| 403 | - $data['ident'] = $line[2]; // ident |
|
| 404 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 405 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 406 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 407 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 408 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 409 | - $data['verticalrate'] = ''; // vertical rate |
|
| 410 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 411 | - $data['emergency'] = ''; // emergency |
|
| 412 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 413 | - $data['format_source'] = 'deltadbtxt'; |
|
| 414 | - $data['id_source'] = $id_source; |
|
| 415 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 416 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 417 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 418 | - $SI->add($data); |
|
| 419 | - unset($data); |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - $last_exec[$id]['last'] = time(); |
|
| 393 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 394 | + $buffer = $Common->getData($value['host']); |
|
| 395 | + if ($buffer != '') $reset = 0; |
|
| 396 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 397 | + $buffer = explode('\n',$buffer); |
|
| 398 | + foreach ($buffer as $line) { |
|
| 399 | + if ($line != '' && count($line) > 7) { |
|
| 400 | + $line = explode(',', $line); |
|
| 401 | + $data = array(); |
|
| 402 | + $data['hex'] = $line[1]; // hex |
|
| 403 | + $data['ident'] = $line[2]; // ident |
|
| 404 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 405 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 406 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 407 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 408 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 409 | + $data['verticalrate'] = ''; // vertical rate |
|
| 410 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 411 | + $data['emergency'] = ''; // emergency |
|
| 412 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 413 | + $data['format_source'] = 'deltadbtxt'; |
|
| 414 | + $data['id_source'] = $id_source; |
|
| 415 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 416 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 417 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 418 | + $SI->add($data); |
|
| 419 | + unset($data); |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + $last_exec[$id]['last'] = time(); |
|
| 423 | 423 | } elseif ($value['format'] == 'aisnmeatxt' && |
| 424 | - ( |
|
| 424 | + ( |
|
| 425 | 425 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 426 | 426 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 427 | - ) |
|
| 427 | + ) |
|
| 428 | 428 | ) { |
| 429 | - date_default_timezone_set('CET'); |
|
| 430 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 431 | - date_default_timezone_set('UTC'); |
|
| 432 | - if ($buffer != '') $reset = 0; |
|
| 433 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 434 | - $buffer = explode('\n',$buffer); |
|
| 435 | - foreach ($buffer as $line) { |
|
| 429 | + date_default_timezone_set('CET'); |
|
| 430 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 431 | + date_default_timezone_set('UTC'); |
|
| 432 | + if ($buffer != '') $reset = 0; |
|
| 433 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 434 | + $buffer = explode('\n',$buffer); |
|
| 435 | + foreach ($buffer as $line) { |
|
| 436 | 436 | if ($line != '') { |
| 437 | - //echo "'".$line."'\n"; |
|
| 438 | - $add = false; |
|
| 439 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 440 | - $data = array(); |
|
| 441 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 442 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 443 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 444 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 445 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 446 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 447 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 448 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 449 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 450 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 451 | - if (isset($ais_data['timestamp'])) { |
|
| 437 | + //echo "'".$line."'\n"; |
|
| 438 | + $add = false; |
|
| 439 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 440 | + $data = array(); |
|
| 441 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 442 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 443 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 444 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 445 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 446 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 447 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 448 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 449 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 450 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 451 | + if (isset($ais_data['timestamp'])) { |
|
| 452 | 452 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 453 | 453 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 454 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 455 | - $add = true; |
|
| 454 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 455 | + $add = true; |
|
| 456 | 456 | } |
| 457 | - } else { |
|
| 457 | + } else { |
|
| 458 | 458 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 459 | 459 | $add = true; |
| 460 | - } |
|
| 461 | - $data['format_source'] = 'aisnmeatxt'; |
|
| 462 | - $data['id_source'] = $id_source; |
|
| 463 | - //print_r($data); |
|
| 464 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 465 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 466 | - unset($data); |
|
| 460 | + } |
|
| 461 | + $data['format_source'] = 'aisnmeatxt'; |
|
| 462 | + $data['id_source'] = $id_source; |
|
| 463 | + //print_r($data); |
|
| 464 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 465 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 466 | + unset($data); |
|
| 467 | 467 | } |
| 468 | - } |
|
| 469 | - $last_exec[$id]['last'] = time(); |
|
| 468 | + } |
|
| 469 | + $last_exec[$id]['last'] = time(); |
|
| 470 | 470 | } elseif ($value['format'] == 'aisnmeahttp') { |
| 471 | - $arr = $httpfeeds; |
|
| 472 | - $w = $e = null; |
|
| 471 | + $arr = $httpfeeds; |
|
| 472 | + $w = $e = null; |
|
| 473 | 473 | |
| 474 | - if (isset($arr[$id])) { |
|
| 474 | + if (isset($arr[$id])) { |
|
| 475 | 475 | $nn = stream_select($arr,$w,$e,$timeout); |
| 476 | 476 | if ($nn > 0) { |
| 477 | - foreach ($httpfeeds as $feed) { |
|
| 477 | + foreach ($httpfeeds as $feed) { |
|
| 478 | 478 | $buffer = stream_get_line($feed,2000,"\n"); |
| 479 | 479 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 480 | 480 | $buffer = explode('\n',$buffer); |
| 481 | 481 | foreach ($buffer as $line) { |
| 482 | - if ($line != '') { |
|
| 482 | + if ($line != '') { |
|
| 483 | 483 | $ais_data = $AIS->parse_line(trim($line)); |
| 484 | 484 | $data = array(); |
| 485 | 485 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -497,111 +497,111 @@ discard block |
||
| 497 | 497 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 498 | 498 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
| 499 | 499 | if (isset($ais_data['timestamp'])) { |
| 500 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 500 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 501 | 501 | } else { |
| 502 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 502 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 503 | 503 | } |
| 504 | 504 | $data['format_source'] = 'aisnmeahttp'; |
| 505 | 505 | $data['id_source'] = $id_source; |
| 506 | 506 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 507 | 507 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
| 508 | 508 | unset($data); |
| 509 | - } |
|
| 509 | + } |
|
| 510 | + } |
|
| 510 | 511 | } |
| 511 | - } |
|
| 512 | 512 | } else { |
| 513 | - $format = $value['format']; |
|
| 514 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 515 | - else $tt[$format] = 0; |
|
| 516 | - if ($tt[$format] > 30) { |
|
| 513 | + $format = $value['format']; |
|
| 514 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 515 | + else $tt[$format] = 0; |
|
| 516 | + if ($tt[$format] > 30) { |
|
| 517 | 517 | if ($globalDebug) echo 'Reconnect...'."\n"; |
| 518 | 518 | sleep(2); |
| 519 | 519 | $sourceeen[] = $value; |
| 520 | 520 | connect_all($sourceeen); |
| 521 | 521 | $sourceeen = array(); |
| 522 | - } |
|
| 522 | + } |
|
| 523 | + } |
|
| 523 | 524 | } |
| 524 | - } |
|
| 525 | 525 | } elseif ($value['format'] == 'myshiptracking' && |
| 526 | - ( |
|
| 526 | + ( |
|
| 527 | 527 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 528 | 528 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 529 | - ) |
|
| 529 | + ) |
|
| 530 | 530 | ) { |
| 531 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 532 | - if ($buffer != '') { |
|
| 531 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 532 | + if ($buffer != '') { |
|
| 533 | 533 | //echo $buffer; |
| 534 | 534 | $all_data = json_decode($buffer,true); |
| 535 | 535 | //print_r($all_data); |
| 536 | 536 | if (isset($all_data[0]['DATA'])) { |
| 537 | - foreach ($all_data[0]['DATA'] as $line) { |
|
| 537 | + foreach ($all_data[0]['DATA'] as $line) { |
|
| 538 | 538 | if ($line != '') { |
| 539 | - $data = array(); |
|
| 540 | - $data['ident'] = $line['NAME']; |
|
| 541 | - $data['mmsi'] = $line['MMSI']; |
|
| 542 | - $data['speed'] = $line['SOG']; |
|
| 543 | - $data['heading'] = $line['COG']; |
|
| 544 | - $data['latitude'] = $line['LAT']; |
|
| 545 | - $data['longitude'] = $line['LNG']; |
|
| 546 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 547 | - $data['imo'] = $line['IMO']; |
|
| 548 | - //$data['arrival_code'] = $ais_data['destination']; |
|
| 549 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 550 | - $data['format_source'] = 'myshiptracking'; |
|
| 551 | - $data['id_source'] = $id_source; |
|
| 552 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 553 | - $MI->add($data); |
|
| 554 | - unset($data); |
|
| 539 | + $data = array(); |
|
| 540 | + $data['ident'] = $line['NAME']; |
|
| 541 | + $data['mmsi'] = $line['MMSI']; |
|
| 542 | + $data['speed'] = $line['SOG']; |
|
| 543 | + $data['heading'] = $line['COG']; |
|
| 544 | + $data['latitude'] = $line['LAT']; |
|
| 545 | + $data['longitude'] = $line['LNG']; |
|
| 546 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 547 | + $data['imo'] = $line['IMO']; |
|
| 548 | + //$data['arrival_code'] = $ais_data['destination']; |
|
| 549 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 550 | + $data['format_source'] = 'myshiptracking'; |
|
| 551 | + $data['id_source'] = $id_source; |
|
| 552 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 553 | + $MI->add($data); |
|
| 554 | + unset($data); |
|
| 555 | + } |
|
| 555 | 556 | } |
| 556 | - } |
|
| 557 | 557 | } |
| 558 | - } |
|
| 559 | - $last_exec[$id]['last'] = time(); |
|
| 558 | + } |
|
| 559 | + $last_exec[$id]['last'] = time(); |
|
| 560 | 560 | } elseif ($value['format'] == 'boatbeaconapp' && |
| 561 | - ( |
|
| 561 | + ( |
|
| 562 | 562 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 563 | 563 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 564 | - ) |
|
| 564 | + ) |
|
| 565 | 565 | ) { |
| 566 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 567 | - if ($buffer != '') { |
|
| 566 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 567 | + if ($buffer != '') { |
|
| 568 | 568 | $all_data = json_decode($buffer,true); |
| 569 | 569 | if (isset($all_data[0]['mmsi'])) { |
| 570 | - foreach ($all_data as $line) { |
|
| 570 | + foreach ($all_data as $line) { |
|
| 571 | 571 | if ($line != '') { |
| 572 | - $data = array(); |
|
| 573 | - $data['ident'] = $line['shipname']; |
|
| 574 | - $data['callsign'] = $line['callsign']; |
|
| 575 | - $data['mmsi'] = $line['mmsi']; |
|
| 576 | - $data['speed'] = $line['sog']; |
|
| 577 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 578 | - $data['latitude'] = $line['latitude']; |
|
| 579 | - $data['longitude'] = $line['longitude']; |
|
| 580 | - $data['type_id'] = $line['shiptype']; |
|
| 581 | - $data['arrival_code'] = $line['destination']; |
|
| 582 | - $data['datetime'] = $line['time']; |
|
| 583 | - $data['format_source'] = 'boatbeaconapp'; |
|
| 584 | - $data['id_source'] = $id_source; |
|
| 585 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 586 | - $MI->add($data); |
|
| 587 | - unset($data); |
|
| 572 | + $data = array(); |
|
| 573 | + $data['ident'] = $line['shipname']; |
|
| 574 | + $data['callsign'] = $line['callsign']; |
|
| 575 | + $data['mmsi'] = $line['mmsi']; |
|
| 576 | + $data['speed'] = $line['sog']; |
|
| 577 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 578 | + $data['latitude'] = $line['latitude']; |
|
| 579 | + $data['longitude'] = $line['longitude']; |
|
| 580 | + $data['type_id'] = $line['shiptype']; |
|
| 581 | + $data['arrival_code'] = $line['destination']; |
|
| 582 | + $data['datetime'] = $line['time']; |
|
| 583 | + $data['format_source'] = 'boatbeaconapp'; |
|
| 584 | + $data['id_source'] = $id_source; |
|
| 585 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 586 | + $MI->add($data); |
|
| 587 | + unset($data); |
|
| 588 | + } |
|
| 588 | 589 | } |
| 589 | - } |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - } |
|
| 593 | - $last_exec[$id]['last'] = time(); |
|
| 592 | + } |
|
| 593 | + $last_exec[$id]['last'] = time(); |
|
| 594 | 594 | } elseif ($value['format'] == 'boatnerd' && |
| 595 | - ( |
|
| 595 | + ( |
|
| 596 | 596 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 597 | 597 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 598 | - ) |
|
| 598 | + ) |
|
| 599 | 599 | ) { |
| 600 | - $buffer = $Common->getData($value['host']); |
|
| 601 | - if ($buffer != '') { |
|
| 600 | + $buffer = $Common->getData($value['host']); |
|
| 601 | + if ($buffer != '') { |
|
| 602 | 602 | $all_data = json_decode($buffer,true); |
| 603 | 603 | if (isset($all_data['features'][0]['id'])) { |
| 604 | - foreach ($all_data['features'] as $line) { |
|
| 604 | + foreach ($all_data['features'] as $line) { |
|
| 605 | 605 | $data = array(); |
| 606 | 606 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
| 607 | 607 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -620,78 +620,78 @@ discard block |
||
| 620 | 620 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 621 | 621 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
| 622 | 622 | unset($data); |
| 623 | - } |
|
| 623 | + } |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | - } |
|
| 627 | - $last_exec[$id]['last'] = time(); |
|
| 626 | + } |
|
| 627 | + $last_exec[$id]['last'] = time(); |
|
| 628 | 628 | } elseif ($value['format'] == 'shipplotter' && |
| 629 | - ( |
|
| 629 | + ( |
|
| 630 | 630 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 631 | 631 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 632 | - ) |
|
| 632 | + ) |
|
| 633 | 633 | ) { |
| 634 | - echo 'download...'; |
|
| 635 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 636 | - echo 'done !'."\n"; |
|
| 637 | - if ($buffer != '') $reset = 0; |
|
| 638 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 639 | - $buffer = explode('\n',$buffer); |
|
| 640 | - foreach ($buffer as $line) { |
|
| 634 | + echo 'download...'; |
|
| 635 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 636 | + echo 'done !'."\n"; |
|
| 637 | + if ($buffer != '') $reset = 0; |
|
| 638 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 639 | + $buffer = explode('\n',$buffer); |
|
| 640 | + foreach ($buffer as $line) { |
|
| 641 | 641 | if ($line != '') { |
| 642 | - $data = array(); |
|
| 643 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 644 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 645 | - //$data['status'] = substr($line,21,2); |
|
| 646 | - //$data['type'] = substr($line,24,3); |
|
| 647 | - $data['latitude'] = substr($line,29,9); |
|
| 648 | - $data['longitude'] = substr($line,41,9); |
|
| 649 | - $data['speed'] = round(substr($line,51,5)); |
|
| 650 | - //$data['course'] = substr($line,57,5); |
|
| 651 | - $data['heading'] = round(substr($line,63,3)); |
|
| 652 | - //$data['draft'] = substr($line,67,4); |
|
| 653 | - //$data['length'] = substr($line,72,3); |
|
| 654 | - //$data['beam'] = substr($line,76,2); |
|
| 655 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 656 | - //$data['callsign'] = trim(substr($line,100,7); |
|
| 657 | - //$data['dest'] = substr($line,108,20); |
|
| 658 | - //$data['etaDate'] = substr($line,129,5); |
|
| 659 | - //$data['etaTime'] = substr($line,135,5); |
|
| 660 | - $data['format_source'] = 'shipplotter'; |
|
| 661 | - $data['id_source'] = $id_source; |
|
| 662 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 663 | - //print_r($data); |
|
| 664 | - echo 'Add...'."\n"; |
|
| 665 | - $MI->add($data); |
|
| 666 | - unset($data); |
|
| 642 | + $data = array(); |
|
| 643 | + $data['mmsi'] = (int)substr($line,0,9); |
|
| 644 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 645 | + //$data['status'] = substr($line,21,2); |
|
| 646 | + //$data['type'] = substr($line,24,3); |
|
| 647 | + $data['latitude'] = substr($line,29,9); |
|
| 648 | + $data['longitude'] = substr($line,41,9); |
|
| 649 | + $data['speed'] = round(substr($line,51,5)); |
|
| 650 | + //$data['course'] = substr($line,57,5); |
|
| 651 | + $data['heading'] = round(substr($line,63,3)); |
|
| 652 | + //$data['draft'] = substr($line,67,4); |
|
| 653 | + //$data['length'] = substr($line,72,3); |
|
| 654 | + //$data['beam'] = substr($line,76,2); |
|
| 655 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 656 | + //$data['callsign'] = trim(substr($line,100,7); |
|
| 657 | + //$data['dest'] = substr($line,108,20); |
|
| 658 | + //$data['etaDate'] = substr($line,129,5); |
|
| 659 | + //$data['etaTime'] = substr($line,135,5); |
|
| 660 | + $data['format_source'] = 'shipplotter'; |
|
| 661 | + $data['id_source'] = $id_source; |
|
| 662 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 663 | + //print_r($data); |
|
| 664 | + echo 'Add...'."\n"; |
|
| 665 | + $MI->add($data); |
|
| 666 | + unset($data); |
|
| 667 | 667 | } |
| 668 | - } |
|
| 669 | - $last_exec[$id]['last'] = time(); |
|
| 668 | + } |
|
| 669 | + $last_exec[$id]['last'] = time(); |
|
| 670 | 670 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 671 | 671 | } elseif ( |
| 672 | - ( |
|
| 672 | + ( |
|
| 673 | 673 | $value['format'] == 'whazzup' && |
| 674 | 674 | ( |
| 675 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 676 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 675 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 676 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 677 | 677 | ) |
| 678 | - ) || ( |
|
| 678 | + ) || ( |
|
| 679 | 679 | $value['format'] == 'vatsimtxt' && |
| 680 | 680 | ( |
| 681 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 682 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 681 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 682 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 683 | + ) |
|
| 683 | 684 | ) |
| 684 | - ) |
|
| 685 | 685 | ) { |
| 686 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 687 | - $buffer = $Common->getData($value['host']); |
|
| 688 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 689 | - $buffer = explode('\n',$buffer); |
|
| 690 | - $reset = 0; |
|
| 691 | - foreach ($buffer as $line) { |
|
| 692 | - if ($line != '') { |
|
| 693 | - $line = explode(':', $line); |
|
| 694 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 686 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 687 | + $buffer = $Common->getData($value['host']); |
|
| 688 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 689 | + $buffer = explode('\n',$buffer); |
|
| 690 | + $reset = 0; |
|
| 691 | + foreach ($buffer as $line) { |
|
| 692 | + if ($line != '') { |
|
| 693 | + $line = explode(':', $line); |
|
| 694 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 695 | 695 | $data = array(); |
| 696 | 696 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 697 | 697 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -704,37 +704,37 @@ discard block |
||
| 704 | 704 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 705 | 705 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 706 | 706 | $data['latitude'] = $line[5]; // lat |
| 707 | - $data['longitude'] = $line[6]; // long |
|
| 708 | - $data['verticalrate'] = ''; // vertical rate |
|
| 709 | - $data['squawk'] = ''; // squawk |
|
| 710 | - $data['emergency'] = ''; // emergency |
|
| 711 | - $data['waypoints'] = $line[30]; |
|
| 707 | + $data['longitude'] = $line[6]; // long |
|
| 708 | + $data['verticalrate'] = ''; // vertical rate |
|
| 709 | + $data['squawk'] = ''; // squawk |
|
| 710 | + $data['emergency'] = ''; // emergency |
|
| 711 | + $data['waypoints'] = $line[30]; |
|
| 712 | 712 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 713 | 713 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 714 | 714 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 715 | - $data['departure_airport_icao'] = $line[11]; |
|
| 716 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 717 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 715 | + $data['departure_airport_icao'] = $line[11]; |
|
| 716 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 717 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 718 | 718 | $data['frequency'] = $line[4]; |
| 719 | 719 | $data['type'] = $line[18]; |
| 720 | 720 | $data['range'] = $line[19]; |
| 721 | 721 | if (isset($line[35])) $data['info'] = $line[35]; |
| 722 | - $data['id_source'] = $id_source; |
|
| 723 | - //$data['arrival_airport_time'] = ; |
|
| 724 | - if ($line[9] != '') { |
|
| 725 | - $aircraft_data = explode('/',$line[9]); |
|
| 726 | - if (isset($aircraft_data[1])) { |
|
| 727 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 728 | - } |
|
| 729 | - } |
|
| 730 | - /* |
|
| 722 | + $data['id_source'] = $id_source; |
|
| 723 | + //$data['arrival_airport_time'] = ; |
|
| 724 | + if ($line[9] != '') { |
|
| 725 | + $aircraft_data = explode('/',$line[9]); |
|
| 726 | + if (isset($aircraft_data[1])) { |
|
| 727 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 728 | + } |
|
| 729 | + } |
|
| 730 | + /* |
|
| 731 | 731 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 732 | 732 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 733 | 733 | */ |
| 734 | - $data['format_source'] = $value['format']; |
|
| 734 | + $data['format_source'] = $value['format']; |
|
| 735 | 735 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 736 | 736 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 737 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 737 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 738 | 738 | elseif ($line[3] == 'ATC') { |
| 739 | 739 | //print_r($data); |
| 740 | 740 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -755,21 +755,21 @@ discard block |
||
| 755 | 755 | else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
| 756 | 756 | } |
| 757 | 757 | } |
| 758 | - unset($data); |
|
| 759 | - } |
|
| 760 | - } |
|
| 761 | - } |
|
| 762 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 763 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 764 | - $last_exec[$id]['last'] = time(); |
|
| 765 | - } elseif ($value['format'] == 'airwhere' && |
|
| 766 | - ( |
|
| 767 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 768 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 769 | - ) |
|
| 770 | - ) { |
|
| 771 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 772 | - if ($buffer != '') { |
|
| 758 | + unset($data); |
|
| 759 | + } |
|
| 760 | + } |
|
| 761 | + } |
|
| 762 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 763 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 764 | + $last_exec[$id]['last'] = time(); |
|
| 765 | + } elseif ($value['format'] == 'airwhere' && |
|
| 766 | + ( |
|
| 767 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 768 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 769 | + ) |
|
| 770 | + ) { |
|
| 771 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 772 | + if ($buffer != '') { |
|
| 773 | 773 | $all_data = simplexml_load_string($buffer); |
| 774 | 774 | foreach($all_data->children() as $childdata) { |
| 775 | 775 | $data = array(); |
@@ -791,10 +791,10 @@ discard block |
||
| 791 | 791 | $SI->add($data); |
| 792 | 792 | unset($data); |
| 793 | 793 | } |
| 794 | - } |
|
| 795 | - $Source->deleteOldLocationByType('gs'); |
|
| 796 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 797 | - if ($buffer != '') { |
|
| 794 | + } |
|
| 795 | + $Source->deleteOldLocationByType('gs'); |
|
| 796 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 797 | + if ($buffer != '') { |
|
| 798 | 798 | $all_data = simplexml_load_string($buffer); |
| 799 | 799 | foreach($all_data->children() as $childdata) { |
| 800 | 800 | $data = array(); |
@@ -812,8 +812,8 @@ discard block |
||
| 812 | 812 | } |
| 813 | 813 | unset($data); |
| 814 | 814 | } |
| 815 | - } |
|
| 816 | - $last_exec[$id]['last'] = time(); |
|
| 815 | + } |
|
| 816 | + $last_exec[$id]['last'] = time(); |
|
| 817 | 817 | /* |
| 818 | 818 | } if ($value['format'] == 'aircraftlistjson') { |
| 819 | 819 | print_r($globalSources); |
@@ -821,17 +821,17 @@ discard block |
||
| 821 | 821 | echo $globalMinFetch; |
| 822 | 822 | */ |
| 823 | 823 | } elseif ($value['format'] == 'aircraftlistjson' && |
| 824 | - ( |
|
| 824 | + ( |
|
| 825 | 825 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 826 | 826 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 827 | - ) |
|
| 827 | + ) |
|
| 828 | 828 | ) { |
| 829 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 830 | - if ($buffer != '') { |
|
| 831 | - $all_data = json_decode($buffer,true); |
|
| 829 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 830 | + if ($buffer != '') { |
|
| 831 | + $all_data = json_decode($buffer,true); |
|
| 832 | 832 | if (isset($all_data['acList'])) { |
| 833 | - $reset = 0; |
|
| 834 | - foreach ($all_data['acList'] as $line) { |
|
| 833 | + $reset = 0; |
|
| 834 | + foreach ($all_data['acList'] as $line) { |
|
| 835 | 835 | $data = array(); |
| 836 | 836 | $data['hex'] = $line['Icao']; // hex |
| 837 | 837 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -854,10 +854,10 @@ discard block |
||
| 854 | 854 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 855 | 855 | if (isset($data['latitude'])) $SI->add($data); |
| 856 | 856 | unset($data); |
| 857 | - } |
|
| 857 | + } |
|
| 858 | 858 | } elseif (is_array($all_data)) { |
| 859 | - $reset = 0; |
|
| 860 | - foreach ($all_data as $line) { |
|
| 859 | + $reset = 0; |
|
| 860 | + foreach ($all_data as $line) { |
|
| 861 | 861 | $data = array(); |
| 862 | 862 | $data['hex'] = $line['hex']; // hex |
| 863 | 863 | $data['ident'] = $line['flight']; // ident |
@@ -877,218 +877,218 @@ discard block |
||
| 877 | 877 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 878 | 878 | $SI->add($data); |
| 879 | 879 | unset($data); |
| 880 | - } |
|
| 880 | + } |
|
| 881 | 881 | } |
| 882 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 883 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 884 | - $last_exec[$id]['last'] = time(); |
|
| 885 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 886 | - } elseif ($value['format'] == 'planeupdatefaa' && |
|
| 887 | - ( |
|
| 888 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 889 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 890 | - ) |
|
| 891 | - ) { |
|
| 892 | - $buffer = $Common->getData($value['host']); |
|
| 893 | - $all_data = json_decode($buffer,true); |
|
| 894 | - if (isset($all_data['planes'])) { |
|
| 882 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 883 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 884 | + $last_exec[$id]['last'] = time(); |
|
| 885 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 886 | + } elseif ($value['format'] == 'planeupdatefaa' && |
|
| 887 | + ( |
|
| 888 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 889 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 890 | + ) |
|
| 891 | + ) { |
|
| 892 | + $buffer = $Common->getData($value['host']); |
|
| 893 | + $all_data = json_decode($buffer,true); |
|
| 894 | + if (isset($all_data['planes'])) { |
|
| 895 | 895 | $reset = 0; |
| 896 | 896 | foreach ($all_data['planes'] as $key => $line) { |
| 897 | - $data = array(); |
|
| 898 | - $data['hex'] = $key; // hex |
|
| 899 | - $data['ident'] = $line[3]; // ident |
|
| 900 | - $data['altitude'] = $line[6]; // altitude |
|
| 901 | - $data['speed'] = $line[8]; // speed |
|
| 902 | - $data['heading'] = $line[7]; // heading |
|
| 903 | - $data['latitude'] = $line[4]; // lat |
|
| 904 | - $data['longitude'] = $line[5]; // long |
|
| 905 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 906 | - $data['squawk'] = $line[10]; // squawk |
|
| 907 | - $data['emergency'] = ''; // emergency |
|
| 908 | - $data['registration'] = $line[2]; |
|
| 909 | - $data['aircraft_icao'] = $line[0]; |
|
| 910 | - $deparr = explode('-',$line[1]); |
|
| 911 | - if (count($deparr) == 2) { |
|
| 897 | + $data = array(); |
|
| 898 | + $data['hex'] = $key; // hex |
|
| 899 | + $data['ident'] = $line[3]; // ident |
|
| 900 | + $data['altitude'] = $line[6]; // altitude |
|
| 901 | + $data['speed'] = $line[8]; // speed |
|
| 902 | + $data['heading'] = $line[7]; // heading |
|
| 903 | + $data['latitude'] = $line[4]; // lat |
|
| 904 | + $data['longitude'] = $line[5]; // long |
|
| 905 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 906 | + $data['squawk'] = $line[10]; // squawk |
|
| 907 | + $data['emergency'] = ''; // emergency |
|
| 908 | + $data['registration'] = $line[2]; |
|
| 909 | + $data['aircraft_icao'] = $line[0]; |
|
| 910 | + $deparr = explode('-',$line[1]); |
|
| 911 | + if (count($deparr) == 2) { |
|
| 912 | 912 | $data['departure_airport_icao'] = $deparr[0]; |
| 913 | 913 | $data['arrival_airport_icao'] = $deparr[1]; |
| 914 | - } |
|
| 915 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 916 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 917 | - $data['id_source'] = $id_source; |
|
| 918 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 919 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 920 | - $SI->add($data); |
|
| 921 | - unset($data); |
|
| 914 | + } |
|
| 915 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 916 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 917 | + $data['id_source'] = $id_source; |
|
| 918 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 919 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 920 | + $SI->add($data); |
|
| 921 | + unset($data); |
|
| 922 | + } |
|
| 922 | 923 | } |
| 923 | - } |
|
| 924 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 925 | - $last_exec[$id]['last'] = time(); |
|
| 924 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 925 | + $last_exec[$id]['last'] = time(); |
|
| 926 | 926 | } elseif ($value['format'] == 'opensky' && |
| 927 | - ( |
|
| 927 | + ( |
|
| 928 | 928 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 929 | 929 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 930 | - ) |
|
| 930 | + ) |
|
| 931 | 931 | ) { |
| 932 | - $buffer = $Common->getData($value['host']); |
|
| 933 | - $all_data = json_decode($buffer,true); |
|
| 934 | - if (isset($all_data['states'])) { |
|
| 932 | + $buffer = $Common->getData($value['host']); |
|
| 933 | + $all_data = json_decode($buffer,true); |
|
| 934 | + if (isset($all_data['states'])) { |
|
| 935 | 935 | $reset = 0; |
| 936 | 936 | foreach ($all_data['states'] as $key => $line) { |
| 937 | - $data = array(); |
|
| 938 | - $data['hex'] = $line[0]; // hex |
|
| 939 | - $data['ident'] = trim($line[1]); // ident |
|
| 940 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 941 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 942 | - $data['heading'] = round($line[10]); // heading |
|
| 943 | - $data['latitude'] = $line[6]; // lat |
|
| 944 | - $data['longitude'] = $line[5]; // long |
|
| 945 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 946 | - //$data['squawk'] = $line[10]; // squawk |
|
| 947 | - //$data['emergency'] = ''; // emergency |
|
| 948 | - //$data['registration'] = $line[2]; |
|
| 949 | - //$data['aircraft_icao'] = $line[0]; |
|
| 950 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 951 | - $data['format_source'] = 'opensky'; |
|
| 952 | - $data['id_source'] = $id_source; |
|
| 953 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 954 | - $SI->add($data); |
|
| 955 | - unset($data); |
|
| 937 | + $data = array(); |
|
| 938 | + $data['hex'] = $line[0]; // hex |
|
| 939 | + $data['ident'] = trim($line[1]); // ident |
|
| 940 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 941 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 942 | + $data['heading'] = round($line[10]); // heading |
|
| 943 | + $data['latitude'] = $line[6]; // lat |
|
| 944 | + $data['longitude'] = $line[5]; // long |
|
| 945 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 946 | + //$data['squawk'] = $line[10]; // squawk |
|
| 947 | + //$data['emergency'] = ''; // emergency |
|
| 948 | + //$data['registration'] = $line[2]; |
|
| 949 | + //$data['aircraft_icao'] = $line[0]; |
|
| 950 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 951 | + $data['format_source'] = 'opensky'; |
|
| 952 | + $data['id_source'] = $id_source; |
|
| 953 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 954 | + $SI->add($data); |
|
| 955 | + unset($data); |
|
| 956 | 956 | } |
| 957 | - } |
|
| 958 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 959 | - $last_exec[$id]['last'] = time(); |
|
| 957 | + } |
|
| 958 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 959 | + $last_exec[$id]['last'] = time(); |
|
| 960 | 960 | //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
| 961 | 961 | } elseif ($value['format'] == 'fr24json' && |
| 962 | - ( |
|
| 962 | + ( |
|
| 963 | 963 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 964 | 964 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 965 | - ) |
|
| 965 | + ) |
|
| 966 | 966 | ) { |
| 967 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 968 | - $buffer = $Common->getData($value['host']); |
|
| 969 | - $all_data = json_decode($buffer,true); |
|
| 970 | - if (!empty($all_data)) $reset = 0; |
|
| 971 | - foreach ($all_data as $key => $line) { |
|
| 967 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 968 | + $buffer = $Common->getData($value['host']); |
|
| 969 | + $all_data = json_decode($buffer,true); |
|
| 970 | + if (!empty($all_data)) $reset = 0; |
|
| 971 | + foreach ($all_data as $key => $line) { |
|
| 972 | 972 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 973 | - $data = array(); |
|
| 974 | - $data['hex'] = $line[0]; |
|
| 975 | - $data['ident'] = $line[16]; //$line[13] |
|
| 976 | - $data['altitude'] = $line[4]; // altitude |
|
| 977 | - $data['speed'] = $line[5]; // speed |
|
| 978 | - $data['heading'] = $line[3]; // heading |
|
| 979 | - $data['latitude'] = $line[1]; // lat |
|
| 980 | - $data['longitude'] = $line[2]; // long |
|
| 981 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 982 | - $data['squawk'] = $line[6]; // squawk |
|
| 983 | - $data['aircraft_icao'] = $line[8]; |
|
| 984 | - $data['registration'] = $line[9]; |
|
| 985 | - $data['departure_airport_iata'] = $line[11]; |
|
| 986 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 987 | - $data['emergency'] = ''; // emergency |
|
| 988 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 989 | - $data['format_source'] = 'fr24json'; |
|
| 990 | - $data['id_source'] = $id_source; |
|
| 991 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 993 | - $SI->add($data); |
|
| 994 | - unset($data); |
|
| 973 | + $data = array(); |
|
| 974 | + $data['hex'] = $line[0]; |
|
| 975 | + $data['ident'] = $line[16]; //$line[13] |
|
| 976 | + $data['altitude'] = $line[4]; // altitude |
|
| 977 | + $data['speed'] = $line[5]; // speed |
|
| 978 | + $data['heading'] = $line[3]; // heading |
|
| 979 | + $data['latitude'] = $line[1]; // lat |
|
| 980 | + $data['longitude'] = $line[2]; // long |
|
| 981 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 982 | + $data['squawk'] = $line[6]; // squawk |
|
| 983 | + $data['aircraft_icao'] = $line[8]; |
|
| 984 | + $data['registration'] = $line[9]; |
|
| 985 | + $data['departure_airport_iata'] = $line[11]; |
|
| 986 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 987 | + $data['emergency'] = ''; // emergency |
|
| 988 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 989 | + $data['format_source'] = 'fr24json'; |
|
| 990 | + $data['id_source'] = $id_source; |
|
| 991 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 992 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 993 | + $SI->add($data); |
|
| 994 | + unset($data); |
|
| 995 | 995 | } |
| 996 | - } |
|
| 997 | - //$last_exec['fr24json'] = time(); |
|
| 998 | - $last_exec[$id]['last'] = time(); |
|
| 996 | + } |
|
| 997 | + //$last_exec['fr24json'] = time(); |
|
| 998 | + $last_exec[$id]['last'] = time(); |
|
| 999 | 999 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 1000 | 1000 | } elseif ($value['format'] == 'radarvirtueljson' && |
| 1001 | - ( |
|
| 1001 | + ( |
|
| 1002 | 1002 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1003 | 1003 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1004 | - ) |
|
| 1004 | + ) |
|
| 1005 | 1005 | ) { |
| 1006 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1007 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1008 | - //echo $buffer; |
|
| 1009 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1010 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1011 | - $all_data = json_decode($buffer,true); |
|
| 1012 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1006 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1007 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1008 | + //echo $buffer; |
|
| 1009 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1010 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1011 | + $all_data = json_decode($buffer,true); |
|
| 1012 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1013 | 1013 | die(json_last_error_msg()); |
| 1014 | - } |
|
| 1015 | - if (isset($all_data['mrkrs'])) { |
|
| 1014 | + } |
|
| 1015 | + if (isset($all_data['mrkrs'])) { |
|
| 1016 | 1016 | $reset = 0; |
| 1017 | 1017 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 1018 | - if (isset($line['inf'])) { |
|
| 1018 | + if (isset($line['inf'])) { |
|
| 1019 | 1019 | $data = array(); |
| 1020 | 1020 | $data['hex'] = $line['inf']['ia']; |
| 1021 | 1021 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 1022 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1023 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1024 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1025 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 1026 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 1027 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1028 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1029 | - //$data['aircraft_icao'] = $line[8]; |
|
| 1030 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1022 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1023 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1024 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1025 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 1026 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 1027 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1028 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1029 | + //$data['aircraft_icao'] = $line[8]; |
|
| 1030 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1031 | 1031 | //$data['departure_airport_iata'] = $line[11]; |
| 1032 | 1032 | //$data['arrival_airport_iata'] = $line[12]; |
| 1033 | - //$data['emergency'] = ''; // emergency |
|
| 1033 | + //$data['emergency'] = ''; // emergency |
|
| 1034 | 1034 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1035 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 1036 | - $data['id_source'] = $id_source; |
|
| 1035 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 1036 | + $data['id_source'] = $id_source; |
|
| 1037 | 1037 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1038 | 1038 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1039 | 1039 | $SI->add($data); |
| 1040 | 1040 | unset($data); |
| 1041 | - } |
|
| 1041 | + } |
|
| 1042 | + } |
|
| 1042 | 1043 | } |
| 1043 | - } |
|
| 1044 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 1045 | - $last_exec[$id]['last'] = time(); |
|
| 1044 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 1045 | + $last_exec[$id]['last'] = time(); |
|
| 1046 | 1046 | //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
| 1047 | 1047 | } elseif ($value['format'] == 'pirepsjson' && |
| 1048 | - ( |
|
| 1048 | + ( |
|
| 1049 | 1049 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1050 | 1050 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1051 | - ) |
|
| 1051 | + ) |
|
| 1052 | 1052 | ) { |
| 1053 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1054 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1055 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1053 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1054 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1055 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1056 | 1056 | |
| 1057 | - if (isset($all_data['pireps'])) { |
|
| 1057 | + if (isset($all_data['pireps'])) { |
|
| 1058 | 1058 | $reset = 0; |
| 1059 | - foreach ($all_data['pireps'] as $line) { |
|
| 1060 | - $data = array(); |
|
| 1061 | - $data['id'] = $line['id']; |
|
| 1062 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1063 | - $data['ident'] = $line['callsign']; // ident |
|
| 1064 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1065 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1066 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1067 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1068 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1069 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1070 | - $data['latitude'] = $line['lat']; // lat |
|
| 1071 | - $data['longitude'] = $line['lon']; // long |
|
| 1072 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1073 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 1074 | - //$data['emergency'] = ''; // emergency |
|
| 1075 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1076 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1077 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1078 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1079 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1080 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1081 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1082 | - else $data['info'] = ''; |
|
| 1083 | - $data['format_source'] = 'pireps'; |
|
| 1084 | - $data['id_source'] = $id_source; |
|
| 1085 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1086 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1087 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1088 | - if ($line['icon'] == 'plane') { |
|
| 1059 | + foreach ($all_data['pireps'] as $line) { |
|
| 1060 | + $data = array(); |
|
| 1061 | + $data['id'] = $line['id']; |
|
| 1062 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1063 | + $data['ident'] = $line['callsign']; // ident |
|
| 1064 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1065 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1066 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1067 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1068 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1069 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1070 | + $data['latitude'] = $line['lat']; // lat |
|
| 1071 | + $data['longitude'] = $line['lon']; // long |
|
| 1072 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1073 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 1074 | + //$data['emergency'] = ''; // emergency |
|
| 1075 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1076 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1077 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1078 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1079 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1080 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1081 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1082 | + else $data['info'] = ''; |
|
| 1083 | + $data['format_source'] = 'pireps'; |
|
| 1084 | + $data['id_source'] = $id_source; |
|
| 1085 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1086 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1087 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1088 | + if ($line['icon'] == 'plane') { |
|
| 1089 | 1089 | $SI->add($data); |
| 1090 | - // print_r($data); |
|
| 1091 | - } elseif ($line['icon'] == 'ct') { |
|
| 1090 | + // print_r($data); |
|
| 1091 | + } elseif ($line['icon'] == 'ct') { |
|
| 1092 | 1092 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 1093 | 1093 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1094 | 1094 | $typec = substr($data['ident'],-3); |
@@ -1103,148 +1103,148 @@ discard block |
||
| 1103 | 1103 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1104 | 1104 | else $data['type'] = 'Observer'; |
| 1105 | 1105 | if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
| 1106 | - } |
|
| 1107 | - unset($data); |
|
| 1106 | + } |
|
| 1107 | + unset($data); |
|
| 1108 | + } |
|
| 1108 | 1109 | } |
| 1109 | - } |
|
| 1110 | - //$last_exec['pirepsjson'] = time(); |
|
| 1111 | - $last_exec[$id]['last'] = time(); |
|
| 1110 | + //$last_exec['pirepsjson'] = time(); |
|
| 1111 | + $last_exec[$id]['last'] = time(); |
|
| 1112 | 1112 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 1113 | 1113 | } elseif ($value['format'] == 'phpvmacars' && |
| 1114 | - ( |
|
| 1114 | + ( |
|
| 1115 | 1115 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1116 | 1116 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1117 | - ) |
|
| 1117 | + ) |
|
| 1118 | 1118 | ) { |
| 1119 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1120 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1121 | - $buffer = $Common->getData($value['host']); |
|
| 1122 | - $all_data = json_decode($buffer,true); |
|
| 1123 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1119 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1120 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1121 | + $buffer = $Common->getData($value['host']); |
|
| 1122 | + $all_data = json_decode($buffer,true); |
|
| 1123 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1124 | 1124 | $reset = 0; |
| 1125 | 1125 | foreach ($all_data as $line) { |
| 1126 | - $data = array(); |
|
| 1127 | - //$data['id'] = $line['id']; // id not usable |
|
| 1128 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1129 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1130 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1131 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1132 | - $data['ident'] = $line['flightnum']; // ident |
|
| 1133 | - $data['altitude'] = $line['alt']; // altitude |
|
| 1134 | - $data['speed'] = $line['gs']; // speed |
|
| 1135 | - $data['heading'] = $line['heading']; // heading |
|
| 1136 | - $data['latitude'] = $line['lat']; // lat |
|
| 1137 | - $data['longitude'] = $line['lng']; // long |
|
| 1138 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1139 | - $data['squawk'] = ''; // squawk |
|
| 1140 | - $data['emergency'] = ''; // emergency |
|
| 1141 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1142 | - //$data['last_update'] = $line['lastupdate']; |
|
| 1143 | - if (isset($value['timezone'])) { |
|
| 1144 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1145 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1146 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1147 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1148 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 1149 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 1150 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1151 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1152 | - $data['registration'] = $line['aircraft']; |
|
| 1153 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1154 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1155 | - if (isset($line['aircraftname'])) { |
|
| 1126 | + $data = array(); |
|
| 1127 | + //$data['id'] = $line['id']; // id not usable |
|
| 1128 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1129 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1130 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1131 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1132 | + $data['ident'] = $line['flightnum']; // ident |
|
| 1133 | + $data['altitude'] = $line['alt']; // altitude |
|
| 1134 | + $data['speed'] = $line['gs']; // speed |
|
| 1135 | + $data['heading'] = $line['heading']; // heading |
|
| 1136 | + $data['latitude'] = $line['lat']; // lat |
|
| 1137 | + $data['longitude'] = $line['lng']; // long |
|
| 1138 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1139 | + $data['squawk'] = ''; // squawk |
|
| 1140 | + $data['emergency'] = ''; // emergency |
|
| 1141 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1142 | + //$data['last_update'] = $line['lastupdate']; |
|
| 1143 | + if (isset($value['timezone'])) { |
|
| 1144 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1145 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1146 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1147 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1148 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1149 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1150 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1151 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1152 | + $data['registration'] = $line['aircraft']; |
|
| 1153 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1154 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1155 | + if (isset($line['aircraftname'])) { |
|
| 1156 | 1156 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1157 | 1157 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1158 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1159 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1160 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1161 | - else { |
|
| 1162 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1163 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1164 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1165 | - } |
|
| 1166 | - } |
|
| 1167 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1168 | - $data['id_source'] = $id_source; |
|
| 1169 | - $data['format_source'] = 'phpvmacars'; |
|
| 1170 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1171 | - $SI->add($data); |
|
| 1172 | - unset($data); |
|
| 1158 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1159 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1160 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1161 | + else { |
|
| 1162 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1163 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1164 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1165 | + } |
|
| 1166 | + } |
|
| 1167 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1168 | + $data['id_source'] = $id_source; |
|
| 1169 | + $data['format_source'] = 'phpvmacars'; |
|
| 1170 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1171 | + $SI->add($data); |
|
| 1172 | + unset($data); |
|
| 1173 | 1173 | } |
| 1174 | 1174 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1175 | 1175 | unset($buffer); |
| 1176 | 1176 | unset($all_data); |
| 1177 | - } |
|
| 1178 | - //$last_exec['phpvmacars'] = time(); |
|
| 1179 | - $last_exec[$id]['last'] = time(); |
|
| 1177 | + } |
|
| 1178 | + //$last_exec['phpvmacars'] = time(); |
|
| 1179 | + $last_exec[$id]['last'] = time(); |
|
| 1180 | 1180 | } elseif ($value['format'] == 'vam' && |
| 1181 | - ( |
|
| 1181 | + ( |
|
| 1182 | 1182 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1183 | 1183 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1184 | - ) |
|
| 1184 | + ) |
|
| 1185 | 1185 | ) { |
| 1186 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1187 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1188 | - $buffer = $Common->getData($value['host']); |
|
| 1189 | - $all_data = json_decode($buffer,true); |
|
| 1190 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1186 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1187 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1188 | + $buffer = $Common->getData($value['host']); |
|
| 1189 | + $all_data = json_decode($buffer,true); |
|
| 1190 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1191 | 1191 | $reset = 0; |
| 1192 | 1192 | foreach ($all_data as $line) { |
| 1193 | - $data = array(); |
|
| 1194 | - //$data['id'] = $line['id']; // id not usable |
|
| 1195 | - $data['id'] = trim($line['flight_id']); |
|
| 1196 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1197 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 1198 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 1199 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 1200 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1201 | - $data['speed'] = $line['gs']; // speed |
|
| 1202 | - $data['heading'] = $line['heading']; // heading |
|
| 1203 | - $data['latitude'] = $line['latitude']; // lat |
|
| 1204 | - $data['longitude'] = $line['longitude']; // long |
|
| 1205 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1206 | - $data['squawk'] = ''; // squawk |
|
| 1207 | - $data['emergency'] = ''; // emergency |
|
| 1208 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1209 | - $data['last_update'] = $line['last_update']; |
|
| 1210 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1211 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 1212 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1213 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1214 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1215 | - //$data['registration'] = $line['aircraft']; |
|
| 1216 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1217 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 1218 | - $data['id_source'] = $id_source; |
|
| 1219 | - $data['format_source'] = 'vam'; |
|
| 1220 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1221 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1222 | - $SI->add($data); |
|
| 1223 | - unset($data); |
|
| 1193 | + $data = array(); |
|
| 1194 | + //$data['id'] = $line['id']; // id not usable |
|
| 1195 | + $data['id'] = trim($line['flight_id']); |
|
| 1196 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1197 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 1198 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 1199 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 1200 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1201 | + $data['speed'] = $line['gs']; // speed |
|
| 1202 | + $data['heading'] = $line['heading']; // heading |
|
| 1203 | + $data['latitude'] = $line['latitude']; // lat |
|
| 1204 | + $data['longitude'] = $line['longitude']; // long |
|
| 1205 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1206 | + $data['squawk'] = ''; // squawk |
|
| 1207 | + $data['emergency'] = ''; // emergency |
|
| 1208 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1209 | + $data['last_update'] = $line['last_update']; |
|
| 1210 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1211 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 1212 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1213 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1214 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1215 | + //$data['registration'] = $line['aircraft']; |
|
| 1216 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1217 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 1218 | + $data['id_source'] = $id_source; |
|
| 1219 | + $data['format_source'] = 'vam'; |
|
| 1220 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1221 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1222 | + $SI->add($data); |
|
| 1223 | + unset($data); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1226 | 1226 | unset($buffer); |
| 1227 | 1227 | unset($all_data); |
| 1228 | - } |
|
| 1229 | - //$last_exec['phpvmacars'] = time(); |
|
| 1230 | - $last_exec[$id]['last'] = time(); |
|
| 1228 | + } |
|
| 1229 | + //$last_exec['phpvmacars'] = time(); |
|
| 1230 | + $last_exec[$id]['last'] = time(); |
|
| 1231 | 1231 | } elseif ($value['format'] == 'blitzortung' && |
| 1232 | - ( |
|
| 1232 | + ( |
|
| 1233 | 1233 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1234 | 1234 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1235 | - ) |
|
| 1235 | + ) |
|
| 1236 | 1236 | ) { |
| 1237 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1238 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1239 | - $buffer = $Common->getData($value['host']); |
|
| 1240 | - $all_data = json_decode($buffer,true); |
|
| 1241 | - if ($buffer != '') { |
|
| 1237 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1238 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1239 | + $buffer = $Common->getData($value['host']); |
|
| 1240 | + $all_data = json_decode($buffer,true); |
|
| 1241 | + if ($buffer != '') { |
|
| 1242 | 1242 | $Source->deleteLocationBySource('blitzortung'); |
| 1243 | 1243 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 1244 | 1244 | $buffer = explode('\n',$buffer); |
| 1245 | 1245 | foreach ($buffer as $buffer_line) { |
| 1246 | - $line = json_decode($buffer_line,true); |
|
| 1247 | - if (isset($line['time'])) { |
|
| 1246 | + $line = json_decode($buffer_line,true); |
|
| 1247 | + if (isset($line['time'])) { |
|
| 1248 | 1248 | $data = array(); |
| 1249 | 1249 | $data['altitude'] = $line['alt']; // altitude |
| 1250 | 1250 | $data['latitude'] = $line['lat']; // lat |
@@ -1256,94 +1256,94 @@ discard block |
||
| 1256 | 1256 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1257 | 1257 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1258 | 1258 | unset($data); |
| 1259 | - } |
|
| 1259 | + } |
|
| 1260 | 1260 | } |
| 1261 | 1261 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1262 | 1262 | unset($buffer); |
| 1263 | - } |
|
| 1264 | - $last_exec[$id]['last'] = time(); |
|
| 1263 | + } |
|
| 1264 | + $last_exec[$id]['last'] = time(); |
|
| 1265 | 1265 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1266 | 1266 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1267 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1268 | - //$last_exec[$id]['last'] = time(); |
|
| 1267 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1268 | + //$last_exec[$id]['last'] = time(); |
|
| 1269 | 1269 | |
| 1270 | - //$read = array( $sockets[$id] ); |
|
| 1271 | - $read = $sockets; |
|
| 1272 | - $write = NULL; |
|
| 1273 | - $e = NULL; |
|
| 1274 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1275 | - if ($e != NULL) var_dump($e); |
|
| 1276 | - if ($n > 0) { |
|
| 1270 | + //$read = array( $sockets[$id] ); |
|
| 1271 | + $read = $sockets; |
|
| 1272 | + $write = NULL; |
|
| 1273 | + $e = NULL; |
|
| 1274 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1275 | + if ($e != NULL) var_dump($e); |
|
| 1276 | + if ($n > 0) { |
|
| 1277 | 1277 | $reset = 0; |
| 1278 | 1278 | foreach ($read as $nb => $r) { |
| 1279 | - //$value = $formats[$nb]; |
|
| 1280 | - $format = $globalSources[$nb]['format']; |
|
| 1281 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 1279 | + //$value = $formats[$nb]; |
|
| 1280 | + $format = $globalSources[$nb]['format']; |
|
| 1281 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 1282 | 1282 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
| 1283 | - } elseif ($format == 'vrstcp') { |
|
| 1283 | + } elseif ($format == 'vrstcp') { |
|
| 1284 | 1284 | $buffer = @socket_read($r, 6000); |
| 1285 | - } else { |
|
| 1285 | + } else { |
|
| 1286 | 1286 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
| 1287 | - } |
|
| 1288 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1289 | - //echo $buffer."\n"; |
|
| 1290 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1291 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1292 | - $error = false; |
|
| 1293 | - //$SI::del(); |
|
| 1294 | - if ($format == 'vrstcp') { |
|
| 1287 | + } |
|
| 1288 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1289 | + //echo $buffer."\n"; |
|
| 1290 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1291 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1292 | + $error = false; |
|
| 1293 | + //$SI::del(); |
|
| 1294 | + if ($format == 'vrstcp') { |
|
| 1295 | 1295 | $buffer = explode('},{',$buffer); |
| 1296 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1297 | - // SBS format is CSV format |
|
| 1298 | - if ($buffer !== FALSE && $buffer != '') { |
|
| 1296 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1297 | + // SBS format is CSV format |
|
| 1298 | + if ($buffer !== FALSE && $buffer != '') { |
|
| 1299 | 1299 | $tt[$format] = 0; |
| 1300 | 1300 | if ($format == 'acarssbs3') { |
| 1301 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1302 | - $ACARS->add(trim($buffer)); |
|
| 1303 | - $ACARS->deleteLiveAcarsData(); |
|
| 1301 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1302 | + $ACARS->add(trim($buffer)); |
|
| 1303 | + $ACARS->deleteLiveAcarsData(); |
|
| 1304 | 1304 | } elseif ($format == 'raw') { |
| 1305 | - // AVR format |
|
| 1306 | - $data = $SBS->parse($buffer); |
|
| 1307 | - if (is_array($data)) { |
|
| 1305 | + // AVR format |
|
| 1306 | + $data = $SBS->parse($buffer); |
|
| 1307 | + if (is_array($data)) { |
|
| 1308 | 1308 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1309 | 1309 | $data['format_source'] = 'raw'; |
| 1310 | 1310 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1311 | 1311 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1312 | 1312 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1313 | 1313 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1314 | - } |
|
| 1314 | + } |
|
| 1315 | 1315 | } elseif ($format == 'ais') { |
| 1316 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1317 | - $data = array(); |
|
| 1318 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1319 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1320 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1321 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1322 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1323 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1324 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1325 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1326 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1327 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1328 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1329 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1330 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1331 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1332 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1333 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1316 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1317 | + $data = array(); |
|
| 1318 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1319 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1320 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1321 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1322 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1323 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1324 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1325 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1326 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1327 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1328 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1329 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1330 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1331 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1332 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1333 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1334 | 1334 | |
| 1335 | - if (isset($ais_data['timestamp'])) { |
|
| 1335 | + if (isset($ais_data['timestamp'])) { |
|
| 1336 | 1336 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1337 | - } else { |
|
| 1337 | + } else { |
|
| 1338 | 1338 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1339 | - } |
|
| 1340 | - $data['format_source'] = 'aisnmea'; |
|
| 1341 | - $data['id_source'] = $id_source; |
|
| 1342 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1343 | - unset($data); |
|
| 1344 | - } elseif ($format == 'flightgearsp') { |
|
| 1345 | - //echo $buffer."\n"; |
|
| 1346 | - if (strlen($buffer) > 5) { |
|
| 1339 | + } |
|
| 1340 | + $data['format_source'] = 'aisnmea'; |
|
| 1341 | + $data['id_source'] = $id_source; |
|
| 1342 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1343 | + unset($data); |
|
| 1344 | + } elseif ($format == 'flightgearsp') { |
|
| 1345 | + //echo $buffer."\n"; |
|
| 1346 | + if (strlen($buffer) > 5) { |
|
| 1347 | 1347 | $line = explode(',',$buffer); |
| 1348 | 1348 | $data = array(); |
| 1349 | 1349 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1360,38 +1360,38 @@ discard block |
||
| 1360 | 1360 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1361 | 1361 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1362 | 1362 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1363 | - } |
|
| 1364 | - } elseif ($format == 'acars') { |
|
| 1365 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1366 | - $ACARS->add(trim($buffer)); |
|
| 1367 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1368 | - $ACARS->deleteLiveAcarsData(); |
|
| 1363 | + } |
|
| 1364 | + } elseif ($format == 'acars') { |
|
| 1365 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1366 | + $ACARS->add(trim($buffer)); |
|
| 1367 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1368 | + $ACARS->deleteLiveAcarsData(); |
|
| 1369 | 1369 | } elseif ($format == 'flightgearmp') { |
| 1370 | - if (substr($buffer,0,1) != '#') { |
|
| 1370 | + if (substr($buffer,0,1) != '#') { |
|
| 1371 | 1371 | $data = array(); |
| 1372 | 1372 | //echo $buffer."\n"; |
| 1373 | 1373 | $line = explode(' ',$buffer); |
| 1374 | 1374 | if (count($line) == 11) { |
| 1375 | - $userserver = explode('@',$line[0]); |
|
| 1376 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1377 | - $data['ident'] = $userserver[0]; |
|
| 1378 | - $data['registration'] = $userserver[0]; |
|
| 1379 | - $data['latitude'] = $line[4]; |
|
| 1380 | - $data['longitude'] = $line[5]; |
|
| 1381 | - $data['altitude'] = $line[6]; |
|
| 1382 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1383 | - $aircraft_type = $line[10]; |
|
| 1384 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1385 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1386 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1387 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1375 | + $userserver = explode('@',$line[0]); |
|
| 1376 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1377 | + $data['ident'] = $userserver[0]; |
|
| 1378 | + $data['registration'] = $userserver[0]; |
|
| 1379 | + $data['latitude'] = $line[4]; |
|
| 1380 | + $data['longitude'] = $line[5]; |
|
| 1381 | + $data['altitude'] = $line[6]; |
|
| 1382 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1383 | + $aircraft_type = $line[10]; |
|
| 1384 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1385 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1386 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1387 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1388 | + } |
|
| 1388 | 1389 | } |
| 1389 | - } |
|
| 1390 | 1390 | } elseif ($format == 'beast') { |
| 1391 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1392 | - die; |
|
| 1391 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1392 | + die; |
|
| 1393 | 1393 | } elseif ($format == 'vrstcp') { |
| 1394 | - foreach($buffer as $all_data) { |
|
| 1394 | + foreach($buffer as $all_data) { |
|
| 1395 | 1395 | $line = json_decode('{'.$all_data.'}',true); |
| 1396 | 1396 | $data = array(); |
| 1397 | 1397 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1411,148 +1411,148 @@ discard block |
||
| 1411 | 1411 | */ |
| 1412 | 1412 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1413 | 1413 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1414 | - $data['format_source'] = 'vrstcp'; |
|
| 1414 | + $data['format_source'] = 'vrstcp'; |
|
| 1415 | 1415 | $data['id_source'] = $id_source; |
| 1416 | 1416 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1417 | 1417 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1418 | 1418 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1419 | 1419 | unset($data); |
| 1420 | - } |
|
| 1420 | + } |
|
| 1421 | 1421 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 1422 | - $line = explode("\t", $buffer); |
|
| 1423 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1422 | + $line = explode("\t", $buffer); |
|
| 1423 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1424 | 1424 | $key = $line[$k]; |
| 1425 | - $lined[$key] = $line[$k+1]; |
|
| 1426 | - } |
|
| 1427 | - if (count($lined) > 3) { |
|
| 1428 | - $data['hex'] = $lined['hexid']; |
|
| 1429 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1430 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1431 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1432 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1433 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1434 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1435 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1436 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1437 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1438 | - $data['id_source'] = $id_source; |
|
| 1439 | - $data['format_source'] = 'tsv'; |
|
| 1440 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1441 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1425 | + $lined[$key] = $line[$k+1]; |
|
| 1426 | + } |
|
| 1427 | + if (count($lined) > 3) { |
|
| 1428 | + $data['hex'] = $lined['hexid']; |
|
| 1429 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1430 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1431 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1432 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1433 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1434 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1435 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1436 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1437 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1438 | + $data['id_source'] = $id_source; |
|
| 1439 | + $data['format_source'] = 'tsv'; |
|
| 1440 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1441 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1442 | 1442 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1443 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1444 | - unset($lined); |
|
| 1445 | - unset($data); |
|
| 1446 | - } else $error = true; |
|
| 1443 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1444 | + unset($lined); |
|
| 1445 | + unset($data); |
|
| 1446 | + } else $error = true; |
|
| 1447 | 1447 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1448 | - if ($aprs_connect == 0) { |
|
| 1448 | + if ($aprs_connect == 0) { |
|
| 1449 | 1449 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1450 | 1450 | $aprs_connect = 1; |
| 1451 | - } |
|
| 1451 | + } |
|
| 1452 | 1452 | |
| 1453 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1453 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1454 | 1454 | $aprs_last_tx = time(); |
| 1455 | 1455 | $data_aprs = "# Keep alive"; |
| 1456 | 1456 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1457 | - } |
|
| 1457 | + } |
|
| 1458 | 1458 | |
| 1459 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1460 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1461 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1462 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1463 | - //echo $buffer."\n"; |
|
| 1464 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1459 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1460 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1461 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1462 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1463 | + //echo $buffer."\n"; |
|
| 1464 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1465 | 1465 | $line = $APRS->parse($buffer); |
| 1466 | 1466 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1467 | 1467 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
| 1468 | - $aprs_last_tx = time(); |
|
| 1469 | - $data = array(); |
|
| 1470 | - //print_r($line); |
|
| 1471 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1472 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1473 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1474 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1475 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1476 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1477 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1478 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1479 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1480 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1481 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1482 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1483 | - $data['latitude'] = $line['latitude']; |
|
| 1484 | - $data['longitude'] = $line['longitude']; |
|
| 1485 | - //$data['verticalrate'] = $line[16]; |
|
| 1486 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1487 | - //else $data['speed'] = 0; |
|
| 1488 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1489 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1490 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1491 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1492 | - //else $data['heading'] = 0; |
|
| 1493 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1494 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1495 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1496 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1497 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1498 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1499 | - $data['id_source'] = $id_source; |
|
| 1500 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1501 | - else $data['format_source'] = 'aprs'; |
|
| 1502 | - $data['source_name'] = $line['source']; |
|
| 1503 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1504 | - else $data['source_type'] = 'flarm'; |
|
| 1505 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1506 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1507 | - $aprsdate = strtotime($data['datetime']); |
|
| 1508 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1509 | - // Accept data if time <= system time + 20s |
|
| 1510 | - //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1511 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1468 | + $aprs_last_tx = time(); |
|
| 1469 | + $data = array(); |
|
| 1470 | + //print_r($line); |
|
| 1471 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1472 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1473 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1474 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1475 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1476 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1477 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1478 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1479 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1480 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1481 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1482 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1483 | + $data['latitude'] = $line['latitude']; |
|
| 1484 | + $data['longitude'] = $line['longitude']; |
|
| 1485 | + //$data['verticalrate'] = $line[16]; |
|
| 1486 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1487 | + //else $data['speed'] = 0; |
|
| 1488 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1489 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1490 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1491 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1492 | + //else $data['heading'] = 0; |
|
| 1493 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1494 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1495 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1496 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1497 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1498 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1499 | + $data['id_source'] = $id_source; |
|
| 1500 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1501 | + else $data['format_source'] = 'aprs'; |
|
| 1502 | + $data['source_name'] = $line['source']; |
|
| 1503 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1504 | + else $data['source_type'] = 'flarm'; |
|
| 1505 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1506 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1507 | + $aprsdate = strtotime($data['datetime']); |
|
| 1508 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1509 | + // Accept data if time <= system time + 20s |
|
| 1510 | + //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1511 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1512 | 1512 | $send = $SI->add($data); |
| 1513 | - } elseif ($data['source_type'] == 'ais') { |
|
| 1513 | + } elseif ($data['source_type'] == 'ais') { |
|
| 1514 | 1514 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
| 1515 | - } elseif (isset($line['stealth'])) { |
|
| 1515 | + } elseif (isset($line['stealth'])) { |
|
| 1516 | 1516 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1517 | 1517 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 1518 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1519 | - //$line['symbol'] == 'Balloon' || |
|
| 1520 | - $line['symbol'] == 'Glider' || |
|
| 1521 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1522 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1523 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1524 | - $send = $SI->add($data); |
|
| 1525 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1526 | - $line['symbol'] == 'Yacht (Sail)' || |
|
| 1527 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
| 1528 | - $send = $MI->add($data); |
|
| 1529 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1530 | - $line['symbol'] == 'Car' || |
|
| 1531 | - $line['symbol'] == 'Ambulance' || |
|
| 1532 | - $line['symbol'] == 'Van' || |
|
| 1533 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
| 1534 | - $line['symbol'] == 'Motorcycle' || |
|
| 1535 | - $line['symbol'] == 'Tractor' || |
|
| 1536 | - $line['symbol'] == 'Police' || |
|
| 1537 | - $line['symbol'] == 'Bike' || |
|
| 1538 | - $line['symbol'] == 'Jogger' || |
|
| 1539 | - $line['symbol'] == 'Horse' || |
|
| 1540 | - $line['symbol'] == 'Bus' || |
|
| 1541 | - $line['symbol'] == 'Jeep' || |
|
| 1542 | - $line['symbol'] == 'Recreational Vehicle' || |
|
| 1543 | - $line['symbol'] == 'Yacht (Sail)' || |
|
| 1544 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
| 1545 | - $line['symbol'] == 'Firetruck' || |
|
| 1546 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
| 1547 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
| 1548 | - $line['symbol'] == 'SUV' || |
|
| 1549 | - $line['symbol'] == 'Snowmobile' || |
|
| 1550 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
| 1551 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
| 1518 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1519 | + //$line['symbol'] == 'Balloon' || |
|
| 1520 | + $line['symbol'] == 'Glider' || |
|
| 1521 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1522 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1523 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1524 | + $send = $SI->add($data); |
|
| 1525 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1526 | + $line['symbol'] == 'Yacht (Sail)' || |
|
| 1527 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
| 1528 | + $send = $MI->add($data); |
|
| 1529 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1530 | + $line['symbol'] == 'Car' || |
|
| 1531 | + $line['symbol'] == 'Ambulance' || |
|
| 1532 | + $line['symbol'] == 'Van' || |
|
| 1533 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
| 1534 | + $line['symbol'] == 'Motorcycle' || |
|
| 1535 | + $line['symbol'] == 'Tractor' || |
|
| 1536 | + $line['symbol'] == 'Police' || |
|
| 1537 | + $line['symbol'] == 'Bike' || |
|
| 1538 | + $line['symbol'] == 'Jogger' || |
|
| 1539 | + $line['symbol'] == 'Horse' || |
|
| 1540 | + $line['symbol'] == 'Bus' || |
|
| 1541 | + $line['symbol'] == 'Jeep' || |
|
| 1542 | + $line['symbol'] == 'Recreational Vehicle' || |
|
| 1543 | + $line['symbol'] == 'Yacht (Sail)' || |
|
| 1544 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
| 1545 | + $line['symbol'] == 'Firetruck' || |
|
| 1546 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
| 1547 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
| 1548 | + $line['symbol'] == 'SUV' || |
|
| 1549 | + $line['symbol'] == 'Snowmobile' || |
|
| 1550 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
| 1551 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
| 1552 | 1552 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1553 | 1553 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1554 | 1554 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 1555 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1555 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1556 | 1556 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 1557 | 1557 | $Source->deleteOldLocationByType('gs'); |
| 1558 | 1558 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1560,7 +1560,7 @@ discard block |
||
| 1560 | 1560 | } else { |
| 1561 | 1561 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
| 1562 | 1562 | } |
| 1563 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1563 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1564 | 1564 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1565 | 1565 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 1566 | 1566 | $Source->deleteOldLocationByType('wx'); |
@@ -1570,7 +1570,7 @@ discard block |
||
| 1570 | 1570 | } else { |
| 1571 | 1571 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
| 1572 | 1572 | } |
| 1573 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
| 1573 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
| 1574 | 1574 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1575 | 1575 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1576 | 1576 | $Source->deleteOldLocationByType('lightning'); |
@@ -1579,11 +1579,11 @@ discard block |
||
| 1579 | 1579 | } else { |
| 1580 | 1580 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
| 1581 | 1581 | } |
| 1582 | - } elseif ($globalDebug) { |
|
| 1583 | - echo '/!\ Not added: '.$buffer."\n"; |
|
| 1584 | - print_r($line); |
|
| 1585 | - } |
|
| 1586 | - unset($data); |
|
| 1582 | + } elseif ($globalDebug) { |
|
| 1583 | + echo '/!\ Not added: '.$buffer."\n"; |
|
| 1584 | + print_r($line); |
|
| 1585 | + } |
|
| 1586 | + unset($data); |
|
| 1587 | 1587 | } |
| 1588 | 1588 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 1589 | 1589 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1602,12 +1602,12 @@ discard block |
||
| 1602 | 1602 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
| 1603 | 1603 | $globalSources[$nb]['last_weather_clean'] = time(); |
| 1604 | 1604 | } |
| 1605 | - } |
|
| 1605 | + } |
|
| 1606 | 1606 | } else { |
| 1607 | - $line = explode(',', $buffer); |
|
| 1608 | - if (count($line) > 20) { |
|
| 1609 | - $data['hex'] = $line[4]; |
|
| 1610 | - /* |
|
| 1607 | + $line = explode(',', $buffer); |
|
| 1608 | + if (count($line) > 20) { |
|
| 1609 | + $data['hex'] = $line[4]; |
|
| 1610 | + /* |
|
| 1611 | 1611 | $data['datetime'] = $line[6].' '.$line[7]; |
| 1612 | 1612 | date_default_timezone_set($globalTimezone); |
| 1613 | 1613 | $datetime = new DateTime($data['datetime']); |
@@ -1615,30 +1615,30 @@ discard block |
||
| 1615 | 1615 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1616 | 1616 | date_default_timezone_set('UTC'); |
| 1617 | 1617 | */ |
| 1618 | - // Force datetime to current UTC datetime |
|
| 1619 | - date_default_timezone_set('UTC'); |
|
| 1620 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1621 | - $data['ident'] = trim($line[10]); |
|
| 1622 | - $data['latitude'] = $line[14]; |
|
| 1623 | - $data['longitude'] = $line[15]; |
|
| 1624 | - $data['verticalrate'] = $line[16]; |
|
| 1625 | - $data['emergency'] = $line[20]; |
|
| 1626 | - $data['speed'] = $line[12]; |
|
| 1627 | - $data['squawk'] = $line[17]; |
|
| 1628 | - $data['altitude'] = $line[11]; |
|
| 1629 | - $data['heading'] = $line[13]; |
|
| 1630 | - $data['ground'] = $line[21]; |
|
| 1631 | - $data['emergency'] = $line[19]; |
|
| 1632 | - $data['format_source'] = 'sbs'; |
|
| 1618 | + // Force datetime to current UTC datetime |
|
| 1619 | + date_default_timezone_set('UTC'); |
|
| 1620 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1621 | + $data['ident'] = trim($line[10]); |
|
| 1622 | + $data['latitude'] = $line[14]; |
|
| 1623 | + $data['longitude'] = $line[15]; |
|
| 1624 | + $data['verticalrate'] = $line[16]; |
|
| 1625 | + $data['emergency'] = $line[20]; |
|
| 1626 | + $data['speed'] = $line[12]; |
|
| 1627 | + $data['squawk'] = $line[17]; |
|
| 1628 | + $data['altitude'] = $line[11]; |
|
| 1629 | + $data['heading'] = $line[13]; |
|
| 1630 | + $data['ground'] = $line[21]; |
|
| 1631 | + $data['emergency'] = $line[19]; |
|
| 1632 | + $data['format_source'] = 'sbs'; |
|
| 1633 | 1633 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1634 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1634 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1635 | 1635 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1636 | - $data['id_source'] = $id_source; |
|
| 1637 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1638 | - else $error = true; |
|
| 1639 | - unset($data); |
|
| 1640 | - } else $error = true; |
|
| 1641 | - if ($error) { |
|
| 1636 | + $data['id_source'] = $id_source; |
|
| 1637 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1638 | + else $error = true; |
|
| 1639 | + unset($data); |
|
| 1640 | + } else $error = true; |
|
| 1641 | + if ($error) { |
|
| 1642 | 1642 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1643 | 1643 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1644 | 1644 | } else { |
@@ -1654,13 +1654,13 @@ discard block |
||
| 1654 | 1654 | connect_all($sourceer); |
| 1655 | 1655 | $sourceer = array(); |
| 1656 | 1656 | } |
| 1657 | - } |
|
| 1657 | + } |
|
| 1658 | 1658 | } |
| 1659 | 1659 | // Sleep for xxx microseconds |
| 1660 | 1660 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1661 | - } else { |
|
| 1661 | + } else { |
|
| 1662 | 1662 | if ($format == 'flightgearmp') { |
| 1663 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1663 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1664 | 1664 | //@socket_close($r); |
| 1665 | 1665 | sleep($globalMinFetch); |
| 1666 | 1666 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1669,9 +1669,9 @@ discard block |
||
| 1669 | 1669 | break; |
| 1670 | 1670 | |
| 1671 | 1671 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1672 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1673 | - else $tt[$format] = 0; |
|
| 1674 | - if ($tt[$format] > 30) { |
|
| 1672 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1673 | + else $tt[$format] = 0; |
|
| 1674 | + if ($tt[$format] > 30) { |
|
| 1675 | 1675 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1676 | 1676 | //@socket_close($r); |
| 1677 | 1677 | sleep(2); |
@@ -1682,23 +1682,23 @@ discard block |
||
| 1682 | 1682 | //connect_all($globalSources); |
| 1683 | 1683 | $tt[$format]=0; |
| 1684 | 1684 | break; |
| 1685 | - } |
|
| 1685 | + } |
|
| 1686 | + } |
|
| 1686 | 1687 | } |
| 1687 | - } |
|
| 1688 | 1688 | } |
| 1689 | - } else { |
|
| 1689 | + } else { |
|
| 1690 | 1690 | $error = socket_strerror(socket_last_error()); |
| 1691 | 1691 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1692 | 1692 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1693 | 1693 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1694 | 1694 | // Restart the script if possible |
| 1695 | 1695 | if (is_array($sockets)) { |
| 1696 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1696 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1697 | 1697 | |
| 1698 | - foreach ($sockets as $sock) { |
|
| 1698 | + foreach ($sockets as $sock) { |
|
| 1699 | 1699 | @socket_shutdown($sock,2); |
| 1700 | 1700 | @socket_close($sock); |
| 1701 | - } |
|
| 1701 | + } |
|
| 1702 | 1702 | |
| 1703 | 1703 | } |
| 1704 | 1704 | if ($globalDebug) echo "Waiting..."; |
@@ -1713,15 +1713,15 @@ discard block |
||
| 1713 | 1713 | if ($globalDebug) echo "Restart all connections..."; |
| 1714 | 1714 | connect_all($globalSources); |
| 1715 | 1715 | } |
| 1716 | - } |
|
| 1716 | + } |
|
| 1717 | 1717 | } |
| 1718 | 1718 | if ($globalDaemon === false) { |
| 1719 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1720 | - if (isset($SI)) $SI->checkAll(); |
|
| 1721 | - if (isset($TI)) $TI->checkAll(); |
|
| 1722 | - if (isset($MI)) $MI->checkAll(); |
|
| 1719 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1720 | + if (isset($SI)) $SI->checkAll(); |
|
| 1721 | + if (isset($TI)) $TI->checkAll(); |
|
| 1722 | + if (isset($MI)) $MI->checkAll(); |
|
| 1723 | + } |
|
| 1723 | 1724 | } |
| 1724 | - } |
|
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | 1727 | ?> |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | /** |
| 22 | - * Change IATA to ICAO value for ident |
|
| 23 | - * |
|
| 24 | - * @param String $ident ident |
|
| 25 | - * @return String the icao |
|
| 26 | - */ |
|
| 22 | + * Change IATA to ICAO value for ident |
|
| 23 | + * |
|
| 24 | + * @param String $ident ident |
|
| 25 | + * @return String the icao |
|
| 26 | + */ |
|
| 27 | 27 | public function ident2icao($ident) { |
| 28 | 28 | if (substr($ident,0,2) == 'AF') { |
| 29 | 29 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * Deletes all info in the live table |
|
| 43 | - * |
|
| 44 | - * @return String success or false |
|
| 45 | - * |
|
| 46 | - */ |
|
| 42 | + * Deletes all info in the live table |
|
| 43 | + * |
|
| 44 | + * @return String success or false |
|
| 45 | + * |
|
| 46 | + */ |
|
| 47 | 47 | public function deleteLiveAcarsData() |
| 48 | 48 | { |
| 49 | 49 | global $globalDBdriver; |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * Deletes all info in the archive table |
|
| 67 | - * |
|
| 68 | - * @return String success or false |
|
| 69 | - * |
|
| 70 | - */ |
|
| 66 | + * Deletes all info in the archive table |
|
| 67 | + * |
|
| 68 | + * @return String success or false |
|
| 69 | + * |
|
| 70 | + */ |
|
| 71 | 71 | public function deleteArchiveAcarsData() |
| 72 | 72 | { |
| 73 | 73 | global $globalACARSArchiveKeepMonths, $globalDBdriver; |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | - * Parse ACARS data |
|
| 92 | - * |
|
| 93 | - * @param String ACARS data in acarsdec data |
|
| 94 | - * |
|
| 95 | - */ |
|
| 91 | + * Parse ACARS data |
|
| 92 | + * |
|
| 93 | + * @param String ACARS data in acarsdec data |
|
| 94 | + * |
|
| 95 | + */ |
|
| 96 | 96 | public function parse($data) { |
| 97 | 97 | global $globalDebug, $globalACARSArchive; |
| 98 | 98 | //$Image = new Image($this->db); |
@@ -722,11 +722,11 @@ discard block |
||
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
| 725 | - * Add ACARS data |
|
| 726 | - * |
|
| 727 | - * @param String ACARS data in acarsdec data |
|
| 728 | - * |
|
| 729 | - */ |
|
| 725 | + * Add ACARS data |
|
| 726 | + * |
|
| 727 | + * @param String ACARS data in acarsdec data |
|
| 728 | + * |
|
| 729 | + */ |
|
| 730 | 730 | function add($data) { |
| 731 | 731 | global $globalDebug, $globalACARSArchive; |
| 732 | 732 | $Image = new Image($this->db); |
@@ -773,15 +773,15 @@ discard block |
||
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | /** |
| 776 | - * Add Live ACARS data in DB |
|
| 777 | - * |
|
| 778 | - * @param String $ident ident |
|
| 779 | - * @param String $registration Registration of the aircraft |
|
| 780 | - * @param String $label Label of the ACARS message |
|
| 781 | - * @param String $block_id Block id of the ACARS message |
|
| 782 | - * @param String $msg_no Number of the ACARS message |
|
| 783 | - * @param String $message ACARS message |
|
| 784 | - */ |
|
| 776 | + * Add Live ACARS data in DB |
|
| 777 | + * |
|
| 778 | + * @param String $ident ident |
|
| 779 | + * @param String $registration Registration of the aircraft |
|
| 780 | + * @param String $label Label of the ACARS message |
|
| 781 | + * @param String $block_id Block id of the ACARS message |
|
| 782 | + * @param String $msg_no Number of the ACARS message |
|
| 783 | + * @param String $message ACARS message |
|
| 784 | + */ |
|
| 785 | 785 | public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
| 786 | 786 | global $globalDebug; |
| 787 | 787 | date_default_timezone_set('UTC'); |
@@ -817,15 +817,15 @@ discard block |
||
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | /** |
| 820 | - * Add Archive ACARS data in DB |
|
| 821 | - * |
|
| 822 | - * @param String $ident ident |
|
| 823 | - * @param String $registration Registration of the aircraft |
|
| 824 | - * @param String $label Label of the ACARS message |
|
| 825 | - * @param String $block_id Block id of the ACARS message |
|
| 826 | - * @param String $msg_no Number of the ACARS message |
|
| 827 | - * @param String $message ACARS message |
|
| 828 | - */ |
|
| 820 | + * Add Archive ACARS data in DB |
|
| 821 | + * |
|
| 822 | + * @param String $ident ident |
|
| 823 | + * @param String $registration Registration of the aircraft |
|
| 824 | + * @param String $label Label of the ACARS message |
|
| 825 | + * @param String $block_id Block id of the ACARS message |
|
| 826 | + * @param String $msg_no Number of the ACARS message |
|
| 827 | + * @param String $message ACARS message |
|
| 828 | + */ |
|
| 829 | 829 | public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
| 830 | 830 | global $globalDebug; |
| 831 | 831 | date_default_timezone_set('UTC'); |
@@ -856,11 +856,11 @@ discard block |
||
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | /** |
| 859 | - * Get Message title from label from DB |
|
| 860 | - * |
|
| 861 | - * @param String $label |
|
| 862 | - * @return String Return ACARS title |
|
| 863 | - */ |
|
| 859 | + * Get Message title from label from DB |
|
| 860 | + * |
|
| 861 | + * @param String $label |
|
| 862 | + * @return String Return ACARS title |
|
| 863 | + */ |
|
| 864 | 864 | public function getTitlefromLabel($label) { |
| 865 | 865 | $Connection = new Connection($this->db); |
| 866 | 866 | $this->db = $Connection->db; |
@@ -879,10 +879,10 @@ discard block |
||
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
| 882 | - * List all Message title & label from DB |
|
| 883 | - * |
|
| 884 | - * @return Array Return ACARS data in array |
|
| 885 | - */ |
|
| 882 | + * List all Message title & label from DB |
|
| 883 | + * |
|
| 884 | + * @return Array Return ACARS data in array |
|
| 885 | + */ |
|
| 886 | 886 | public function getAllTitleLabel() { |
| 887 | 887 | $query = "SELECT * FROM acars_label ORDER BY title"; |
| 888 | 888 | $query_values = array(); |
@@ -899,11 +899,11 @@ discard block |
||
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | /** |
| 902 | - * Get Live ACARS data from DB |
|
| 903 | - * |
|
| 904 | - * @param String $ident |
|
| 905 | - * @return Array Return ACARS data in array |
|
| 906 | - */ |
|
| 902 | + * Get Live ACARS data from DB |
|
| 903 | + * |
|
| 904 | + * @param String $ident |
|
| 905 | + * @return Array Return ACARS data in array |
|
| 906 | + */ |
|
| 907 | 907 | public function getLiveAcarsData($ident) { |
| 908 | 908 | $query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC"; |
| 909 | 909 | $query_values = array(':ident' => $ident); |
@@ -920,10 +920,10 @@ discard block |
||
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | /** |
| 923 | - * Get Latest ACARS data from DB |
|
| 924 | - * |
|
| 925 | - * @return Array Return ACARS data in array |
|
| 926 | - */ |
|
| 923 | + * Get Latest ACARS data from DB |
|
| 924 | + * |
|
| 925 | + * @return Array Return ACARS data in array |
|
| 926 | + */ |
|
| 927 | 927 | public function getLatestAcarsData($limit = '',$label = '') { |
| 928 | 928 | global $globalURL, $globalDBdriver; |
| 929 | 929 | $Image = new Image($this->db); |
@@ -1011,10 +1011,10 @@ discard block |
||
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | /** |
| 1014 | - * Get Archive ACARS data from DB |
|
| 1015 | - * |
|
| 1016 | - * @return Array Return ACARS data in array |
|
| 1017 | - */ |
|
| 1014 | + * Get Archive ACARS data from DB |
|
| 1015 | + * |
|
| 1016 | + * @return Array Return ACARS data in array |
|
| 1017 | + */ |
|
| 1018 | 1018 | public function getArchiveAcarsData($limit = '',$label = '') { |
| 1019 | 1019 | global $globalURL, $globalDBdriver; |
| 1020 | 1020 | $Image = new Image($this->db); |
@@ -1102,13 +1102,13 @@ discard block |
||
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | /** |
| 1105 | - * Add ModeS data to DB |
|
| 1106 | - * |
|
| 1107 | - * @param String $ident ident |
|
| 1108 | - * @param String $registration Registration of the aircraft |
|
| 1109 | - * @param String $icao |
|
| 1110 | - * @param String $ICAOTypeCode |
|
| 1111 | - */ |
|
| 1105 | + * Add ModeS data to DB |
|
| 1106 | + * |
|
| 1107 | + * @param String $ident ident |
|
| 1108 | + * @param String $registration Registration of the aircraft |
|
| 1109 | + * @param String $icao |
|
| 1110 | + * @param String $ICAOTypeCode |
|
| 1111 | + */ |
|
| 1112 | 1112 | public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
| 1113 | 1113 | global $globalDebug, $globalDBdriver; |
| 1114 | 1114 | $ident = trim($ident); |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | if ($this->db === null) die('Error: No DB connection.'); |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Get SQL query part for filter used |
|
| 14 | - * @param Array $filter the filter |
|
| 15 | - * @return Array the SQL part |
|
| 16 | - */ |
|
| 17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 12 | + /** |
|
| 13 | + * Get SQL query part for filter used |
|
| 14 | + * @param Array $filter the filter |
|
| 15 | + * @return Array the SQL part |
|
| 16 | + */ |
|
| 17 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
| 20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -31,88 +31,88 @@ discard block |
||
| 31 | 31 | $filter_query_join = ''; |
| 32 | 32 | $filter_query_where = ''; |
| 33 | 33 | foreach($filters as $flt) { |
| 34 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
| 34 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
| 35 | 35 | if ($flt['airlines'][0] != '') { |
| 36 | - if (isset($flt['source'])) { |
|
| 36 | + if (isset($flt['source'])) { |
|
| 37 | 37 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
| 38 | - } else { |
|
| 38 | + } else { |
|
| 39 | 39 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
| 40 | - } |
|
| 40 | + } |
|
| 41 | + } |
|
| 41 | 42 | } |
| 42 | - } |
|
| 43 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 43 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 45 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 46 | 46 | } else { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 48 | 48 | } |
| 49 | - } |
|
| 50 | - if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
| 49 | + } |
|
| 50 | + if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
| 51 | 51 | if (isset($flt['source'])) { |
| 52 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 52 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 53 | 53 | } else { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 55 | + } |
|
| 55 | 56 | } |
| 56 | - } |
|
| 57 | - if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
| 57 | + if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
| 58 | 58 | if (isset($flt['source'])) { |
| 59 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 59 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 60 | 60 | } else { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 62 | + } |
|
| 62 | 63 | } |
| 63 | - } |
|
| 64 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
| 64 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
| 65 | 65 | if (isset($flt['source'])) { |
| 66 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 66 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 67 | + } |
|
| 67 | 68 | } |
| 68 | - } |
|
| 69 | 69 | } |
| 70 | 70 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 71 | - if ($filter['airlines'][0] != '') { |
|
| 71 | + if ($filter['airlines'][0] != '') { |
|
| 72 | 72 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
| 73 | - } |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 77 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
| 77 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
| 78 | 78 | } |
| 79 | 79 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 80 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 80 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 83 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 83 | + $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 84 | 84 | } |
| 85 | 85 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 86 | - $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
| 86 | + $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
| 87 | 87 | } |
| 88 | 88 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 89 | 89 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 90 | 90 | } |
| 91 | 91 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 92 | - $filter_query_date = ''; |
|
| 92 | + $filter_query_date = ''; |
|
| 93 | 93 | |
| 94 | - if (isset($filter['year']) && $filter['year'] != '') { |
|
| 94 | + if (isset($filter['year']) && $filter['year'] != '') { |
|
| 95 | 95 | if ($globalDBdriver == 'mysql') { |
| 96 | - $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 96 | + $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 97 | 97 | } else { |
| 98 | - $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 98 | + $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 99 | + } |
|
| 99 | 100 | } |
| 100 | - } |
|
| 101 | - if (isset($filter['month']) && $filter['month'] != '') { |
|
| 101 | + if (isset($filter['month']) && $filter['month'] != '') { |
|
| 102 | 102 | if ($globalDBdriver == 'mysql') { |
| 103 | - $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 103 | + $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 104 | 104 | } else { |
| 105 | - $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 105 | + $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 106 | 106 | } |
| 107 | - } |
|
| 108 | - if (isset($filter['day']) && $filter['day'] != '') { |
|
| 107 | + } |
|
| 108 | + if (isset($filter['day']) && $filter['day'] != '') { |
|
| 109 | 109 | if ($globalDBdriver == 'mysql') { |
| 110 | - $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 110 | + $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 111 | 111 | } else { |
| 112 | - $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 112 | + $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 113 | + } |
|
| 113 | 114 | } |
| 114 | - } |
|
| 115 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 115 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 116 | 116 | } |
| 117 | 117 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 118 | 118 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | $filter_query = $filter_query_join.$filter_query_where; |
| 123 | 123 | return $filter_query; |
| 124 | - } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | // Spotter_archive |
| 127 | 127 | 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 = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -153,44 +153,44 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * Gets all the spotter information based on a particular callsign |
|
| 158 | - * |
|
| 159 | - * @return Array the spotter information |
|
| 160 | - * |
|
| 161 | - */ |
|
| 162 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
| 163 | - { |
|
| 156 | + /** |
|
| 157 | + * Gets all the spotter information based on a particular callsign |
|
| 158 | + * |
|
| 159 | + * @return Array the spotter information |
|
| 160 | + * |
|
| 161 | + */ |
|
| 162 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
| 163 | + { |
|
| 164 | 164 | $Spotter = new Spotter($this->db); |
| 165 | - date_default_timezone_set('UTC'); |
|
| 165 | + date_default_timezone_set('UTC'); |
|
| 166 | 166 | |
| 167 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 168 | - //$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"; |
|
| 169 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 167 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 168 | + //$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"; |
|
| 169 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 170 | 170 | |
| 171 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 171 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 172 | 172 | |
| 173 | - return $spotter_array; |
|
| 174 | - } |
|
| 173 | + return $spotter_array; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * Gets last the spotter information based on a particular id |
|
| 179 | - * |
|
| 180 | - * @return Array the spotter information |
|
| 181 | - * |
|
| 182 | - */ |
|
| 183 | - public function getLastArchiveSpotterDataById($id) |
|
| 184 | - { |
|
| 185 | - $Spotter = new Spotter($this->db); |
|
| 186 | - date_default_timezone_set('UTC'); |
|
| 187 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 188 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 189 | - //$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"; |
|
| 190 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 177 | + /** |
|
| 178 | + * Gets last the spotter information based on a particular id |
|
| 179 | + * |
|
| 180 | + * @return Array the spotter information |
|
| 181 | + * |
|
| 182 | + */ |
|
| 183 | + public function getLastArchiveSpotterDataById($id) |
|
| 184 | + { |
|
| 185 | + $Spotter = new Spotter($this->db); |
|
| 186 | + date_default_timezone_set('UTC'); |
|
| 187 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 188 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 189 | + //$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"; |
|
| 190 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 191 | 191 | |
| 192 | 192 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 193 | - /* |
|
| 193 | + /* |
|
| 194 | 194 | try { |
| 195 | 195 | $Connection = new Connection(); |
| 196 | 196 | $sth = Connection->$db->prepare($query); |
@@ -200,235 +200,235 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 202 | 202 | */ |
| 203 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 204 | - |
|
| 205 | - return $spotter_array; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Gets all the spotter information based on a particular id |
|
| 210 | - * |
|
| 211 | - * @return Array the spotter information |
|
| 212 | - * |
|
| 213 | - */ |
|
| 214 | - public function getAllArchiveSpotterDataById($id) |
|
| 203 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 204 | + |
|
| 205 | + return $spotter_array; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Gets all the spotter information based on a particular id |
|
| 210 | + * |
|
| 211 | + * @return Array the spotter information |
|
| 212 | + * |
|
| 213 | + */ |
|
| 214 | + public function getAllArchiveSpotterDataById($id) |
|
| 215 | 215 | { |
| 216 | - date_default_timezone_set('UTC'); |
|
| 217 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 218 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 216 | + date_default_timezone_set('UTC'); |
|
| 217 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 218 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 219 | 219 | |
| 220 | 220 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 221 | 221 | |
| 222 | - try { |
|
| 223 | - $sth = $this->db->prepare($query); |
|
| 224 | - $sth->execute(array(':id' => $id)); |
|
| 225 | - } catch(PDOException $e) { |
|
| 226 | - echo $e->getMessage(); |
|
| 227 | - die; |
|
| 228 | - } |
|
| 229 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 230 | - |
|
| 231 | - return $spotter_array; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * Gets coordinate & time spotter information based on a particular id |
|
| 236 | - * |
|
| 237 | - * @return Array the spotter information |
|
| 238 | - * |
|
| 239 | - */ |
|
| 240 | - public function getCoordArchiveSpotterDataById($id) |
|
| 241 | - { |
|
| 242 | - date_default_timezone_set('UTC'); |
|
| 243 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 244 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 222 | + try { |
|
| 223 | + $sth = $this->db->prepare($query); |
|
| 224 | + $sth->execute(array(':id' => $id)); |
|
| 225 | + } catch(PDOException $e) { |
|
| 226 | + echo $e->getMessage(); |
|
| 227 | + die; |
|
| 228 | + } |
|
| 229 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 230 | + |
|
| 231 | + return $spotter_array; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * Gets coordinate & time spotter information based on a particular id |
|
| 236 | + * |
|
| 237 | + * @return Array the spotter information |
|
| 238 | + * |
|
| 239 | + */ |
|
| 240 | + public function getCoordArchiveSpotterDataById($id) |
|
| 241 | + { |
|
| 242 | + date_default_timezone_set('UTC'); |
|
| 243 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 244 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 245 | 245 | |
| 246 | 246 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 247 | 247 | |
| 248 | - try { |
|
| 249 | - $sth = $this->db->prepare($query); |
|
| 250 | - $sth->execute(array(':id' => $id)); |
|
| 251 | - } catch(PDOException $e) { |
|
| 252 | - echo $e->getMessage(); |
|
| 253 | - die; |
|
| 254 | - } |
|
| 255 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 248 | + try { |
|
| 249 | + $sth = $this->db->prepare($query); |
|
| 250 | + $sth->execute(array(':id' => $id)); |
|
| 251 | + } catch(PDOException $e) { |
|
| 252 | + echo $e->getMessage(); |
|
| 253 | + die; |
|
| 254 | + } |
|
| 255 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 256 | 256 | |
| 257 | - return $spotter_array; |
|
| 258 | - } |
|
| 257 | + return $spotter_array; |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | 260 | |
| 261 | - /** |
|
| 262 | - * Gets altitude information based on a particular callsign |
|
| 263 | - * |
|
| 264 | - * @return Array the spotter information |
|
| 265 | - * |
|
| 266 | - */ |
|
| 267 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 268 | - { |
|
| 261 | + /** |
|
| 262 | + * Gets altitude information based on a particular callsign |
|
| 263 | + * |
|
| 264 | + * @return Array the spotter information |
|
| 265 | + * |
|
| 266 | + */ |
|
| 267 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 268 | + { |
|
| 269 | 269 | |
| 270 | - date_default_timezone_set('UTC'); |
|
| 270 | + date_default_timezone_set('UTC'); |
|
| 271 | 271 | |
| 272 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 273 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 272 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 273 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 274 | 274 | |
| 275 | - try { |
|
| 276 | - $sth = $this->db->prepare($query); |
|
| 277 | - $sth->execute(array(':ident' => $ident)); |
|
| 278 | - } catch(PDOException $e) { |
|
| 279 | - echo $e->getMessage(); |
|
| 280 | - die; |
|
| 281 | - } |
|
| 282 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 275 | + try { |
|
| 276 | + $sth = $this->db->prepare($query); |
|
| 277 | + $sth->execute(array(':ident' => $ident)); |
|
| 278 | + } catch(PDOException $e) { |
|
| 279 | + echo $e->getMessage(); |
|
| 280 | + die; |
|
| 281 | + } |
|
| 282 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 283 | 283 | |
| 284 | - return $spotter_array; |
|
| 285 | - } |
|
| 284 | + return $spotter_array; |
|
| 285 | + } |
|
| 286 | 286 | |
| 287 | - /** |
|
| 288 | - * Gets altitude information based on a particular id |
|
| 289 | - * |
|
| 290 | - * @return Array the spotter information |
|
| 291 | - * |
|
| 292 | - */ |
|
| 293 | - public function getAltitudeArchiveSpotterDataById($id) |
|
| 294 | - { |
|
| 287 | + /** |
|
| 288 | + * Gets altitude information based on a particular id |
|
| 289 | + * |
|
| 290 | + * @return Array the spotter information |
|
| 291 | + * |
|
| 292 | + */ |
|
| 293 | + public function getAltitudeArchiveSpotterDataById($id) |
|
| 294 | + { |
|
| 295 | 295 | |
| 296 | - date_default_timezone_set('UTC'); |
|
| 296 | + date_default_timezone_set('UTC'); |
|
| 297 | 297 | |
| 298 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 299 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 298 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 299 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 300 | 300 | |
| 301 | - try { |
|
| 302 | - $sth = $this->db->prepare($query); |
|
| 303 | - $sth->execute(array(':id' => $id)); |
|
| 304 | - } catch(PDOException $e) { |
|
| 305 | - echo $e->getMessage(); |
|
| 306 | - die; |
|
| 307 | - } |
|
| 308 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 301 | + try { |
|
| 302 | + $sth = $this->db->prepare($query); |
|
| 303 | + $sth->execute(array(':id' => $id)); |
|
| 304 | + } catch(PDOException $e) { |
|
| 305 | + echo $e->getMessage(); |
|
| 306 | + die; |
|
| 307 | + } |
|
| 308 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 309 | 309 | |
| 310 | - return $spotter_array; |
|
| 311 | - } |
|
| 310 | + return $spotter_array; |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - /** |
|
| 314 | - * Gets altitude & speed information based on a particular id |
|
| 315 | - * |
|
| 316 | - * @return Array the spotter information |
|
| 317 | - * |
|
| 318 | - */ |
|
| 319 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 320 | - { |
|
| 313 | + /** |
|
| 314 | + * Gets altitude & speed information based on a particular id |
|
| 315 | + * |
|
| 316 | + * @return Array the spotter information |
|
| 317 | + * |
|
| 318 | + */ |
|
| 319 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 320 | + { |
|
| 321 | 321 | |
| 322 | - date_default_timezone_set('UTC'); |
|
| 322 | + date_default_timezone_set('UTC'); |
|
| 323 | 323 | |
| 324 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 325 | - $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 324 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 325 | + $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 326 | 326 | |
| 327 | - try { |
|
| 328 | - $sth = $this->db->prepare($query); |
|
| 329 | - $sth->execute(array(':id' => $id)); |
|
| 330 | - } catch(PDOException $e) { |
|
| 331 | - echo $e->getMessage(); |
|
| 332 | - die; |
|
| 333 | - } |
|
| 334 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 327 | + try { |
|
| 328 | + $sth = $this->db->prepare($query); |
|
| 329 | + $sth->execute(array(':id' => $id)); |
|
| 330 | + } catch(PDOException $e) { |
|
| 331 | + echo $e->getMessage(); |
|
| 332 | + die; |
|
| 333 | + } |
|
| 334 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 335 | 335 | |
| 336 | - return $spotter_array; |
|
| 337 | - } |
|
| 336 | + return $spotter_array; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | 339 | |
| 340 | - /** |
|
| 341 | - * Gets altitude information based on a particular callsign |
|
| 342 | - * |
|
| 343 | - * @return Array the spotter information |
|
| 344 | - * |
|
| 345 | - */ |
|
| 346 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 347 | - { |
|
| 340 | + /** |
|
| 341 | + * Gets altitude information based on a particular callsign |
|
| 342 | + * |
|
| 343 | + * @return Array the spotter information |
|
| 344 | + * |
|
| 345 | + */ |
|
| 346 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 347 | + { |
|
| 348 | 348 | |
| 349 | - date_default_timezone_set('UTC'); |
|
| 349 | + date_default_timezone_set('UTC'); |
|
| 350 | 350 | |
| 351 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 352 | - $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"; |
|
| 351 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 352 | + $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"; |
|
| 353 | 353 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 354 | 354 | |
| 355 | - try { |
|
| 356 | - $sth = $this->db->prepare($query); |
|
| 357 | - $sth->execute(array(':ident' => $ident)); |
|
| 358 | - } catch(PDOException $e) { |
|
| 359 | - echo $e->getMessage(); |
|
| 360 | - die; |
|
| 361 | - } |
|
| 362 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 355 | + try { |
|
| 356 | + $sth = $this->db->prepare($query); |
|
| 357 | + $sth->execute(array(':ident' => $ident)); |
|
| 358 | + } catch(PDOException $e) { |
|
| 359 | + echo $e->getMessage(); |
|
| 360 | + die; |
|
| 361 | + } |
|
| 362 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 363 | 363 | |
| 364 | - return $spotter_array; |
|
| 365 | - } |
|
| 364 | + return $spotter_array; |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | 367 | |
| 368 | 368 | |
| 369 | - /** |
|
| 370 | - * Gets all the archive spotter information |
|
| 371 | - * |
|
| 372 | - * @return Array the spotter information |
|
| 373 | - * |
|
| 374 | - */ |
|
| 375 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 376 | - { |
|
| 377 | - $Spotter = new Spotter($this->db); |
|
| 378 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 379 | - $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"; |
|
| 369 | + /** |
|
| 370 | + * Gets all the archive spotter information |
|
| 371 | + * |
|
| 372 | + * @return Array the spotter information |
|
| 373 | + * |
|
| 374 | + */ |
|
| 375 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 376 | + { |
|
| 377 | + $Spotter = new Spotter($this->db); |
|
| 378 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 379 | + $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"; |
|
| 380 | 380 | |
| 381 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 381 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 382 | 382 | |
| 383 | - return $spotter_array; |
|
| 384 | - } |
|
| 383 | + return $spotter_array; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - public function deleteSpotterArchiveTrackData() |
|
| 387 | - { |
|
| 386 | + public function deleteSpotterArchiveTrackData() |
|
| 387 | + { |
|
| 388 | 388 | global $globalArchiveKeepTrackMonths, $globalDBdriver; |
| 389 | 389 | if ($globalDBdriver == 'mysql') { |
| 390 | 390 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 391 | 391 | } else { |
| 392 | 392 | $query = "DELETE FROM spotter_archive WHERE spotter_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH'"; |
| 393 | 393 | } |
| 394 | - try { |
|
| 395 | - $sth = $this->db->prepare($query); |
|
| 396 | - $sth->execute(); |
|
| 397 | - } catch(PDOException $e) { |
|
| 398 | - echo $e->getMessage(); |
|
| 399 | - die; |
|
| 400 | - } |
|
| 394 | + try { |
|
| 395 | + $sth = $this->db->prepare($query); |
|
| 396 | + $sth->execute(); |
|
| 397 | + } catch(PDOException $e) { |
|
| 398 | + echo $e->getMessage(); |
|
| 399 | + die; |
|
| 400 | + } |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /** |
| 404 | - * Gets Minimal Live Spotter data |
|
| 405 | - * |
|
| 406 | - * @return Array the spotter information |
|
| 407 | - * |
|
| 408 | - */ |
|
| 409 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 410 | - { |
|
| 411 | - global $globalDBdriver, $globalLiveInterval; |
|
| 412 | - date_default_timezone_set('UTC'); |
|
| 413 | - |
|
| 414 | - $filter_query = ''; |
|
| 415 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 416 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 417 | - } |
|
| 418 | - // Use spotter_output also ? |
|
| 419 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 420 | - $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 "; |
|
| 421 | - } |
|
| 422 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 423 | - $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 "; |
|
| 424 | - } |
|
| 425 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 426 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 430 | - if ($globalDBdriver == 'mysql') { |
|
| 431 | - /* |
|
| 404 | + * Gets Minimal Live Spotter data |
|
| 405 | + * |
|
| 406 | + * @return Array the spotter information |
|
| 407 | + * |
|
| 408 | + */ |
|
| 409 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 410 | + { |
|
| 411 | + global $globalDBdriver, $globalLiveInterval; |
|
| 412 | + date_default_timezone_set('UTC'); |
|
| 413 | + |
|
| 414 | + $filter_query = ''; |
|
| 415 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 416 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 417 | + } |
|
| 418 | + // Use spotter_output also ? |
|
| 419 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 420 | + $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 "; |
|
| 421 | + } |
|
| 422 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 423 | + $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 "; |
|
| 424 | + } |
|
| 425 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 426 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 430 | + if ($globalDBdriver == 'mysql') { |
|
| 431 | + /* |
|
| 432 | 432 | $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 |
| 433 | 433 | FROM spotter_archive |
| 434 | 434 | 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'; |
@@ -447,56 +447,56 @@ discard block |
||
| 447 | 447 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 448 | 448 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 449 | 449 | '.$filter_query.' ORDER BY flightaware_id'; |
| 450 | - } else { |
|
| 451 | - //$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'; |
|
| 452 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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,a.engine_type, a.engine_count, a.wake_category |
|
| 450 | + } else { |
|
| 451 | + //$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'; |
|
| 452 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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,a.engine_type, a.engine_count, a.wake_category |
|
| 453 | 453 | FROM spotter_archive |
| 454 | 454 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 455 | 455 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
| 456 | 456 | '.$filter_query.' ORDER BY flightaware_id'; |
| 457 | - } |
|
| 458 | - //echo $query; |
|
| 459 | - try { |
|
| 460 | - $sth = $this->db->prepare($query); |
|
| 461 | - $sth->execute(); |
|
| 462 | - } catch(PDOException $e) { |
|
| 463 | - echo $e->getMessage(); |
|
| 464 | - die; |
|
| 465 | - } |
|
| 466 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 467 | - |
|
| 468 | - return $spotter_array; |
|
| 469 | - } |
|
| 457 | + } |
|
| 458 | + //echo $query; |
|
| 459 | + try { |
|
| 460 | + $sth = $this->db->prepare($query); |
|
| 461 | + $sth->execute(); |
|
| 462 | + } catch(PDOException $e) { |
|
| 463 | + echo $e->getMessage(); |
|
| 464 | + die; |
|
| 465 | + } |
|
| 466 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 467 | + |
|
| 468 | + return $spotter_array; |
|
| 469 | + } |
|
| 470 | 470 | |
| 471 | 471 | /** |
| 472 | - * Gets Minimal Live Spotter data |
|
| 473 | - * |
|
| 474 | - * @return Array the spotter information |
|
| 475 | - * |
|
| 476 | - */ |
|
| 477 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 478 | - { |
|
| 479 | - global $globalDBdriver, $globalLiveInterval; |
|
| 480 | - date_default_timezone_set('UTC'); |
|
| 481 | - |
|
| 482 | - $filter_query = ''; |
|
| 483 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 484 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 485 | - } |
|
| 486 | - // Should use spotter_output also ? |
|
| 487 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 488 | - $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 "; |
|
| 489 | - } |
|
| 490 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 491 | - $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 "; |
|
| 492 | - } |
|
| 493 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 494 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 498 | - if ($globalDBdriver == 'mysql') { |
|
| 499 | - /* |
|
| 472 | + * Gets Minimal Live Spotter data |
|
| 473 | + * |
|
| 474 | + * @return Array the spotter information |
|
| 475 | + * |
|
| 476 | + */ |
|
| 477 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 478 | + { |
|
| 479 | + global $globalDBdriver, $globalLiveInterval; |
|
| 480 | + date_default_timezone_set('UTC'); |
|
| 481 | + |
|
| 482 | + $filter_query = ''; |
|
| 483 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 484 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 485 | + } |
|
| 486 | + // Should use spotter_output also ? |
|
| 487 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 488 | + $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 "; |
|
| 489 | + } |
|
| 490 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 491 | + $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 "; |
|
| 492 | + } |
|
| 493 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 494 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 498 | + if ($globalDBdriver == 'mysql') { |
|
| 499 | + /* |
|
| 500 | 500 | $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 |
| 501 | 501 | FROM spotter_archive |
| 502 | 502 | 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'; |
@@ -507,95 +507,95 @@ discard block |
||
| 507 | 507 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 508 | 508 | '.$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'; |
| 509 | 509 | |
| 510 | - } else { |
|
| 511 | - //$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'; |
|
| 512 | - /* |
|
| 510 | + } else { |
|
| 511 | + //$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'; |
|
| 512 | + /* |
|
| 513 | 513 | $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 |
| 514 | 514 | FROM spotter_archive_output |
| 515 | 515 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 516 | 516 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 517 | 517 | '.$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'; |
| 518 | 518 | */ |
| 519 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, 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 |
|
| 519 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, 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 |
|
| 520 | 520 | FROM spotter_archive_output |
| 521 | 521 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 522 | 522 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 523 | 523 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 524 | 524 | // .' 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'; |
| 525 | 525 | |
| 526 | - } |
|
| 527 | - //echo $query; |
|
| 528 | - try { |
|
| 529 | - $sth = $this->db->prepare($query); |
|
| 530 | - $sth->execute(); |
|
| 531 | - } catch(PDOException $e) { |
|
| 532 | - echo $e->getMessage(); |
|
| 533 | - die; |
|
| 534 | - } |
|
| 535 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 536 | - |
|
| 537 | - return $spotter_array; |
|
| 538 | - } |
|
| 526 | + } |
|
| 527 | + //echo $query; |
|
| 528 | + try { |
|
| 529 | + $sth = $this->db->prepare($query); |
|
| 530 | + $sth->execute(); |
|
| 531 | + } catch(PDOException $e) { |
|
| 532 | + echo $e->getMessage(); |
|
| 533 | + die; |
|
| 534 | + } |
|
| 535 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 536 | + |
|
| 537 | + return $spotter_array; |
|
| 538 | + } |
|
| 539 | 539 | |
| 540 | 540 | /** |
| 541 | - * Gets count Live Spotter data |
|
| 542 | - * |
|
| 543 | - * @return Array the spotter information |
|
| 544 | - * |
|
| 545 | - */ |
|
| 546 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 547 | - { |
|
| 548 | - global $globalDBdriver, $globalLiveInterval; |
|
| 549 | - date_default_timezone_set('UTC'); |
|
| 550 | - |
|
| 551 | - $filter_query = ''; |
|
| 552 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 553 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 554 | - } |
|
| 555 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 556 | - $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 "; |
|
| 557 | - } |
|
| 558 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 559 | - $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 "; |
|
| 560 | - } |
|
| 561 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 562 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 566 | - if ($globalDBdriver == 'mysql') { |
|
| 541 | + * Gets count Live Spotter data |
|
| 542 | + * |
|
| 543 | + * @return Array the spotter information |
|
| 544 | + * |
|
| 545 | + */ |
|
| 546 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 547 | + { |
|
| 548 | + global $globalDBdriver, $globalLiveInterval; |
|
| 549 | + date_default_timezone_set('UTC'); |
|
| 550 | + |
|
| 551 | + $filter_query = ''; |
|
| 552 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 553 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 554 | + } |
|
| 555 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 556 | + $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 "; |
|
| 557 | + } |
|
| 558 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 559 | + $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 "; |
|
| 560 | + } |
|
| 561 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 562 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 566 | + if ($globalDBdriver == 'mysql') { |
|
| 567 | 567 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
| 568 | 568 | FROM spotter_archive l |
| 569 | 569 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 570 | - } else { |
|
| 570 | + } else { |
|
| 571 | 571 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 572 | - } |
|
| 573 | - //echo $query; |
|
| 574 | - try { |
|
| 575 | - $sth = $this->db->prepare($query); |
|
| 576 | - $sth->execute(); |
|
| 577 | - } catch(PDOException $e) { |
|
| 578 | - echo $e->getMessage(); |
|
| 579 | - die; |
|
| 580 | - } |
|
| 572 | + } |
|
| 573 | + //echo $query; |
|
| 574 | + try { |
|
| 575 | + $sth = $this->db->prepare($query); |
|
| 576 | + $sth->execute(); |
|
| 577 | + } catch(PDOException $e) { |
|
| 578 | + echo $e->getMessage(); |
|
| 579 | + die; |
|
| 580 | + } |
|
| 581 | 581 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 582 | 582 | $sth->closeCursor(); |
| 583 | - return $result['nb']; |
|
| 583 | + return $result['nb']; |
|
| 584 | 584 | |
| 585 | - } |
|
| 585 | + } |
|
| 586 | 586 | |
| 587 | 587 | |
| 588 | 588 | |
| 589 | 589 | // Spotter_Archive_output |
| 590 | 590 | |
| 591 | - /** |
|
| 592 | - * Gets all the spotter information |
|
| 593 | - * |
|
| 594 | - * @return Array the spotter information |
|
| 595 | - * |
|
| 596 | - */ |
|
| 597 | - 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 = '', $filters=array()) |
|
| 598 | - { |
|
| 591 | + /** |
|
| 592 | + * Gets all the spotter information |
|
| 593 | + * |
|
| 594 | + * @return Array the spotter information |
|
| 595 | + * |
|
| 596 | + */ |
|
| 597 | + 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 = '', $filters=array()) |
|
| 598 | + { |
|
| 599 | 599 | global $globalTimezone, $globalDBdriver; |
| 600 | 600 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 601 | 601 | $Translation = new Translation(); |
@@ -609,159 +609,159 @@ discard block |
||
| 609 | 609 | $filter_query = $this->getFilter($filters); |
| 610 | 610 | if ($q != "") |
| 611 | 611 | { |
| 612 | - if (!is_string($q)) |
|
| 613 | - { |
|
| 612 | + if (!is_string($q)) |
|
| 613 | + { |
|
| 614 | 614 | return false; |
| 615 | - } else { |
|
| 615 | + } else { |
|
| 616 | 616 | |
| 617 | 617 | $q_array = explode(" ", $q); |
| 618 | 618 | |
| 619 | 619 | foreach ($q_array as $q_item){ |
| 620 | - $additional_query .= " AND ("; |
|
| 621 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 622 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 623 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 624 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 625 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 626 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 627 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 628 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 629 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 630 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 631 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 632 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 633 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 634 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 635 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 636 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 637 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 638 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 639 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 640 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 641 | - $translate = $Translation->ident2icao($q_item); |
|
| 642 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 643 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 644 | - $additional_query .= ")"; |
|
| 645 | - } |
|
| 646 | - } |
|
| 620 | + $additional_query .= " AND ("; |
|
| 621 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 622 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 623 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 624 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 625 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 626 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 627 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 628 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 629 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 630 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 631 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 632 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 633 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 634 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 635 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 636 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 637 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 638 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 639 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 640 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 641 | + $translate = $Translation->ident2icao($q_item); |
|
| 642 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 643 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 644 | + $additional_query .= ")"; |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | if ($registration != "") |
| 650 | 650 | { |
| 651 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 652 | - if (!is_string($registration)) |
|
| 653 | - { |
|
| 651 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 652 | + if (!is_string($registration)) |
|
| 653 | + { |
|
| 654 | 654 | return false; |
| 655 | - } else { |
|
| 655 | + } else { |
|
| 656 | 656 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
| 657 | - } |
|
| 657 | + } |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | if ($aircraft_icao != "") |
| 661 | 661 | { |
| 662 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 663 | - if (!is_string($aircraft_icao)) |
|
| 664 | - { |
|
| 662 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 663 | + if (!is_string($aircraft_icao)) |
|
| 664 | + { |
|
| 665 | 665 | return false; |
| 666 | - } else { |
|
| 666 | + } else { |
|
| 667 | 667 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 668 | - } |
|
| 668 | + } |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | if ($aircraft_manufacturer != "") |
| 672 | 672 | { |
| 673 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 674 | - if (!is_string($aircraft_manufacturer)) |
|
| 675 | - { |
|
| 673 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 674 | + if (!is_string($aircraft_manufacturer)) |
|
| 675 | + { |
|
| 676 | 676 | return false; |
| 677 | - } else { |
|
| 677 | + } else { |
|
| 678 | 678 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 679 | - } |
|
| 679 | + } |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | if ($highlights == "true") |
| 683 | 683 | { |
| 684 | - if (!is_string($highlights)) |
|
| 685 | - { |
|
| 684 | + if (!is_string($highlights)) |
|
| 685 | + { |
|
| 686 | 686 | return false; |
| 687 | - } else { |
|
| 687 | + } else { |
|
| 688 | 688 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
| 689 | - } |
|
| 689 | + } |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | if ($airline_icao != "") |
| 693 | 693 | { |
| 694 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 695 | - if (!is_string($airline_icao)) |
|
| 696 | - { |
|
| 694 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 695 | + if (!is_string($airline_icao)) |
|
| 696 | + { |
|
| 697 | 697 | return false; |
| 698 | - } else { |
|
| 698 | + } else { |
|
| 699 | 699 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
| 700 | - } |
|
| 700 | + } |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | if ($airline_country != "") |
| 704 | 704 | { |
| 705 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 706 | - if (!is_string($airline_country)) |
|
| 707 | - { |
|
| 705 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 706 | + if (!is_string($airline_country)) |
|
| 707 | + { |
|
| 708 | 708 | return false; |
| 709 | - } else { |
|
| 709 | + } else { |
|
| 710 | 710 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
| 711 | - } |
|
| 711 | + } |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | if ($airline_type != "") |
| 715 | 715 | { |
| 716 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 717 | - if (!is_string($airline_type)) |
|
| 718 | - { |
|
| 716 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 717 | + if (!is_string($airline_type)) |
|
| 718 | + { |
|
| 719 | 719 | return false; |
| 720 | - } else { |
|
| 720 | + } else { |
|
| 721 | 721 | if ($airline_type == "passenger") |
| 722 | 722 | { |
| 723 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 723 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 724 | 724 | } |
| 725 | 725 | if ($airline_type == "cargo") |
| 726 | 726 | { |
| 727 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 727 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 728 | 728 | } |
| 729 | 729 | if ($airline_type == "military") |
| 730 | 730 | { |
| 731 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 731 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 732 | + } |
|
| 732 | 733 | } |
| 733 | - } |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | if ($airport != "") |
| 737 | 737 | { |
| 738 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 739 | - if (!is_string($airport)) |
|
| 740 | - { |
|
| 738 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 739 | + if (!is_string($airport)) |
|
| 740 | + { |
|
| 741 | 741 | return false; |
| 742 | - } else { |
|
| 742 | + } else { |
|
| 743 | 743 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 744 | - } |
|
| 744 | + } |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | if ($airport_country != "") |
| 748 | 748 | { |
| 749 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 750 | - if (!is_string($airport_country)) |
|
| 751 | - { |
|
| 749 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 750 | + if (!is_string($airport_country)) |
|
| 751 | + { |
|
| 752 | 752 | return false; |
| 753 | - } else { |
|
| 753 | + } else { |
|
| 754 | 754 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 755 | - } |
|
| 755 | + } |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | if ($callsign != "") |
| 759 | 759 | { |
| 760 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 761 | - if (!is_string($callsign)) |
|
| 762 | - { |
|
| 760 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 761 | + if (!is_string($callsign)) |
|
| 762 | + { |
|
| 763 | 763 | return false; |
| 764 | - } else { |
|
| 764 | + } else { |
|
| 765 | 765 | $translate = $Translation->ident2icao($callsign); |
| 766 | 766 | if ($translate != $callsign) { |
| 767 | 767 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -769,99 +769,99 @@ discard block |
||
| 769 | 769 | } else { |
| 770 | 770 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 771 | 771 | } |
| 772 | - } |
|
| 772 | + } |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | if ($owner != "") |
| 776 | 776 | { |
| 777 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 778 | - if (!is_string($owner)) |
|
| 779 | - { |
|
| 777 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 778 | + if (!is_string($owner)) |
|
| 779 | + { |
|
| 780 | 780 | return false; |
| 781 | - } else { |
|
| 781 | + } else { |
|
| 782 | 782 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
| 783 | - } |
|
| 783 | + } |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | if ($pilot_name != "") |
| 787 | 787 | { |
| 788 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 789 | - if (!is_string($pilot_name)) |
|
| 790 | - { |
|
| 788 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 789 | + if (!is_string($pilot_name)) |
|
| 790 | + { |
|
| 791 | 791 | return false; |
| 792 | - } else { |
|
| 792 | + } else { |
|
| 793 | 793 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
| 794 | - } |
|
| 794 | + } |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | if ($pilot_id != "") |
| 798 | 798 | { |
| 799 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 800 | - if (!is_string($pilot_id)) |
|
| 801 | - { |
|
| 799 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 800 | + if (!is_string($pilot_id)) |
|
| 801 | + { |
|
| 802 | 802 | return false; |
| 803 | - } else { |
|
| 803 | + } else { |
|
| 804 | 804 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
| 805 | - } |
|
| 805 | + } |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | if ($departure_airport_route != "") |
| 809 | 809 | { |
| 810 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 811 | - if (!is_string($departure_airport_route)) |
|
| 812 | - { |
|
| 810 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 811 | + if (!is_string($departure_airport_route)) |
|
| 812 | + { |
|
| 813 | 813 | return false; |
| 814 | - } else { |
|
| 814 | + } else { |
|
| 815 | 815 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 816 | - } |
|
| 816 | + } |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | if ($arrival_airport_route != "") |
| 820 | 820 | { |
| 821 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 822 | - if (!is_string($arrival_airport_route)) |
|
| 823 | - { |
|
| 821 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 822 | + if (!is_string($arrival_airport_route)) |
|
| 823 | + { |
|
| 824 | 824 | return false; |
| 825 | - } else { |
|
| 825 | + } else { |
|
| 826 | 826 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 827 | - } |
|
| 827 | + } |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | if ($altitude != "") |
| 831 | 831 | { |
| 832 | - $altitude_array = explode(",", $altitude); |
|
| 832 | + $altitude_array = explode(",", $altitude); |
|
| 833 | 833 | |
| 834 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 835 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 834 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 835 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 836 | 836 | |
| 837 | 837 | |
| 838 | - if ($altitude_array[1] != "") |
|
| 839 | - { |
|
| 838 | + if ($altitude_array[1] != "") |
|
| 839 | + { |
|
| 840 | 840 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 841 | 841 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 842 | 842 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 843 | - } else { |
|
| 843 | + } else { |
|
| 844 | 844 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 845 | 845 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 846 | - } |
|
| 846 | + } |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | if ($date_posted != "") |
| 850 | 850 | { |
| 851 | - $date_array = explode(",", $date_posted); |
|
| 851 | + $date_array = explode(",", $date_posted); |
|
| 852 | 852 | |
| 853 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 854 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 853 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 854 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 855 | 855 | |
| 856 | - if ($globalTimezone != '') { |
|
| 856 | + if ($globalTimezone != '') { |
|
| 857 | 857 | date_default_timezone_set($globalTimezone); |
| 858 | 858 | $datetime = new DateTime(); |
| 859 | 859 | $offset = $datetime->format('P'); |
| 860 | - } else $offset = '+00:00'; |
|
| 860 | + } else $offset = '+00:00'; |
|
| 861 | 861 | |
| 862 | 862 | |
| 863 | - if ($date_array[1] != "") |
|
| 864 | - { |
|
| 863 | + if ($date_array[1] != "") |
|
| 864 | + { |
|
| 865 | 865 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 866 | 866 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 867 | 867 | if ($globalDBdriver == 'mysql') { |
@@ -869,28 +869,28 @@ discard block |
||
| 869 | 869 | } else { |
| 870 | 870 | $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) "; |
| 871 | 871 | } |
| 872 | - } else { |
|
| 872 | + } else { |
|
| 873 | 873 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 874 | - if ($globalDBdriver == 'mysql') { |
|
| 874 | + if ($globalDBdriver == 'mysql') { |
|
| 875 | 875 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 876 | 876 | } else { |
| 877 | 877 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 878 | 878 | } |
| 879 | - } |
|
| 879 | + } |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | if ($limit != "") |
| 883 | 883 | { |
| 884 | - $limit_array = explode(",", $limit); |
|
| 884 | + $limit_array = explode(",", $limit); |
|
| 885 | 885 | |
| 886 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 887 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 886 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 887 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 888 | 888 | |
| 889 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 890 | - { |
|
| 889 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 890 | + { |
|
| 891 | 891 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 892 | 892 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 893 | - } |
|
| 893 | + } |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | |
@@ -921,33 +921,33 @@ discard block |
||
| 921 | 921 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
| 922 | 922 | |
| 923 | 923 | return $spotter_array; |
| 924 | - } |
|
| 924 | + } |
|
| 925 | 925 | |
| 926 | - public function deleteSpotterArchiveData() |
|
| 927 | - { |
|
| 926 | + public function deleteSpotterArchiveData() |
|
| 927 | + { |
|
| 928 | 928 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 929 | - date_default_timezone_set('UTC'); |
|
| 930 | - if ($globalDBdriver == 'mysql') { |
|
| 929 | + date_default_timezone_set('UTC'); |
|
| 930 | + if ($globalDBdriver == 'mysql') { |
|
| 931 | 931 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 932 | 932 | } else { |
| 933 | 933 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 934 | 934 | } |
| 935 | - try { |
|
| 936 | - $sth = $this->db->prepare($query); |
|
| 937 | - $sth->execute(); |
|
| 938 | - } catch(PDOException $e) { |
|
| 939 | - return "error"; |
|
| 940 | - } |
|
| 935 | + try { |
|
| 936 | + $sth = $this->db->prepare($query); |
|
| 937 | + $sth->execute(); |
|
| 938 | + } catch(PDOException $e) { |
|
| 939 | + return "error"; |
|
| 940 | + } |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - /** |
|
| 944 | - * Gets all the spotter information based on the callsign |
|
| 945 | - * |
|
| 946 | - * @return Array the spotter information |
|
| 947 | - * |
|
| 948 | - */ |
|
| 949 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 950 | - { |
|
| 943 | + /** |
|
| 944 | + * Gets all the spotter information based on the callsign |
|
| 945 | + * |
|
| 946 | + * @return Array the spotter information |
|
| 947 | + * |
|
| 948 | + */ |
|
| 949 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 950 | + { |
|
| 951 | 951 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 952 | 952 | |
| 953 | 953 | date_default_timezone_set('UTC'); |
@@ -959,35 +959,35 @@ discard block |
||
| 959 | 959 | |
| 960 | 960 | if ($ident != "") |
| 961 | 961 | { |
| 962 | - if (!is_string($ident)) |
|
| 963 | - { |
|
| 962 | + if (!is_string($ident)) |
|
| 963 | + { |
|
| 964 | 964 | return false; |
| 965 | - } else { |
|
| 965 | + } else { |
|
| 966 | 966 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
| 967 | 967 | $query_values = array(':ident' => $ident); |
| 968 | - } |
|
| 968 | + } |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | if ($limit != "") |
| 972 | 972 | { |
| 973 | - $limit_array = explode(",", $limit); |
|
| 973 | + $limit_array = explode(",", $limit); |
|
| 974 | 974 | |
| 975 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 976 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 975 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 976 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 977 | 977 | |
| 978 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 979 | - { |
|
| 978 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 979 | + { |
|
| 980 | 980 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 981 | 981 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 982 | - } |
|
| 982 | + } |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | if ($sort != "") |
| 986 | 986 | { |
| 987 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 988 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 987 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 988 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 989 | 989 | } else { |
| 990 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 990 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -995,17 +995,17 @@ discard block |
||
| 995 | 995 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 996 | 996 | |
| 997 | 997 | return $spotter_array; |
| 998 | - } |
|
| 998 | + } |
|
| 999 | 999 | |
| 1000 | 1000 | |
| 1001 | - /** |
|
| 1002 | - * Gets all the spotter information based on the owner |
|
| 1003 | - * |
|
| 1004 | - * @return Array the spotter information |
|
| 1005 | - * |
|
| 1006 | - */ |
|
| 1007 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1008 | - { |
|
| 1001 | + /** |
|
| 1002 | + * Gets all the spotter information based on the owner |
|
| 1003 | + * |
|
| 1004 | + * @return Array the spotter information |
|
| 1005 | + * |
|
| 1006 | + */ |
|
| 1007 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1008 | + { |
|
| 1009 | 1009 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1010 | 1010 | |
| 1011 | 1011 | date_default_timezone_set('UTC'); |
@@ -1018,35 +1018,35 @@ discard block |
||
| 1018 | 1018 | |
| 1019 | 1019 | if ($owner != "") |
| 1020 | 1020 | { |
| 1021 | - if (!is_string($owner)) |
|
| 1022 | - { |
|
| 1021 | + if (!is_string($owner)) |
|
| 1022 | + { |
|
| 1023 | 1023 | return false; |
| 1024 | - } else { |
|
| 1024 | + } else { |
|
| 1025 | 1025 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
| 1026 | 1026 | $query_values = array(':owner' => $owner); |
| 1027 | - } |
|
| 1027 | + } |
|
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | if ($limit != "") |
| 1031 | 1031 | { |
| 1032 | - $limit_array = explode(",", $limit); |
|
| 1032 | + $limit_array = explode(",", $limit); |
|
| 1033 | 1033 | |
| 1034 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1034 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1036 | 1036 | |
| 1037 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1038 | - { |
|
| 1037 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1038 | + { |
|
| 1039 | 1039 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1040 | 1040 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1041 | - } |
|
| 1041 | + } |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | if ($sort != "") |
| 1045 | 1045 | { |
| 1046 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1047 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1046 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1047 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1048 | 1048 | } else { |
| 1049 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1049 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1054,16 +1054,16 @@ discard block |
||
| 1054 | 1054 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1055 | 1055 | |
| 1056 | 1056 | return $spotter_array; |
| 1057 | - } |
|
| 1058 | - |
|
| 1059 | - /** |
|
| 1060 | - * Gets all the spotter information based on the pilot |
|
| 1061 | - * |
|
| 1062 | - * @return Array the spotter information |
|
| 1063 | - * |
|
| 1064 | - */ |
|
| 1065 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1066 | - { |
|
| 1057 | + } |
|
| 1058 | + |
|
| 1059 | + /** |
|
| 1060 | + * Gets all the spotter information based on the pilot |
|
| 1061 | + * |
|
| 1062 | + * @return Array the spotter information |
|
| 1063 | + * |
|
| 1064 | + */ |
|
| 1065 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1066 | + { |
|
| 1067 | 1067 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1068 | 1068 | |
| 1069 | 1069 | date_default_timezone_set('UTC'); |
@@ -1082,24 +1082,24 @@ discard block |
||
| 1082 | 1082 | |
| 1083 | 1083 | if ($limit != "") |
| 1084 | 1084 | { |
| 1085 | - $limit_array = explode(",", $limit); |
|
| 1085 | + $limit_array = explode(",", $limit); |
|
| 1086 | 1086 | |
| 1087 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1088 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1087 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1088 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1089 | 1089 | |
| 1090 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1091 | - { |
|
| 1090 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1091 | + { |
|
| 1092 | 1092 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1093 | 1093 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1094 | - } |
|
| 1094 | + } |
|
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | 1097 | if ($sort != "") |
| 1098 | 1098 | { |
| 1099 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1100 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1099 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1100 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1101 | 1101 | } else { |
| 1102 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1102 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | 1105 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1107,16 +1107,16 @@ discard block |
||
| 1107 | 1107 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1108 | 1108 | |
| 1109 | 1109 | return $spotter_array; |
| 1110 | - } |
|
| 1111 | - |
|
| 1112 | - /** |
|
| 1113 | - * Gets all number of flight over countries |
|
| 1114 | - * |
|
| 1115 | - * @return Array the airline country list |
|
| 1116 | - * |
|
| 1117 | - */ |
|
| 1118 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1119 | - { |
|
| 1110 | + } |
|
| 1111 | + |
|
| 1112 | + /** |
|
| 1113 | + * Gets all number of flight over countries |
|
| 1114 | + * |
|
| 1115 | + * @return Array the airline country list |
|
| 1116 | + * |
|
| 1117 | + */ |
|
| 1118 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1119 | + { |
|
| 1120 | 1120 | global $globalDBdriver; |
| 1121 | 1121 | /* |
| 1122 | 1122 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1126,14 +1126,14 @@ discard block |
||
| 1126 | 1126 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1127 | 1127 | FROM countries c, spotter_archive s |
| 1128 | 1128 | WHERE c.iso2 = s.over_country "; |
| 1129 | - if ($olderthanmonths > 0) { |
|
| 1130 | - if ($globalDBdriver == 'mysql') { |
|
| 1129 | + if ($olderthanmonths > 0) { |
|
| 1130 | + if ($globalDBdriver == 'mysql') { |
|
| 1131 | 1131 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1132 | 1132 | } else { |
| 1133 | 1133 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1134 | 1134 | } |
| 1135 | 1135 | } |
| 1136 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1136 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1137 | 1137 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1138 | 1138 | if ($limit) $query .= " LIMIT 0,10"; |
| 1139 | 1139 | |
@@ -1146,23 +1146,23 @@ discard block |
||
| 1146 | 1146 | |
| 1147 | 1147 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1148 | 1148 | { |
| 1149 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1150 | - $temp_array['flight_country'] = $row['name']; |
|
| 1151 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1152 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1153 | - $flight_array[] = $temp_array; |
|
| 1149 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1150 | + $temp_array['flight_country'] = $row['name']; |
|
| 1151 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1152 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1153 | + $flight_array[] = $temp_array; |
|
| 1154 | 1154 | } |
| 1155 | 1155 | return $flight_array; |
| 1156 | - } |
|
| 1157 | - |
|
| 1158 | - /** |
|
| 1159 | - * Gets all number of flight over countries |
|
| 1160 | - * |
|
| 1161 | - * @return Array the airline country list |
|
| 1162 | - * |
|
| 1163 | - */ |
|
| 1164 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1165 | - { |
|
| 1156 | + } |
|
| 1157 | + |
|
| 1158 | + /** |
|
| 1159 | + * Gets all number of flight over countries |
|
| 1160 | + * |
|
| 1161 | + * @return Array the airline country list |
|
| 1162 | + * |
|
| 1163 | + */ |
|
| 1164 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1165 | + { |
|
| 1166 | 1166 | global $globalDBdriver; |
| 1167 | 1167 | /* |
| 1168 | 1168 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1172,14 +1172,14 @@ discard block |
||
| 1172 | 1172 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1173 | 1173 | FROM countries c, spotter_archive s, spotter_output o |
| 1174 | 1174 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
| 1175 | - if ($olderthanmonths > 0) { |
|
| 1176 | - if ($globalDBdriver == 'mysql') { |
|
| 1175 | + if ($olderthanmonths > 0) { |
|
| 1176 | + if ($globalDBdriver == 'mysql') { |
|
| 1177 | 1177 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1178 | 1178 | } else { |
| 1179 | 1179 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1180 | 1180 | } |
| 1181 | 1181 | } |
| 1182 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1182 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1183 | 1183 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1184 | 1184 | if ($limit) $query .= " LIMIT 0,10"; |
| 1185 | 1185 | |
@@ -1192,24 +1192,24 @@ discard block |
||
| 1192 | 1192 | |
| 1193 | 1193 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1194 | 1194 | { |
| 1195 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1196 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1197 | - $temp_array['flight_country'] = $row['name']; |
|
| 1198 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1199 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1200 | - $flight_array[] = $temp_array; |
|
| 1195 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1196 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1197 | + $temp_array['flight_country'] = $row['name']; |
|
| 1198 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1199 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1200 | + $flight_array[] = $temp_array; |
|
| 1201 | 1201 | } |
| 1202 | 1202 | return $flight_array; |
| 1203 | - } |
|
| 1204 | - |
|
| 1205 | - /** |
|
| 1206 | - * Gets last spotter information based on a particular callsign |
|
| 1207 | - * |
|
| 1208 | - * @return Array the spotter information |
|
| 1209 | - * |
|
| 1210 | - */ |
|
| 1211 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1212 | - { |
|
| 1203 | + } |
|
| 1204 | + |
|
| 1205 | + /** |
|
| 1206 | + * Gets last spotter information based on a particular callsign |
|
| 1207 | + * |
|
| 1208 | + * @return Array the spotter information |
|
| 1209 | + * |
|
| 1210 | + */ |
|
| 1211 | + public function getDateArchiveSpotterDataById($id,$date) |
|
| 1212 | + { |
|
| 1213 | 1213 | $Spotter = new Spotter($this->db); |
| 1214 | 1214 | date_default_timezone_set('UTC'); |
| 1215 | 1215 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1217,16 +1217,16 @@ discard block |
||
| 1217 | 1217 | $date = date('c',$date); |
| 1218 | 1218 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1219 | 1219 | return $spotter_array; |
| 1220 | - } |
|
| 1221 | - |
|
| 1222 | - /** |
|
| 1223 | - * Gets all the spotter information based on a particular callsign |
|
| 1224 | - * |
|
| 1225 | - * @return Array the spotter information |
|
| 1226 | - * |
|
| 1227 | - */ |
|
| 1228 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1229 | - { |
|
| 1220 | + } |
|
| 1221 | + |
|
| 1222 | + /** |
|
| 1223 | + * Gets all the spotter information based on a particular callsign |
|
| 1224 | + * |
|
| 1225 | + * @return Array the spotter information |
|
| 1226 | + * |
|
| 1227 | + */ |
|
| 1228 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1229 | + { |
|
| 1230 | 1230 | $Spotter = new Spotter($this->db); |
| 1231 | 1231 | date_default_timezone_set('UTC'); |
| 1232 | 1232 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1234,16 +1234,16 @@ discard block |
||
| 1234 | 1234 | $date = date('c',$date); |
| 1235 | 1235 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1236 | 1236 | return $spotter_array; |
| 1237 | - } |
|
| 1238 | - |
|
| 1239 | - /** |
|
| 1240 | - * Gets all the spotter information based on the airport |
|
| 1241 | - * |
|
| 1242 | - * @return Array the spotter information |
|
| 1243 | - * |
|
| 1244 | - */ |
|
| 1245 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1246 | - { |
|
| 1237 | + } |
|
| 1238 | + |
|
| 1239 | + /** |
|
| 1240 | + * Gets all the spotter information based on the airport |
|
| 1241 | + * |
|
| 1242 | + * @return Array the spotter information |
|
| 1243 | + * |
|
| 1244 | + */ |
|
| 1245 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1246 | + { |
|
| 1247 | 1247 | global $global_query; |
| 1248 | 1248 | $Spotter = new Spotter(); |
| 1249 | 1249 | date_default_timezone_set('UTC'); |
@@ -1254,35 +1254,35 @@ discard block |
||
| 1254 | 1254 | |
| 1255 | 1255 | if ($airport != "") |
| 1256 | 1256 | { |
| 1257 | - if (!is_string($airport)) |
|
| 1258 | - { |
|
| 1257 | + if (!is_string($airport)) |
|
| 1258 | + { |
|
| 1259 | 1259 | return false; |
| 1260 | - } else { |
|
| 1260 | + } else { |
|
| 1261 | 1261 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
| 1262 | 1262 | $query_values = array(':airport' => $airport); |
| 1263 | - } |
|
| 1263 | + } |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | if ($limit != "") |
| 1267 | 1267 | { |
| 1268 | - $limit_array = explode(",", $limit); |
|
| 1268 | + $limit_array = explode(",", $limit); |
|
| 1269 | 1269 | |
| 1270 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1271 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1270 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1271 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1272 | 1272 | |
| 1273 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1274 | - { |
|
| 1273 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1274 | + { |
|
| 1275 | 1275 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1276 | 1276 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1277 | - } |
|
| 1277 | + } |
|
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | if ($sort != "") |
| 1281 | 1281 | { |
| 1282 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1283 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1282 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1283 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1284 | 1284 | } else { |
| 1285 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1285 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1290,6 +1290,6 @@ discard block |
||
| 1290 | 1290 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1291 | 1291 | |
| 1292 | 1292 | return $spotter_array; |
| 1293 | - } |
|
| 1293 | + } |
|
| 1294 | 1294 | } |
| 1295 | 1295 | ?> |
| 1296 | 1296 | \ No newline at end of file |
@@ -8,7 +8,7 @@ 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(); |
@@ -16,22 +16,22 @@ discard block |
||
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * Add schedule data to database |
|
| 20 | - * @param String $ident aircraft ident |
|
| 21 | - * @param String $departure_airport_icao departure airport icao |
|
| 22 | - * @param String $departure_airport_time departure airport time |
|
| 23 | - * @param String $arrival_airport_icao arrival airport icao |
|
| 24 | - * @param String $arrival_airport_time arrival airport time |
|
| 19 | + * Add schedule data to database |
|
| 20 | + * @param String $ident aircraft ident |
|
| 21 | + * @param String $departure_airport_icao departure airport icao |
|
| 22 | + * @param String $departure_airport_time departure airport time |
|
| 23 | + * @param String $arrival_airport_icao arrival airport icao |
|
| 24 | + * @param String $arrival_airport_time arrival airport time |
|
| 25 | 25 | / @param String $source source of data |
| 26 | - */ |
|
| 26 | + */ |
|
| 27 | 27 | |
| 28 | 28 | public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
| 29 | 29 | date_default_timezone_set('UTC'); |
| 30 | 30 | $date = date("Y-m-d H:i:s",time()); |
| 31 | - //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
|
| 32 | - //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
|
| 33 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
|
| 34 | - $query_values = array(':ident' => $ident); |
|
| 31 | + //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
|
| 32 | + //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
|
| 33 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
|
| 34 | + $query_values = array(':ident' => $ident); |
|
| 35 | 35 | try { |
| 36 | 36 | $sth = $this->db->prepare($query); |
| 37 | 37 | $sth->execute($query_values); |
@@ -40,18 +40,18 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | if ($sth->fetchColumn() > 0) { |
| 42 | 42 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 43 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 44 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 43 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 44 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 45 | 45 | } elseif ($arrival_airport_time == '') { |
| 46 | - $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"; |
|
| 47 | - $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 = "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"; |
|
| 47 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 48 | 48 | } elseif ($departure_airport_time == '') { |
| 49 | - $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"; |
|
| 50 | - $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 = "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"; |
|
| 50 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 51 | 51 | } else { |
| 52 | - //$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"; |
|
| 53 | - $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"; |
|
| 54 | - $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); |
|
| 52 | + //$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"; |
|
| 53 | + $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"; |
|
| 54 | + $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); |
|
| 55 | 55 | } |
| 56 | 56 | try { |
| 57 | 57 | $sth = $this->db->prepare($query); |
@@ -62,17 +62,17 @@ discard block |
||
| 62 | 62 | if ($sth->fetchColumn() == 0) { |
| 63 | 63 | //$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'; |
| 64 | 64 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 65 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 66 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 65 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 66 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 67 | 67 | } elseif ($arrival_airport_time == '') { |
| 68 | - $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'; |
|
| 69 | - $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 = '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'; |
|
| 69 | + $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); |
|
| 70 | 70 | } elseif ($departure_airport_time == '') { |
| 71 | - $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'; |
|
| 72 | - $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 = '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'; |
|
| 72 | + $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); |
|
| 73 | 73 | } else { |
| 74 | - $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'; |
|
| 75 | - $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 = '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'; |
|
| 75 | + $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); |
|
| 76 | 76 | } |
| 77 | 77 | try { |
| 78 | 78 | $sth = $this->db->prepare($query); |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function getSchedule($ident) { |
| 108 | - $Translation = new Translation($this->db); |
|
| 109 | - $operator = $Translation->checkTranslation($ident,false); |
|
| 110 | - if ($ident != $operator) { |
|
| 111 | - $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 FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
|
| 112 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
| 113 | - } else { |
|
| 114 | - $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 FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
|
| 115 | - $query_values = array(':ident' => $ident); |
|
| 116 | - } |
|
| 108 | + $Translation = new Translation($this->db); |
|
| 109 | + $operator = $Translation->checkTranslation($ident,false); |
|
| 110 | + if ($ident != $operator) { |
|
| 111 | + $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 FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
|
| 112 | + $query_values = array(':ident' => $ident,'operator' => $operator); |
|
| 113 | + } else { |
|
| 114 | + $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 FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
|
| 115 | + $query_values = array(':ident' => $ident); |
|
| 116 | + } |
|
| 117 | 117 | try { |
| 118 | 118 | $sth = $this->db->prepare($query); |
| 119 | 119 | $sth->execute($query_values); |
@@ -129,15 +129,15 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | public function checkSchedule($ident) { |
| 131 | 131 | global $globalDBdriver; |
| 132 | - //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
| 133 | - if ($globalDBdriver == 'mysql') { |
|
| 132 | + //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
| 133 | + if ($globalDBdriver == 'mysql') { |
|
| 134 | 134 | $query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND 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"; |
| 135 | 135 | } else { |
| 136 | 136 | $query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident |
| 137 | 137 | AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL) |
| 138 | 138 | OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1"; |
| 139 | 139 | } |
| 140 | - $query_values = array(':ident' => $ident); |
|
| 140 | + $query_values = array(':ident' => $ident); |
|
| 141 | 141 | try { |
| 142 | 142 | $sth = $this->db->prepare($query); |
| 143 | 143 | $sth->execute($query_values); |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | - * Get flight info from Air France |
|
| 154 | - * @param String $callsign The callsign |
|
| 155 | - * @param String $date date we want flight number info |
|
| 156 | - * @param String $carrier IATA code |
|
| 157 | - * @return Flight departure and arrival airports and time |
|
| 158 | - */ |
|
| 153 | + * Get flight info from Air France |
|
| 154 | + * @param String $callsign The callsign |
|
| 155 | + * @param String $date date we want flight number info |
|
| 156 | + * @param String $carrier IATA code |
|
| 157 | + * @return Flight departure and arrival airports and time |
|
| 158 | + */ |
|
| 159 | 159 | private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
| 160 | 160 | $Common = new Common(); |
| 161 | 161 | $check_date = new Datetime($date); |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | - * Get flight info from EasyJet |
|
| 195 | - * @param String $callsign The callsign |
|
| 196 | - * @param String $date date we want flight number info |
|
| 197 | - * @return Flight departure and arrival airports and time |
|
| 198 | - */ |
|
| 194 | + * Get flight info from EasyJet |
|
| 195 | + * @param String $callsign The callsign |
|
| 196 | + * @param String $date date we want flight number info |
|
| 197 | + * @return Flight departure and arrival airports and time |
|
| 198 | + */ |
|
| 199 | 199 | private function getEasyJet($callsign, $date = 'NOW') { |
| 200 | 200 | global $globalTimezone; |
| 201 | 201 | $Common = new Common(); |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | - * Get flight info from Ryanair |
|
| 223 | - * @param String $callsign The callsign |
|
| 224 | - * @return Flight departure and arrival airports and time |
|
| 225 | - */ |
|
| 222 | + * Get flight info from Ryanair |
|
| 223 | + * @param String $callsign The callsign |
|
| 224 | + * @return Flight departure and arrival airports and time |
|
| 225 | + */ |
|
| 226 | 226 | private function getRyanair($callsign) { |
| 227 | 227 | $Common = new Common(); |
| 228 | 228 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -245,10 +245,10 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | - * Get flight info from Swiss |
|
| 249 | - * @param String $callsign The callsign |
|
| 250 | - * @return Flight departure and arrival airports and time |
|
| 251 | - */ |
|
| 248 | + * Get flight info from Swiss |
|
| 249 | + * @param String $callsign The callsign |
|
| 250 | + * @return Flight departure and arrival airports and time |
|
| 251 | + */ |
|
| 252 | 252 | private function getSwiss($callsign) { |
| 253 | 253 | $Common = new Common(); |
| 254 | 254 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | - * Get flight info from British Airways API |
|
| 281 | - * @param String $callsign The callsign |
|
| 282 | - * @param String $date date we want flight number info |
|
| 283 | - * @return Flight departure and arrival airports and time |
|
| 284 | - */ |
|
| 280 | + * Get flight info from British Airways API |
|
| 281 | + * @param String $callsign The callsign |
|
| 282 | + * @param String $date date we want flight number info |
|
| 283 | + * @return Flight departure and arrival airports and time |
|
| 284 | + */ |
|
| 285 | 285 | public function getBritishAirways($callsign, $date = 'NOW') { |
| 286 | 286 | global $globalBritishAirwaysKey; |
| 287 | 287 | $Common = new Common(); |
@@ -305,11 +305,11 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
| 308 | - * Get flight info from Lutfhansa API |
|
| 309 | - * @param String $callsign The callsign |
|
| 310 | - * @param String $date date we want flight number info |
|
| 311 | - * @return Flight departure and arrival airports and time |
|
| 312 | - */ |
|
| 308 | + * Get flight info from Lutfhansa API |
|
| 309 | + * @param String $callsign The callsign |
|
| 310 | + * @param String $date date we want flight number info |
|
| 311 | + * @return Flight departure and arrival airports and time |
|
| 312 | + */ |
|
| 313 | 313 | public function getLufthansa($callsign, $date = 'NOW') { |
| 314 | 314 | global $globalLufthansaKey; |
| 315 | 315 | $Common = new Common(); |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
| 342 | - * Get flight info from Transavia API |
|
| 343 | - * @param String $callsign The callsign |
|
| 344 | - * @param String $date date we want flight number info |
|
| 345 | - * @return Flight departure and arrival airports and time |
|
| 346 | - */ |
|
| 342 | + * Get flight info from Transavia API |
|
| 343 | + * @param String $callsign The callsign |
|
| 344 | + * @param String $date date we want flight number info |
|
| 345 | + * @return Flight departure and arrival airports and time |
|
| 346 | + */ |
|
| 347 | 347 | public function getTransavia($callsign, $date = 'NOW') { |
| 348 | 348 | global $globalTransaviaKey; |
| 349 | 349 | $Common = new Common(); |
@@ -369,10 +369,10 @@ discard block |
||
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
| 372 | - * Get flight info from Tunisair |
|
| 373 | - * @param String $callsign The callsign |
|
| 374 | - * @return Flight departure and arrival airports and time |
|
| 375 | - */ |
|
| 372 | + * Get flight info from Tunisair |
|
| 373 | + * @param String $callsign The callsign |
|
| 374 | + * @return Flight departure and arrival airports and time |
|
| 375 | + */ |
|
| 376 | 376 | public function getTunisair($callsign) { |
| 377 | 377 | $Common = new Common(); |
| 378 | 378 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -389,10 +389,10 @@ discard block |
||
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | - * Get flight info from Vueling |
|
| 393 | - * @param String $callsign The callsign |
|
| 394 | - * @return Flight departure and arrival airports and time |
|
| 395 | - */ |
|
| 392 | + * Get flight info from Vueling |
|
| 393 | + * @param String $callsign The callsign |
|
| 394 | + * @return Flight departure and arrival airports and time |
|
| 395 | + */ |
|
| 396 | 396 | public function getVueling($callsign,$date = 'NOW') { |
| 397 | 397 | $Common = new Common(); |
| 398 | 398 | $check_date = new Datetime($date); |
@@ -414,11 +414,11 @@ discard block |
||
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
| 417 | - * Get flight info from Iberia |
|
| 418 | - * @param String $callsign The callsign |
|
| 419 | - * @param String $date date we want flight number info |
|
| 420 | - * @return Flight departure and arrival airports and time |
|
| 421 | - */ |
|
| 417 | + * Get flight info from Iberia |
|
| 418 | + * @param String $callsign The callsign |
|
| 419 | + * @param String $date date we want flight number info |
|
| 420 | + * @return Flight departure and arrival airports and time |
|
| 421 | + */ |
|
| 422 | 422 | public function getIberia($callsign, $date = 'NOW') { |
| 423 | 423 | $Common = new Common(); |
| 424 | 424 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -448,11 +448,11 @@ discard block |
||
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | /** |
| 451 | - * Get flight info from Star Alliance |
|
| 452 | - * @param String $callsign The callsign |
|
| 453 | - * @param String $date date we want flight number info |
|
| 454 | - * @return Flight departure and arrival airports and time |
|
| 455 | - */ |
|
| 451 | + * Get flight info from Star Alliance |
|
| 452 | + * @param String $callsign The callsign |
|
| 453 | + * @param String $date date we want flight number info |
|
| 454 | + * @return Flight departure and arrival airports and time |
|
| 455 | + */ |
|
| 456 | 456 | |
| 457 | 457 | private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
| 458 | 458 | $Common = new Common(); |
@@ -484,11 +484,11 @@ discard block |
||
| 484 | 484 | |
| 485 | 485 | |
| 486 | 486 | /** |
| 487 | - * Get flight info from Alitalia |
|
| 488 | - * @param String $callsign The callsign |
|
| 489 | - * @param String $date date we want flight number info |
|
| 490 | - * @return Flight departure and arrival airports and time |
|
| 491 | - */ |
|
| 487 | + * Get flight info from Alitalia |
|
| 488 | + * @param String $callsign The callsign |
|
| 489 | + * @param String $date date we want flight number info |
|
| 490 | + * @return Flight departure and arrival airports and time |
|
| 491 | + */ |
|
| 492 | 492 | private function getAlitalia($callsign, $date = 'NOW') { |
| 493 | 493 | $Common = new Common(); |
| 494 | 494 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -507,11 +507,11 @@ discard block |
||
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /** |
| 510 | - * Get flight info from Brussels airlines |
|
| 511 | - * @param String $callsign The callsign |
|
| 512 | - * @param String $date date we want flight number info |
|
| 513 | - * @return Flight departure and arrival airports and time |
|
| 514 | - */ |
|
| 510 | + * Get flight info from Brussels airlines |
|
| 511 | + * @param String $callsign The callsign |
|
| 512 | + * @param String $date date we want flight number info |
|
| 513 | + * @return Flight departure and arrival airports and time |
|
| 514 | + */ |
|
| 515 | 515 | private function getBrussels($callsign, $date = 'NOW') { |
| 516 | 516 | $Common = new Common(); |
| 517 | 517 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -521,24 +521,24 @@ discard block |
||
| 521 | 521 | if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
| 522 | 522 | $data = $Common->getData($url); |
| 523 | 523 | if ($data != '') { |
| 524 | - //echo $data; |
|
| 525 | - $parsed_json = json_decode($data,true); |
|
| 526 | - if (isset($parsed_json[0]['FromAirportCode'])) { |
|
| 524 | + //echo $data; |
|
| 525 | + $parsed_json = json_decode($data,true); |
|
| 526 | + if (isset($parsed_json[0]['FromAirportCode'])) { |
|
| 527 | 527 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
| 528 | 528 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
| 529 | 529 | $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
| 530 | 530 | $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
| 531 | 531 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
| 532 | - } |
|
| 532 | + } |
|
| 533 | 533 | } |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | /** |
| 537 | - * Get flight info from FlightRadar24 |
|
| 538 | - * @param String $callsign The callsign |
|
| 539 | - * @param String $date date we want flight number info |
|
| 540 | - * @return Flight departure and arrival airports and time |
|
| 541 | - */ |
|
| 537 | + * Get flight info from FlightRadar24 |
|
| 538 | + * @param String $callsign The callsign |
|
| 539 | + * @param String $date date we want flight number info |
|
| 540 | + * @return Flight departure and arrival airports and time |
|
| 541 | + */ |
|
| 542 | 542 | /* |
| 543 | 543 | public function getFlightRadar24($callsign, $date = 'NOW') { |
| 544 | 544 | $Common = new Common(); |
@@ -567,11 +567,11 @@ discard block |
||
| 567 | 567 | } |
| 568 | 568 | */ |
| 569 | 569 | /** |
| 570 | - * Get flight info from Lufthansa |
|
| 571 | - * @param String $callsign The callsign |
|
| 572 | - * @param String $date date we want flight number info |
|
| 573 | - * @return Flight departure and arrival airports and time |
|
| 574 | - */ |
|
| 570 | + * Get flight info from Lufthansa |
|
| 571 | + * @param String $callsign The callsign |
|
| 572 | + * @param String $date date we want flight number info |
|
| 573 | + * @return Flight departure and arrival airports and time |
|
| 574 | + */ |
|
| 575 | 575 | |
| 576 | 576 | /* private function getLufthansa($callsign, $date = 'NOW') { |
| 577 | 577 | $Common = new Common(); |
@@ -599,10 +599,10 @@ discard block |
||
| 599 | 599 | } |
| 600 | 600 | */ |
| 601 | 601 | /** |
| 602 | - * Get flight info from flytap |
|
| 603 | - * @param String $callsign The callsign |
|
| 604 | - * @return Flight departure and arrival airports and time |
|
| 605 | - */ |
|
| 602 | + * Get flight info from flytap |
|
| 603 | + * @param String $callsign The callsign |
|
| 604 | + * @return Flight departure and arrival airports and time |
|
| 605 | + */ |
|
| 606 | 606 | private function getFlyTap($callsign) { |
| 607 | 607 | $Common = new Common(); |
| 608 | 608 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -625,10 +625,10 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | /** |
| 628 | - * Get flight info from flightmapper |
|
| 629 | - * @param String $callsign The callsign |
|
| 630 | - * @return Flight departure and arrival airports and time |
|
| 631 | - */ |
|
| 628 | + * Get flight info from flightmapper |
|
| 629 | + * @param String $callsign The callsign |
|
| 630 | + * @return Flight departure and arrival airports and time |
|
| 631 | + */ |
|
| 632 | 632 | public function getFlightMapper($callsign) { |
| 633 | 633 | $Common = new Common(); |
| 634 | 634 | $airline_icao = ''; |
@@ -656,11 +656,11 @@ discard block |
||
| 656 | 656 | $aarr = ''; |
| 657 | 657 | $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
| 658 | 658 | if ($n == 7) { |
| 659 | - $departureTime = $dhour; |
|
| 660 | - $arrivalTime = $ahour; |
|
| 661 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 662 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 663 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 659 | + $departureTime = $dhour; |
|
| 660 | + $arrivalTime = $ahour; |
|
| 661 | + $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 662 | + $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 663 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 664 | 664 | } |
| 665 | 665 | } |
| 666 | 666 | } |
@@ -668,10 +668,10 @@ discard block |
||
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | /** |
| 671 | - * Get flight info from flightaware |
|
| 672 | - * @param String $callsign The callsign |
|
| 673 | - * @return Flight departure and arrival airports and time |
|
| 674 | - */ |
|
| 671 | + * Get flight info from flightaware |
|
| 672 | + * @param String $callsign The callsign |
|
| 673 | + * @return Flight departure and arrival airports and time |
|
| 674 | + */ |
|
| 675 | 675 | public function getFlightAware($callsign) { |
| 676 | 676 | $Common = new Common(); |
| 677 | 677 | /* |
@@ -704,10 +704,10 @@ discard block |
||
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | /** |
| 707 | - * Get flight info from CostToTravel |
|
| 708 | - * @param String $callsign The callsign |
|
| 709 | - * @return Flight departure and arrival airports and time |
|
| 710 | - */ |
|
| 707 | + * Get flight info from CostToTravel |
|
| 708 | + * @param String $callsign The callsign |
|
| 709 | + * @return Flight departure and arrival airports and time |
|
| 710 | + */ |
|
| 711 | 711 | public function getCostToTravel($callsign) { |
| 712 | 712 | $Common = new Common(); |
| 713 | 713 | $url= "http://www.costtotravel.com/flight-number/".$callsign; |
@@ -729,11 +729,11 @@ discard block |
||
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | /** |
| 732 | - * Get flight info from Air Canada |
|
| 733 | - * @param String $callsign The callsign |
|
| 734 | - * @param String $date date we want flight number info |
|
| 735 | - * @return Flight departure and arrival airports and time |
|
| 736 | - */ |
|
| 732 | + * Get flight info from Air Canada |
|
| 733 | + * @param String $callsign The callsign |
|
| 734 | + * @param String $date date we want flight number info |
|
| 735 | + * @return Flight departure and arrival airports and time |
|
| 736 | + */ |
|
| 737 | 737 | private function getAirCanada($callsign,$date = 'NOW') { |
| 738 | 738 | $Common = new Common(); |
| 739 | 739 | date_default_timezone_set('UTC'); |
@@ -757,11 +757,11 @@ discard block |
||
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | /** |
| 760 | - * Get flight info from Vietnam Airlines |
|
| 761 | - * @param String $callsign The callsign |
|
| 762 | - * @param String $date date we want flight number info |
|
| 763 | - * @return Flight departure and arrival airports and time |
|
| 764 | - */ |
|
| 760 | + * Get flight info from Vietnam Airlines |
|
| 761 | + * @param String $callsign The callsign |
|
| 762 | + * @param String $date date we want flight number info |
|
| 763 | + * @return Flight departure and arrival airports and time |
|
| 764 | + */ |
|
| 765 | 765 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
| 766 | 766 | $Common = new Common(); |
| 767 | 767 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -783,12 +783,12 @@ discard block |
||
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | /** |
| 786 | - * Get flight info from Air Berlin |
|
| 787 | - * @param String $callsign The callsign |
|
| 788 | - * @param String $date date we want flight number info |
|
| 789 | - * @param String $carrier airline code |
|
| 790 | - * @return Flight departure and arrival airports and time |
|
| 791 | - */ |
|
| 786 | + * Get flight info from Air Berlin |
|
| 787 | + * @param String $callsign The callsign |
|
| 788 | + * @param String $date date we want flight number info |
|
| 789 | + * @param String $carrier airline code |
|
| 790 | + * @return Flight departure and arrival airports and time |
|
| 791 | + */ |
|
| 792 | 792 | private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
| 793 | 793 | $Common = new Common(); |
| 794 | 794 | date_default_timezone_set('UTC'); |
@@ -817,11 +817,11 @@ discard block |
||
| 817 | 817 | $table = $Common->table2array($data); |
| 818 | 818 | $flight = $table; |
| 819 | 819 | if (isset($flight[5][4])) { |
| 820 | - $arrivalTime = $flight[5][4]; |
|
| 821 | - $arrivalAirport = $flight[5][3]; |
|
| 820 | + $arrivalTime = $flight[5][4]; |
|
| 821 | + $arrivalAirport = $flight[5][3]; |
|
| 822 | 822 | } else { |
| 823 | - $arrivalTime = ''; |
|
| 824 | - $arrivalAirport = ''; |
|
| 823 | + $arrivalTime = ''; |
|
| 824 | + $arrivalAirport = ''; |
|
| 825 | 825 | } |
| 826 | 826 | } else return array(); |
| 827 | 827 | $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'; |
@@ -1089,7 +1089,7 @@ discard block |
||
| 1089 | 1089 | } |
| 1090 | 1090 | } |
| 1091 | 1091 | } |
| 1092 | - return array(); |
|
| 1092 | + return array(); |
|
| 1093 | 1093 | } |
| 1094 | 1094 | } |
| 1095 | 1095 | |