@@ -19,47 +19,47 @@ discard block |
||
| 19 | 19 | // Check if schema is at latest version |
| 20 | 20 | $Connection = new Connection(); |
| 21 | 21 | if ($Connection->latest() === false) { |
| 22 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 23 | - exit(); |
|
| 22 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 23 | + exit(); |
|
| 24 | 24 | } |
| 25 | 25 | if (PHP_SAPI != 'cli') { |
| 26 | - echo "This script MUST be called from console, not a web browser."; |
|
| 26 | + echo "This script MUST be called from console, not a web browser."; |
|
| 27 | 27 | // exit(); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // This is to be compatible with old version of settings.php |
| 31 | 31 | if (!isset($globalSources)) { |
| 32 | - if (isset($globalSBS1Hosts)) { |
|
| 33 | - //$hosts = $globalSBS1Hosts; |
|
| 34 | - foreach ($globalSBS1Hosts as $host) { |
|
| 35 | - $globalSources[] = array('host' => $host); |
|
| 36 | - } |
|
| 37 | - } else { |
|
| 38 | - if (!isset($globalSBS1Host)) { |
|
| 39 | - echo '$globalSources MUST be defined !'; |
|
| 40 | - die; |
|
| 32 | + if (isset($globalSBS1Hosts)) { |
|
| 33 | + //$hosts = $globalSBS1Hosts; |
|
| 34 | + foreach ($globalSBS1Hosts as $host) { |
|
| 35 | + $globalSources[] = array('host' => $host); |
|
| 36 | + } |
|
| 37 | + } else { |
|
| 38 | + if (!isset($globalSBS1Host)) { |
|
| 39 | + echo '$globalSources MUST be defined !'; |
|
| 40 | + die; |
|
| 41 | 41 | } |
| 42 | 42 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 43 | 43 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $options = getopt('s::',array('source::','server','idsource::')); |
| 48 | 48 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 49 | 49 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 50 | 50 | if (isset($options['s'])) { |
| 51 | - $globalSources = array(); |
|
| 52 | - $globalSources[] = array('host' => $options['s']); |
|
| 51 | + $globalSources = array(); |
|
| 52 | + $globalSources[] = array('host' => $options['s']); |
|
| 53 | 53 | } elseif (isset($options['source'])) { |
| 54 | - $globalSources = array(); |
|
| 55 | - $globalSources[] = array('host' => $options['source']); |
|
| 54 | + $globalSources = array(); |
|
| 55 | + $globalSources[] = array('host' => $options['source']); |
|
| 56 | 56 | } |
| 57 | 57 | if (isset($options['server'])) $globalServer = TRUE; |
| 58 | 58 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 59 | 59 | else $id_source = 1; |
| 60 | 60 | if (isset($globalServer) && $globalServer) { |
| 61 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 62 | - $SI=new SpotterServer(); |
|
| 61 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 62 | + $SI=new SpotterServer(); |
|
| 63 | 63 | } else $SI=new SpotterImport($Connection->db); |
| 64 | 64 | //$APRS=new APRS($Connection->db); |
| 65 | 65 | $SBS=new SBS(); |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | //$servertz = system('date +%Z'); |
| 70 | 70 | // signal handler - playing nice with sockets and dump1090 |
| 71 | 71 | if (function_exists('pcntl_fork')) { |
| 72 | - pcntl_signal(SIGINT, function() { |
|
| 73 | - global $sockets; |
|
| 74 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 75 | - die("Bye!\n"); |
|
| 76 | - }); |
|
| 77 | - pcntl_signal_dispatch(); |
|
| 72 | + pcntl_signal(SIGINT, function() { |
|
| 73 | + global $sockets; |
|
| 74 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 75 | + die("Bye!\n"); |
|
| 76 | + }); |
|
| 77 | + pcntl_signal_dispatch(); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // let's try and connect |
@@ -84,162 +84,162 @@ discard block |
||
| 84 | 84 | $reset = 0; |
| 85 | 85 | |
| 86 | 86 | function create_socket($host, $port, &$errno, &$errstr) { |
| 87 | - $ip = gethostbyname($host); |
|
| 88 | - $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 89 | - $r = @socket_connect($s, $ip, $port); |
|
| 90 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 91 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 92 | - return $s; |
|
| 93 | - } |
|
| 94 | - $errno = socket_last_error($s); |
|
| 95 | - $errstr = socket_strerror($errno); |
|
| 96 | - socket_close($s); |
|
| 97 | - return false; |
|
| 87 | + $ip = gethostbyname($host); |
|
| 88 | + $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 89 | + $r = @socket_connect($s, $ip, $port); |
|
| 90 | + if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 91 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 92 | + return $s; |
|
| 93 | + } |
|
| 94 | + $errno = socket_last_error($s); |
|
| 95 | + $errstr = socket_strerror($errno); |
|
| 96 | + socket_close($s); |
|
| 97 | + return false; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | function create_socket_udp($host, $port, &$errno, &$errstr) { |
| 101 | - echo "Create an UDP socket...\n"; |
|
| 102 | - $ip = gethostbyname($host); |
|
| 103 | - $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
| 104 | - $r = @socket_bind($s, $ip, $port); |
|
| 105 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 106 | - return $s; |
|
| 107 | - } |
|
| 108 | - $errno = socket_last_error($s); |
|
| 109 | - $errstr = socket_strerror($errno); |
|
| 110 | - socket_close($s); |
|
| 111 | - return false; |
|
| 101 | + echo "Create an UDP socket...\n"; |
|
| 102 | + $ip = gethostbyname($host); |
|
| 103 | + $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
| 104 | + $r = @socket_bind($s, $ip, $port); |
|
| 105 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 106 | + return $s; |
|
| 107 | + } |
|
| 108 | + $errno = socket_last_error($s); |
|
| 109 | + $errstr = socket_strerror($errno); |
|
| 110 | + socket_close($s); |
|
| 111 | + return false; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | function connect_all($hosts) { |
| 115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 117 | - $reset++; |
|
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | - foreach ($hosts as $id => $value) { |
|
| 115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | + global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 117 | + $reset++; |
|
| 118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | + foreach ($hosts as $id => $value) { |
|
| 120 | 120 | $host = $value['host']; |
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; |
| 122 | 122 | // Here we check type of source(s) |
| 123 | 123 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | - //$formats[$id] = 'deltadbtxt'; |
|
| 126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | - //$last_exec['deltadbtxt'] = 0; |
|
| 128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | - //$formats[$id] = 'vatsimtxt'; |
|
| 131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | - //$last_exec['vatsimtxt'] = 0; |
|
| 133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 145 | - //$formats[$id] = 'radarvirtueljson'; |
|
| 146 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 147 | - //$last_exec['radarvirtueljson'] = 0; |
|
| 148 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 149 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 150 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 151 | - exit(0); |
|
| 152 | - } |
|
| 153 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 154 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 155 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 156 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 157 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 158 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 159 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 160 | - exit(0); |
|
| 161 | - } |
|
| 162 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 163 | - //$formats[$id] = 'phpvmacars'; |
|
| 164 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 165 | - //$last_exec['phpvmacars'] = 0; |
|
| 166 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 167 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 168 | - //$formats[$id] = 'phpvmacars'; |
|
| 169 | - $globalSources[$id]['format'] = 'vam'; |
|
| 170 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 171 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 172 | - //$formats[$id] = 'whazzup'; |
|
| 173 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 174 | - //$last_exec['whazzup'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 176 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 177 | - //$formats[$id] = 'pirepsjson'; |
|
| 178 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 179 | - //$last_exec['pirepsjson'] = 0; |
|
| 180 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 181 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 182 | - //$formats[$id] = 'fr24json'; |
|
| 183 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 184 | - //$last_exec['fr24json'] = 0; |
|
| 185 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 186 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 187 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 188 | - exit(0); |
|
| 189 | - } |
|
| 190 | - //} else if (preg_match('/10001/',$host)) { |
|
| 191 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 192 | - //$formats[$id] = 'tsv'; |
|
| 193 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 194 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 195 | - } |
|
| 196 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 197 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 198 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 199 | - $hostport = explode(':',$host); |
|
| 200 | - if (isset($hostport[1])) { |
|
| 124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | + //$formats[$id] = 'deltadbtxt'; |
|
| 126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | + //$last_exec['deltadbtxt'] = 0; |
|
| 128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | + //$formats[$id] = 'vatsimtxt'; |
|
| 131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | + //$last_exec['vatsimtxt'] = 0; |
|
| 133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 145 | + //$formats[$id] = 'radarvirtueljson'; |
|
| 146 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 147 | + //$last_exec['radarvirtueljson'] = 0; |
|
| 148 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 149 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 150 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 151 | + exit(0); |
|
| 152 | + } |
|
| 153 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 154 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 155 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 156 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 157 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 158 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 159 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 160 | + exit(0); |
|
| 161 | + } |
|
| 162 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 163 | + //$formats[$id] = 'phpvmacars'; |
|
| 164 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 165 | + //$last_exec['phpvmacars'] = 0; |
|
| 166 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 167 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 168 | + //$formats[$id] = 'phpvmacars'; |
|
| 169 | + $globalSources[$id]['format'] = 'vam'; |
|
| 170 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 171 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 172 | + //$formats[$id] = 'whazzup'; |
|
| 173 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 174 | + //$last_exec['whazzup'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 176 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 177 | + //$formats[$id] = 'pirepsjson'; |
|
| 178 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 179 | + //$last_exec['pirepsjson'] = 0; |
|
| 180 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 181 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 182 | + //$formats[$id] = 'fr24json'; |
|
| 183 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 184 | + //$last_exec['fr24json'] = 0; |
|
| 185 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 186 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 187 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 188 | + exit(0); |
|
| 189 | + } |
|
| 190 | + //} else if (preg_match('/10001/',$host)) { |
|
| 191 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 192 | + //$formats[$id] = 'tsv'; |
|
| 193 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 194 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 195 | + } |
|
| 196 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 197 | + if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 198 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 199 | + $hostport = explode(':',$host); |
|
| 200 | + if (isset($hostport[1])) { |
|
| 201 | 201 | $port = $hostport[1]; |
| 202 | 202 | $hostn = $hostport[0]; |
| 203 | - } else { |
|
| 203 | + } else { |
|
| 204 | 204 | $port = $globalSources[$id]['port']; |
| 205 | 205 | $hostn = $globalSources[$id]['host']; |
| 206 | - } |
|
| 207 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 208 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 209 | - } else { |
|
| 210 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 211 | - } |
|
| 212 | - if ($s) { |
|
| 213 | - $sockets[$id] = $s; |
|
| 214 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 215 | - if (preg_match('/aprs/',$hostn)) { |
|
| 206 | + } |
|
| 207 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 208 | + $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 209 | + } else { |
|
| 210 | + $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 211 | + } |
|
| 212 | + if ($s) { |
|
| 213 | + $sockets[$id] = $s; |
|
| 214 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 215 | + if (preg_match('/aprs/',$hostn)) { |
|
| 216 | 216 | //$formats[$id] = 'aprs'; |
| 217 | 217 | $globalSources[$id]['format'] = 'aprs'; |
| 218 | 218 | //$aprs_connect = 0; |
| 219 | 219 | //$use_aprs = true; |
| 220 | - } elseif ($port == '10001') { |
|
| 221 | - //$formats[$id] = 'tsv'; |
|
| 222 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 223 | - } elseif ($port == '30002') { |
|
| 224 | - //$formats[$id] = 'raw'; |
|
| 225 | - $globalSources[$id]['format'] = 'raw'; |
|
| 226 | - } elseif ($port == '5001') { |
|
| 227 | - //$formats[$id] = 'raw'; |
|
| 228 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 229 | - } elseif ($port == '30005') { |
|
| 220 | + } elseif ($port == '10001') { |
|
| 221 | + //$formats[$id] = 'tsv'; |
|
| 222 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 223 | + } elseif ($port == '30002') { |
|
| 224 | + //$formats[$id] = 'raw'; |
|
| 225 | + $globalSources[$id]['format'] = 'raw'; |
|
| 226 | + } elseif ($port == '5001') { |
|
| 227 | + //$formats[$id] = 'raw'; |
|
| 228 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 229 | + } elseif ($port == '30005') { |
|
| 230 | 230 | // Not yet supported |
| 231 | - //$formats[$id] = 'beast'; |
|
| 232 | - $globalSources[$id]['format'] = 'beast'; |
|
| 233 | - //} else $formats[$id] = 'sbs'; |
|
| 234 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 235 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 231 | + //$formats[$id] = 'beast'; |
|
| 232 | + $globalSources[$id]['format'] = 'beast'; |
|
| 233 | + //} else $formats[$id] = 'sbs'; |
|
| 234 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 235 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 236 | 236 | } |
| 237 | 237 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 238 | - } else { |
|
| 238 | + } else { |
|
| 239 | 239 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 240 | - } |
|
| 241 | - } |
|
| 242 | - } |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | 243 | } |
| 244 | 244 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 245 | 245 | |
@@ -266,18 +266,18 @@ discard block |
||
| 266 | 266 | die; |
| 267 | 267 | } |
| 268 | 268 | foreach ($globalSources as $key => $source) { |
| 269 | - if (!isset($source['format'])) { |
|
| 270 | - $globalSources[$key]['format'] = 'auto'; |
|
| 271 | - } |
|
| 269 | + if (!isset($source['format'])) { |
|
| 270 | + $globalSources[$key]['format'] = 'auto'; |
|
| 271 | + } |
|
| 272 | 272 | } |
| 273 | 273 | connect_all($globalSources); |
| 274 | 274 | foreach ($globalSources as $key => $source) { |
| 275 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 275 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 276 | 276 | $aprs_connect = 0; |
| 277 | 277 | $use_aprs = true; |
| 278 | 278 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 279 | 279 | break; |
| 280 | - } |
|
| 280 | + } |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | if ($use_aprs) { |
@@ -316,70 +316,70 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 318 | 318 | while ($i > 0) { |
| 319 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 320 | - // Delete old ATC |
|
| 321 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 319 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 320 | + // Delete old ATC |
|
| 321 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 322 | 322 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 323 | - $ATC->deleteOldATC(); |
|
| 324 | - } |
|
| 323 | + $ATC->deleteOldATC(); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - if (count($last_exec) > 0) { |
|
| 326 | + if (count($last_exec) > 0) { |
|
| 327 | 327 | $max = $globalMinFetch; |
| 328 | 328 | foreach ($last_exec as $last) { |
| 329 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 329 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 330 | 330 | } |
| 331 | 331 | if ($max != $globalMinFetch) { |
| 332 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 333 | - sleep($globalMinFetch-$max+2); |
|
| 332 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 333 | + sleep($globalMinFetch-$max+2); |
|
| 334 | + } |
|
| 334 | 335 | } |
| 335 | - } |
|
| 336 | 336 | |
| 337 | 337 | |
| 338 | - //foreach ($formats as $id => $value) { |
|
| 339 | - foreach ($globalSources as $id => $value) { |
|
| 338 | + //foreach ($formats as $id => $value) { |
|
| 339 | + foreach ($globalSources as $id => $value) { |
|
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 342 | 342 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 343 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 344 | - $buffer = $Common->getData($value['host']); |
|
| 345 | - if ($buffer != '') $reset = 0; |
|
| 346 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 347 | - $buffer = explode('\n',$buffer); |
|
| 348 | - foreach ($buffer as $line) { |
|
| 349 | - if ($line != '' && count($line) > 7) { |
|
| 350 | - $line = explode(',', $line); |
|
| 351 | - $data = array(); |
|
| 352 | - $data['hex'] = $line[1]; // hex |
|
| 353 | - $data['ident'] = $line[2]; // ident |
|
| 354 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 355 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 356 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 357 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 358 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 359 | - $data['verticalrate'] = ''; // vertical rate |
|
| 360 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 361 | - $data['emergency'] = ''; // emergency |
|
| 362 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 363 | - $data['format_source'] = 'deltadbtxt'; |
|
| 364 | - $data['id_source'] = $id_source; |
|
| 365 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 366 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 367 | - $SI->add($data); |
|
| 368 | - unset($data); |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - $last_exec[$id]['last'] = time(); |
|
| 343 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 344 | + $buffer = $Common->getData($value['host']); |
|
| 345 | + if ($buffer != '') $reset = 0; |
|
| 346 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 347 | + $buffer = explode('\n',$buffer); |
|
| 348 | + foreach ($buffer as $line) { |
|
| 349 | + if ($line != '' && count($line) > 7) { |
|
| 350 | + $line = explode(',', $line); |
|
| 351 | + $data = array(); |
|
| 352 | + $data['hex'] = $line[1]; // hex |
|
| 353 | + $data['ident'] = $line[2]; // ident |
|
| 354 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 355 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 356 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 357 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 358 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 359 | + $data['verticalrate'] = ''; // vertical rate |
|
| 360 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 361 | + $data['emergency'] = ''; // emergency |
|
| 362 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 363 | + $data['format_source'] = 'deltadbtxt'; |
|
| 364 | + $data['id_source'] = $id_source; |
|
| 365 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 366 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 367 | + $SI->add($data); |
|
| 368 | + unset($data); |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + $last_exec[$id]['last'] = time(); |
|
| 372 | 372 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 373 | 373 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 374 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 375 | - $buffer = $Common->getData($value['host']); |
|
| 376 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 377 | - $buffer = explode('\n',$buffer); |
|
| 378 | - $reset = 0; |
|
| 379 | - foreach ($buffer as $line) { |
|
| 380 | - if ($line != '') { |
|
| 381 | - $line = explode(':', $line); |
|
| 382 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 374 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 375 | + $buffer = $Common->getData($value['host']); |
|
| 376 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 377 | + $buffer = explode('\n',$buffer); |
|
| 378 | + $reset = 0; |
|
| 379 | + foreach ($buffer as $line) { |
|
| 380 | + if ($line != '') { |
|
| 381 | + $line = explode(':', $line); |
|
| 382 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 383 | 383 | $data = array(); |
| 384 | 384 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 385 | 385 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -392,36 +392,36 @@ discard block |
||
| 392 | 392 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 393 | 393 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 394 | 394 | $data['latitude'] = $line[5]; // lat |
| 395 | - $data['longitude'] = $line[6]; // long |
|
| 396 | - $data['verticalrate'] = ''; // vertical rate |
|
| 397 | - $data['squawk'] = ''; // squawk |
|
| 398 | - $data['emergency'] = ''; // emergency |
|
| 399 | - $data['waypoints'] = $line[30]; |
|
| 395 | + $data['longitude'] = $line[6]; // long |
|
| 396 | + $data['verticalrate'] = ''; // vertical rate |
|
| 397 | + $data['squawk'] = ''; // squawk |
|
| 398 | + $data['emergency'] = ''; // emergency |
|
| 399 | + $data['waypoints'] = $line[30]; |
|
| 400 | 400 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 401 | 401 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 402 | 402 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 403 | - $data['departure_airport_icao'] = $line[11]; |
|
| 404 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 405 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 403 | + $data['departure_airport_icao'] = $line[11]; |
|
| 404 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 405 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 406 | 406 | $data['frequency'] = $line[4]; |
| 407 | 407 | $data['type'] = $line[18]; |
| 408 | 408 | $data['range'] = $line[19]; |
| 409 | 409 | if (isset($line[35])) $data['info'] = $line[35]; |
| 410 | - $data['id_source'] = $id_source; |
|
| 411 | - //$data['arrival_airport_time'] = ; |
|
| 412 | - if ($line[9] != '') { |
|
| 413 | - $aircraft_data = explode('/',$line[9]); |
|
| 414 | - if (isset($aircraft_data[1])) { |
|
| 415 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 416 | - } |
|
| 417 | - } |
|
| 418 | - /* |
|
| 410 | + $data['id_source'] = $id_source; |
|
| 411 | + //$data['arrival_airport_time'] = ; |
|
| 412 | + if ($line[9] != '') { |
|
| 413 | + $aircraft_data = explode('/',$line[9]); |
|
| 414 | + if (isset($aircraft_data[1])) { |
|
| 415 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + /* |
|
| 419 | 419 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 420 | 420 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 421 | 421 | */ |
| 422 | - $data['format_source'] = $value['format']; |
|
| 422 | + $data['format_source'] = $value['format']; |
|
| 423 | 423 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 424 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 424 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 425 | 425 | elseif ($line[3] == 'ATC') { |
| 426 | 426 | //print_r($data); |
| 427 | 427 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -439,247 +439,247 @@ discard block |
||
| 439 | 439 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 440 | 440 | if (isset($ATC)) 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']); |
| 441 | 441 | } |
| 442 | - unset($data); |
|
| 443 | - } |
|
| 444 | - } |
|
| 445 | - } |
|
| 446 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 447 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 448 | - $last_exec[$id]['last'] = time(); |
|
| 449 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 450 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 451 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 452 | - if ($buffer != '') { |
|
| 453 | - $all_data = json_decode($buffer,true); |
|
| 454 | - if (isset($all_data['acList'])) { |
|
| 442 | + unset($data); |
|
| 443 | + } |
|
| 444 | + } |
|
| 445 | + } |
|
| 446 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 447 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 448 | + $last_exec[$id]['last'] = time(); |
|
| 449 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 450 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 451 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 452 | + if ($buffer != '') { |
|
| 453 | + $all_data = json_decode($buffer,true); |
|
| 454 | + if (isset($all_data['acList'])) { |
|
| 455 | 455 | $reset = 0; |
| 456 | 456 | foreach ($all_data['acList'] as $line) { |
| 457 | - $data = array(); |
|
| 458 | - $data['hex'] = $line['Icao']; // hex |
|
| 459 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 460 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 461 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 462 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 463 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 464 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 465 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
| 466 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 467 | - $data['emergency'] = ''; // emergency |
|
| 468 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 469 | - /* |
|
| 457 | + $data = array(); |
|
| 458 | + $data['hex'] = $line['Icao']; // hex |
|
| 459 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 460 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 461 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 462 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 463 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 464 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 465 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
| 466 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 467 | + $data['emergency'] = ''; // emergency |
|
| 468 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 469 | + /* |
|
| 470 | 470 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 471 | 471 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 472 | 472 | */ |
| 473 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 474 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 475 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 476 | - $data['id_source'] = $id_source; |
|
| 477 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 478 | - if (isset($data['datetime'])) $SI->add($data); |
|
| 479 | - unset($data); |
|
| 473 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 474 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 475 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 476 | + $data['id_source'] = $id_source; |
|
| 477 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 478 | + if (isset($data['datetime'])) $SI->add($data); |
|
| 479 | + unset($data); |
|
| 480 | 480 | } |
| 481 | - } else { |
|
| 481 | + } else { |
|
| 482 | 482 | $reset = 0; |
| 483 | 483 | foreach ($all_data as $line) { |
| 484 | - $data = array(); |
|
| 485 | - $data['hex'] = $line['hex']; // hex |
|
| 486 | - $data['ident'] = $line['flight']; // ident |
|
| 487 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 488 | - $data['speed'] = $line['speed']; // speed |
|
| 489 | - $data['heading'] = $line['track']; // heading |
|
| 490 | - $data['latitude'] = $line['lat']; // lat |
|
| 491 | - $data['longitude'] = $line['lon']; // long |
|
| 492 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 493 | - $data['squawk'] = $line['squawk']; // squawk |
|
| 494 | - $data['emergency'] = ''; // emergency |
|
| 495 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 496 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 497 | - $data['id_source'] = $id_source; |
|
| 498 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 499 | - $SI->add($data); |
|
| 500 | - unset($data); |
|
| 484 | + $data = array(); |
|
| 485 | + $data['hex'] = $line['hex']; // hex |
|
| 486 | + $data['ident'] = $line['flight']; // ident |
|
| 487 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 488 | + $data['speed'] = $line['speed']; // speed |
|
| 489 | + $data['heading'] = $line['track']; // heading |
|
| 490 | + $data['latitude'] = $line['lat']; // lat |
|
| 491 | + $data['longitude'] = $line['lon']; // long |
|
| 492 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 493 | + $data['squawk'] = $line['squawk']; // squawk |
|
| 494 | + $data['emergency'] = ''; // emergency |
|
| 495 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 496 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 497 | + $data['id_source'] = $id_source; |
|
| 498 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 499 | + $SI->add($data); |
|
| 500 | + unset($data); |
|
| 501 | + } |
|
| 501 | 502 | } |
| 502 | - } |
|
| 503 | - } |
|
| 504 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 505 | - $last_exec[$id]['last'] = time(); |
|
| 506 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 507 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 508 | - $buffer = $Common->getData($value['host']); |
|
| 509 | - $all_data = json_decode($buffer,true); |
|
| 510 | - if (isset($all_data['planes'])) { |
|
| 503 | + } |
|
| 504 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 505 | + $last_exec[$id]['last'] = time(); |
|
| 506 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 507 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 508 | + $buffer = $Common->getData($value['host']); |
|
| 509 | + $all_data = json_decode($buffer,true); |
|
| 510 | + if (isset($all_data['planes'])) { |
|
| 511 | 511 | $reset = 0; |
| 512 | 512 | foreach ($all_data['planes'] as $key => $line) { |
| 513 | - $data = array(); |
|
| 514 | - $data['hex'] = $key; // hex |
|
| 515 | - $data['ident'] = $line[3]; // ident |
|
| 516 | - $data['altitude'] = $line[6]; // altitude |
|
| 517 | - $data['speed'] = $line[8]; // speed |
|
| 518 | - $data['heading'] = $line[7]; // heading |
|
| 519 | - $data['latitude'] = $line[4]; // lat |
|
| 520 | - $data['longitude'] = $line[5]; // long |
|
| 521 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 522 | - $data['squawk'] = $line[10]; // squawk |
|
| 523 | - $data['emergency'] = ''; // emergency |
|
| 524 | - $data['registration'] = $line[2]; |
|
| 525 | - $data['aircraft_icao'] = $line[0]; |
|
| 526 | - $deparr = explode('-',$line[1]); |
|
| 527 | - if (count($deparr) == 2) { |
|
| 513 | + $data = array(); |
|
| 514 | + $data['hex'] = $key; // hex |
|
| 515 | + $data['ident'] = $line[3]; // ident |
|
| 516 | + $data['altitude'] = $line[6]; // altitude |
|
| 517 | + $data['speed'] = $line[8]; // speed |
|
| 518 | + $data['heading'] = $line[7]; // heading |
|
| 519 | + $data['latitude'] = $line[4]; // lat |
|
| 520 | + $data['longitude'] = $line[5]; // long |
|
| 521 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 522 | + $data['squawk'] = $line[10]; // squawk |
|
| 523 | + $data['emergency'] = ''; // emergency |
|
| 524 | + $data['registration'] = $line[2]; |
|
| 525 | + $data['aircraft_icao'] = $line[0]; |
|
| 526 | + $deparr = explode('-',$line[1]); |
|
| 527 | + if (count($deparr) == 2) { |
|
| 528 | 528 | $data['departure_airport_icao'] = $deparr[0]; |
| 529 | 529 | $data['arrival_airport_icao'] = $deparr[1]; |
| 530 | - } |
|
| 531 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 532 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 533 | - $data['id_source'] = $id_source; |
|
| 534 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 535 | - $SI->add($data); |
|
| 536 | - unset($data); |
|
| 530 | + } |
|
| 531 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 532 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 533 | + $data['id_source'] = $id_source; |
|
| 534 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 535 | + $SI->add($data); |
|
| 536 | + unset($data); |
|
| 537 | + } |
|
| 537 | 538 | } |
| 538 | - } |
|
| 539 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 540 | - $last_exec[$id]['last'] = time(); |
|
| 541 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 542 | - $buffer = $Common->getData($value['host']); |
|
| 543 | - $all_data = json_decode($buffer,true); |
|
| 544 | - if (isset($all_data['states'])) { |
|
| 539 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 540 | + $last_exec[$id]['last'] = time(); |
|
| 541 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 542 | + $buffer = $Common->getData($value['host']); |
|
| 543 | + $all_data = json_decode($buffer,true); |
|
| 544 | + if (isset($all_data['states'])) { |
|
| 545 | 545 | $reset = 0; |
| 546 | 546 | foreach ($all_data['states'] as $key => $line) { |
| 547 | - $data = array(); |
|
| 548 | - $data['hex'] = $line[0]; // hex |
|
| 549 | - $data['ident'] = trim($line[1]); // ident |
|
| 550 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 551 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 552 | - $data['heading'] = round($line[10]); // heading |
|
| 553 | - $data['latitude'] = $line[5]; // lat |
|
| 554 | - $data['longitude'] = $line[6]; // long |
|
| 555 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 556 | - //$data['squawk'] = $line[10]; // squawk |
|
| 557 | - //$data['emergency'] = ''; // emergency |
|
| 558 | - //$data['registration'] = $line[2]; |
|
| 559 | - //$data['aircraft_icao'] = $line[0]; |
|
| 560 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 561 | - $data['format_source'] = 'opensky'; |
|
| 562 | - $data['id_source'] = $id_source; |
|
| 563 | - $SI->add($data); |
|
| 564 | - unset($data); |
|
| 547 | + $data = array(); |
|
| 548 | + $data['hex'] = $line[0]; // hex |
|
| 549 | + $data['ident'] = trim($line[1]); // ident |
|
| 550 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 551 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 552 | + $data['heading'] = round($line[10]); // heading |
|
| 553 | + $data['latitude'] = $line[5]; // lat |
|
| 554 | + $data['longitude'] = $line[6]; // long |
|
| 555 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 556 | + //$data['squawk'] = $line[10]; // squawk |
|
| 557 | + //$data['emergency'] = ''; // emergency |
|
| 558 | + //$data['registration'] = $line[2]; |
|
| 559 | + //$data['aircraft_icao'] = $line[0]; |
|
| 560 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 561 | + $data['format_source'] = 'opensky'; |
|
| 562 | + $data['id_source'] = $id_source; |
|
| 563 | + $SI->add($data); |
|
| 564 | + unset($data); |
|
| 565 | + } |
|
| 565 | 566 | } |
| 566 | - } |
|
| 567 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 568 | - $last_exec[$id]['last'] = time(); |
|
| 569 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 570 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 571 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 572 | - $buffer = $Common->getData($value['host']); |
|
| 573 | - $all_data = json_decode($buffer,true); |
|
| 574 | - if (!empty($all_data)) $reset = 0; |
|
| 575 | - foreach ($all_data as $key => $line) { |
|
| 567 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 568 | + $last_exec[$id]['last'] = time(); |
|
| 569 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 570 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 571 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 572 | + $buffer = $Common->getData($value['host']); |
|
| 573 | + $all_data = json_decode($buffer,true); |
|
| 574 | + if (!empty($all_data)) $reset = 0; |
|
| 575 | + foreach ($all_data as $key => $line) { |
|
| 576 | 576 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 577 | - $data = array(); |
|
| 578 | - $data['hex'] = $line[0]; |
|
| 579 | - $data['ident'] = $line[16]; //$line[13] |
|
| 580 | - $data['altitude'] = $line[4]; // altitude |
|
| 581 | - $data['speed'] = $line[5]; // speed |
|
| 582 | - $data['heading'] = $line[3]; // heading |
|
| 583 | - $data['latitude'] = $line[1]; // lat |
|
| 584 | - $data['longitude'] = $line[2]; // long |
|
| 585 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 586 | - $data['squawk'] = $line[6]; // squawk |
|
| 587 | - $data['aircraft_icao'] = $line[8]; |
|
| 588 | - $data['registration'] = $line[9]; |
|
| 589 | - $data['departure_airport_iata'] = $line[11]; |
|
| 590 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 591 | - $data['emergency'] = ''; // emergency |
|
| 592 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 593 | - $data['format_source'] = 'fr24json'; |
|
| 594 | - $data['id_source'] = $id_source; |
|
| 595 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 596 | - $SI->add($data); |
|
| 597 | - unset($data); |
|
| 577 | + $data = array(); |
|
| 578 | + $data['hex'] = $line[0]; |
|
| 579 | + $data['ident'] = $line[16]; //$line[13] |
|
| 580 | + $data['altitude'] = $line[4]; // altitude |
|
| 581 | + $data['speed'] = $line[5]; // speed |
|
| 582 | + $data['heading'] = $line[3]; // heading |
|
| 583 | + $data['latitude'] = $line[1]; // lat |
|
| 584 | + $data['longitude'] = $line[2]; // long |
|
| 585 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 586 | + $data['squawk'] = $line[6]; // squawk |
|
| 587 | + $data['aircraft_icao'] = $line[8]; |
|
| 588 | + $data['registration'] = $line[9]; |
|
| 589 | + $data['departure_airport_iata'] = $line[11]; |
|
| 590 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 591 | + $data['emergency'] = ''; // emergency |
|
| 592 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 593 | + $data['format_source'] = 'fr24json'; |
|
| 594 | + $data['id_source'] = $id_source; |
|
| 595 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 596 | + $SI->add($data); |
|
| 597 | + unset($data); |
|
| 598 | + } |
|
| 598 | 599 | } |
| 599 | - } |
|
| 600 | - //$last_exec['fr24json'] = time(); |
|
| 601 | - $last_exec[$id]['last'] = time(); |
|
| 602 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 603 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 604 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 605 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 606 | - //echo $buffer; |
|
| 607 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 608 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 609 | - $all_data = json_decode($buffer,true); |
|
| 610 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 600 | + //$last_exec['fr24json'] = time(); |
|
| 601 | + $last_exec[$id]['last'] = time(); |
|
| 602 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 603 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 604 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 605 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 606 | + //echo $buffer; |
|
| 607 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 608 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 609 | + $all_data = json_decode($buffer,true); |
|
| 610 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 611 | 611 | die(json_last_error_msg()); |
| 612 | - } |
|
| 613 | - if (isset($all_data['mrkrs'])) { |
|
| 612 | + } |
|
| 613 | + if (isset($all_data['mrkrs'])) { |
|
| 614 | 614 | $reset = 0; |
| 615 | 615 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 616 | - if (isset($line['inf'])) { |
|
| 616 | + if (isset($line['inf'])) { |
|
| 617 | 617 | $data = array(); |
| 618 | 618 | $data['hex'] = $line['inf']['ia']; |
| 619 | 619 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 620 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 621 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 622 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 623 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 624 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 625 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 626 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 627 | - //$data['aircraft_icao'] = $line[8]; |
|
| 628 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 620 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 621 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 622 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 623 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 624 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 625 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 626 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 627 | + //$data['aircraft_icao'] = $line[8]; |
|
| 628 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 629 | 629 | //$data['departure_airport_iata'] = $line[11]; |
| 630 | 630 | //$data['arrival_airport_iata'] = $line[12]; |
| 631 | - //$data['emergency'] = ''; // emergency |
|
| 631 | + //$data['emergency'] = ''; // emergency |
|
| 632 | 632 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 633 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 634 | - $data['id_source'] = $id_source; |
|
| 633 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 634 | + $data['id_source'] = $id_source; |
|
| 635 | 635 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 636 | 636 | $SI->add($data); |
| 637 | 637 | unset($data); |
| 638 | - } |
|
| 638 | + } |
|
| 639 | + } |
|
| 639 | 640 | } |
| 640 | - } |
|
| 641 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 642 | - $last_exec[$id]['last'] = time(); |
|
| 643 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 644 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 645 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 646 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 647 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 641 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 642 | + $last_exec[$id]['last'] = time(); |
|
| 643 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 644 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 645 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 646 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 647 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 648 | 648 | |
| 649 | - if (isset($all_data['pireps'])) { |
|
| 649 | + if (isset($all_data['pireps'])) { |
|
| 650 | 650 | $reset = 0; |
| 651 | - foreach ($all_data['pireps'] as $line) { |
|
| 652 | - $data = array(); |
|
| 653 | - $data['id'] = $line['id']; |
|
| 654 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 655 | - $data['ident'] = $line['callsign']; // ident |
|
| 656 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 657 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 658 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 659 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 660 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 661 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 662 | - $data['latitude'] = $line['lat']; // lat |
|
| 663 | - $data['longitude'] = $line['lon']; // long |
|
| 664 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 665 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 666 | - //$data['emergency'] = ''; // emergency |
|
| 667 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 668 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 669 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 670 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 671 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 672 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 673 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 674 | - else $data['info'] = ''; |
|
| 675 | - $data['format_source'] = 'pireps'; |
|
| 676 | - $data['id_source'] = $id_source; |
|
| 677 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 678 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 679 | - if ($line['icon'] == 'plane') { |
|
| 651 | + foreach ($all_data['pireps'] as $line) { |
|
| 652 | + $data = array(); |
|
| 653 | + $data['id'] = $line['id']; |
|
| 654 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 655 | + $data['ident'] = $line['callsign']; // ident |
|
| 656 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 657 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 658 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 659 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 660 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 661 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 662 | + $data['latitude'] = $line['lat']; // lat |
|
| 663 | + $data['longitude'] = $line['lon']; // long |
|
| 664 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 665 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 666 | + //$data['emergency'] = ''; // emergency |
|
| 667 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 668 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 669 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 670 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 671 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 672 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 673 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 674 | + else $data['info'] = ''; |
|
| 675 | + $data['format_source'] = 'pireps'; |
|
| 676 | + $data['id_source'] = $id_source; |
|
| 677 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 678 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 679 | + if ($line['icon'] == 'plane') { |
|
| 680 | 680 | $SI->add($data); |
| 681 | - // print_r($data); |
|
| 682 | - } elseif ($line['icon'] == 'ct') { |
|
| 681 | + // print_r($data); |
|
| 682 | + } elseif ($line['icon'] == 'ct') { |
|
| 683 | 683 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 684 | 684 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 685 | 685 | $typec = substr($data['ident'],-3); |
@@ -694,163 +694,163 @@ discard block |
||
| 694 | 694 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 695 | 695 | else $data['type'] = 'Observer'; |
| 696 | 696 | 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']); |
| 697 | - } |
|
| 698 | - unset($data); |
|
| 697 | + } |
|
| 698 | + unset($data); |
|
| 699 | + } |
|
| 699 | 700 | } |
| 700 | - } |
|
| 701 | - //$last_exec['pirepsjson'] = time(); |
|
| 702 | - $last_exec[$id]['last'] = time(); |
|
| 703 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 704 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 705 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 706 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 707 | - $buffer = $Common->getData($value['host']); |
|
| 708 | - $all_data = json_decode($buffer,true); |
|
| 709 | - if ($buffer != '' && is_array($all_data)) { |
|
| 701 | + //$last_exec['pirepsjson'] = time(); |
|
| 702 | + $last_exec[$id]['last'] = time(); |
|
| 703 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 704 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 705 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 706 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 707 | + $buffer = $Common->getData($value['host']); |
|
| 708 | + $all_data = json_decode($buffer,true); |
|
| 709 | + if ($buffer != '' && is_array($all_data)) { |
|
| 710 | 710 | $reset = 0; |
| 711 | 711 | foreach ($all_data as $line) { |
| 712 | - $data = array(); |
|
| 713 | - //$data['id'] = $line['id']; // id not usable |
|
| 714 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 715 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 716 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 717 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 718 | - $data['ident'] = $line['flightnum']; // ident |
|
| 719 | - $data['altitude'] = $line['alt']; // altitude |
|
| 720 | - $data['speed'] = $line['gs']; // speed |
|
| 721 | - $data['heading'] = $line['heading']; // heading |
|
| 722 | - $data['latitude'] = $line['lat']; // lat |
|
| 723 | - $data['longitude'] = $line['lng']; // long |
|
| 724 | - $data['verticalrate'] = ''; // verticale rate |
|
| 725 | - $data['squawk'] = ''; // squawk |
|
| 726 | - $data['emergency'] = ''; // emergency |
|
| 727 | - //$data['datetime'] = $line['lastupdate']; |
|
| 728 | - $data['last_update'] = $line['lastupdate']; |
|
| 729 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 730 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 731 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 732 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 733 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 734 | - $data['registration'] = $line['aircraft']; |
|
| 735 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 736 | - if (isset($line['aircraftname'])) { |
|
| 712 | + $data = array(); |
|
| 713 | + //$data['id'] = $line['id']; // id not usable |
|
| 714 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 715 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 716 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 717 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 718 | + $data['ident'] = $line['flightnum']; // ident |
|
| 719 | + $data['altitude'] = $line['alt']; // altitude |
|
| 720 | + $data['speed'] = $line['gs']; // speed |
|
| 721 | + $data['heading'] = $line['heading']; // heading |
|
| 722 | + $data['latitude'] = $line['lat']; // lat |
|
| 723 | + $data['longitude'] = $line['lng']; // long |
|
| 724 | + $data['verticalrate'] = ''; // verticale rate |
|
| 725 | + $data['squawk'] = ''; // squawk |
|
| 726 | + $data['emergency'] = ''; // emergency |
|
| 727 | + //$data['datetime'] = $line['lastupdate']; |
|
| 728 | + $data['last_update'] = $line['lastupdate']; |
|
| 729 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 730 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 731 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 732 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 733 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 734 | + $data['registration'] = $line['aircraft']; |
|
| 735 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 736 | + if (isset($line['aircraftname'])) { |
|
| 737 | 737 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 738 | 738 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 739 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 740 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 741 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 742 | - else { |
|
| 743 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 744 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 745 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 749 | - $data['id_source'] = $id_source; |
|
| 750 | - $data['format_source'] = 'phpvmacars'; |
|
| 751 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 752 | - $SI->add($data); |
|
| 753 | - unset($data); |
|
| 739 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 740 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 741 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 742 | + else { |
|
| 743 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 744 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 745 | + else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 746 | + } |
|
| 747 | + } |
|
| 748 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 749 | + $data['id_source'] = $id_source; |
|
| 750 | + $data['format_source'] = 'phpvmacars'; |
|
| 751 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 752 | + $SI->add($data); |
|
| 753 | + unset($data); |
|
| 754 | 754 | } |
| 755 | 755 | if ($globalDebug) echo 'No more data...'."\n"; |
| 756 | 756 | unset($buffer); |
| 757 | 757 | unset($all_data); |
| 758 | - } |
|
| 759 | - //$last_exec['phpvmacars'] = time(); |
|
| 760 | - $last_exec[$id]['last'] = time(); |
|
| 761 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 762 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 763 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 764 | - $buffer = $Common->getData($value['host']); |
|
| 765 | - $all_data = json_decode($buffer,true); |
|
| 766 | - if ($buffer != '' && is_array($all_data)) { |
|
| 758 | + } |
|
| 759 | + //$last_exec['phpvmacars'] = time(); |
|
| 760 | + $last_exec[$id]['last'] = time(); |
|
| 761 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 762 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 763 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 764 | + $buffer = $Common->getData($value['host']); |
|
| 765 | + $all_data = json_decode($buffer,true); |
|
| 766 | + if ($buffer != '' && is_array($all_data)) { |
|
| 767 | 767 | $reset = 0; |
| 768 | 768 | foreach ($all_data as $line) { |
| 769 | - $data = array(); |
|
| 770 | - //$data['id'] = $line['id']; // id not usable |
|
| 771 | - $data['id'] = trim($line['flight_id']); |
|
| 772 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 773 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 774 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 775 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 776 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 777 | - $data['speed'] = $line['gs']; // speed |
|
| 778 | - $data['heading'] = $line['heading']; // heading |
|
| 779 | - $data['latitude'] = $line['latitude']; // lat |
|
| 780 | - $data['longitude'] = $line['longitude']; // long |
|
| 781 | - $data['verticalrate'] = ''; // verticale rate |
|
| 782 | - $data['squawk'] = ''; // squawk |
|
| 783 | - $data['emergency'] = ''; // emergency |
|
| 784 | - //$data['datetime'] = $line['lastupdate']; |
|
| 785 | - $data['last_update'] = $line['last_update']; |
|
| 786 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 787 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 788 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 789 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 790 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 791 | - //$data['registration'] = $line['aircraft']; |
|
| 792 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 793 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 794 | - $data['id_source'] = $id_source; |
|
| 795 | - $data['format_source'] = 'vam'; |
|
| 796 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 797 | - $SI->add($data); |
|
| 798 | - unset($data); |
|
| 769 | + $data = array(); |
|
| 770 | + //$data['id'] = $line['id']; // id not usable |
|
| 771 | + $data['id'] = trim($line['flight_id']); |
|
| 772 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 773 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 774 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 775 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 776 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 777 | + $data['speed'] = $line['gs']; // speed |
|
| 778 | + $data['heading'] = $line['heading']; // heading |
|
| 779 | + $data['latitude'] = $line['latitude']; // lat |
|
| 780 | + $data['longitude'] = $line['longitude']; // long |
|
| 781 | + $data['verticalrate'] = ''; // verticale rate |
|
| 782 | + $data['squawk'] = ''; // squawk |
|
| 783 | + $data['emergency'] = ''; // emergency |
|
| 784 | + //$data['datetime'] = $line['lastupdate']; |
|
| 785 | + $data['last_update'] = $line['last_update']; |
|
| 786 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 787 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 788 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 789 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 790 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 791 | + //$data['registration'] = $line['aircraft']; |
|
| 792 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 793 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 794 | + $data['id_source'] = $id_source; |
|
| 795 | + $data['format_source'] = 'vam'; |
|
| 796 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 797 | + $SI->add($data); |
|
| 798 | + unset($data); |
|
| 799 | 799 | } |
| 800 | 800 | if ($globalDebug) echo 'No more data...'."\n"; |
| 801 | 801 | unset($buffer); |
| 802 | 802 | unset($all_data); |
| 803 | - } |
|
| 804 | - //$last_exec['phpvmacars'] = time(); |
|
| 805 | - $last_exec[$id]['last'] = time(); |
|
| 803 | + } |
|
| 804 | + //$last_exec['phpvmacars'] = time(); |
|
| 805 | + $last_exec[$id]['last'] = time(); |
|
| 806 | 806 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 807 | 807 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') { |
| 808 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 809 | - //$last_exec[$id]['last'] = time(); |
|
| 808 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 809 | + //$last_exec[$id]['last'] = time(); |
|
| 810 | 810 | |
| 811 | - //$read = array( $sockets[$id] ); |
|
| 812 | - $read = $sockets; |
|
| 813 | - $write = NULL; |
|
| 814 | - $e = NULL; |
|
| 815 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 816 | - if ($e != NULL) var_dump($e); |
|
| 817 | - if ($n > 0) { |
|
| 811 | + //$read = array( $sockets[$id] ); |
|
| 812 | + $read = $sockets; |
|
| 813 | + $write = NULL; |
|
| 814 | + $e = NULL; |
|
| 815 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 816 | + if ($e != NULL) var_dump($e); |
|
| 817 | + if ($n > 0) { |
|
| 818 | 818 | $reset = 0; |
| 819 | 819 | foreach ($read as $nb => $r) { |
| 820 | - //$value = $formats[$nb]; |
|
| 821 | - $format = $globalSources[$nb]['format']; |
|
| 822 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 823 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 824 | - } else { |
|
| 825 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 826 | - } |
|
| 827 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 828 | - //echo $buffer."\n"; |
|
| 829 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 830 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 831 | - $error = false; |
|
| 832 | - //$SI::del(); |
|
| 833 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 834 | - // SBS format is CSV format |
|
| 835 | - if ($buffer != '') { |
|
| 820 | + //$value = $formats[$nb]; |
|
| 821 | + $format = $globalSources[$nb]['format']; |
|
| 822 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 823 | + $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 824 | + } else { |
|
| 825 | + $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 826 | + } |
|
| 827 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 828 | + //echo $buffer."\n"; |
|
| 829 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 830 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 831 | + $error = false; |
|
| 832 | + //$SI::del(); |
|
| 833 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 834 | + // SBS format is CSV format |
|
| 835 | + if ($buffer != '') { |
|
| 836 | 836 | $tt[$format] = 0; |
| 837 | 837 | if ($format == 'acarssbs3') { |
| 838 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 839 | - $ACARS->add(trim($buffer)); |
|
| 840 | - $ACARS->deleteLiveAcarsData(); |
|
| 838 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 839 | + $ACARS->add(trim($buffer)); |
|
| 840 | + $ACARS->deleteLiveAcarsData(); |
|
| 841 | 841 | } elseif ($format == 'raw') { |
| 842 | - // AVR format |
|
| 843 | - $data = $SBS->parse($buffer); |
|
| 844 | - if (is_array($data)) { |
|
| 842 | + // AVR format |
|
| 843 | + $data = $SBS->parse($buffer); |
|
| 844 | + if (is_array($data)) { |
|
| 845 | 845 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 846 | 846 | $data['format_source'] = 'raw'; |
| 847 | 847 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 848 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 849 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 850 | - } |
|
| 851 | - } elseif ($format == 'flightgearsp') { |
|
| 852 | - //echo $buffer."\n"; |
|
| 853 | - if (strlen($buffer) > 5) { |
|
| 848 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 849 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 850 | + } |
|
| 851 | + } elseif ($format == 'flightgearsp') { |
|
| 852 | + //echo $buffer."\n"; |
|
| 853 | + if (strlen($buffer) > 5) { |
|
| 854 | 854 | $line = explode(',',$buffer); |
| 855 | 855 | $data = array(); |
| 856 | 856 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -866,124 +866,124 @@ discard block |
||
| 866 | 866 | $data['format_source'] = 'flightgearsp'; |
| 867 | 867 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 868 | 868 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 869 | - } |
|
| 870 | - } elseif ($format == 'acars') { |
|
| 871 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 872 | - $ACARS->add(trim($buffer)); |
|
| 873 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 874 | - $ACARS->deleteLiveAcarsData(); |
|
| 869 | + } |
|
| 870 | + } elseif ($format == 'acars') { |
|
| 871 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 872 | + $ACARS->add(trim($buffer)); |
|
| 873 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 874 | + $ACARS->deleteLiveAcarsData(); |
|
| 875 | 875 | } elseif ($format == 'flightgearmp') { |
| 876 | - if (substr($buffer,0,1) != '#') { |
|
| 876 | + if (substr($buffer,0,1) != '#') { |
|
| 877 | 877 | $data = array(); |
| 878 | 878 | //echo $buffer."\n"; |
| 879 | 879 | $line = explode(' ',$buffer); |
| 880 | 880 | if (count($line) == 11) { |
| 881 | - $userserver = explode('@',$line[0]); |
|
| 882 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 883 | - $data['ident'] = $userserver[0]; |
|
| 884 | - $data['registration'] = $userserver[0]; |
|
| 885 | - $data['latitude'] = $line[4]; |
|
| 886 | - $data['longitude'] = $line[5]; |
|
| 887 | - $data['altitude'] = $line[6]; |
|
| 888 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 889 | - $aircraft_type = $line[10]; |
|
| 890 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 891 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 892 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 881 | + $userserver = explode('@',$line[0]); |
|
| 882 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 883 | + $data['ident'] = $userserver[0]; |
|
| 884 | + $data['registration'] = $userserver[0]; |
|
| 885 | + $data['latitude'] = $line[4]; |
|
| 886 | + $data['longitude'] = $line[5]; |
|
| 887 | + $data['altitude'] = $line[6]; |
|
| 888 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 889 | + $aircraft_type = $line[10]; |
|
| 890 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 891 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 892 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 893 | + } |
|
| 893 | 894 | } |
| 894 | - } |
|
| 895 | 895 | } elseif ($format == 'beast') { |
| 896 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 897 | - die; |
|
| 896 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 897 | + die; |
|
| 898 | 898 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 899 | - $line = explode("\t", $buffer); |
|
| 900 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 899 | + $line = explode("\t", $buffer); |
|
| 900 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 901 | 901 | $key = $line[$k]; |
| 902 | - $lined[$key] = $line[$k+1]; |
|
| 903 | - } |
|
| 904 | - if (count($lined) > 3) { |
|
| 905 | - $data['hex'] = $lined['hexid']; |
|
| 906 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 907 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 908 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 909 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 910 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 911 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 912 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 913 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 914 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 915 | - $data['id_source'] = $id_source; |
|
| 916 | - $data['format_source'] = 'tsv'; |
|
| 917 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 918 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 919 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 920 | - unset($lined); |
|
| 921 | - unset($data); |
|
| 922 | - } else $error = true; |
|
| 902 | + $lined[$key] = $line[$k+1]; |
|
| 903 | + } |
|
| 904 | + if (count($lined) > 3) { |
|
| 905 | + $data['hex'] = $lined['hexid']; |
|
| 906 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 907 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 908 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 909 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 910 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 911 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 912 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 913 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 914 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 915 | + $data['id_source'] = $id_source; |
|
| 916 | + $data['format_source'] = 'tsv'; |
|
| 917 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 918 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 919 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 920 | + unset($lined); |
|
| 921 | + unset($data); |
|
| 922 | + } else $error = true; |
|
| 923 | 923 | } elseif ($format == 'aprs' && $use_aprs) { |
| 924 | - if ($aprs_connect == 0) { |
|
| 924 | + if ($aprs_connect == 0) { |
|
| 925 | 925 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 926 | 926 | $aprs_connect = 1; |
| 927 | - } |
|
| 927 | + } |
|
| 928 | 928 | |
| 929 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 929 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 930 | 930 | $aprs_last_tx = time(); |
| 931 | 931 | $data_aprs = "# Keep alive"; |
| 932 | 932 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 933 | - } |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 936 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 937 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 938 | - //echo $buffer."\n"; |
|
| 939 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 935 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 936 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 937 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 938 | + //echo $buffer."\n"; |
|
| 939 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 940 | 940 | $line = $APRS->parse($buffer); |
| 941 | 941 | //print_r($line); |
| 942 | 942 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 943 | - $aprs_last_tx = time(); |
|
| 944 | - $data = array(); |
|
| 945 | - //print_r($line); |
|
| 946 | - $data['hex'] = $line['address']; |
|
| 947 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 948 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 949 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 950 | - $data['ident'] = $line['ident']; |
|
| 951 | - $data['latitude'] = $line['latitude']; |
|
| 952 | - $data['longitude'] = $line['longitude']; |
|
| 953 | - //$data['verticalrate'] = $line[16]; |
|
| 954 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 955 | - else $data['speed'] = 0; |
|
| 956 | - $data['altitude'] = $line['altitude']; |
|
| 957 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 958 | - //else $data['heading'] = 0; |
|
| 959 | - $data['aircraft_type'] = $line['stealth']; |
|
| 960 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 961 | - $data['id_source'] = $id_source; |
|
| 962 | - $data['format_source'] = 'aprs'; |
|
| 963 | - $data['source_name'] = $line['source']; |
|
| 964 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 965 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 966 | - $aprsdate = strtotime($data['datetime']); |
|
| 967 | - // Accept data if time <= system time + 20s |
|
| 968 | - if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 943 | + $aprs_last_tx = time(); |
|
| 944 | + $data = array(); |
|
| 945 | + //print_r($line); |
|
| 946 | + $data['hex'] = $line['address']; |
|
| 947 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 948 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 949 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 950 | + $data['ident'] = $line['ident']; |
|
| 951 | + $data['latitude'] = $line['latitude']; |
|
| 952 | + $data['longitude'] = $line['longitude']; |
|
| 953 | + //$data['verticalrate'] = $line[16]; |
|
| 954 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 955 | + else $data['speed'] = 0; |
|
| 956 | + $data['altitude'] = $line['altitude']; |
|
| 957 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 958 | + //else $data['heading'] = 0; |
|
| 959 | + $data['aircraft_type'] = $line['stealth']; |
|
| 960 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 961 | + $data['id_source'] = $id_source; |
|
| 962 | + $data['format_source'] = 'aprs'; |
|
| 963 | + $data['source_name'] = $line['source']; |
|
| 964 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 965 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 966 | + $aprsdate = strtotime($data['datetime']); |
|
| 967 | + // Accept data if time <= system time + 20s |
|
| 968 | + if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 969 | 969 | $send = $SI->add($data); |
| 970 | - } else { |
|
| 970 | + } else { |
|
| 971 | 971 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 972 | 972 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 973 | - } |
|
| 974 | - unset($data); |
|
| 973 | + } |
|
| 974 | + unset($data); |
|
| 975 | 975 | } |
| 976 | 976 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
| 977 | 977 | echo '!! Weather Station not yet supported'."\n"; |
| 978 | 978 | } |
| 979 | 979 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 980 | 980 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 981 | - } |
|
| 981 | + } |
|
| 982 | 982 | } else { |
| 983 | - $line = explode(',', $buffer); |
|
| 984 | - if (count($line) > 20) { |
|
| 985 | - $data['hex'] = $line[4]; |
|
| 986 | - /* |
|
| 983 | + $line = explode(',', $buffer); |
|
| 984 | + if (count($line) > 20) { |
|
| 985 | + $data['hex'] = $line[4]; |
|
| 986 | + /* |
|
| 987 | 987 | $data['datetime'] = $line[6].' '.$line[7]; |
| 988 | 988 | date_default_timezone_set($globalTimezone); |
| 989 | 989 | $datetime = new DateTime($data['datetime']); |
@@ -991,29 +991,29 @@ discard block |
||
| 991 | 991 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 992 | 992 | date_default_timezone_set('UTC'); |
| 993 | 993 | */ |
| 994 | - // Force datetime to current UTC datetime |
|
| 995 | - date_default_timezone_set('UTC'); |
|
| 996 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 997 | - $data['ident'] = trim($line[10]); |
|
| 998 | - $data['latitude'] = $line[14]; |
|
| 999 | - $data['longitude'] = $line[15]; |
|
| 1000 | - $data['verticalrate'] = $line[16]; |
|
| 1001 | - $data['emergency'] = $line[20]; |
|
| 1002 | - $data['speed'] = $line[12]; |
|
| 1003 | - $data['squawk'] = $line[17]; |
|
| 1004 | - $data['altitude'] = $line[11]; |
|
| 1005 | - $data['heading'] = $line[13]; |
|
| 1006 | - $data['ground'] = $line[21]; |
|
| 1007 | - $data['emergency'] = $line[19]; |
|
| 1008 | - $data['format_source'] = 'sbs'; |
|
| 994 | + // Force datetime to current UTC datetime |
|
| 995 | + date_default_timezone_set('UTC'); |
|
| 996 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 997 | + $data['ident'] = trim($line[10]); |
|
| 998 | + $data['latitude'] = $line[14]; |
|
| 999 | + $data['longitude'] = $line[15]; |
|
| 1000 | + $data['verticalrate'] = $line[16]; |
|
| 1001 | + $data['emergency'] = $line[20]; |
|
| 1002 | + $data['speed'] = $line[12]; |
|
| 1003 | + $data['squawk'] = $line[17]; |
|
| 1004 | + $data['altitude'] = $line[11]; |
|
| 1005 | + $data['heading'] = $line[13]; |
|
| 1006 | + $data['ground'] = $line[21]; |
|
| 1007 | + $data['emergency'] = $line[19]; |
|
| 1008 | + $data['format_source'] = 'sbs'; |
|
| 1009 | 1009 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1010 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1011 | - $data['id_source'] = $id_source; |
|
| 1012 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1013 | - else $error = true; |
|
| 1014 | - unset($data); |
|
| 1015 | - } else $error = true; |
|
| 1016 | - if ($error) { |
|
| 1010 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1011 | + $data['id_source'] = $id_source; |
|
| 1012 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1013 | + else $error = true; |
|
| 1014 | + unset($data); |
|
| 1015 | + } else $error = true; |
|
| 1016 | + if ($error) { |
|
| 1017 | 1017 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1018 | 1018 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1019 | 1019 | } else { |
@@ -1029,13 +1029,13 @@ discard block |
||
| 1029 | 1029 | connect_all($sourceer); |
| 1030 | 1030 | $sourceer = array(); |
| 1031 | 1031 | } |
| 1032 | - } |
|
| 1032 | + } |
|
| 1033 | 1033 | } |
| 1034 | 1034 | // Sleep for xxx microseconds |
| 1035 | 1035 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1036 | - } else { |
|
| 1036 | + } else { |
|
| 1037 | 1037 | if ($format == 'flightgearmp') { |
| 1038 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1038 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1039 | 1039 | //@socket_close($r); |
| 1040 | 1040 | sleep($globalMinFetch); |
| 1041 | 1041 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1044,9 +1044,9 @@ discard block |
||
| 1044 | 1044 | break; |
| 1045 | 1045 | |
| 1046 | 1046 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1047 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1048 | - else $tt[$format] = 0; |
|
| 1049 | - if ($tt[$format] > 30) { |
|
| 1047 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1048 | + else $tt[$format] = 0; |
|
| 1049 | + if ($tt[$format] > 30) { |
|
| 1050 | 1050 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1051 | 1051 | //@socket_close($r); |
| 1052 | 1052 | sleep(2); |
@@ -1057,23 +1057,23 @@ discard block |
||
| 1057 | 1057 | //connect_all($globalSources); |
| 1058 | 1058 | $tt[$format]=0; |
| 1059 | 1059 | break; |
| 1060 | - } |
|
| 1060 | + } |
|
| 1061 | + } |
|
| 1061 | 1062 | } |
| 1062 | - } |
|
| 1063 | 1063 | } |
| 1064 | - } else { |
|
| 1064 | + } else { |
|
| 1065 | 1065 | $error = socket_strerror(socket_last_error()); |
| 1066 | 1066 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1067 | 1067 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
| 1068 | 1068 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1069 | 1069 | // Restart the script if possible |
| 1070 | 1070 | if (is_array($sockets)) { |
| 1071 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1071 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1072 | 1072 | |
| 1073 | - foreach ($sockets as $sock) { |
|
| 1073 | + foreach ($sockets as $sock) { |
|
| 1074 | 1074 | @socket_shutdown($sock,2); |
| 1075 | 1075 | @socket_close($sock); |
| 1076 | - } |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | 1078 | } |
| 1079 | 1079 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1084,13 +1084,13 @@ discard block |
||
| 1084 | 1084 | if ($reset > 40) exit('Too many attempts...'); |
| 1085 | 1085 | connect_all($globalSources); |
| 1086 | 1086 | } |
| 1087 | - } |
|
| 1087 | + } |
|
| 1088 | 1088 | } |
| 1089 | 1089 | if ($globalDaemon === false) { |
| 1090 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1091 | - $SI->checkAll(); |
|
| 1090 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1091 | + $SI->checkAll(); |
|
| 1092 | + } |
|
| 1092 | 1093 | } |
| 1093 | - } |
|
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | 1096 | ?> |
@@ -9,16 +9,16 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 10 | 10 | |
| 11 | 11 | class SpotterImport { |
| 12 | - private $all_flights = array(); |
|
| 13 | - private $last_delete_hourly = 0; |
|
| 14 | - private $last_delete = 0; |
|
| 15 | - private $stats = array(); |
|
| 16 | - private $tmd = 0; |
|
| 17 | - private $source_location = array(); |
|
| 18 | - public $db = null; |
|
| 19 | - public $nb = 0; |
|
| 20 | - |
|
| 21 | - public function __construct($dbc = null) { |
|
| 12 | + private $all_flights = array(); |
|
| 13 | + private $last_delete_hourly = 0; |
|
| 14 | + private $last_delete = 0; |
|
| 15 | + private $stats = array(); |
|
| 16 | + private $tmd = 0; |
|
| 17 | + private $source_location = array(); |
|
| 18 | + public $db = null; |
|
| 19 | + public $nb = 0; |
|
| 20 | + |
|
| 21 | + public function __construct($dbc = null) { |
|
| 22 | 22 | global $globalBeta; |
| 23 | 23 | $Connection = new Connection($dbc); |
| 24 | 24 | $this->db = $Connection->db(); |
@@ -29,18 +29,18 @@ discard block |
||
| 29 | 29 | $currentdate = date('Y-m-d'); |
| 30 | 30 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 31 | 31 | if (!empty($sourcestat)) { |
| 32 | - foreach($sourcestat as $srcst) { |
|
| 33 | - $type = $srcst['stats_type']; |
|
| 32 | + foreach($sourcestat as $srcst) { |
|
| 33 | + $type = $srcst['stats_type']; |
|
| 34 | 34 | if ($type == 'polar' || $type == 'hist') { |
| 35 | - $source = $srcst['source_name']; |
|
| 36 | - $data = $srcst['source_data']; |
|
| 37 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 38 | - } |
|
| 39 | - } |
|
| 35 | + $source = $srcst['source_name']; |
|
| 36 | + $data = $srcst['source_data']; |
|
| 37 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + } |
|
| 40 | 41 | } |
| 41 | - } |
|
| 42 | 42 | |
| 43 | - public function get_Schedule($id,$ident) { |
|
| 43 | + public function get_Schedule($id,$ident) { |
|
| 44 | 44 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 45 | 45 | // Get schedule here, so it's done only one time |
| 46 | 46 | |
@@ -60,42 +60,42 @@ discard block |
||
| 60 | 60 | $operator = $Spotter->getOperator($ident); |
| 61 | 61 | $scheduleexist = false; |
| 62 | 62 | if ($Schedule->checkSchedule($operator) == 0) { |
| 63 | - $operator = $Translation->checkTranslation($ident); |
|
| 64 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
| 63 | + $operator = $Translation->checkTranslation($ident); |
|
| 64 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
| 65 | 65 | $schedule = $Schedule->fetchSchedule($operator); |
| 66 | 66 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 67 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 68 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 69 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 70 | - // Should also check if route schedule = route from DB |
|
| 71 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
| 67 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 68 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 69 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 70 | + // Should also check if route schedule = route from DB |
|
| 71 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
| 72 | 72 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
| 73 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 74 | - if (trim($airport_icao) != '') { |
|
| 73 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 74 | + if (trim($airport_icao) != '') { |
|
| 75 | 75 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 76 | 76 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
| 77 | - } |
|
| 77 | + } |
|
| 78 | + } |
|
| 78 | 79 | } |
| 79 | - } |
|
| 80 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 80 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 81 | 81 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
| 82 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 83 | - if (trim($airport_icao) != '') { |
|
| 82 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 83 | + if (trim($airport_icao) != '') { |
|
| 84 | 84 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 85 | 85 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
| 86 | - } |
|
| 86 | + } |
|
| 87 | + } |
|
| 87 | 88 | } |
| 88 | - } |
|
| 89 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 89 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 90 | 90 | } |
| 91 | - } else $scheduleexist = true; |
|
| 91 | + } else $scheduleexist = true; |
|
| 92 | 92 | } else $scheduleexist = true; |
| 93 | 93 | // close connection, at least one way will work ? |
| 94 | - if ($scheduleexist) { |
|
| 94 | + if ($scheduleexist) { |
|
| 95 | 95 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 96 | - $sch = $Schedule->getSchedule($operator); |
|
| 96 | + $sch = $Schedule->getSchedule($operator); |
|
| 97 | 97 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | $Spotter->db = null; |
| 100 | 100 | $Schedule->db = null; |
| 101 | 101 | $Translation->db = null; |
@@ -110,92 +110,92 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | */ |
| 112 | 112 | } |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - public function checkAll() { |
|
| 115 | + public function checkAll() { |
|
| 116 | 116 | global $globalDebug; |
| 117 | 117 | if ($globalDebug) echo "Update last seen flights data...\n"; |
| 118 | 118 | foreach ($this->all_flights as $key => $flight) { |
| 119 | - if (isset($this->all_flights[$key]['id'])) { |
|
| 119 | + if (isset($this->all_flights[$key]['id'])) { |
|
| 120 | 120 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 121 | - $Spotter = new Spotter($this->db); |
|
| 122 | - $real_arrival = $this->arrival($key); |
|
| 123 | - $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 124 | - } |
|
| 121 | + $Spotter = new Spotter($this->db); |
|
| 122 | + $real_arrival = $this->arrival($key); |
|
| 123 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 124 | + } |
|
| 125 | + } |
|
| 125 | 126 | } |
| 126 | - } |
|
| 127 | 127 | |
| 128 | - public function arrival($key) { |
|
| 128 | + public function arrival($key) { |
|
| 129 | 129 | global $globalClosestMinDist, $globalDebug; |
| 130 | 130 | if ($globalDebug) echo 'Update arrival...'."\n"; |
| 131 | 131 | $Spotter = new Spotter($this->db); |
| 132 | - $airport_icao = ''; |
|
| 133 | - $airport_time = ''; |
|
| 134 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 132 | + $airport_icao = ''; |
|
| 133 | + $airport_time = ''; |
|
| 134 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 135 | 135 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 136 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 137 | - if (isset($closestAirports[0])) { |
|
| 138 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 139 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 140 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 141 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 142 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 143 | - foreach ($closestAirports as $airport) { |
|
| 144 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 145 | - $airport_icao = $airport['icao']; |
|
| 146 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 147 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 148 | - break; |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 152 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 153 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 154 | - } else { |
|
| 155 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 156 | - } |
|
| 157 | - } else { |
|
| 158 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - } else { |
|
| 162 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 163 | - } |
|
| 164 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - public function del() { |
|
| 136 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 137 | + if (isset($closestAirports[0])) { |
|
| 138 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 139 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 140 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 141 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 142 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 143 | + foreach ($closestAirports as $airport) { |
|
| 144 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 145 | + $airport_icao = $airport['icao']; |
|
| 146 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 147 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 148 | + break; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 152 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 153 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 154 | + } else { |
|
| 155 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 156 | + } |
|
| 157 | + } else { |
|
| 158 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + } else { |
|
| 162 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 163 | + } |
|
| 164 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + public function del() { |
|
| 170 | 170 | global $globalDebug; |
| 171 | 171 | // Delete old infos |
| 172 | 172 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 173 | 173 | foreach ($this->all_flights as $key => $flight) { |
| 174 | - if (isset($flight['lastupdate'])) { |
|
| 175 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 176 | - if (isset($this->all_flights[$key]['id'])) { |
|
| 177 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 174 | + if (isset($flight['lastupdate'])) { |
|
| 175 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
| 176 | + if (isset($this->all_flights[$key]['id'])) { |
|
| 177 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 178 | 178 | /* |
| 179 | 179 | $SpotterLive = new SpotterLive(); |
| 180 | 180 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
| 181 | 181 | $SpotterLive->db = null; |
| 182 | 182 | */ |
| 183 | - $real_arrival = $this->arrival($key); |
|
| 184 | - $Spotter = new Spotter($this->db); |
|
| 185 | - if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
| 183 | + $real_arrival = $this->arrival($key); |
|
| 184 | + $Spotter = new Spotter($this->db); |
|
| 185 | + if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
| 186 | 186 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
| 187 | 187 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 188 | 188 | } |
| 189 | 189 | // Put in archive |
| 190 | 190 | // $Spotter->db = null; |
| 191 | - } |
|
| 192 | - unset($this->all_flights[$key]); |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - public function add($line) { |
|
| 191 | + } |
|
| 192 | + unset($this->all_flights[$key]); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + public function add($line) { |
|
| 199 | 199 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
| 200 | 200 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 201 | 201 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -220,18 +220,18 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | // SBS format is CSV format |
| 222 | 222 | if(is_array($line) && isset($line['hex'])) { |
| 223 | - //print_r($line); |
|
| 224 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 223 | + //print_r($line); |
|
| 224 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 225 | 225 | |
| 226 | 226 | // Increment message number |
| 227 | 227 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 228 | - $current_date = date('Y-m-d'); |
|
| 229 | - $source = $line['source_name']; |
|
| 230 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 231 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 232 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 233 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 234 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 228 | + $current_date = date('Y-m-d'); |
|
| 229 | + $source = $line['source_name']; |
|
| 230 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 231 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 232 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 233 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 234 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /* |
@@ -247,40 +247,40 @@ discard block |
||
| 247 | 247 | //$this->db = $dbc; |
| 248 | 248 | |
| 249 | 249 | //$hex = trim($line['hex']); |
| 250 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 251 | - else $id = trim($line['id']); |
|
| 250 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 251 | + else $id = trim($line['id']); |
|
| 252 | 252 | |
| 253 | 253 | if (!isset($this->all_flights[$id])) { |
| 254 | - $this->all_flights[$id] = array(); |
|
| 255 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 256 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
| 257 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 258 | - if (!isset($line['id'])) { |
|
| 254 | + $this->all_flights[$id] = array(); |
|
| 255 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 256 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
| 257 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 258 | + if (!isset($line['id'])) { |
|
| 259 | 259 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 260 | 260 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
| 261 | 261 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 262 | 262 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 263 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 264 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 265 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 263 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 264 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 265 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | //print_r($this->all_flights); |
| 269 | 269 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 270 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 271 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 270 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 271 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 272 | 272 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 273 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 274 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 273 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 274 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 275 | 275 | $timeelapsed = microtime(true); |
| 276 | 276 | $Spotter = new Spotter($this->db); |
| 277 | 277 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 278 | 278 | $Spotter->db = null; |
| 279 | 279 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 280 | 280 | if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
| 281 | - } |
|
| 282 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 283 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 281 | + } |
|
| 282 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 283 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 284 | 284 | } |
| 285 | 285 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 286 | 286 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
@@ -304,9 +304,9 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 306 | 306 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
| 307 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 307 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 308 | 308 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 309 | - } else { |
|
| 309 | + } else { |
|
| 310 | 310 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 311 | 311 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 312 | 312 | /* |
@@ -315,41 +315,41 @@ discard block |
||
| 315 | 315 | print_r($line); |
| 316 | 316 | */ |
| 317 | 317 | return ''; |
| 318 | - } |
|
| 318 | + } |
|
| 319 | 319 | } else { |
| 320 | 320 | date_default_timezone_set('UTC'); |
| 321 | 321 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 325 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 325 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 326 | 326 | } |
| 327 | 327 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 328 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 328 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 329 | 329 | } |
| 330 | 330 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 331 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
| 331 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
| 332 | 332 | } |
| 333 | 333 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 334 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
| 334 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
| 338 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 339 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 339 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 340 | 340 | $timeelapsed = microtime(true); |
| 341 | - $Spotter = new Spotter($this->db); |
|
| 342 | - $fromsource = NULL; |
|
| 343 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 344 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 341 | + $Spotter = new Spotter($this->db); |
|
| 342 | + $fromsource = NULL; |
|
| 343 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 344 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 345 | 345 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 346 | 346 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 347 | 347 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 348 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 348 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 349 | 349 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 350 | 350 | $Spotter->db = null; |
| 351 | 351 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | /* |
| 355 | 355 | if (!isset($line['id'])) { |
@@ -359,26 +359,26 @@ discard block |
||
| 359 | 359 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 360 | 360 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 361 | 361 | */ |
| 362 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 362 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 363 | 363 | |
| 364 | - //$putinarchive = true; |
|
| 365 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 364 | + //$putinarchive = true; |
|
| 365 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 366 | 366 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
| 367 | - } |
|
| 368 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 367 | + } |
|
| 368 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 369 | 369 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
| 370 | - } |
|
| 371 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 372 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 373 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 370 | + } |
|
| 371 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 372 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 373 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 374 | 374 | $timeelapsed = microtime(true); |
| 375 | 375 | $Spotter = new Spotter($this->db); |
| 376 | 376 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 377 | 377 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 378 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 378 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 379 | 379 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 380 | 380 | |
| 381 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 381 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 382 | 382 | $timeelapsed = microtime(true); |
| 383 | 383 | $Spotter = new Spotter($this->db); |
| 384 | 384 | $route = $Spotter->getRouteInfo(trim($line['ident'])); |
@@ -392,43 +392,43 @@ discard block |
||
| 392 | 392 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 393 | 393 | |
| 394 | 394 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 395 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 396 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 395 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 396 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 397 | 397 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
| 398 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 399 | - } |
|
| 398 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 399 | + } |
|
| 400 | 400 | } |
| 401 | 401 | if (!isset($globalFork)) $globalFork = TRUE; |
| 402 | 402 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 403 | 403 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
| 404 | 404 | } |
| 405 | - } |
|
| 405 | + } |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | if (isset($line['speed']) && $line['speed'] != '') { |
| 409 | 409 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 410 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 411 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 412 | - //$dataFound = true; |
|
| 410 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 411 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 412 | + //$dataFound = true; |
|
| 413 | 413 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 414 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 415 | - if ($distance > 1000 && $distance < 10000) { |
|
| 416 | - // use datetime |
|
| 414 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 415 | + if ($distance > 1000 && $distance < 10000) { |
|
| 416 | + // use datetime |
|
| 417 | 417 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 418 | 418 | $speed = $speed*3.6; |
| 419 | 419 | if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
| 420 | 420 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 421 | - } |
|
| 421 | + } |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | |
| 425 | 425 | |
| 426 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 427 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 428 | - else unset($timediff); |
|
| 429 | - if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
| 426 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 427 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 428 | + else unset($timediff); |
|
| 429 | + if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
| 430 | 430 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
| 431 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 431 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 432 | 432 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 433 | 433 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 434 | 434 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -442,16 +442,16 @@ discard block |
||
| 442 | 442 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 443 | 443 | $this->tmd = 0; |
| 444 | 444 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 445 | - } |
|
| 445 | + } |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 449 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 449 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 450 | 450 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 451 | 451 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
| 452 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 453 | - $dataFound = true; |
|
| 454 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 452 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 453 | + $dataFound = true; |
|
| 454 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 455 | 455 | } |
| 456 | 456 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 457 | 457 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -462,20 +462,20 @@ discard block |
||
| 462 | 462 | //$putinarchive = true; |
| 463 | 463 | } |
| 464 | 464 | */ |
| 465 | - /* |
|
| 465 | + /* |
|
| 466 | 466 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
| 467 | 467 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
| 468 | 468 | } |
| 469 | 469 | */ |
| 470 | 470 | } |
| 471 | 471 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 472 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 473 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 472 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 473 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 474 | 474 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 475 | 475 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
| 476 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 477 | - $dataFound = true; |
|
| 478 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 476 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 477 | + $dataFound = true; |
|
| 478 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 479 | 479 | } |
| 480 | 480 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 481 | 481 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -493,54 +493,54 @@ discard block |
||
| 493 | 493 | */ |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - } else if ($globalDebug && $timediff > 20) { |
|
| 496 | + } else if ($globalDebug && $timediff > 20) { |
|
| 497 | 497 | $this->tmd = $this->tmd + 1; |
| 498 | 498 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 499 | 499 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
| 500 | 500 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 501 | 501 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 502 | - } |
|
| 502 | + } |
|
| 503 | 503 | } |
| 504 | 504 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 505 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 506 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 505 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 506 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 507 | 507 | } |
| 508 | 508 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 509 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 510 | - //$dataFound = true; |
|
| 509 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 510 | + //$dataFound = true; |
|
| 511 | 511 | } |
| 512 | 512 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 513 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 513 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 514 | 514 | } |
| 515 | 515 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 516 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 516 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 517 | 517 | } |
| 518 | 518 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 519 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 520 | - //$dataFound = true; |
|
| 519 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 520 | + //$dataFound = true; |
|
| 521 | 521 | } |
| 522 | 522 | if (isset($line['ground']) && $line['ground'] != '') { |
| 523 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 523 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 524 | 524 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 525 | 525 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 526 | 526 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 527 | 527 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
| 528 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 528 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 529 | 529 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 530 | - } |
|
| 531 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 532 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 533 | - //$dataFound = true; |
|
| 530 | + } |
|
| 531 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 532 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 533 | + //$dataFound = true; |
|
| 534 | 534 | } |
| 535 | 535 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 536 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
| 537 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 538 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 539 | - $highlight = ''; |
|
| 540 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 541 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 542 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 543 | - if ($highlight != '') { |
|
| 536 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
| 537 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 538 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 539 | + $highlight = ''; |
|
| 540 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 541 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 542 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 543 | + if ($highlight != '') { |
|
| 544 | 544 | $timeelapsed = microtime(true); |
| 545 | 545 | $Spotter = new Spotter($this->db); |
| 546 | 546 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
@@ -549,38 +549,38 @@ discard block |
||
| 549 | 549 | |
| 550 | 550 | //$putinarchive = true; |
| 551 | 551 | //$highlight = ''; |
| 552 | - } |
|
| 552 | + } |
|
| 553 | 553 | |
| 554 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 555 | - //$dataFound = true; |
|
| 554 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 555 | + //$dataFound = true; |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 559 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 559 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 560 | 560 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
| 561 | 561 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 562 | 562 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 563 | 563 | //$dataFound = true; |
| 564 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 564 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 568 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 568 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | if (isset($line['heading']) && $line['heading'] != '') { |
| 572 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 573 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 574 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 575 | - //$dataFound = true; |
|
| 572 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 573 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 574 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 575 | + //$dataFound = true; |
|
| 576 | 576 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 577 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 578 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 579 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 580 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 577 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 578 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 579 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 580 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 581 | 581 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 582 | - // If not enough messages and ACARS set heading to 0 |
|
| 583 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 582 | + // If not enough messages and ACARS set heading to 0 |
|
| 583 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 584 | 584 | } |
| 585 | 585 | if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 586 | 586 | elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -591,119 +591,119 @@ discard block |
||
| 591 | 591 | //if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 592 | 592 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 593 | 593 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
| 594 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
| 595 | - if ($this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 596 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 597 | - //print_r($this->all_flights); |
|
| 598 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 599 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 600 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 594 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
| 595 | + if ($this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 596 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 597 | + //print_r($this->all_flights); |
|
| 598 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 599 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 600 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 601 | 601 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
| 602 | 602 | $timeelapsed = microtime(true); |
| 603 | 603 | $SpotterLive = new SpotterLive($this->db); |
| 604 | 604 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
| 605 | - $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
| 606 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 605 | + $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
| 606 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 607 | 607 | } elseif (isset($line['id'])) { |
| 608 | - $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
| 609 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 608 | + $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
| 609 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 610 | 610 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 611 | - $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
| 612 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 611 | + $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
| 612 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 613 | 613 | } else $recent_ident = ''; |
| 614 | 614 | $SpotterLive->db=null; |
| 615 | 615 | |
| 616 | 616 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 617 | 617 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 618 | - } else { |
|
| 618 | + } else { |
|
| 619 | 619 | $recent_ident = ''; |
| 620 | 620 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
| 621 | - } |
|
| 622 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 623 | - if($recent_ident == "") |
|
| 624 | - { |
|
| 621 | + } |
|
| 622 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 623 | + if($recent_ident == "") |
|
| 624 | + { |
|
| 625 | 625 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 626 | 626 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 627 | 627 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 628 | 628 | //adds the spotter data for the archive |
| 629 | 629 | $ignoreImport = false; |
| 630 | 630 | foreach($globalAirportIgnore as $airportIgnore) { |
| 631 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 631 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 632 | 632 | $ignoreImport = true; |
| 633 | - } |
|
| 633 | + } |
|
| 634 | 634 | } |
| 635 | 635 | if (count($globalAirportAccept) > 0) { |
| 636 | - $ignoreImport = true; |
|
| 637 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 636 | + $ignoreImport = true; |
|
| 637 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 638 | 638 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 639 | - $ignoreImport = false; |
|
| 639 | + $ignoreImport = false; |
|
| 640 | + } |
|
| 640 | 641 | } |
| 641 | - } |
|
| 642 | 642 | } |
| 643 | 643 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 644 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 644 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 645 | 645 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
| 646 | - $ignoreImport = true; |
|
| 646 | + $ignoreImport = true; |
|
| 647 | + } |
|
| 647 | 648 | } |
| 648 | - } |
|
| 649 | 649 | } |
| 650 | 650 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 651 | - $ignoreImport = true; |
|
| 652 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 651 | + $ignoreImport = true; |
|
| 652 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
| 653 | 653 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
| 654 | - $ignoreImport = false; |
|
| 654 | + $ignoreImport = false; |
|
| 655 | + } |
|
| 655 | 656 | } |
| 656 | - } |
|
| 657 | 657 | } |
| 658 | 658 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 659 | - $ignoreImport = true; |
|
| 660 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 659 | + $ignoreImport = true; |
|
| 660 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 661 | 661 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 662 | - $ignoreImport = false; |
|
| 662 | + $ignoreImport = false; |
|
| 663 | + } |
|
| 663 | 664 | } |
| 664 | - } |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | if (!$ignoreImport) { |
| 668 | - $highlight = ''; |
|
| 669 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 670 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 671 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 672 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 673 | - $timeelapsed = microtime(true); |
|
| 674 | - $Spotter = new Spotter($this->db); |
|
| 675 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
|
| 676 | - $Spotter->db = null; |
|
| 677 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 668 | + $highlight = ''; |
|
| 669 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 670 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 671 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 672 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 673 | + $timeelapsed = microtime(true); |
|
| 674 | + $Spotter = new Spotter($this->db); |
|
| 675 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
|
| 676 | + $Spotter->db = null; |
|
| 677 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 678 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 679 | 679 | |
| 680 | - // Add source stat in DB |
|
| 681 | - $Stats = new Stats($this->db); |
|
| 682 | - if (!empty($this->stats)) { |
|
| 680 | + // Add source stat in DB |
|
| 681 | + $Stats = new Stats($this->db); |
|
| 682 | + if (!empty($this->stats)) { |
|
| 683 | 683 | if ($globalDebug) echo 'Add source stats : '; |
| 684 | - foreach($this->stats as $date => $data) { |
|
| 685 | - foreach($data as $source => $sourced) { |
|
| 686 | - //print_r($sourced); |
|
| 687 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 688 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 689 | - if (isset($sourced['msg'])) { |
|
| 690 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 691 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 692 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 693 | - unset($this->stats[$date][$source]['msg']); |
|
| 694 | - } |
|
| 695 | - } |
|
| 696 | - } |
|
| 697 | - if ($date != date('Y-m-d')) { |
|
| 698 | - unset($this->stats[$date]); |
|
| 699 | - } |
|
| 700 | - } |
|
| 701 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 702 | - |
|
| 703 | - } |
|
| 704 | - $Stats->db = null; |
|
| 684 | + foreach($this->stats as $date => $data) { |
|
| 685 | + foreach($data as $source => $sourced) { |
|
| 686 | + //print_r($sourced); |
|
| 687 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 688 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 689 | + if (isset($sourced['msg'])) { |
|
| 690 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 691 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 692 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 693 | + unset($this->stats[$date][$source]['msg']); |
|
| 694 | + } |
|
| 695 | + } |
|
| 696 | + } |
|
| 697 | + if ($date != date('Y-m-d')) { |
|
| 698 | + unset($this->stats[$date]); |
|
| 699 | + } |
|
| 700 | + } |
|
| 701 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 702 | + |
|
| 703 | + } |
|
| 704 | + $Stats->db = null; |
|
| 705 | 705 | |
| 706 | - $this->del(); |
|
| 706 | + $this->del(); |
|
| 707 | 707 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
| 708 | 708 | //$ignoreImport = false; |
| 709 | 709 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -721,18 +721,18 @@ discard block |
||
| 721 | 721 | */ |
| 722 | 722 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 723 | 723 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 724 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 725 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 726 | - $SpotterLive = new SpotterLive($this->db); |
|
| 727 | - $SpotterLive->deleteLiveSpotterData(); |
|
| 728 | - $SpotterLive->db=null; |
|
| 729 | - if ($globalDebug) echo " Done\n"; |
|
| 730 | - $this->last_delete = time(); |
|
| 724 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 725 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 726 | + $SpotterLive = new SpotterLive($this->db); |
|
| 727 | + $SpotterLive->deleteLiveSpotterData(); |
|
| 728 | + $SpotterLive->db=null; |
|
| 729 | + if ($globalDebug) echo " Done\n"; |
|
| 730 | + $this->last_delete = time(); |
|
| 731 | 731 | } |
| 732 | - } else { |
|
| 732 | + } else { |
|
| 733 | 733 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
| 734 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
| 735 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 734 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
| 735 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 736 | 736 | } |
| 737 | 737 | if (isset($globalDaemon) && !$globalDaemon) { |
| 738 | 738 | $Spotter = new Spotter($this->db); |
@@ -740,14 +740,14 @@ discard block |
||
| 740 | 740 | $Spotter->db = null; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - } |
|
| 743 | + } |
|
| 744 | 744 | } |
| 745 | - } |
|
| 746 | - //adds the spotter LIVE data |
|
| 747 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 748 | - //echo "\nAdd in Live !! \n"; |
|
| 749 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
| 750 | - if ($globalDebug) { |
|
| 745 | + } |
|
| 746 | + //adds the spotter LIVE data |
|
| 747 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 748 | + //echo "\nAdd in Live !! \n"; |
|
| 749 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
| 750 | + if ($globalDebug) { |
|
| 751 | 751 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 752 | 752 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
| 753 | 753 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -755,49 +755,49 @@ discard block |
||
| 755 | 755 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
| 756 | 756 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
| 757 | 757 | } |
| 758 | - } |
|
| 759 | - $ignoreImport = false; |
|
| 760 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 761 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 758 | + } |
|
| 759 | + $ignoreImport = false; |
|
| 760 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 761 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 762 | 762 | |
| 763 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 764 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 765 | - $ignoreImport = true; |
|
| 763 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 764 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 765 | + $ignoreImport = true; |
|
| 766 | + } |
|
| 766 | 767 | } |
| 767 | - } |
|
| 768 | - if (count($globalAirportAccept) > 0) { |
|
| 769 | - $ignoreImport = true; |
|
| 770 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 771 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 768 | + if (count($globalAirportAccept) > 0) { |
|
| 769 | + $ignoreImport = true; |
|
| 770 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 771 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 772 | 772 | $ignoreImport = false; |
| 773 | - } |
|
| 773 | + } |
|
| 774 | 774 | } |
| 775 | - } |
|
| 776 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 775 | + } |
|
| 776 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 777 | 777 | foreach($globalAirlineIgnore as $airlineIgnore) { |
| 778 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 778 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 779 | 779 | $ignoreImport = true; |
| 780 | - } |
|
| 780 | + } |
|
| 781 | 781 | } |
| 782 | - } |
|
| 783 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 782 | + } |
|
| 783 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 784 | 784 | $ignoreImport = true; |
| 785 | 785 | foreach($globalAirlineAccept as $airlineAccept) { |
| 786 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 786 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 787 | 787 | $ignoreImport = false; |
| 788 | - } |
|
| 788 | + } |
|
| 789 | 789 | } |
| 790 | - } |
|
| 791 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 790 | + } |
|
| 791 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 792 | 792 | $ignoreImport = true; |
| 793 | 793 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
| 794 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 795 | - $ignoreImport = false; |
|
| 796 | - } |
|
| 794 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 795 | + $ignoreImport = false; |
|
| 796 | + } |
|
| 797 | + } |
|
| 797 | 798 | } |
| 798 | - } |
|
| 799 | 799 | |
| 800 | - if (!$ignoreImport) { |
|
| 800 | + if (!$ignoreImport) { |
|
| 801 | 801 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 802 | 802 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 803 | 803 | $timeelapsed = microtime(true); |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | if ($stats_heading == 16) $stats_heading = 0; |
| 837 | 837 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 838 | 838 | for ($i=0;$i<=15;$i++) { |
| 839 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 839 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 840 | 840 | } |
| 841 | 841 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 842 | 842 | } else { |
@@ -849,11 +849,11 @@ discard block |
||
| 849 | 849 | //var_dump($this->stats); |
| 850 | 850 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 851 | 851 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 852 | - end($this->stats[$current_date][$source]['hist']); |
|
| 853 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 852 | + end($this->stats[$current_date][$source]['hist']); |
|
| 853 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 854 | 854 | } else $mini = 0; |
| 855 | 855 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 856 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 856 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 857 | 857 | } |
| 858 | 858 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 859 | 859 | } else { |
@@ -870,22 +870,22 @@ discard block |
||
| 870 | 870 | |
| 871 | 871 | |
| 872 | 872 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 873 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 874 | - $SpotterLive = new SpotterLive($this->db); |
|
| 875 | - $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 876 | - $SpotterLive->db = null; |
|
| 877 | - //SpotterLive->deleteLiveSpotterData(); |
|
| 878 | - if ($globalDebug) echo " Done\n"; |
|
| 879 | - $this->last_delete_hourly = time(); |
|
| 873 | + if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 874 | + $SpotterLive = new SpotterLive($this->db); |
|
| 875 | + $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 876 | + $SpotterLive->db = null; |
|
| 877 | + //SpotterLive->deleteLiveSpotterData(); |
|
| 878 | + if ($globalDebug) echo " Done\n"; |
|
| 879 | + $this->last_delete_hourly = time(); |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - } |
|
| 883 | - //$ignoreImport = false; |
|
| 882 | + } |
|
| 883 | + //$ignoreImport = false; |
|
| 884 | 884 | } |
| 885 | 885 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 886 | 886 | if ($send) return $this->all_flights[$id]; |
| 887 | - } |
|
| 887 | + } |
|
| 888 | + } |
|
| 888 | 889 | } |
| 889 | - } |
|
| 890 | 890 | } |
| 891 | 891 | ?> |