@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 17 | 17 | if (isset($globalMarine) && $globalMarine) { |
| 18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,40 +24,40 @@ discard block |
||
| 24 | 24 | // Check if schema is at latest version |
| 25 | 25 | $Connection = new Connection(); |
| 26 | 26 | if ($Connection->latest() === false) { |
| 27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 28 | - exit(); |
|
| 27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 28 | + exit(); |
|
| 29 | 29 | } |
| 30 | 30 | if (PHP_SAPI != 'cli') { |
| 31 | - echo "This script MUST be called from console, not a web browser."; |
|
| 31 | + echo "This script MUST be called from console, not a web browser."; |
|
| 32 | 32 | // exit(); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // This is to be compatible with old version of settings.php |
| 36 | 36 | if (!isset($globalSources)) { |
| 37 | - if (isset($globalSBS1Hosts)) { |
|
| 38 | - //$hosts = $globalSBS1Hosts; |
|
| 39 | - foreach ($globalSBS1Hosts as $host) { |
|
| 40 | - $globalSources[] = array('host' => $host); |
|
| 41 | - } |
|
| 42 | - } else { |
|
| 43 | - if (!isset($globalSBS1Host)) { |
|
| 44 | - echo '$globalSources MUST be defined !'; |
|
| 45 | - die; |
|
| 37 | + if (isset($globalSBS1Hosts)) { |
|
| 38 | + //$hosts = $globalSBS1Hosts; |
|
| 39 | + foreach ($globalSBS1Hosts as $host) { |
|
| 40 | + $globalSources[] = array('host' => $host); |
|
| 41 | + } |
|
| 42 | + } else { |
|
| 43 | + if (!isset($globalSBS1Host)) { |
|
| 44 | + echo '$globalSources MUST be defined !'; |
|
| 45 | + die; |
|
| 46 | 46 | } |
| 47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::')); |
| 53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 55 | 55 | if (isset($options['s'])) { |
| 56 | - $globalSources = array(); |
|
| 57 | - $globalSources[] = array('host' => $options['s']); |
|
| 56 | + $globalSources = array(); |
|
| 57 | + $globalSources[] = array('host' => $options['s']); |
|
| 58 | 58 | } elseif (isset($options['source'])) { |
| 59 | - $globalSources = array(); |
|
| 60 | - $globalSources[] = array('host' => $options['source']); |
|
| 59 | + $globalSources = array(); |
|
| 60 | + $globalSources[] = array('host' => $options['source']); |
|
| 61 | 61 | } |
| 62 | 62 | if (isset($options['aprsserverhost'])) $globalServerAPRShost = $options['aprsserverhost']; |
| 63 | 63 | if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 69 | 69 | else $id_source = 1; |
| 70 | 70 | if (isset($globalServer) && $globalServer) { |
| 71 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 72 | - $SI=new SpotterServer(); |
|
| 71 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 72 | + $SI=new SpotterServer(); |
|
| 73 | 73 | /* |
| 74 | 74 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 75 | 75 | $SI = new adsb2aprs(); |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | } else $SI=new SpotterImport($Connection->db); |
| 79 | 79 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 80 | 80 | if (isset($globalMarine) && $globalMarine) { |
| 81 | - $AIS = new AIS(); |
|
| 82 | - $MI = new MarineImport($Connection->db); |
|
| 81 | + $AIS = new AIS(); |
|
| 82 | + $MI = new MarineImport($Connection->db); |
|
| 83 | 83 | } |
| 84 | 84 | //$APRS=new APRS($Connection->db); |
| 85 | 85 | $SBS=new SBS(); |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | //$servertz = system('date +%Z'); |
| 90 | 90 | // signal handler - playing nice with sockets and dump1090 |
| 91 | 91 | if (function_exists('pcntl_fork')) { |
| 92 | - pcntl_signal(SIGINT, function() { |
|
| 93 | - global $sockets; |
|
| 94 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 95 | - die("Bye!\n"); |
|
| 96 | - }); |
|
| 97 | - pcntl_signal_dispatch(); |
|
| 92 | + pcntl_signal(SIGINT, function() { |
|
| 93 | + global $sockets; |
|
| 94 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 95 | + die("Bye!\n"); |
|
| 96 | + }); |
|
| 97 | + pcntl_signal_dispatch(); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // let's try and connect |
@@ -104,153 +104,153 @@ discard block |
||
| 104 | 104 | $reset = 0; |
| 105 | 105 | |
| 106 | 106 | function connect_all($hosts) { |
| 107 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 108 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 109 | - $reset++; |
|
| 110 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 111 | - foreach ($hosts as $id => $value) { |
|
| 107 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 108 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 109 | + $reset++; |
|
| 110 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 111 | + foreach ($hosts as $id => $value) { |
|
| 112 | 112 | $host = $value['host']; |
| 113 | 113 | $globalSources[$id]['last_exec'] = 0; |
| 114 | 114 | // Here we check type of source(s) |
| 115 | 115 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 116 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 117 | - //$formats[$id] = 'deltadbtxt'; |
|
| 118 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 119 | - //$last_exec['deltadbtxt'] = 0; |
|
| 120 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 121 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 122 | - //$formats[$id] = 'vatsimtxt'; |
|
| 123 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 124 | - //$last_exec['vatsimtxt'] = 0; |
|
| 125 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 126 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 127 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 128 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 129 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 130 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 131 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 132 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 133 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 134 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 135 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 136 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 137 | - //$formats[$id] = 'radarvirtueljson'; |
|
| 138 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 139 | - //$last_exec['radarvirtueljson'] = 0; |
|
| 140 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 141 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 142 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 143 | - exit(0); |
|
| 144 | - } |
|
| 145 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 146 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 147 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 148 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 149 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 150 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 151 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 152 | - exit(0); |
|
| 153 | - } |
|
| 154 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 155 | - //$formats[$id] = 'phpvmacars'; |
|
| 156 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 157 | - //$last_exec['phpvmacars'] = 0; |
|
| 158 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 159 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 160 | - //$formats[$id] = 'phpvmacars'; |
|
| 161 | - $globalSources[$id]['format'] = 'vam'; |
|
| 162 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 163 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 164 | - //$formats[$id] = 'whazzup'; |
|
| 165 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 166 | - //$last_exec['whazzup'] = 0; |
|
| 167 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 168 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 169 | - //$formats[$id] = 'pirepsjson'; |
|
| 170 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 171 | - //$last_exec['pirepsjson'] = 0; |
|
| 172 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 173 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 174 | - //$formats[$id] = 'fr24json'; |
|
| 175 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 176 | - //$last_exec['fr24json'] = 0; |
|
| 177 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 178 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 179 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 180 | - exit(0); |
|
| 181 | - } |
|
| 182 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 183 | - //$formats[$id] = 'fr24json'; |
|
| 184 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 185 | - //$last_exec['fr24json'] = 0; |
|
| 186 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 187 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 188 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 189 | - exit(0); |
|
| 190 | - } |
|
| 191 | - //} else if (preg_match('/10001/',$host)) { |
|
| 192 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 193 | - //$formats[$id] = 'tsv'; |
|
| 194 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 195 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 196 | - } |
|
| 197 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 198 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 199 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 200 | - if ($idf !== false) { |
|
| 201 | - $httpfeeds[$id] = $idf; |
|
| 202 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 203 | - } |
|
| 204 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 205 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 206 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 207 | - $hostport = explode(':',$host); |
|
| 208 | - if (isset($hostport[1])) { |
|
| 116 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 117 | + //$formats[$id] = 'deltadbtxt'; |
|
| 118 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 119 | + //$last_exec['deltadbtxt'] = 0; |
|
| 120 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 121 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 122 | + //$formats[$id] = 'vatsimtxt'; |
|
| 123 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 124 | + //$last_exec['vatsimtxt'] = 0; |
|
| 125 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 126 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 127 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 128 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 129 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 130 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 131 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 132 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 133 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 134 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 135 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 136 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 137 | + //$formats[$id] = 'radarvirtueljson'; |
|
| 138 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 139 | + //$last_exec['radarvirtueljson'] = 0; |
|
| 140 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 141 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 142 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 143 | + exit(0); |
|
| 144 | + } |
|
| 145 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 146 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 147 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 148 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 149 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 150 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 151 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 152 | + exit(0); |
|
| 153 | + } |
|
| 154 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 155 | + //$formats[$id] = 'phpvmacars'; |
|
| 156 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 157 | + //$last_exec['phpvmacars'] = 0; |
|
| 158 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 159 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 160 | + //$formats[$id] = 'phpvmacars'; |
|
| 161 | + $globalSources[$id]['format'] = 'vam'; |
|
| 162 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 163 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 164 | + //$formats[$id] = 'whazzup'; |
|
| 165 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 166 | + //$last_exec['whazzup'] = 0; |
|
| 167 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 168 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 169 | + //$formats[$id] = 'pirepsjson'; |
|
| 170 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 171 | + //$last_exec['pirepsjson'] = 0; |
|
| 172 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 173 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 174 | + //$formats[$id] = 'fr24json'; |
|
| 175 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 176 | + //$last_exec['fr24json'] = 0; |
|
| 177 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 178 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 179 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 180 | + exit(0); |
|
| 181 | + } |
|
| 182 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 183 | + //$formats[$id] = 'fr24json'; |
|
| 184 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 185 | + //$last_exec['fr24json'] = 0; |
|
| 186 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 187 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 188 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 189 | + exit(0); |
|
| 190 | + } |
|
| 191 | + //} else if (preg_match('/10001/',$host)) { |
|
| 192 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 193 | + //$formats[$id] = 'tsv'; |
|
| 194 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 195 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 196 | + } |
|
| 197 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 198 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 199 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 200 | + if ($idf !== false) { |
|
| 201 | + $httpfeeds[$id] = $idf; |
|
| 202 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 203 | + } |
|
| 204 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 205 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 206 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 207 | + $hostport = explode(':',$host); |
|
| 208 | + if (isset($hostport[1])) { |
|
| 209 | 209 | $port = $hostport[1]; |
| 210 | 210 | $hostn = $hostport[0]; |
| 211 | - } else { |
|
| 211 | + } else { |
|
| 212 | 212 | $port = $globalSources[$id]['port']; |
| 213 | 213 | $hostn = $globalSources[$id]['host']; |
| 214 | - } |
|
| 215 | - $Common = new Common(); |
|
| 216 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 217 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 218 | - } else { |
|
| 219 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 220 | - } |
|
| 221 | - if ($s) { |
|
| 222 | - $sockets[$id] = $s; |
|
| 223 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 224 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 214 | + } |
|
| 215 | + $Common = new Common(); |
|
| 216 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 217 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 218 | + } else { |
|
| 219 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 220 | + } |
|
| 221 | + if ($s) { |
|
| 222 | + $sockets[$id] = $s; |
|
| 223 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 224 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 225 | 225 | //$formats[$id] = 'aprs'; |
| 226 | 226 | $globalSources[$id]['format'] = 'aprs'; |
| 227 | 227 | //$aprs_connect = 0; |
| 228 | 228 | //$use_aprs = true; |
| 229 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 229 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 230 | 230 | $globalSources[$id]['format'] = 'vrstcp'; |
| 231 | - } elseif ($port == '10001') { |
|
| 232 | - //$formats[$id] = 'tsv'; |
|
| 233 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 234 | - } elseif ($port == '30002') { |
|
| 235 | - //$formats[$id] = 'raw'; |
|
| 236 | - $globalSources[$id]['format'] = 'raw'; |
|
| 237 | - } elseif ($port == '5001') { |
|
| 238 | - //$formats[$id] = 'raw'; |
|
| 239 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 240 | - } elseif ($port == '30005') { |
|
| 231 | + } elseif ($port == '10001') { |
|
| 232 | + //$formats[$id] = 'tsv'; |
|
| 233 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 234 | + } elseif ($port == '30002') { |
|
| 235 | + //$formats[$id] = 'raw'; |
|
| 236 | + $globalSources[$id]['format'] = 'raw'; |
|
| 237 | + } elseif ($port == '5001') { |
|
| 238 | + //$formats[$id] = 'raw'; |
|
| 239 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 240 | + } elseif ($port == '30005') { |
|
| 241 | 241 | // Not yet supported |
| 242 | - //$formats[$id] = 'beast'; |
|
| 243 | - $globalSources[$id]['format'] = 'beast'; |
|
| 244 | - //} else $formats[$id] = 'sbs'; |
|
| 245 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 246 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 242 | + //$formats[$id] = 'beast'; |
|
| 243 | + $globalSources[$id]['format'] = 'beast'; |
|
| 244 | + //} else $formats[$id] = 'sbs'; |
|
| 245 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 246 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 247 | 247 | } |
| 248 | 248 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 249 | - } else { |
|
| 249 | + } else { |
|
| 250 | 250 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 251 | - } |
|
| 252 | - } |
|
| 253 | - } |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | 254 | } |
| 255 | 255 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 256 | 256 | |
@@ -273,9 +273,9 @@ discard block |
||
| 273 | 273 | //connect_all($globalSources); |
| 274 | 274 | |
| 275 | 275 | if (isset($globalProxy) && $globalProxy) { |
| 276 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 276 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 277 | 277 | } else { |
| 278 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 278 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // APRS Configuration |
@@ -284,18 +284,18 @@ discard block |
||
| 284 | 284 | die; |
| 285 | 285 | } |
| 286 | 286 | foreach ($globalSources as $key => $source) { |
| 287 | - if (!isset($source['format'])) { |
|
| 288 | - $globalSources[$key]['format'] = 'auto'; |
|
| 289 | - } |
|
| 287 | + if (!isset($source['format'])) { |
|
| 288 | + $globalSources[$key]['format'] = 'auto'; |
|
| 289 | + } |
|
| 290 | 290 | } |
| 291 | 291 | connect_all($globalSources); |
| 292 | 292 | foreach ($globalSources as $key => $source) { |
| 293 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 293 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 294 | 294 | $aprs_connect = 0; |
| 295 | 295 | $use_aprs = true; |
| 296 | 296 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 297 | 297 | break; |
| 298 | - } |
|
| 298 | + } |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | if ($use_aprs) { |
@@ -336,152 +336,152 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 338 | 338 | while ($i > 0) { |
| 339 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 340 | - // Delete old ATC |
|
| 341 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 339 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 340 | + // Delete old ATC |
|
| 341 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 342 | 342 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 343 | - $ATC->deleteOldATC(); |
|
| 344 | - } |
|
| 343 | + $ATC->deleteOldATC(); |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | - //if (count($last_exec) > 0) { |
|
| 347 | - if (count($last_exec) == count($globalSources)) { |
|
| 346 | + //if (count($last_exec) > 0) { |
|
| 347 | + if (count($last_exec) == count($globalSources)) { |
|
| 348 | 348 | $max = $globalMinFetch; |
| 349 | 349 | foreach ($last_exec as $last) { |
| 350 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 350 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 351 | 351 | } |
| 352 | 352 | if ($max != $globalMinFetch) { |
| 353 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 354 | - sleep($globalMinFetch-$max+2); |
|
| 353 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 354 | + sleep($globalMinFetch-$max+2); |
|
| 355 | + } |
|
| 355 | 356 | } |
| 356 | - } |
|
| 357 | 357 | |
| 358 | 358 | |
| 359 | - //foreach ($formats as $id => $value) { |
|
| 360 | - foreach ($globalSources as $id => $value) { |
|
| 359 | + //foreach ($formats as $id => $value) { |
|
| 360 | + foreach ($globalSources as $id => $value) { |
|
| 361 | 361 | date_default_timezone_set('UTC'); |
| 362 | 362 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 363 | 363 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 364 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 365 | - $buffer = $Common->getData($value['host']); |
|
| 366 | - if ($buffer != '') $reset = 0; |
|
| 367 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 368 | - $buffer = explode('\n',$buffer); |
|
| 369 | - foreach ($buffer as $line) { |
|
| 370 | - if ($line != '' && count($line) > 7) { |
|
| 371 | - $line = explode(',', $line); |
|
| 372 | - $data = array(); |
|
| 373 | - $data['hex'] = $line[1]; // hex |
|
| 374 | - $data['ident'] = $line[2]; // ident |
|
| 375 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 376 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 377 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 378 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 379 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 380 | - $data['verticalrate'] = ''; // vertical rate |
|
| 381 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 382 | - $data['emergency'] = ''; // emergency |
|
| 383 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 384 | - $data['format_source'] = 'deltadbtxt'; |
|
| 385 | - $data['id_source'] = $id_source; |
|
| 386 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 387 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 388 | - $SI->add($data); |
|
| 389 | - unset($data); |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - $last_exec[$id]['last'] = time(); |
|
| 364 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 365 | + $buffer = $Common->getData($value['host']); |
|
| 366 | + if ($buffer != '') $reset = 0; |
|
| 367 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 368 | + $buffer = explode('\n',$buffer); |
|
| 369 | + foreach ($buffer as $line) { |
|
| 370 | + if ($line != '' && count($line) > 7) { |
|
| 371 | + $line = explode(',', $line); |
|
| 372 | + $data = array(); |
|
| 373 | + $data['hex'] = $line[1]; // hex |
|
| 374 | + $data['ident'] = $line[2]; // ident |
|
| 375 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 376 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 377 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 378 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 379 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 380 | + $data['verticalrate'] = ''; // vertical rate |
|
| 381 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 382 | + $data['emergency'] = ''; // emergency |
|
| 383 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 384 | + $data['format_source'] = 'deltadbtxt'; |
|
| 385 | + $data['id_source'] = $id_source; |
|
| 386 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 387 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 388 | + $SI->add($data); |
|
| 389 | + unset($data); |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + $last_exec[$id]['last'] = time(); |
|
| 393 | 393 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 394 | - date_default_timezone_set('CET'); |
|
| 395 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 396 | - date_default_timezone_set('UTC'); |
|
| 397 | - if ($buffer != '') $reset = 0; |
|
| 398 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 399 | - $buffer = explode('\n',$buffer); |
|
| 400 | - foreach ($buffer as $line) { |
|
| 394 | + date_default_timezone_set('CET'); |
|
| 395 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 396 | + date_default_timezone_set('UTC'); |
|
| 397 | + if ($buffer != '') $reset = 0; |
|
| 398 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 399 | + $buffer = explode('\n',$buffer); |
|
| 400 | + foreach ($buffer as $line) { |
|
| 401 | 401 | if ($line != '') { |
| 402 | - echo "'".$line."'\n"; |
|
| 403 | - $add = false; |
|
| 404 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 405 | - $data = array(); |
|
| 406 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 407 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 408 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 409 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 410 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 411 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 412 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 413 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 414 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 415 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 416 | - if (isset($ais_data['timestamp'])) { |
|
| 402 | + echo "'".$line."'\n"; |
|
| 403 | + $add = false; |
|
| 404 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 405 | + $data = array(); |
|
| 406 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 407 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 408 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 409 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 410 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 411 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 412 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 413 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 414 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 415 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 416 | + if (isset($ais_data['timestamp'])) { |
|
| 417 | 417 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 418 | 418 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 419 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 420 | - $add = true; |
|
| 419 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 420 | + $add = true; |
|
| 421 | 421 | } |
| 422 | - } else { |
|
| 422 | + } else { |
|
| 423 | 423 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 424 | 424 | $add = true; |
| 425 | - } |
|
| 426 | - $data['format_source'] = 'aisnmeatxt'; |
|
| 427 | - $data['id_source'] = $id_source; |
|
| 428 | - print_r($data); |
|
| 429 | - echo 'Add...'."\n"; |
|
| 430 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 431 | - unset($data); |
|
| 425 | + } |
|
| 426 | + $data['format_source'] = 'aisnmeatxt'; |
|
| 427 | + $data['id_source'] = $id_source; |
|
| 428 | + print_r($data); |
|
| 429 | + echo 'Add...'."\n"; |
|
| 430 | + if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 431 | + unset($data); |
|
| 432 | 432 | } |
| 433 | - } |
|
| 434 | - $last_exec[$id]['last'] = time(); |
|
| 433 | + } |
|
| 434 | + $last_exec[$id]['last'] = time(); |
|
| 435 | 435 | } elseif ($value['format'] == 'aisnmeahttp') { |
| 436 | - $arr = $httpfeeds; |
|
| 437 | - $w = $e = null; |
|
| 436 | + $arr = $httpfeeds; |
|
| 437 | + $w = $e = null; |
|
| 438 | 438 | |
| 439 | - if (isset($arr[$id])) { |
|
| 440 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 441 | - if ($nn > 0) { |
|
| 439 | + if (isset($arr[$id])) { |
|
| 440 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
| 441 | + if ($nn > 0) { |
|
| 442 | 442 | foreach ($httpfeeds as $feed) { |
| 443 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 444 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 445 | - $buffer = explode('\n',$buffer); |
|
| 446 | - foreach ($buffer as $line) { |
|
| 443 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
| 444 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 445 | + $buffer = explode('\n',$buffer); |
|
| 446 | + foreach ($buffer as $line) { |
|
| 447 | 447 | if ($line != '') { |
| 448 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 449 | - $data = array(); |
|
| 450 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 451 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 452 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 453 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 454 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 455 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 456 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 457 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 458 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 459 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 460 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 461 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 462 | - if (isset($ais_data['timestamp'])) { |
|
| 448 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 449 | + $data = array(); |
|
| 450 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 451 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 452 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 453 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 454 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 455 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 456 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 457 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 458 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 459 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 460 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 461 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 462 | + if (isset($ais_data['timestamp'])) { |
|
| 463 | 463 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 464 | - } else { |
|
| 464 | + } else { |
|
| 465 | 465 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 466 | - } |
|
| 467 | - $data['format_source'] = 'aisnmeahttp'; |
|
| 468 | - $data['id_source'] = $id_source; |
|
| 469 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 470 | - unset($data); |
|
| 466 | + } |
|
| 467 | + $data['format_source'] = 'aisnmeahttp'; |
|
| 468 | + $data['id_source'] = $id_source; |
|
| 469 | + if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 470 | + unset($data); |
|
| 471 | 471 | } |
| 472 | - } |
|
| 472 | + } |
|
| 473 | + } |
|
| 473 | 474 | } |
| 474 | 475 | } |
| 475 | - } |
|
| 476 | 476 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 477 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 478 | - if ($buffer != '') { |
|
| 477 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 478 | + if ($buffer != '') { |
|
| 479 | 479 | //echo $buffer; |
| 480 | 480 | $all_data = json_decode($buffer,true); |
| 481 | 481 | //print_r($all_data); |
| 482 | 482 | if (isset($all_data[0]['DATA'])) { |
| 483 | 483 | foreach ($all_data[0]['DATA'] as $line) { |
| 484 | - if ($line != '') { |
|
| 484 | + if ($line != '') { |
|
| 485 | 485 | $data = array(); |
| 486 | 486 | $data['ident'] = $line['NAME']; |
| 487 | 487 | $data['mmsi'] = $line['MMSI']; |
@@ -497,87 +497,87 @@ discard block |
||
| 497 | 497 | $data['id_source'] = $id_source; |
| 498 | 498 | $MI->add($data); |
| 499 | 499 | unset($data); |
| 500 | - } |
|
| 500 | + } |
|
| 501 | 501 | } |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - } |
|
| 505 | - $last_exec[$id]['last'] = time(); |
|
| 504 | + } |
|
| 505 | + $last_exec[$id]['last'] = time(); |
|
| 506 | 506 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 507 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 508 | - if ($buffer != '') { |
|
| 507 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 508 | + if ($buffer != '') { |
|
| 509 | 509 | $all_data = json_decode($buffer,true); |
| 510 | 510 | if (isset($all_data[0]['mmsi'])) { |
| 511 | - foreach ($all_data as $line) { |
|
| 511 | + foreach ($all_data as $line) { |
|
| 512 | 512 | if ($line != '') { |
| 513 | - $data = array(); |
|
| 514 | - $data['ident'] = $line['shipname']; |
|
| 515 | - $data['callsign'] = $line['callsign']; |
|
| 516 | - $data['mmsi'] = $line['mmsi']; |
|
| 517 | - $data['speed'] = $line['sog']; |
|
| 518 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 519 | - $data['latitude'] = $line['latitude']; |
|
| 520 | - $data['longitude'] = $line['longitude']; |
|
| 521 | - $data['type_id'] = $line['shiptype']; |
|
| 522 | - $data['arrival_code'] = $line['destination']; |
|
| 523 | - $data['datetime'] = $line['time']; |
|
| 524 | - $data['format_source'] = 'boatbeaconapp'; |
|
| 525 | - $data['id_source'] = $id_source; |
|
| 526 | - $MI->add($data); |
|
| 527 | - unset($data); |
|
| 513 | + $data = array(); |
|
| 514 | + $data['ident'] = $line['shipname']; |
|
| 515 | + $data['callsign'] = $line['callsign']; |
|
| 516 | + $data['mmsi'] = $line['mmsi']; |
|
| 517 | + $data['speed'] = $line['sog']; |
|
| 518 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 519 | + $data['latitude'] = $line['latitude']; |
|
| 520 | + $data['longitude'] = $line['longitude']; |
|
| 521 | + $data['type_id'] = $line['shiptype']; |
|
| 522 | + $data['arrival_code'] = $line['destination']; |
|
| 523 | + $data['datetime'] = $line['time']; |
|
| 524 | + $data['format_source'] = 'boatbeaconapp'; |
|
| 525 | + $data['id_source'] = $id_source; |
|
| 526 | + $MI->add($data); |
|
| 527 | + unset($data); |
|
| 528 | + } |
|
| 528 | 529 | } |
| 529 | - } |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - } |
|
| 533 | - $last_exec[$id]['last'] = time(); |
|
| 532 | + } |
|
| 533 | + $last_exec[$id]['last'] = time(); |
|
| 534 | 534 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 535 | - echo 'download...'; |
|
| 536 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 537 | - echo 'done !'."\n"; |
|
| 538 | - if ($buffer != '') $reset = 0; |
|
| 539 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 540 | - $buffer = explode('\n',$buffer); |
|
| 541 | - foreach ($buffer as $line) { |
|
| 535 | + echo 'download...'; |
|
| 536 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 537 | + echo 'done !'."\n"; |
|
| 538 | + if ($buffer != '') $reset = 0; |
|
| 539 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 540 | + $buffer = explode('\n',$buffer); |
|
| 541 | + foreach ($buffer as $line) { |
|
| 542 | 542 | if ($line != '') { |
| 543 | - $data = array(); |
|
| 544 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 545 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 546 | - //$data['status'] = substr($line,21,2); |
|
| 547 | - //$data['type'] = substr($line,24,3); |
|
| 548 | - $data['latitude'] = substr($line,29,9); |
|
| 549 | - $data['longitude'] = substr($line,41,9); |
|
| 550 | - $data['speed'] = round(substr($line,51,5)); |
|
| 551 | - //$data['course'] = substr($line,57,5); |
|
| 552 | - $data['heading'] = round(substr($line,63,3)); |
|
| 553 | - //$data['draft'] = substr($line,67,4); |
|
| 554 | - //$data['length'] = substr($line,72,3); |
|
| 555 | - //$data['beam'] = substr($line,76,2); |
|
| 556 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 557 | - //$data['callsign'] = trim(substr($line,100,7); |
|
| 558 | - //$data['dest'] = substr($line,108,20); |
|
| 559 | - //$data['etaDate'] = substr($line,129,5); |
|
| 560 | - //$data['etaTime'] = substr($line,135,5); |
|
| 561 | - $data['format_source'] = 'shipplotter'; |
|
| 562 | - $data['id_source'] = $id_source; |
|
| 563 | - print_r($data); |
|
| 564 | - echo 'Add...'."\n"; |
|
| 565 | - $MI->add($data); |
|
| 566 | - unset($data); |
|
| 543 | + $data = array(); |
|
| 544 | + $data['mmsi'] = (int)substr($line,0,9); |
|
| 545 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 546 | + //$data['status'] = substr($line,21,2); |
|
| 547 | + //$data['type'] = substr($line,24,3); |
|
| 548 | + $data['latitude'] = substr($line,29,9); |
|
| 549 | + $data['longitude'] = substr($line,41,9); |
|
| 550 | + $data['speed'] = round(substr($line,51,5)); |
|
| 551 | + //$data['course'] = substr($line,57,5); |
|
| 552 | + $data['heading'] = round(substr($line,63,3)); |
|
| 553 | + //$data['draft'] = substr($line,67,4); |
|
| 554 | + //$data['length'] = substr($line,72,3); |
|
| 555 | + //$data['beam'] = substr($line,76,2); |
|
| 556 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 557 | + //$data['callsign'] = trim(substr($line,100,7); |
|
| 558 | + //$data['dest'] = substr($line,108,20); |
|
| 559 | + //$data['etaDate'] = substr($line,129,5); |
|
| 560 | + //$data['etaTime'] = substr($line,135,5); |
|
| 561 | + $data['format_source'] = 'shipplotter'; |
|
| 562 | + $data['id_source'] = $id_source; |
|
| 563 | + print_r($data); |
|
| 564 | + echo 'Add...'."\n"; |
|
| 565 | + $MI->add($data); |
|
| 566 | + unset($data); |
|
| 567 | 567 | } |
| 568 | - } |
|
| 569 | - $last_exec[$id]['last'] = time(); |
|
| 568 | + } |
|
| 569 | + $last_exec[$id]['last'] = time(); |
|
| 570 | 570 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 571 | 571 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 572 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 573 | - $buffer = $Common->getData($value['host']); |
|
| 574 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 575 | - $buffer = explode('\n',$buffer); |
|
| 576 | - $reset = 0; |
|
| 577 | - foreach ($buffer as $line) { |
|
| 578 | - if ($line != '') { |
|
| 579 | - $line = explode(':', $line); |
|
| 580 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 572 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 573 | + $buffer = $Common->getData($value['host']); |
|
| 574 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 575 | + $buffer = explode('\n',$buffer); |
|
| 576 | + $reset = 0; |
|
| 577 | + foreach ($buffer as $line) { |
|
| 578 | + if ($line != '') { |
|
| 579 | + $line = explode(':', $line); |
|
| 580 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 581 | 581 | $data = array(); |
| 582 | 582 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 583 | 583 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -590,36 +590,36 @@ discard block |
||
| 590 | 590 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 591 | 591 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 592 | 592 | $data['latitude'] = $line[5]; // lat |
| 593 | - $data['longitude'] = $line[6]; // long |
|
| 594 | - $data['verticalrate'] = ''; // vertical rate |
|
| 595 | - $data['squawk'] = ''; // squawk |
|
| 596 | - $data['emergency'] = ''; // emergency |
|
| 597 | - $data['waypoints'] = $line[30]; |
|
| 593 | + $data['longitude'] = $line[6]; // long |
|
| 594 | + $data['verticalrate'] = ''; // vertical rate |
|
| 595 | + $data['squawk'] = ''; // squawk |
|
| 596 | + $data['emergency'] = ''; // emergency |
|
| 597 | + $data['waypoints'] = $line[30]; |
|
| 598 | 598 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 599 | 599 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 600 | 600 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 601 | - $data['departure_airport_icao'] = $line[11]; |
|
| 602 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 603 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 601 | + $data['departure_airport_icao'] = $line[11]; |
|
| 602 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 603 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 604 | 604 | $data['frequency'] = $line[4]; |
| 605 | 605 | $data['type'] = $line[18]; |
| 606 | 606 | $data['range'] = $line[19]; |
| 607 | 607 | if (isset($line[35])) $data['info'] = $line[35]; |
| 608 | - $data['id_source'] = $id_source; |
|
| 609 | - //$data['arrival_airport_time'] = ; |
|
| 610 | - if ($line[9] != '') { |
|
| 611 | - $aircraft_data = explode('/',$line[9]); |
|
| 612 | - if (isset($aircraft_data[1])) { |
|
| 613 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 614 | - } |
|
| 615 | - } |
|
| 616 | - /* |
|
| 608 | + $data['id_source'] = $id_source; |
|
| 609 | + //$data['arrival_airport_time'] = ; |
|
| 610 | + if ($line[9] != '') { |
|
| 611 | + $aircraft_data = explode('/',$line[9]); |
|
| 612 | + if (isset($aircraft_data[1])) { |
|
| 613 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 614 | + } |
|
| 615 | + } |
|
| 616 | + /* |
|
| 617 | 617 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 618 | 618 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 619 | 619 | */ |
| 620 | - $data['format_source'] = $value['format']; |
|
| 620 | + $data['format_source'] = $value['format']; |
|
| 621 | 621 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 622 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 622 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 623 | 623 | elseif ($line[3] == 'ATC') { |
| 624 | 624 | //print_r($data); |
| 625 | 625 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -637,247 +637,247 @@ discard block |
||
| 637 | 637 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 638 | 638 | 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']); |
| 639 | 639 | } |
| 640 | - unset($data); |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - } |
|
| 644 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 645 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 646 | - $last_exec[$id]['last'] = time(); |
|
| 647 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 648 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 649 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 650 | - if ($buffer != '') { |
|
| 651 | - $all_data = json_decode($buffer,true); |
|
| 652 | - if (isset($all_data['acList'])) { |
|
| 640 | + unset($data); |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + } |
|
| 644 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 645 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 646 | + $last_exec[$id]['last'] = time(); |
|
| 647 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 648 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 649 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 650 | + if ($buffer != '') { |
|
| 651 | + $all_data = json_decode($buffer,true); |
|
| 652 | + if (isset($all_data['acList'])) { |
|
| 653 | 653 | $reset = 0; |
| 654 | 654 | foreach ($all_data['acList'] as $line) { |
| 655 | - $data = array(); |
|
| 656 | - $data['hex'] = $line['Icao']; // hex |
|
| 657 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 658 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 659 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 660 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 661 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 662 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 663 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
| 664 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 665 | - $data['emergency'] = ''; // emergency |
|
| 666 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 667 | - /* |
|
| 655 | + $data = array(); |
|
| 656 | + $data['hex'] = $line['Icao']; // hex |
|
| 657 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 658 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 659 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 660 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 661 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 662 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 663 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
| 664 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 665 | + $data['emergency'] = ''; // emergency |
|
| 666 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 667 | + /* |
|
| 668 | 668 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 669 | 669 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 670 | 670 | */ |
| 671 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 672 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 673 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 674 | - $data['id_source'] = $id_source; |
|
| 675 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 676 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 677 | - unset($data); |
|
| 671 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 672 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 673 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 674 | + $data['id_source'] = $id_source; |
|
| 675 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 676 | + if (isset($data['latitude'])) $SI->add($data); |
|
| 677 | + unset($data); |
|
| 678 | 678 | } |
| 679 | - } elseif (is_array($all_data)) { |
|
| 679 | + } elseif (is_array($all_data)) { |
|
| 680 | 680 | $reset = 0; |
| 681 | 681 | foreach ($all_data as $line) { |
| 682 | - $data = array(); |
|
| 683 | - $data['hex'] = $line['hex']; // hex |
|
| 684 | - $data['ident'] = $line['flight']; // ident |
|
| 685 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 686 | - $data['speed'] = $line['speed']; // speed |
|
| 687 | - $data['heading'] = $line['track']; // heading |
|
| 688 | - $data['latitude'] = $line['lat']; // lat |
|
| 689 | - $data['longitude'] = $line['lon']; // long |
|
| 690 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 691 | - $data['squawk'] = $line['squawk']; // squawk |
|
| 692 | - $data['emergency'] = ''; // emergency |
|
| 693 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 694 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 695 | - $data['id_source'] = $id_source; |
|
| 696 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 697 | - $SI->add($data); |
|
| 698 | - unset($data); |
|
| 682 | + $data = array(); |
|
| 683 | + $data['hex'] = $line['hex']; // hex |
|
| 684 | + $data['ident'] = $line['flight']; // ident |
|
| 685 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 686 | + $data['speed'] = $line['speed']; // speed |
|
| 687 | + $data['heading'] = $line['track']; // heading |
|
| 688 | + $data['latitude'] = $line['lat']; // lat |
|
| 689 | + $data['longitude'] = $line['lon']; // long |
|
| 690 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 691 | + $data['squawk'] = $line['squawk']; // squawk |
|
| 692 | + $data['emergency'] = ''; // emergency |
|
| 693 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 694 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 695 | + $data['id_source'] = $id_source; |
|
| 696 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 697 | + $SI->add($data); |
|
| 698 | + unset($data); |
|
| 699 | + } |
|
| 700 | + } |
|
| 699 | 701 | } |
| 700 | - } |
|
| 701 | - } |
|
| 702 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 703 | - $last_exec[$id]['last'] = time(); |
|
| 704 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 705 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 706 | - $buffer = $Common->getData($value['host']); |
|
| 707 | - $all_data = json_decode($buffer,true); |
|
| 708 | - if (isset($all_data['planes'])) { |
|
| 702 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 703 | + $last_exec[$id]['last'] = time(); |
|
| 704 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 705 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 706 | + $buffer = $Common->getData($value['host']); |
|
| 707 | + $all_data = json_decode($buffer,true); |
|
| 708 | + if (isset($all_data['planes'])) { |
|
| 709 | 709 | $reset = 0; |
| 710 | 710 | foreach ($all_data['planes'] as $key => $line) { |
| 711 | - $data = array(); |
|
| 712 | - $data['hex'] = $key; // hex |
|
| 713 | - $data['ident'] = $line[3]; // ident |
|
| 714 | - $data['altitude'] = $line[6]; // altitude |
|
| 715 | - $data['speed'] = $line[8]; // speed |
|
| 716 | - $data['heading'] = $line[7]; // heading |
|
| 717 | - $data['latitude'] = $line[4]; // lat |
|
| 718 | - $data['longitude'] = $line[5]; // long |
|
| 719 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 720 | - $data['squawk'] = $line[10]; // squawk |
|
| 721 | - $data['emergency'] = ''; // emergency |
|
| 722 | - $data['registration'] = $line[2]; |
|
| 723 | - $data['aircraft_icao'] = $line[0]; |
|
| 724 | - $deparr = explode('-',$line[1]); |
|
| 725 | - if (count($deparr) == 2) { |
|
| 711 | + $data = array(); |
|
| 712 | + $data['hex'] = $key; // hex |
|
| 713 | + $data['ident'] = $line[3]; // ident |
|
| 714 | + $data['altitude'] = $line[6]; // altitude |
|
| 715 | + $data['speed'] = $line[8]; // speed |
|
| 716 | + $data['heading'] = $line[7]; // heading |
|
| 717 | + $data['latitude'] = $line[4]; // lat |
|
| 718 | + $data['longitude'] = $line[5]; // long |
|
| 719 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 720 | + $data['squawk'] = $line[10]; // squawk |
|
| 721 | + $data['emergency'] = ''; // emergency |
|
| 722 | + $data['registration'] = $line[2]; |
|
| 723 | + $data['aircraft_icao'] = $line[0]; |
|
| 724 | + $deparr = explode('-',$line[1]); |
|
| 725 | + if (count($deparr) == 2) { |
|
| 726 | 726 | $data['departure_airport_icao'] = $deparr[0]; |
| 727 | 727 | $data['arrival_airport_icao'] = $deparr[1]; |
| 728 | - } |
|
| 729 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 730 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 731 | - $data['id_source'] = $id_source; |
|
| 732 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 733 | - $SI->add($data); |
|
| 734 | - unset($data); |
|
| 728 | + } |
|
| 729 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 730 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 731 | + $data['id_source'] = $id_source; |
|
| 732 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 733 | + $SI->add($data); |
|
| 734 | + unset($data); |
|
| 735 | + } |
|
| 735 | 736 | } |
| 736 | - } |
|
| 737 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 738 | - $last_exec[$id]['last'] = time(); |
|
| 739 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 740 | - $buffer = $Common->getData($value['host']); |
|
| 741 | - $all_data = json_decode($buffer,true); |
|
| 742 | - if (isset($all_data['states'])) { |
|
| 737 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 738 | + $last_exec[$id]['last'] = time(); |
|
| 739 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 740 | + $buffer = $Common->getData($value['host']); |
|
| 741 | + $all_data = json_decode($buffer,true); |
|
| 742 | + if (isset($all_data['states'])) { |
|
| 743 | 743 | $reset = 0; |
| 744 | 744 | foreach ($all_data['states'] as $key => $line) { |
| 745 | - $data = array(); |
|
| 746 | - $data['hex'] = $line[0]; // hex |
|
| 747 | - $data['ident'] = trim($line[1]); // ident |
|
| 748 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 749 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 750 | - $data['heading'] = round($line[10]); // heading |
|
| 751 | - $data['latitude'] = $line[5]; // lat |
|
| 752 | - $data['longitude'] = $line[6]; // long |
|
| 753 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 754 | - //$data['squawk'] = $line[10]; // squawk |
|
| 755 | - //$data['emergency'] = ''; // emergency |
|
| 756 | - //$data['registration'] = $line[2]; |
|
| 757 | - //$data['aircraft_icao'] = $line[0]; |
|
| 758 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 759 | - $data['format_source'] = 'opensky'; |
|
| 760 | - $data['id_source'] = $id_source; |
|
| 761 | - $SI->add($data); |
|
| 762 | - unset($data); |
|
| 745 | + $data = array(); |
|
| 746 | + $data['hex'] = $line[0]; // hex |
|
| 747 | + $data['ident'] = trim($line[1]); // ident |
|
| 748 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 749 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 750 | + $data['heading'] = round($line[10]); // heading |
|
| 751 | + $data['latitude'] = $line[5]; // lat |
|
| 752 | + $data['longitude'] = $line[6]; // long |
|
| 753 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 754 | + //$data['squawk'] = $line[10]; // squawk |
|
| 755 | + //$data['emergency'] = ''; // emergency |
|
| 756 | + //$data['registration'] = $line[2]; |
|
| 757 | + //$data['aircraft_icao'] = $line[0]; |
|
| 758 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 759 | + $data['format_source'] = 'opensky'; |
|
| 760 | + $data['id_source'] = $id_source; |
|
| 761 | + $SI->add($data); |
|
| 762 | + unset($data); |
|
| 763 | 763 | } |
| 764 | - } |
|
| 765 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 766 | - $last_exec[$id]['last'] = time(); |
|
| 767 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 768 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 769 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 770 | - $buffer = $Common->getData($value['host']); |
|
| 771 | - $all_data = json_decode($buffer,true); |
|
| 772 | - if (!empty($all_data)) $reset = 0; |
|
| 773 | - foreach ($all_data as $key => $line) { |
|
| 764 | + } |
|
| 765 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 766 | + $last_exec[$id]['last'] = time(); |
|
| 767 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 768 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 769 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 770 | + $buffer = $Common->getData($value['host']); |
|
| 771 | + $all_data = json_decode($buffer,true); |
|
| 772 | + if (!empty($all_data)) $reset = 0; |
|
| 773 | + foreach ($all_data as $key => $line) { |
|
| 774 | 774 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 775 | - $data = array(); |
|
| 776 | - $data['hex'] = $line[0]; |
|
| 777 | - $data['ident'] = $line[16]; //$line[13] |
|
| 778 | - $data['altitude'] = $line[4]; // altitude |
|
| 779 | - $data['speed'] = $line[5]; // speed |
|
| 780 | - $data['heading'] = $line[3]; // heading |
|
| 781 | - $data['latitude'] = $line[1]; // lat |
|
| 782 | - $data['longitude'] = $line[2]; // long |
|
| 783 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 784 | - $data['squawk'] = $line[6]; // squawk |
|
| 785 | - $data['aircraft_icao'] = $line[8]; |
|
| 786 | - $data['registration'] = $line[9]; |
|
| 787 | - $data['departure_airport_iata'] = $line[11]; |
|
| 788 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 789 | - $data['emergency'] = ''; // emergency |
|
| 790 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 791 | - $data['format_source'] = 'fr24json'; |
|
| 792 | - $data['id_source'] = $id_source; |
|
| 793 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 794 | - $SI->add($data); |
|
| 795 | - unset($data); |
|
| 775 | + $data = array(); |
|
| 776 | + $data['hex'] = $line[0]; |
|
| 777 | + $data['ident'] = $line[16]; //$line[13] |
|
| 778 | + $data['altitude'] = $line[4]; // altitude |
|
| 779 | + $data['speed'] = $line[5]; // speed |
|
| 780 | + $data['heading'] = $line[3]; // heading |
|
| 781 | + $data['latitude'] = $line[1]; // lat |
|
| 782 | + $data['longitude'] = $line[2]; // long |
|
| 783 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 784 | + $data['squawk'] = $line[6]; // squawk |
|
| 785 | + $data['aircraft_icao'] = $line[8]; |
|
| 786 | + $data['registration'] = $line[9]; |
|
| 787 | + $data['departure_airport_iata'] = $line[11]; |
|
| 788 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 789 | + $data['emergency'] = ''; // emergency |
|
| 790 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 791 | + $data['format_source'] = 'fr24json'; |
|
| 792 | + $data['id_source'] = $id_source; |
|
| 793 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 794 | + $SI->add($data); |
|
| 795 | + unset($data); |
|
| 796 | + } |
|
| 796 | 797 | } |
| 797 | - } |
|
| 798 | - //$last_exec['fr24json'] = time(); |
|
| 799 | - $last_exec[$id]['last'] = time(); |
|
| 800 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 801 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 802 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 803 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 804 | - //echo $buffer; |
|
| 805 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 806 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 807 | - $all_data = json_decode($buffer,true); |
|
| 808 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 798 | + //$last_exec['fr24json'] = time(); |
|
| 799 | + $last_exec[$id]['last'] = time(); |
|
| 800 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 801 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 802 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 803 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 804 | + //echo $buffer; |
|
| 805 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 806 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 807 | + $all_data = json_decode($buffer,true); |
|
| 808 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 809 | 809 | die(json_last_error_msg()); |
| 810 | - } |
|
| 811 | - if (isset($all_data['mrkrs'])) { |
|
| 810 | + } |
|
| 811 | + if (isset($all_data['mrkrs'])) { |
|
| 812 | 812 | $reset = 0; |
| 813 | 813 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 814 | - if (isset($line['inf'])) { |
|
| 814 | + if (isset($line['inf'])) { |
|
| 815 | 815 | $data = array(); |
| 816 | 816 | $data['hex'] = $line['inf']['ia']; |
| 817 | 817 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 818 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 819 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 820 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 821 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 822 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 823 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 824 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 825 | - //$data['aircraft_icao'] = $line[8]; |
|
| 826 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 818 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 819 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 820 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 821 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 822 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 823 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 824 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 825 | + //$data['aircraft_icao'] = $line[8]; |
|
| 826 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 827 | 827 | //$data['departure_airport_iata'] = $line[11]; |
| 828 | 828 | //$data['arrival_airport_iata'] = $line[12]; |
| 829 | - //$data['emergency'] = ''; // emergency |
|
| 829 | + //$data['emergency'] = ''; // emergency |
|
| 830 | 830 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 831 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 832 | - $data['id_source'] = $id_source; |
|
| 831 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 832 | + $data['id_source'] = $id_source; |
|
| 833 | 833 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 834 | 834 | $SI->add($data); |
| 835 | 835 | unset($data); |
| 836 | - } |
|
| 836 | + } |
|
| 837 | + } |
|
| 837 | 838 | } |
| 838 | - } |
|
| 839 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 840 | - $last_exec[$id]['last'] = time(); |
|
| 841 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 842 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 843 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 844 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 845 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 839 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 840 | + $last_exec[$id]['last'] = time(); |
|
| 841 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 842 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 843 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 844 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 845 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 846 | 846 | |
| 847 | - if (isset($all_data['pireps'])) { |
|
| 847 | + if (isset($all_data['pireps'])) { |
|
| 848 | 848 | $reset = 0; |
| 849 | - foreach ($all_data['pireps'] as $line) { |
|
| 850 | - $data = array(); |
|
| 851 | - $data['id'] = $line['id']; |
|
| 852 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 853 | - $data['ident'] = $line['callsign']; // ident |
|
| 854 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 855 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 856 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 857 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 858 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 859 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 860 | - $data['latitude'] = $line['lat']; // lat |
|
| 861 | - $data['longitude'] = $line['lon']; // long |
|
| 862 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 863 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 864 | - //$data['emergency'] = ''; // emergency |
|
| 865 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 866 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 867 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 868 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 869 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 870 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 871 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 872 | - else $data['info'] = ''; |
|
| 873 | - $data['format_source'] = 'pireps'; |
|
| 874 | - $data['id_source'] = $id_source; |
|
| 875 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 876 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 877 | - if ($line['icon'] == 'plane') { |
|
| 849 | + foreach ($all_data['pireps'] as $line) { |
|
| 850 | + $data = array(); |
|
| 851 | + $data['id'] = $line['id']; |
|
| 852 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 853 | + $data['ident'] = $line['callsign']; // ident |
|
| 854 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 855 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 856 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 857 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 858 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 859 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 860 | + $data['latitude'] = $line['lat']; // lat |
|
| 861 | + $data['longitude'] = $line['lon']; // long |
|
| 862 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 863 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 864 | + //$data['emergency'] = ''; // emergency |
|
| 865 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 866 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 867 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 868 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 869 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 870 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 871 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 872 | + else $data['info'] = ''; |
|
| 873 | + $data['format_source'] = 'pireps'; |
|
| 874 | + $data['id_source'] = $id_source; |
|
| 875 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 876 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 877 | + if ($line['icon'] == 'plane') { |
|
| 878 | 878 | $SI->add($data); |
| 879 | - // print_r($data); |
|
| 880 | - } elseif ($line['icon'] == 'ct') { |
|
| 879 | + // print_r($data); |
|
| 880 | + } elseif ($line['icon'] == 'ct') { |
|
| 881 | 881 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 882 | 882 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 883 | 883 | $typec = substr($data['ident'],-3); |
@@ -892,192 +892,192 @@ discard block |
||
| 892 | 892 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 893 | 893 | else $data['type'] = 'Observer'; |
| 894 | 894 | 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']); |
| 895 | - } |
|
| 896 | - unset($data); |
|
| 895 | + } |
|
| 896 | + unset($data); |
|
| 897 | + } |
|
| 897 | 898 | } |
| 898 | - } |
|
| 899 | - //$last_exec['pirepsjson'] = time(); |
|
| 900 | - $last_exec[$id]['last'] = time(); |
|
| 901 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 902 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 903 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 904 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 905 | - $buffer = $Common->getData($value['host']); |
|
| 906 | - $all_data = json_decode($buffer,true); |
|
| 907 | - if ($buffer != '' && is_array($all_data)) { |
|
| 899 | + //$last_exec['pirepsjson'] = time(); |
|
| 900 | + $last_exec[$id]['last'] = time(); |
|
| 901 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 902 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 903 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 904 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 905 | + $buffer = $Common->getData($value['host']); |
|
| 906 | + $all_data = json_decode($buffer,true); |
|
| 907 | + if ($buffer != '' && is_array($all_data)) { |
|
| 908 | 908 | $reset = 0; |
| 909 | 909 | foreach ($all_data as $line) { |
| 910 | - $data = array(); |
|
| 911 | - //$data['id'] = $line['id']; // id not usable |
|
| 912 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 913 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 914 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 915 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 916 | - $data['ident'] = $line['flightnum']; // ident |
|
| 917 | - $data['altitude'] = $line['alt']; // altitude |
|
| 918 | - $data['speed'] = $line['gs']; // speed |
|
| 919 | - $data['heading'] = $line['heading']; // heading |
|
| 920 | - $data['latitude'] = $line['lat']; // lat |
|
| 921 | - $data['longitude'] = $line['lng']; // long |
|
| 922 | - $data['verticalrate'] = ''; // verticale rate |
|
| 923 | - $data['squawk'] = ''; // squawk |
|
| 924 | - $data['emergency'] = ''; // emergency |
|
| 925 | - //$data['datetime'] = $line['lastupdate']; |
|
| 926 | - $data['last_update'] = $line['lastupdate']; |
|
| 927 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 928 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 929 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 930 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 931 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 932 | - $data['registration'] = $line['aircraft']; |
|
| 933 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 934 | - if (isset($line['aircraftname'])) { |
|
| 910 | + $data = array(); |
|
| 911 | + //$data['id'] = $line['id']; // id not usable |
|
| 912 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 913 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 914 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 915 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 916 | + $data['ident'] = $line['flightnum']; // ident |
|
| 917 | + $data['altitude'] = $line['alt']; // altitude |
|
| 918 | + $data['speed'] = $line['gs']; // speed |
|
| 919 | + $data['heading'] = $line['heading']; // heading |
|
| 920 | + $data['latitude'] = $line['lat']; // lat |
|
| 921 | + $data['longitude'] = $line['lng']; // long |
|
| 922 | + $data['verticalrate'] = ''; // verticale rate |
|
| 923 | + $data['squawk'] = ''; // squawk |
|
| 924 | + $data['emergency'] = ''; // emergency |
|
| 925 | + //$data['datetime'] = $line['lastupdate']; |
|
| 926 | + $data['last_update'] = $line['lastupdate']; |
|
| 927 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 928 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 929 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 930 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 931 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 932 | + $data['registration'] = $line['aircraft']; |
|
| 933 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 934 | + if (isset($line['aircraftname'])) { |
|
| 935 | 935 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 936 | 936 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 937 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 938 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 939 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 940 | - else { |
|
| 941 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 942 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 943 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 944 | - } |
|
| 945 | - } |
|
| 946 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 947 | - $data['id_source'] = $id_source; |
|
| 948 | - $data['format_source'] = 'phpvmacars'; |
|
| 949 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 950 | - $SI->add($data); |
|
| 951 | - unset($data); |
|
| 937 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 938 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 939 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 940 | + else { |
|
| 941 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 942 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 943 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 944 | + } |
|
| 945 | + } |
|
| 946 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 947 | + $data['id_source'] = $id_source; |
|
| 948 | + $data['format_source'] = 'phpvmacars'; |
|
| 949 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 950 | + $SI->add($data); |
|
| 951 | + unset($data); |
|
| 952 | 952 | } |
| 953 | 953 | if ($globalDebug) echo 'No more data...'."\n"; |
| 954 | 954 | unset($buffer); |
| 955 | 955 | unset($all_data); |
| 956 | - } |
|
| 957 | - //$last_exec['phpvmacars'] = time(); |
|
| 958 | - $last_exec[$id]['last'] = time(); |
|
| 959 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 960 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 961 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 962 | - $buffer = $Common->getData($value['host']); |
|
| 963 | - $all_data = json_decode($buffer,true); |
|
| 964 | - if ($buffer != '' && is_array($all_data)) { |
|
| 956 | + } |
|
| 957 | + //$last_exec['phpvmacars'] = time(); |
|
| 958 | + $last_exec[$id]['last'] = time(); |
|
| 959 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 960 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 961 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 962 | + $buffer = $Common->getData($value['host']); |
|
| 963 | + $all_data = json_decode($buffer,true); |
|
| 964 | + if ($buffer != '' && is_array($all_data)) { |
|
| 965 | 965 | $reset = 0; |
| 966 | 966 | foreach ($all_data as $line) { |
| 967 | - $data = array(); |
|
| 968 | - //$data['id'] = $line['id']; // id not usable |
|
| 969 | - $data['id'] = trim($line['flight_id']); |
|
| 970 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 971 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 972 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 973 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 974 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 975 | - $data['speed'] = $line['gs']; // speed |
|
| 976 | - $data['heading'] = $line['heading']; // heading |
|
| 977 | - $data['latitude'] = $line['latitude']; // lat |
|
| 978 | - $data['longitude'] = $line['longitude']; // long |
|
| 979 | - $data['verticalrate'] = ''; // verticale rate |
|
| 980 | - $data['squawk'] = ''; // squawk |
|
| 981 | - $data['emergency'] = ''; // emergency |
|
| 982 | - //$data['datetime'] = $line['lastupdate']; |
|
| 983 | - $data['last_update'] = $line['last_update']; |
|
| 984 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 985 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 986 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 987 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 988 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 989 | - //$data['registration'] = $line['aircraft']; |
|
| 990 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 991 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 992 | - $data['id_source'] = $id_source; |
|
| 993 | - $data['format_source'] = 'vam'; |
|
| 994 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 995 | - $SI->add($data); |
|
| 996 | - unset($data); |
|
| 967 | + $data = array(); |
|
| 968 | + //$data['id'] = $line['id']; // id not usable |
|
| 969 | + $data['id'] = trim($line['flight_id']); |
|
| 970 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 971 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 972 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 973 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 974 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 975 | + $data['speed'] = $line['gs']; // speed |
|
| 976 | + $data['heading'] = $line['heading']; // heading |
|
| 977 | + $data['latitude'] = $line['latitude']; // lat |
|
| 978 | + $data['longitude'] = $line['longitude']; // long |
|
| 979 | + $data['verticalrate'] = ''; // verticale rate |
|
| 980 | + $data['squawk'] = ''; // squawk |
|
| 981 | + $data['emergency'] = ''; // emergency |
|
| 982 | + //$data['datetime'] = $line['lastupdate']; |
|
| 983 | + $data['last_update'] = $line['last_update']; |
|
| 984 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 985 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 986 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 987 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 988 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 989 | + //$data['registration'] = $line['aircraft']; |
|
| 990 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 991 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 992 | + $data['id_source'] = $id_source; |
|
| 993 | + $data['format_source'] = 'vam'; |
|
| 994 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 995 | + $SI->add($data); |
|
| 996 | + unset($data); |
|
| 997 | 997 | } |
| 998 | 998 | if ($globalDebug) echo 'No more data...'."\n"; |
| 999 | 999 | unset($buffer); |
| 1000 | 1000 | unset($all_data); |
| 1001 | - } |
|
| 1002 | - //$last_exec['phpvmacars'] = time(); |
|
| 1003 | - $last_exec[$id]['last'] = time(); |
|
| 1001 | + } |
|
| 1002 | + //$last_exec['phpvmacars'] = time(); |
|
| 1003 | + $last_exec[$id]['last'] = time(); |
|
| 1004 | 1004 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1005 | 1005 | } 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' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1006 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1007 | - //$last_exec[$id]['last'] = time(); |
|
| 1006 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1007 | + //$last_exec[$id]['last'] = time(); |
|
| 1008 | 1008 | |
| 1009 | - //$read = array( $sockets[$id] ); |
|
| 1010 | - $read = $sockets; |
|
| 1011 | - $write = NULL; |
|
| 1012 | - $e = NULL; |
|
| 1013 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1014 | - if ($e != NULL) var_dump($e); |
|
| 1015 | - if ($n > 0) { |
|
| 1009 | + //$read = array( $sockets[$id] ); |
|
| 1010 | + $read = $sockets; |
|
| 1011 | + $write = NULL; |
|
| 1012 | + $e = NULL; |
|
| 1013 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1014 | + if ($e != NULL) var_dump($e); |
|
| 1015 | + if ($n > 0) { |
|
| 1016 | 1016 | $reset = 0; |
| 1017 | 1017 | foreach ($read as $nb => $r) { |
| 1018 | - //$value = $formats[$nb]; |
|
| 1019 | - $format = $globalSources[$nb]['format']; |
|
| 1020 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 1018 | + //$value = $formats[$nb]; |
|
| 1019 | + $format = $globalSources[$nb]['format']; |
|
| 1020 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 1021 | 1021 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
| 1022 | - } elseif ($format == 'vrstcp') { |
|
| 1022 | + } elseif ($format == 'vrstcp') { |
|
| 1023 | 1023 | $buffer = @socket_read($r, 6000); |
| 1024 | - } else { |
|
| 1024 | + } else { |
|
| 1025 | 1025 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
| 1026 | - } |
|
| 1027 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1028 | - //echo $buffer."\n"; |
|
| 1029 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1030 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1031 | - $error = false; |
|
| 1032 | - //$SI::del(); |
|
| 1033 | - if ($format == 'vrstcp') { |
|
| 1026 | + } |
|
| 1027 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1028 | + //echo $buffer."\n"; |
|
| 1029 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1030 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1031 | + $error = false; |
|
| 1032 | + //$SI::del(); |
|
| 1033 | + if ($format == 'vrstcp') { |
|
| 1034 | 1034 | $buffer = explode('},{',$buffer); |
| 1035 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1036 | - // SBS format is CSV format |
|
| 1037 | - if ($buffer !== FALSE && $buffer != '') { |
|
| 1035 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1036 | + // SBS format is CSV format |
|
| 1037 | + if ($buffer !== FALSE && $buffer != '') { |
|
| 1038 | 1038 | $tt[$format] = 0; |
| 1039 | 1039 | if ($format == 'acarssbs3') { |
| 1040 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1041 | - $ACARS->add(trim($buffer)); |
|
| 1042 | - $ACARS->deleteLiveAcarsData(); |
|
| 1040 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1041 | + $ACARS->add(trim($buffer)); |
|
| 1042 | + $ACARS->deleteLiveAcarsData(); |
|
| 1043 | 1043 | } elseif ($format == 'raw') { |
| 1044 | - // AVR format |
|
| 1045 | - $data = $SBS->parse($buffer); |
|
| 1046 | - if (is_array($data)) { |
|
| 1044 | + // AVR format |
|
| 1045 | + $data = $SBS->parse($buffer); |
|
| 1046 | + if (is_array($data)) { |
|
| 1047 | 1047 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1048 | 1048 | $data['format_source'] = 'raw'; |
| 1049 | 1049 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1050 | 1050 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1051 | 1051 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1052 | - } |
|
| 1052 | + } |
|
| 1053 | 1053 | } elseif ($format == 'ais') { |
| 1054 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1055 | - $data = array(); |
|
| 1056 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1057 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1058 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1059 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1060 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1061 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1062 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1063 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1064 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1065 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1066 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1067 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1054 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1055 | + $data = array(); |
|
| 1056 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1057 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1058 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1059 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1060 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1061 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1062 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1063 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1064 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1065 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1066 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1067 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1068 | 1068 | |
| 1069 | - if (isset($ais_data['timestamp'])) { |
|
| 1069 | + if (isset($ais_data['timestamp'])) { |
|
| 1070 | 1070 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1071 | - } else { |
|
| 1071 | + } else { |
|
| 1072 | 1072 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1073 | - } |
|
| 1074 | - $data['format_source'] = 'aisnmea'; |
|
| 1075 | - $data['id_source'] = $id_source; |
|
| 1076 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1077 | - unset($data); |
|
| 1078 | - } elseif ($format == 'flightgearsp') { |
|
| 1079 | - //echo $buffer."\n"; |
|
| 1080 | - if (strlen($buffer) > 5) { |
|
| 1073 | + } |
|
| 1074 | + $data['format_source'] = 'aisnmea'; |
|
| 1075 | + $data['id_source'] = $id_source; |
|
| 1076 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1077 | + unset($data); |
|
| 1078 | + } elseif ($format == 'flightgearsp') { |
|
| 1079 | + //echo $buffer."\n"; |
|
| 1080 | + if (strlen($buffer) > 5) { |
|
| 1081 | 1081 | $line = explode(',',$buffer); |
| 1082 | 1082 | $data = array(); |
| 1083 | 1083 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1093,37 +1093,37 @@ discard block |
||
| 1093 | 1093 | $data['format_source'] = 'flightgearsp'; |
| 1094 | 1094 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1095 | 1095 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1096 | - } |
|
| 1097 | - } elseif ($format == 'acars') { |
|
| 1098 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1099 | - $ACARS->add(trim($buffer)); |
|
| 1100 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1101 | - $ACARS->deleteLiveAcarsData(); |
|
| 1096 | + } |
|
| 1097 | + } elseif ($format == 'acars') { |
|
| 1098 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1099 | + $ACARS->add(trim($buffer)); |
|
| 1100 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1101 | + $ACARS->deleteLiveAcarsData(); |
|
| 1102 | 1102 | } elseif ($format == 'flightgearmp') { |
| 1103 | - if (substr($buffer,0,1) != '#') { |
|
| 1103 | + if (substr($buffer,0,1) != '#') { |
|
| 1104 | 1104 | $data = array(); |
| 1105 | 1105 | //echo $buffer."\n"; |
| 1106 | 1106 | $line = explode(' ',$buffer); |
| 1107 | 1107 | if (count($line) == 11) { |
| 1108 | - $userserver = explode('@',$line[0]); |
|
| 1109 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1110 | - $data['ident'] = $userserver[0]; |
|
| 1111 | - $data['registration'] = $userserver[0]; |
|
| 1112 | - $data['latitude'] = $line[4]; |
|
| 1113 | - $data['longitude'] = $line[5]; |
|
| 1114 | - $data['altitude'] = $line[6]; |
|
| 1115 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1116 | - $aircraft_type = $line[10]; |
|
| 1117 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1118 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1119 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1108 | + $userserver = explode('@',$line[0]); |
|
| 1109 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1110 | + $data['ident'] = $userserver[0]; |
|
| 1111 | + $data['registration'] = $userserver[0]; |
|
| 1112 | + $data['latitude'] = $line[4]; |
|
| 1113 | + $data['longitude'] = $line[5]; |
|
| 1114 | + $data['altitude'] = $line[6]; |
|
| 1115 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1116 | + $aircraft_type = $line[10]; |
|
| 1117 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1118 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1119 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1120 | + } |
|
| 1120 | 1121 | } |
| 1121 | - } |
|
| 1122 | 1122 | } elseif ($format == 'beast') { |
| 1123 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1124 | - die; |
|
| 1123 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1124 | + die; |
|
| 1125 | 1125 | } elseif ($format == 'vrstcp') { |
| 1126 | - foreach($buffer as $all_data) { |
|
| 1126 | + foreach($buffer as $all_data) { |
|
| 1127 | 1127 | $line = json_decode('{'.$all_data.'}',true); |
| 1128 | 1128 | $data = array(); |
| 1129 | 1129 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1143,100 +1143,100 @@ discard block |
||
| 1143 | 1143 | */ |
| 1144 | 1144 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1145 | 1145 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1146 | - $data['format_source'] = 'vrstcp'; |
|
| 1146 | + $data['format_source'] = 'vrstcp'; |
|
| 1147 | 1147 | $data['id_source'] = $id_source; |
| 1148 | 1148 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1149 | 1149 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1150 | 1150 | unset($data); |
| 1151 | - } |
|
| 1151 | + } |
|
| 1152 | 1152 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 1153 | - $line = explode("\t", $buffer); |
|
| 1154 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1153 | + $line = explode("\t", $buffer); |
|
| 1154 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1155 | 1155 | $key = $line[$k]; |
| 1156 | - $lined[$key] = $line[$k+1]; |
|
| 1157 | - } |
|
| 1158 | - if (count($lined) > 3) { |
|
| 1159 | - $data['hex'] = $lined['hexid']; |
|
| 1160 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1161 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1162 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1163 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1164 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1165 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1166 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1167 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1168 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1169 | - $data['id_source'] = $id_source; |
|
| 1170 | - $data['format_source'] = 'tsv'; |
|
| 1171 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1172 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1173 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1174 | - unset($lined); |
|
| 1175 | - unset($data); |
|
| 1176 | - } else $error = true; |
|
| 1156 | + $lined[$key] = $line[$k+1]; |
|
| 1157 | + } |
|
| 1158 | + if (count($lined) > 3) { |
|
| 1159 | + $data['hex'] = $lined['hexid']; |
|
| 1160 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1161 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1162 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1163 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1164 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1165 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1166 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1167 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1168 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1169 | + $data['id_source'] = $id_source; |
|
| 1170 | + $data['format_source'] = 'tsv'; |
|
| 1171 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1172 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1173 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1174 | + unset($lined); |
|
| 1175 | + unset($data); |
|
| 1176 | + } else $error = true; |
|
| 1177 | 1177 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1178 | - if ($aprs_connect == 0) { |
|
| 1178 | + if ($aprs_connect == 0) { |
|
| 1179 | 1179 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1180 | 1180 | $aprs_connect = 1; |
| 1181 | - } |
|
| 1181 | + } |
|
| 1182 | 1182 | |
| 1183 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1183 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1184 | 1184 | $aprs_last_tx = time(); |
| 1185 | 1185 | $data_aprs = "# Keep alive"; |
| 1186 | 1186 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1187 | - } |
|
| 1187 | + } |
|
| 1188 | 1188 | |
| 1189 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1190 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1191 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1192 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1193 | - //echo $buffer."\n"; |
|
| 1194 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1189 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1190 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1191 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1192 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1193 | + //echo $buffer."\n"; |
|
| 1194 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1195 | 1195 | $line = $APRS->parse($buffer); |
| 1196 | 1196 | //print_r($line); |
| 1197 | 1197 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1198 | 1198 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']))) { |
| 1199 | - $aprs_last_tx = time(); |
|
| 1200 | - $data = array(); |
|
| 1201 | - //print_r($line); |
|
| 1202 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1203 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1204 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1205 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1206 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1207 | - $data['latitude'] = $line['latitude']; |
|
| 1208 | - $data['longitude'] = $line['longitude']; |
|
| 1209 | - //$data['verticalrate'] = $line[16]; |
|
| 1210 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1211 | - else $data['speed'] = 0; |
|
| 1212 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1213 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1214 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1215 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1216 | - //else $data['heading'] = 0; |
|
| 1217 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1218 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 1219 | - $data['id_source'] = $id_source; |
|
| 1220 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1221 | - else $data['format_source'] = 'aprs'; |
|
| 1222 | - $data['source_name'] = $line['source']; |
|
| 1223 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1224 | - else $data['source_type'] = 'flarm'; |
|
| 1225 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1226 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1227 | - $aprsdate = strtotime($data['datetime']); |
|
| 1228 | - // Accept data if time <= system time + 20s |
|
| 1229 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1199 | + $aprs_last_tx = time(); |
|
| 1200 | + $data = array(); |
|
| 1201 | + //print_r($line); |
|
| 1202 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1203 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1204 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1205 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1206 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1207 | + $data['latitude'] = $line['latitude']; |
|
| 1208 | + $data['longitude'] = $line['longitude']; |
|
| 1209 | + //$data['verticalrate'] = $line[16]; |
|
| 1210 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1211 | + else $data['speed'] = 0; |
|
| 1212 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1213 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1214 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1215 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1216 | + //else $data['heading'] = 0; |
|
| 1217 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1218 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 1219 | + $data['id_source'] = $id_source; |
|
| 1220 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1221 | + else $data['format_source'] = 'aprs'; |
|
| 1222 | + $data['source_name'] = $line['source']; |
|
| 1223 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1224 | + else $data['source_type'] = 'flarm'; |
|
| 1225 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1226 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1227 | + $aprsdate = strtotime($data['datetime']); |
|
| 1228 | + // Accept data if time <= system time + 20s |
|
| 1229 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1230 | 1230 | $send = $SI->add($data); |
| 1231 | - } elseif (isset($line['stealth'])) { |
|
| 1231 | + } elseif (isset($line['stealth'])) { |
|
| 1232 | 1232 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1233 | 1233 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 1234 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1235 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
| 1234 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1235 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
| 1236 | 1236 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1237 | 1237 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 1238 | - } |
|
| 1239 | - unset($data); |
|
| 1238 | + } |
|
| 1239 | + unset($data); |
|
| 1240 | 1240 | } |
| 1241 | 1241 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
| 1242 | 1242 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1246,12 +1246,12 @@ discard block |
||
| 1246 | 1246 | } |
| 1247 | 1247 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1248 | 1248 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 1249 | - } |
|
| 1249 | + } |
|
| 1250 | 1250 | } else { |
| 1251 | - $line = explode(',', $buffer); |
|
| 1252 | - if (count($line) > 20) { |
|
| 1253 | - $data['hex'] = $line[4]; |
|
| 1254 | - /* |
|
| 1251 | + $line = explode(',', $buffer); |
|
| 1252 | + if (count($line) > 20) { |
|
| 1253 | + $data['hex'] = $line[4]; |
|
| 1254 | + /* |
|
| 1255 | 1255 | $data['datetime'] = $line[6].' '.$line[7]; |
| 1256 | 1256 | date_default_timezone_set($globalTimezone); |
| 1257 | 1257 | $datetime = new DateTime($data['datetime']); |
@@ -1259,29 +1259,29 @@ discard block |
||
| 1259 | 1259 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1260 | 1260 | date_default_timezone_set('UTC'); |
| 1261 | 1261 | */ |
| 1262 | - // Force datetime to current UTC datetime |
|
| 1263 | - date_default_timezone_set('UTC'); |
|
| 1264 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1265 | - $data['ident'] = trim($line[10]); |
|
| 1266 | - $data['latitude'] = $line[14]; |
|
| 1267 | - $data['longitude'] = $line[15]; |
|
| 1268 | - $data['verticalrate'] = $line[16]; |
|
| 1269 | - $data['emergency'] = $line[20]; |
|
| 1270 | - $data['speed'] = $line[12]; |
|
| 1271 | - $data['squawk'] = $line[17]; |
|
| 1272 | - $data['altitude'] = $line[11]; |
|
| 1273 | - $data['heading'] = $line[13]; |
|
| 1274 | - $data['ground'] = $line[21]; |
|
| 1275 | - $data['emergency'] = $line[19]; |
|
| 1276 | - $data['format_source'] = 'sbs'; |
|
| 1262 | + // Force datetime to current UTC datetime |
|
| 1263 | + date_default_timezone_set('UTC'); |
|
| 1264 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1265 | + $data['ident'] = trim($line[10]); |
|
| 1266 | + $data['latitude'] = $line[14]; |
|
| 1267 | + $data['longitude'] = $line[15]; |
|
| 1268 | + $data['verticalrate'] = $line[16]; |
|
| 1269 | + $data['emergency'] = $line[20]; |
|
| 1270 | + $data['speed'] = $line[12]; |
|
| 1271 | + $data['squawk'] = $line[17]; |
|
| 1272 | + $data['altitude'] = $line[11]; |
|
| 1273 | + $data['heading'] = $line[13]; |
|
| 1274 | + $data['ground'] = $line[21]; |
|
| 1275 | + $data['emergency'] = $line[19]; |
|
| 1276 | + $data['format_source'] = 'sbs'; |
|
| 1277 | 1277 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1278 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1279 | - $data['id_source'] = $id_source; |
|
| 1280 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1281 | - else $error = true; |
|
| 1282 | - unset($data); |
|
| 1283 | - } else $error = true; |
|
| 1284 | - if ($error) { |
|
| 1278 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1279 | + $data['id_source'] = $id_source; |
|
| 1280 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1281 | + else $error = true; |
|
| 1282 | + unset($data); |
|
| 1283 | + } else $error = true; |
|
| 1284 | + if ($error) { |
|
| 1285 | 1285 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1286 | 1286 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1287 | 1287 | } else { |
@@ -1297,13 +1297,13 @@ discard block |
||
| 1297 | 1297 | connect_all($sourceer); |
| 1298 | 1298 | $sourceer = array(); |
| 1299 | 1299 | } |
| 1300 | - } |
|
| 1300 | + } |
|
| 1301 | 1301 | } |
| 1302 | 1302 | // Sleep for xxx microseconds |
| 1303 | 1303 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1304 | - } else { |
|
| 1304 | + } else { |
|
| 1305 | 1305 | if ($format == 'flightgearmp') { |
| 1306 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1306 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1307 | 1307 | //@socket_close($r); |
| 1308 | 1308 | sleep($globalMinFetch); |
| 1309 | 1309 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1312,9 +1312,9 @@ discard block |
||
| 1312 | 1312 | break; |
| 1313 | 1313 | |
| 1314 | 1314 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1315 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1316 | - else $tt[$format] = 0; |
|
| 1317 | - if ($tt[$format] > 30) { |
|
| 1315 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1316 | + else $tt[$format] = 0; |
|
| 1317 | + if ($tt[$format] > 30) { |
|
| 1318 | 1318 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1319 | 1319 | //@socket_close($r); |
| 1320 | 1320 | sleep(2); |
@@ -1325,23 +1325,23 @@ discard block |
||
| 1325 | 1325 | //connect_all($globalSources); |
| 1326 | 1326 | $tt[$format]=0; |
| 1327 | 1327 | break; |
| 1328 | - } |
|
| 1328 | + } |
|
| 1329 | + } |
|
| 1329 | 1330 | } |
| 1330 | - } |
|
| 1331 | 1331 | } |
| 1332 | - } else { |
|
| 1332 | + } else { |
|
| 1333 | 1333 | $error = socket_strerror(socket_last_error()); |
| 1334 | 1334 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1335 | 1335 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1336 | 1336 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1337 | 1337 | // Restart the script if possible |
| 1338 | 1338 | if (is_array($sockets)) { |
| 1339 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1339 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1340 | 1340 | |
| 1341 | - foreach ($sockets as $sock) { |
|
| 1341 | + foreach ($sockets as $sock) { |
|
| 1342 | 1342 | @socket_shutdown($sock,2); |
| 1343 | 1343 | @socket_close($sock); |
| 1344 | - } |
|
| 1344 | + } |
|
| 1345 | 1345 | |
| 1346 | 1346 | } |
| 1347 | 1347 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1355,13 +1355,13 @@ discard block |
||
| 1355 | 1355 | if ($reset > 100) exit('Too many attempts...'); |
| 1356 | 1356 | connect_all($globalSources); |
| 1357 | 1357 | } |
| 1358 | - } |
|
| 1358 | + } |
|
| 1359 | 1359 | } |
| 1360 | 1360 | if ($globalDaemon === false) { |
| 1361 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1362 | - $SI->checkAll(); |
|
| 1361 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1362 | + $SI->checkAll(); |
|
| 1363 | + } |
|
| 1363 | 1364 | } |
| 1364 | - } |
|
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | 1367 | ?> |
@@ -13,13 +13,17 @@ discard block |
||
| 13 | 13 | require_once(dirname(__FILE__).'/../require/class.SBS.php'); |
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 16 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 16 | +if (isset($globalTracker) && $globalTracker) { |
|
| 17 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 18 | +} |
|
| 17 | 19 | if (isset($globalMarine) && $globalMarine) { |
| 18 | 20 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 20 | 22 | } |
| 21 | 23 | |
| 22 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 24 | +if (!isset($globalDebug)) { |
|
| 25 | + $globalDebug = FALSE; |
|
| 26 | +} |
|
| 23 | 27 | |
| 24 | 28 | // Check if schema is at latest version |
| 25 | 29 | $Connection = new Connection(); |
@@ -59,24 +63,45 @@ discard block |
||
| 59 | 63 | $globalSources = array(); |
| 60 | 64 | $globalSources[] = array('host' => $options['source']); |
| 61 | 65 | } |
| 62 | -if (isset($options['aprsserverhost'])) $globalServerAPRShost = $options['aprsserverhost']; |
|
| 63 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 64 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 65 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 66 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 67 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 68 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 69 | -else $id_source = 1; |
|
| 66 | +if (isset($options['aprsserverhost'])) { |
|
| 67 | + $globalServerAPRShost = $options['aprsserverhost']; |
|
| 68 | +} |
|
| 69 | +if (isset($options['aprsserverport'])) { |
|
| 70 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 71 | +} |
|
| 72 | +if (isset($options['aprsserverssid'])) { |
|
| 73 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 74 | +} |
|
| 75 | +if (isset($options['aprsserverpass'])) { |
|
| 76 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 77 | +} |
|
| 78 | +if (isset($options['nodaemon'])) { |
|
| 79 | + $globalDaemon = FALSE; |
|
| 80 | +} |
|
| 81 | +if (isset($options['server'])) { |
|
| 82 | + $globalServer = TRUE; |
|
| 83 | +} |
|
| 84 | +if (isset($options['idsource'])) { |
|
| 85 | + $id_source = $options['idsource']; |
|
| 86 | +} else { |
|
| 87 | + $id_source = 1; |
|
| 88 | +} |
|
| 70 | 89 | if (isset($globalServer) && $globalServer) { |
| 71 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 90 | + if ($globalDebug) { |
|
| 91 | + echo "Using Server Mode\n"; |
|
| 92 | + } |
|
| 72 | 93 | $SI=new SpotterServer(); |
| 73 | 94 | /* |
| 74 | 95 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 75 | 96 | $SI = new adsb2aprs(); |
| 76 | 97 | $SI->connect(); |
| 77 | 98 | */ |
| 78 | -} else $SI=new SpotterImport($Connection->db); |
|
| 79 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 99 | +} else { |
|
| 100 | + $SI=new SpotterImport($Connection->db); |
|
| 101 | +} |
|
| 102 | +if (isset($globalTracker) && $globalTracker) { |
|
| 103 | + $TI = new TrackerImport($Connection->db); |
|
| 104 | +} |
|
| 80 | 105 | if (isset($globalMarine) && $globalMarine) { |
| 81 | 106 | $AIS = new AIS(); |
| 82 | 107 | $MI = new MarineImport($Connection->db); |
@@ -98,7 +123,9 @@ discard block |
||
| 98 | 123 | } |
| 99 | 124 | |
| 100 | 125 | // let's try and connect |
| 101 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 126 | +if ($globalDebug) { |
|
| 127 | + echo "Connecting...\n"; |
|
| 128 | +} |
|
| 102 | 129 | $use_aprs = false; |
| 103 | 130 | $aprs_full = false; |
| 104 | 131 | $reset = 0; |
@@ -107,7 +134,9 @@ discard block |
||
| 107 | 134 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 108 | 135 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 109 | 136 | $reset++; |
| 110 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 137 | + if ($globalDebug) { |
|
| 138 | + echo 'Connect to all...'."\n"; |
|
| 139 | + } |
|
| 111 | 140 | foreach ($hosts as $id => $value) { |
| 112 | 141 | $host = $value['host']; |
| 113 | 142 | $globalSources[$id]['last_exec'] = 0; |
@@ -117,27 +146,37 @@ discard block |
||
| 117 | 146 | //$formats[$id] = 'deltadbtxt'; |
| 118 | 147 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 119 | 148 | //$last_exec['deltadbtxt'] = 0; |
| 120 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 149 | + if ($globalDebug) { |
|
| 150 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 151 | + } |
|
| 121 | 152 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 122 | 153 | //$formats[$id] = 'vatsimtxt'; |
| 123 | 154 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 124 | 155 | //$last_exec['vatsimtxt'] = 0; |
| 125 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 156 | + if ($globalDebug) { |
|
| 157 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 158 | + } |
|
| 126 | 159 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 127 | 160 | //$formats[$id] = 'aircraftlistjson'; |
| 128 | 161 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 129 | 162 | //$last_exec['aircraftlistjson'] = 0; |
| 130 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 163 | + if ($globalDebug) { |
|
| 164 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 165 | + } |
|
| 131 | 166 | } else if (preg_match('/opensky/i',$host)) { |
| 132 | 167 | //$formats[$id] = 'aircraftlistjson'; |
| 133 | 168 | $globalSources[$id]['format'] = 'opensky'; |
| 134 | 169 | //$last_exec['aircraftlistjson'] = 0; |
| 135 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 170 | + if ($globalDebug) { |
|
| 171 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 172 | + } |
|
| 136 | 173 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
| 137 | 174 | //$formats[$id] = 'radarvirtueljson'; |
| 138 | 175 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 139 | 176 | //$last_exec['radarvirtueljson'] = 0; |
| 140 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 177 | + if ($globalDebug) { |
|
| 178 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 179 | + } |
|
| 141 | 180 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 142 | 181 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 143 | 182 | exit(0); |
@@ -146,7 +185,9 @@ discard block |
||
| 146 | 185 | //$formats[$id] = 'planeupdatefaa'; |
| 147 | 186 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 148 | 187 | //$last_exec['planeupdatefaa'] = 0; |
| 149 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 188 | + if ($globalDebug) { |
|
| 189 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 190 | + } |
|
| 150 | 191 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 151 | 192 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 152 | 193 | exit(0); |
@@ -155,26 +196,36 @@ discard block |
||
| 155 | 196 | //$formats[$id] = 'phpvmacars'; |
| 156 | 197 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 157 | 198 | //$last_exec['phpvmacars'] = 0; |
| 158 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 199 | + if ($globalDebug) { |
|
| 200 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 201 | + } |
|
| 159 | 202 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 160 | 203 | //$formats[$id] = 'phpvmacars'; |
| 161 | 204 | $globalSources[$id]['format'] = 'vam'; |
| 162 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 205 | + if ($globalDebug) { |
|
| 206 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 207 | + } |
|
| 163 | 208 | } else if (preg_match('/whazzup/i',$host)) { |
| 164 | 209 | //$formats[$id] = 'whazzup'; |
| 165 | 210 | $globalSources[$id]['format'] = 'whazzup'; |
| 166 | 211 | //$last_exec['whazzup'] = 0; |
| 167 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 212 | + if ($globalDebug) { |
|
| 213 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 214 | + } |
|
| 168 | 215 | } else if (preg_match('/recentpireps/i',$host)) { |
| 169 | 216 | //$formats[$id] = 'pirepsjson'; |
| 170 | 217 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 171 | 218 | //$last_exec['pirepsjson'] = 0; |
| 172 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 219 | + if ($globalDebug) { |
|
| 220 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 221 | + } |
|
| 173 | 222 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 174 | 223 | //$formats[$id] = 'fr24json'; |
| 175 | 224 | $globalSources[$id]['format'] = 'fr24json'; |
| 176 | 225 | //$last_exec['fr24json'] = 0; |
| 177 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 226 | + if ($globalDebug) { |
|
| 227 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 228 | + } |
|
| 178 | 229 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 179 | 230 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 180 | 231 | exit(0); |
@@ -183,7 +234,9 @@ discard block |
||
| 183 | 234 | //$formats[$id] = 'fr24json'; |
| 184 | 235 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 185 | 236 | //$last_exec['fr24json'] = 0; |
| 186 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 237 | + if ($globalDebug) { |
|
| 238 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 239 | + } |
|
| 187 | 240 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 188 | 241 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 189 | 242 | exit(0); |
@@ -192,17 +245,24 @@ discard block |
||
| 192 | 245 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 193 | 246 | //$formats[$id] = 'tsv'; |
| 194 | 247 | $globalSources[$id]['format'] = 'tsv'; |
| 195 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 248 | + if ($globalDebug) { |
|
| 249 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 250 | + } |
|
| 196 | 251 | } |
| 197 | 252 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 198 | 253 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 199 | 254 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 200 | 255 | if ($idf !== false) { |
| 201 | 256 | $httpfeeds[$id] = $idf; |
| 202 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 257 | + if ($globalDebug) { |
|
| 258 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 259 | + } |
|
| 260 | + } elseif ($globalDebug) { |
|
| 261 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 203 | 262 | } |
| 204 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 205 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 263 | + } elseif ($globalDebug) { |
|
| 264 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 265 | + } |
|
| 206 | 266 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 207 | 267 | $hostport = explode(':',$host); |
| 208 | 268 | if (isset($hostport[1])) { |
@@ -242,17 +302,25 @@ discard block |
||
| 242 | 302 | //$formats[$id] = 'beast'; |
| 243 | 303 | $globalSources[$id]['format'] = 'beast'; |
| 244 | 304 | //} else $formats[$id] = 'sbs'; |
| 245 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 305 | + } else { |
|
| 306 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 307 | + } |
|
| 246 | 308 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 247 | 309 | } |
| 248 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 310 | + if ($globalDebug) { |
|
| 311 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 312 | + } |
|
| 249 | 313 | } else { |
| 250 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 314 | + if ($globalDebug) { |
|
| 315 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 316 | + } |
|
| 251 | 317 | } |
| 252 | 318 | } |
| 253 | 319 | } |
| 254 | 320 | } |
| 255 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 321 | +if (!isset($globalMinFetch)) { |
|
| 322 | + $globalMinFetch = 15; |
|
| 323 | +} |
|
| 256 | 324 | |
| 257 | 325 | // Initialize all |
| 258 | 326 | $status = array(); |
@@ -261,13 +329,19 @@ discard block |
||
| 261 | 329 | $formats = array(); |
| 262 | 330 | $last_exec = array(); |
| 263 | 331 | $time = time(); |
| 264 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 265 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 266 | -else $timeout = 20; |
|
| 332 | +if (isset($globalSourcesTimeout)) { |
|
| 333 | + $timeout = $globalSourcesTimeOut; |
|
| 334 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 335 | + $timeout = $globalSBS1TimeOut; |
|
| 336 | +} else { |
|
| 337 | + $timeout = 20; |
|
| 338 | +} |
|
| 267 | 339 | $errno = ''; |
| 268 | 340 | $errstr=''; |
| 269 | 341 | |
| 270 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 342 | +if (!isset($globalDaemon)) { |
|
| 343 | + $globalDaemon = TRUE; |
|
| 344 | +} |
|
| 271 | 345 | /* Initiate connections to all the hosts simultaneously */ |
| 272 | 346 | //connect_all($hosts); |
| 273 | 347 | //connect_all($globalSources); |
@@ -293,7 +367,9 @@ discard block |
||
| 293 | 367 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 294 | 368 | $aprs_connect = 0; |
| 295 | 369 | $use_aprs = true; |
| 296 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 370 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 371 | + $aprs_full = true; |
|
| 372 | + } |
|
| 297 | 373 | break; |
| 298 | 374 | } |
| 299 | 375 | } |
@@ -304,25 +380,48 @@ discard block |
||
| 304 | 380 | $aprs_connect = 0; |
| 305 | 381 | $aprs_keep = 120; |
| 306 | 382 | $aprs_last_tx = time(); |
| 307 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 308 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 309 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 310 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 311 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 312 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 313 | - if ($aprs_full) $aprs_filter = ''; |
|
| 314 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 315 | - else $aprs_pass = '-1'; |
|
| 383 | + if (isset($globalAPRSversion)) { |
|
| 384 | + $aprs_version = $globalAPRSversion; |
|
| 385 | + } else { |
|
| 386 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 387 | + } |
|
| 388 | + if (isset($globalAPRSssid)) { |
|
| 389 | + $aprs_ssid = $globalAPRSssid; |
|
| 390 | + } else { |
|
| 391 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 392 | + } |
|
| 393 | + if (isset($globalAPRSfilter)) { |
|
| 394 | + $aprs_filter = $globalAPRSfilter; |
|
| 395 | + } else { |
|
| 396 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 397 | + } |
|
| 398 | + if ($aprs_full) { |
|
| 399 | + $aprs_filter = ''; |
|
| 400 | + } |
|
| 401 | + if (isset($globalAPRSpass)) { |
|
| 402 | + $aprs_pass = $globalAPRSpass; |
|
| 403 | + } else { |
|
| 404 | + $aprs_pass = '-1'; |
|
| 405 | + } |
|
| 316 | 406 | |
| 317 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 318 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 319 | -} |
|
| 407 | + if ($aprs_filter != '') { |
|
| 408 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 409 | + } else { |
|
| 410 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 411 | + } |
|
| 412 | + } |
|
| 320 | 413 | |
| 321 | 414 | // connected - lets do some work |
| 322 | -if ($globalDebug) echo "Connected!\n"; |
|
| 415 | +if ($globalDebug) { |
|
| 416 | + echo "Connected!\n"; |
|
| 417 | +} |
|
| 323 | 418 | sleep(1); |
| 324 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 325 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 419 | +if ($globalDebug) { |
|
| 420 | + echo "SCAN MODE \n\n"; |
|
| 421 | +} |
|
| 422 | +if (!isset($globalCronEnd)) { |
|
| 423 | + $globalCronEnd = 60; |
|
| 424 | +} |
|
| 326 | 425 | $endtime = time()+$globalCronEnd; |
| 327 | 426 | $i = 1; |
| 328 | 427 | $tt = array(); |
@@ -336,10 +435,14 @@ discard block |
||
| 336 | 435 | |
| 337 | 436 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 338 | 437 | while ($i > 0) { |
| 339 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 438 | + if (!$globalDaemon) { |
|
| 439 | + $i = $endtime-time(); |
|
| 440 | + } |
|
| 340 | 441 | // Delete old ATC |
| 341 | 442 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 342 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 443 | + if ($globalDebug) { |
|
| 444 | + echo 'Delete old ATC...'."\n"; |
|
| 445 | + } |
|
| 343 | 446 | $ATC->deleteOldATC(); |
| 344 | 447 | } |
| 345 | 448 | |
@@ -347,10 +450,14 @@ discard block |
||
| 347 | 450 | if (count($last_exec) == count($globalSources)) { |
| 348 | 451 | $max = $globalMinFetch; |
| 349 | 452 | foreach ($last_exec as $last) { |
| 350 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 453 | + if ((time() - $last['last']) < $max) { |
|
| 454 | + $max = time() - $last['last']; |
|
| 455 | + } |
|
| 351 | 456 | } |
| 352 | 457 | if ($max != $globalMinFetch) { |
| 353 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 458 | + if ($globalDebug) { |
|
| 459 | + echo 'Sleeping...'."\n"; |
|
| 460 | + } |
|
| 354 | 461 | sleep($globalMinFetch-$max+2); |
| 355 | 462 | } |
| 356 | 463 | } |
@@ -359,11 +466,15 @@ discard block |
||
| 359 | 466 | //foreach ($formats as $id => $value) { |
| 360 | 467 | foreach ($globalSources as $id => $value) { |
| 361 | 468 | date_default_timezone_set('UTC'); |
| 362 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 469 | + if (!isset($last_exec[$id]['last'])) { |
|
| 470 | + $last_exec[$id]['last'] = 0; |
|
| 471 | + } |
|
| 363 | 472 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 364 | 473 | //$buffer = $Common->getData($hosts[$id]); |
| 365 | 474 | $buffer = $Common->getData($value['host']); |
| 366 | - if ($buffer != '') $reset = 0; |
|
| 475 | + if ($buffer != '') { |
|
| 476 | + $reset = 0; |
|
| 477 | + } |
|
| 367 | 478 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 368 | 479 | $buffer = explode('\n',$buffer); |
| 369 | 480 | foreach ($buffer as $line) { |
@@ -372,19 +483,38 @@ discard block |
||
| 372 | 483 | $data = array(); |
| 373 | 484 | $data['hex'] = $line[1]; // hex |
| 374 | 485 | $data['ident'] = $line[2]; // ident |
| 375 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 376 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 377 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 378 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 379 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 486 | + if (isset($line[3])) { |
|
| 487 | + $data['altitude'] = $line[3]; |
|
| 488 | + } |
|
| 489 | + // altitude |
|
| 490 | + if (isset($line[4])) { |
|
| 491 | + $data['speed'] = $line[4]; |
|
| 492 | + } |
|
| 493 | + // speed |
|
| 494 | + if (isset($line[5])) { |
|
| 495 | + $data['heading'] = $line[5]; |
|
| 496 | + } |
|
| 497 | + // heading |
|
| 498 | + if (isset($line[6])) { |
|
| 499 | + $data['latitude'] = $line[6]; |
|
| 500 | + } |
|
| 501 | + // lat |
|
| 502 | + if (isset($line[7])) { |
|
| 503 | + $data['longitude'] = $line[7]; |
|
| 504 | + } |
|
| 505 | + // long |
|
| 380 | 506 | $data['verticalrate'] = ''; // vertical rate |
| 381 | 507 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 382 | 508 | $data['emergency'] = ''; // emergency |
| 383 | 509 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 384 | 510 | $data['format_source'] = 'deltadbtxt'; |
| 385 | 511 | $data['id_source'] = $id_source; |
| 386 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 387 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 512 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 513 | + $data['source_name'] = $value['name']; |
|
| 514 | + } |
|
| 515 | + if (isset($value['sourcestats'])) { |
|
| 516 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 517 | + } |
|
| 388 | 518 | $SI->add($data); |
| 389 | 519 | unset($data); |
| 390 | 520 | } |
@@ -394,7 +524,9 @@ discard block |
||
| 394 | 524 | date_default_timezone_set('CET'); |
| 395 | 525 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 396 | 526 | date_default_timezone_set('UTC'); |
| 397 | - if ($buffer != '') $reset = 0; |
|
| 527 | + if ($buffer != '') { |
|
| 528 | + $reset = 0; |
|
| 529 | + } |
|
| 398 | 530 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 399 | 531 | $buffer = explode('\n',$buffer); |
| 400 | 532 | foreach ($buffer as $line) { |
@@ -403,16 +535,36 @@ discard block |
||
| 403 | 535 | $add = false; |
| 404 | 536 | $ais_data = $AIS->parse_line(trim($line)); |
| 405 | 537 | $data = array(); |
| 406 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 407 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 408 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 409 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 410 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 411 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 412 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 413 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 414 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 415 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 538 | + if (isset($ais_data['ident'])) { |
|
| 539 | + $data['ident'] = $ais_data['ident']; |
|
| 540 | + } |
|
| 541 | + if (isset($ais_data['mmsi'])) { |
|
| 542 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 543 | + } |
|
| 544 | + if (isset($ais_data['speed'])) { |
|
| 545 | + $data['speed'] = $ais_data['speed']; |
|
| 546 | + } |
|
| 547 | + if (isset($ais_data['heading'])) { |
|
| 548 | + $data['heading'] = $ais_data['heading']; |
|
| 549 | + } |
|
| 550 | + if (isset($ais_data['latitude'])) { |
|
| 551 | + $data['latitude'] = $ais_data['latitude']; |
|
| 552 | + } |
|
| 553 | + if (isset($ais_data['longitude'])) { |
|
| 554 | + $data['longitude'] = $ais_data['longitude']; |
|
| 555 | + } |
|
| 556 | + if (isset($ais_data['status'])) { |
|
| 557 | + $data['status'] = $ais_data['status']; |
|
| 558 | + } |
|
| 559 | + if (isset($ais_data['type'])) { |
|
| 560 | + $data['type'] = $ais_data['type']; |
|
| 561 | + } |
|
| 562 | + if (isset($ais_data['imo'])) { |
|
| 563 | + $data['imo'] = $ais_data['imo']; |
|
| 564 | + } |
|
| 565 | + if (isset($ais_data['callsign'])) { |
|
| 566 | + $data['callsign'] = $ais_data['callsign']; |
|
| 567 | + } |
|
| 416 | 568 | if (isset($ais_data['timestamp'])) { |
| 417 | 569 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 418 | 570 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -427,7 +579,9 @@ discard block |
||
| 427 | 579 | $data['id_source'] = $id_source; |
| 428 | 580 | print_r($data); |
| 429 | 581 | echo 'Add...'."\n"; |
| 430 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 582 | + if ($add && $ais_data['mmsi_type'] == 'Ship') { |
|
| 583 | + $MI->add($data); |
|
| 584 | + } |
|
| 431 | 585 | unset($data); |
| 432 | 586 | } |
| 433 | 587 | } |
@@ -447,18 +601,42 @@ discard block |
||
| 447 | 601 | if ($line != '') { |
| 448 | 602 | $ais_data = $AIS->parse_line(trim($line)); |
| 449 | 603 | $data = array(); |
| 450 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 451 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 452 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 453 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 454 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 455 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 456 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 457 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 458 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 459 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 460 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 461 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 604 | + if (isset($ais_data['ident'])) { |
|
| 605 | + $data['ident'] = $ais_data['ident']; |
|
| 606 | + } |
|
| 607 | + if (isset($ais_data['mmsi'])) { |
|
| 608 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 609 | + } |
|
| 610 | + if (isset($ais_data['speed'])) { |
|
| 611 | + $data['speed'] = $ais_data['speed']; |
|
| 612 | + } |
|
| 613 | + if (isset($ais_data['heading'])) { |
|
| 614 | + $data['heading'] = $ais_data['heading']; |
|
| 615 | + } |
|
| 616 | + if (isset($ais_data['latitude'])) { |
|
| 617 | + $data['latitude'] = $ais_data['latitude']; |
|
| 618 | + } |
|
| 619 | + if (isset($ais_data['longitude'])) { |
|
| 620 | + $data['longitude'] = $ais_data['longitude']; |
|
| 621 | + } |
|
| 622 | + if (isset($ais_data['status'])) { |
|
| 623 | + $data['status'] = $ais_data['status']; |
|
| 624 | + } |
|
| 625 | + if (isset($ais_data['type'])) { |
|
| 626 | + $data['type'] = $ais_data['type']; |
|
| 627 | + } |
|
| 628 | + if (isset($ais_data['imo'])) { |
|
| 629 | + $data['imo'] = $ais_data['imo']; |
|
| 630 | + } |
|
| 631 | + if (isset($ais_data['callsign'])) { |
|
| 632 | + $data['callsign'] = $ais_data['callsign']; |
|
| 633 | + } |
|
| 634 | + if (isset($ais_data['destination'])) { |
|
| 635 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 636 | + } |
|
| 637 | + if (isset($ais_data['eta_ts'])) { |
|
| 638 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 639 | + } |
|
| 462 | 640 | if (isset($ais_data['timestamp'])) { |
| 463 | 641 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 464 | 642 | } else { |
@@ -466,7 +644,9 @@ discard block |
||
| 466 | 644 | } |
| 467 | 645 | $data['format_source'] = 'aisnmeahttp'; |
| 468 | 646 | $data['id_source'] = $id_source; |
| 469 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 647 | + if ($ais_data['mmsi_type'] == 'Ship') { |
|
| 648 | + $MI->add($data); |
|
| 649 | + } |
|
| 470 | 650 | unset($data); |
| 471 | 651 | } |
| 472 | 652 | } |
@@ -515,7 +695,9 @@ discard block |
||
| 515 | 695 | $data['callsign'] = $line['callsign']; |
| 516 | 696 | $data['mmsi'] = $line['mmsi']; |
| 517 | 697 | $data['speed'] = $line['sog']; |
| 518 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 698 | + if ($line['heading'] != '511') { |
|
| 699 | + $data['heading'] = $line['heading']; |
|
| 700 | + } |
|
| 519 | 701 | $data['latitude'] = $line['latitude']; |
| 520 | 702 | $data['longitude'] = $line['longitude']; |
| 521 | 703 | $data['type_id'] = $line['shiptype']; |
@@ -535,7 +717,9 @@ discard block |
||
| 535 | 717 | echo 'download...'; |
| 536 | 718 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 537 | 719 | echo 'done !'."\n"; |
| 538 | - if ($buffer != '') $reset = 0; |
|
| 720 | + if ($buffer != '') { |
|
| 721 | + $reset = 0; |
|
| 722 | + } |
|
| 539 | 723 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 540 | 724 | $buffer = explode('\n',$buffer); |
| 541 | 725 | foreach ($buffer as $line) { |
@@ -579,16 +763,28 @@ discard block |
||
| 579 | 763 | $line = explode(':', $line); |
| 580 | 764 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 581 | 765 | $data = array(); |
| 582 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 583 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 766 | + if (isset($line[37]) && $line[37] != '') { |
|
| 767 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 768 | + } else { |
|
| 769 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 770 | + } |
|
| 584 | 771 | $data['pilot_id'] = $line[1]; |
| 585 | 772 | $data['pilot_name'] = $line[2]; |
| 586 | 773 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 587 | 774 | $data['ident'] = $line[0]; // ident |
| 588 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 775 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 776 | + $data['altitude'] = $line[7]; |
|
| 777 | + } |
|
| 778 | + // altitude |
|
| 589 | 779 | $data['speed'] = $line[8]; // speed |
| 590 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 591 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 780 | + if (isset($line[45])) { |
|
| 781 | + $data['heading'] = $line[45]; |
|
| 782 | + } |
|
| 783 | + // heading |
|
| 784 | + elseif (isset($line[38])) { |
|
| 785 | + $data['heading'] = $line[38]; |
|
| 786 | + } |
|
| 787 | + // heading |
|
| 592 | 788 | $data['latitude'] = $line[5]; // lat |
| 593 | 789 | $data['longitude'] = $line[6]; // long |
| 594 | 790 | $data['verticalrate'] = ''; // vertical rate |
@@ -604,7 +800,9 @@ discard block |
||
| 604 | 800 | $data['frequency'] = $line[4]; |
| 605 | 801 | $data['type'] = $line[18]; |
| 606 | 802 | $data['range'] = $line[19]; |
| 607 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 803 | + if (isset($line[35])) { |
|
| 804 | + $data['info'] = $line[35]; |
|
| 805 | + } |
|
| 608 | 806 | $data['id_source'] = $id_source; |
| 609 | 807 | //$data['arrival_airport_time'] = ; |
| 610 | 808 | if ($line[9] != '') { |
@@ -618,24 +816,41 @@ discard block |
||
| 618 | 816 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 619 | 817 | */ |
| 620 | 818 | $data['format_source'] = $value['format']; |
| 621 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 622 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 623 | - elseif ($line[3] == 'ATC') { |
|
| 819 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 820 | + $data['source_name'] = $value['name']; |
|
| 821 | + } |
|
| 822 | + if ($line[3] == 'PILOT') { |
|
| 823 | + $SI->add($data); |
|
| 824 | + } elseif ($line[3] == 'ATC') { |
|
| 624 | 825 | //print_r($data); |
| 625 | 826 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 626 | 827 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 627 | 828 | $typec = substr($data['ident'],-3); |
| 628 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 629 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 630 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 631 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 632 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 633 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 634 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 635 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 636 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 637 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 638 | - 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']); |
|
| 829 | + if ($typec == 'APP') { |
|
| 830 | + $data['type'] = 'Approach'; |
|
| 831 | + } elseif ($typec == 'TWR') { |
|
| 832 | + $data['type'] = 'Tower'; |
|
| 833 | + } elseif ($typec == 'OBS') { |
|
| 834 | + $data['type'] = 'Observer'; |
|
| 835 | + } elseif ($typec == 'GND') { |
|
| 836 | + $data['type'] = 'Ground'; |
|
| 837 | + } elseif ($typec == 'DEL') { |
|
| 838 | + $data['type'] = 'Delivery'; |
|
| 839 | + } elseif ($typec == 'DEP') { |
|
| 840 | + $data['type'] = 'Departure'; |
|
| 841 | + } elseif ($typec == 'FSS') { |
|
| 842 | + $data['type'] = 'Flight Service Station'; |
|
| 843 | + } elseif ($typec == 'CTR') { |
|
| 844 | + $data['type'] = 'Control Radar or Centre'; |
|
| 845 | + } elseif ($data['type'] == '') { |
|
| 846 | + $data['type'] = 'Observer'; |
|
| 847 | + } |
|
| 848 | + if (!isset($data['source_name'])) { |
|
| 849 | + $data['source_name'] = ''; |
|
| 850 | + } |
|
| 851 | + if (isset($ATC)) { |
|
| 852 | + 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']); |
|
| 853 | + } |
|
| 639 | 854 | } |
| 640 | 855 | unset($data); |
| 641 | 856 | } |
@@ -654,26 +869,55 @@ discard block |
||
| 654 | 869 | foreach ($all_data['acList'] as $line) { |
| 655 | 870 | $data = array(); |
| 656 | 871 | $data['hex'] = $line['Icao']; // hex |
| 657 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 658 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 659 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 660 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 661 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 662 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 872 | + if (isset($line['Call'])) { |
|
| 873 | + $data['ident'] = $line['Call']; |
|
| 874 | + } |
|
| 875 | + // ident |
|
| 876 | + if (isset($line['Alt'])) { |
|
| 877 | + $data['altitude'] = $line['Alt']; |
|
| 878 | + } |
|
| 879 | + // altitude |
|
| 880 | + if (isset($line['Spd'])) { |
|
| 881 | + $data['speed'] = $line['Spd']; |
|
| 882 | + } |
|
| 883 | + // speed |
|
| 884 | + if (isset($line['Trak'])) { |
|
| 885 | + $data['heading'] = $line['Trak']; |
|
| 886 | + } |
|
| 887 | + // heading |
|
| 888 | + if (isset($line['Lat'])) { |
|
| 889 | + $data['latitude'] = $line['Lat']; |
|
| 890 | + } |
|
| 891 | + // lat |
|
| 892 | + if (isset($line['Long'])) { |
|
| 893 | + $data['longitude'] = $line['Long']; |
|
| 894 | + } |
|
| 895 | + // long |
|
| 663 | 896 | //$data['verticalrate'] = $line['']; // verticale rate |
| 664 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 897 | + if (isset($line['Sqk'])) { |
|
| 898 | + $data['squawk'] = $line['Sqk']; |
|
| 899 | + } |
|
| 900 | + // squawk |
|
| 665 | 901 | $data['emergency'] = ''; // emergency |
| 666 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 902 | + if (isset($line['Reg'])) { |
|
| 903 | + $data['registration'] = $line['Reg']; |
|
| 904 | + } |
|
| 667 | 905 | /* |
| 668 | 906 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 669 | 907 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 670 | 908 | */ |
| 671 | 909 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 672 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 910 | + if (isset($line['Type'])) { |
|
| 911 | + $data['aircraft_icao'] = $line['Type']; |
|
| 912 | + } |
|
| 673 | 913 | $data['format_source'] = 'aircraftlistjson'; |
| 674 | 914 | $data['id_source'] = $id_source; |
| 675 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 676 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 915 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 916 | + $data['source_name'] = $value['name']; |
|
| 917 | + } |
|
| 918 | + if (isset($data['latitude'])) { |
|
| 919 | + $SI->add($data); |
|
| 920 | + } |
|
| 677 | 921 | unset($data); |
| 678 | 922 | } |
| 679 | 923 | } elseif (is_array($all_data)) { |
@@ -693,7 +937,9 @@ discard block |
||
| 693 | 937 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 694 | 938 | $data['format_source'] = 'aircraftlistjson'; |
| 695 | 939 | $data['id_source'] = $id_source; |
| 696 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 940 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 941 | + $data['source_name'] = $value['name']; |
|
| 942 | + } |
|
| 697 | 943 | $SI->add($data); |
| 698 | 944 | unset($data); |
| 699 | 945 | } |
@@ -729,7 +975,9 @@ discard block |
||
| 729 | 975 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 730 | 976 | $data['format_source'] = 'planeupdatefaa'; |
| 731 | 977 | $data['id_source'] = $id_source; |
| 732 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 978 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 979 | + $data['source_name'] = $value['name']; |
|
| 980 | + } |
|
| 733 | 981 | $SI->add($data); |
| 734 | 982 | unset($data); |
| 735 | 983 | } |
@@ -769,7 +1017,9 @@ discard block |
||
| 769 | 1017 | //$buffer = $Common->getData($hosts[$id]); |
| 770 | 1018 | $buffer = $Common->getData($value['host']); |
| 771 | 1019 | $all_data = json_decode($buffer,true); |
| 772 | - if (!empty($all_data)) $reset = 0; |
|
| 1020 | + if (!empty($all_data)) { |
|
| 1021 | + $reset = 0; |
|
| 1022 | + } |
|
| 773 | 1023 | foreach ($all_data as $key => $line) { |
| 774 | 1024 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 775 | 1025 | $data = array(); |
@@ -790,7 +1040,9 @@ discard block |
||
| 790 | 1040 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 791 | 1041 | $data['format_source'] = 'fr24json'; |
| 792 | 1042 | $data['id_source'] = $id_source; |
| 793 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1043 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1044 | + $data['source_name'] = $value['name']; |
|
| 1045 | + } |
|
| 794 | 1046 | $SI->add($data); |
| 795 | 1047 | unset($data); |
| 796 | 1048 | } |
@@ -814,23 +1066,39 @@ discard block |
||
| 814 | 1066 | if (isset($line['inf'])) { |
| 815 | 1067 | $data = array(); |
| 816 | 1068 | $data['hex'] = $line['inf']['ia']; |
| 817 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1069 | + if (isset($line['inf']['cs'])) { |
|
| 1070 | + $data['ident'] = $line['inf']['cs']; |
|
| 1071 | + } |
|
| 1072 | + //$line[13] |
|
| 818 | 1073 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 819 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 820 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1074 | + if (isset($line['inf']['gs'])) { |
|
| 1075 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1076 | + } |
|
| 1077 | + // speed |
|
| 1078 | + if (isset($line['inf']['tr'])) { |
|
| 1079 | + $data['heading'] = $line['inf']['tr']; |
|
| 1080 | + } |
|
| 1081 | + // heading |
|
| 821 | 1082 | $data['latitude'] = $line['pt'][0]; // lat |
| 822 | 1083 | $data['longitude'] = $line['pt'][1]; // long |
| 823 | 1084 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 824 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1085 | + if (isset($line['inf']['sq'])) { |
|
| 1086 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1087 | + } |
|
| 1088 | + // squawk |
|
| 825 | 1089 | //$data['aircraft_icao'] = $line[8]; |
| 826 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1090 | + if (isset($line['inf']['rc'])) { |
|
| 1091 | + $data['registration'] = $line['inf']['rc']; |
|
| 1092 | + } |
|
| 827 | 1093 | //$data['departure_airport_iata'] = $line[11]; |
| 828 | 1094 | //$data['arrival_airport_iata'] = $line[12]; |
| 829 | 1095 | //$data['emergency'] = ''; // emergency |
| 830 | 1096 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 831 | 1097 | $data['format_source'] = 'radarvirtueljson'; |
| 832 | 1098 | $data['id_source'] = $id_source; |
| 833 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1099 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1100 | + $data['source_name'] = $value['name']; |
|
| 1101 | + } |
|
| 834 | 1102 | $SI->add($data); |
| 835 | 1103 | unset($data); |
| 836 | 1104 | } |
@@ -851,29 +1119,62 @@ discard block |
||
| 851 | 1119 | $data['id'] = $line['id']; |
| 852 | 1120 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 853 | 1121 | $data['ident'] = $line['callsign']; // ident |
| 854 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 855 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 856 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 857 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 858 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 859 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1122 | + if (isset($line['pilotid'])) { |
|
| 1123 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1124 | + } |
|
| 1125 | + // pilot id |
|
| 1126 | + if (isset($line['name'])) { |
|
| 1127 | + $data['pilot_name'] = $line['name']; |
|
| 1128 | + } |
|
| 1129 | + // pilot name |
|
| 1130 | + if (isset($line['alt'])) { |
|
| 1131 | + $data['altitude'] = $line['alt']; |
|
| 1132 | + } |
|
| 1133 | + // altitude |
|
| 1134 | + if (isset($line['gs'])) { |
|
| 1135 | + $data['speed'] = $line['gs']; |
|
| 1136 | + } |
|
| 1137 | + // speed |
|
| 1138 | + if (isset($line['heading'])) { |
|
| 1139 | + $data['heading'] = $line['heading']; |
|
| 1140 | + } |
|
| 1141 | + // heading |
|
| 1142 | + if (isset($line['route'])) { |
|
| 1143 | + $data['waypoints'] = $line['route']; |
|
| 1144 | + } |
|
| 1145 | + // route |
|
| 860 | 1146 | $data['latitude'] = $line['lat']; // lat |
| 861 | 1147 | $data['longitude'] = $line['lon']; // long |
| 862 | 1148 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 863 | 1149 | //$data['squawk'] = $line['squawk']; // squawk |
| 864 | 1150 | //$data['emergency'] = ''; // emergency |
| 865 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 866 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 867 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1151 | + if (isset($line['depicao'])) { |
|
| 1152 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1153 | + } |
|
| 1154 | + if (isset($line['deptime'])) { |
|
| 1155 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1156 | + } |
|
| 1157 | + if (isset($line['arricao'])) { |
|
| 1158 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1159 | + } |
|
| 868 | 1160 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 869 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 870 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 871 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 872 | - else $data['info'] = ''; |
|
| 1161 | + if (isset($line['aircraft'])) { |
|
| 1162 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1163 | + } |
|
| 1164 | + if (isset($line['transponder'])) { |
|
| 1165 | + $data['squawk'] = $line['transponder']; |
|
| 1166 | + } |
|
| 1167 | + if (isset($line['atis'])) { |
|
| 1168 | + $data['info'] = $line['atis']; |
|
| 1169 | + } else { |
|
| 1170 | + $data['info'] = ''; |
|
| 1171 | + } |
|
| 873 | 1172 | $data['format_source'] = 'pireps'; |
| 874 | 1173 | $data['id_source'] = $id_source; |
| 875 | 1174 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 876 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1175 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1176 | + $data['source_name'] = $value['name']; |
|
| 1177 | + } |
|
| 877 | 1178 | if ($line['icon'] == 'plane') { |
| 878 | 1179 | $SI->add($data); |
| 879 | 1180 | // print_r($data); |
@@ -882,16 +1183,28 @@ discard block |
||
| 882 | 1183 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 883 | 1184 | $typec = substr($data['ident'],-3); |
| 884 | 1185 | $data['type'] = ''; |
| 885 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 886 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 887 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 888 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 889 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 890 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 891 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 892 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 893 | - else $data['type'] = 'Observer'; |
|
| 894 | - 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']); |
|
| 1186 | + if ($typec == 'APP') { |
|
| 1187 | + $data['type'] = 'Approach'; |
|
| 1188 | + } elseif ($typec == 'TWR') { |
|
| 1189 | + $data['type'] = 'Tower'; |
|
| 1190 | + } elseif ($typec == 'OBS') { |
|
| 1191 | + $data['type'] = 'Observer'; |
|
| 1192 | + } elseif ($typec == 'GND') { |
|
| 1193 | + $data['type'] = 'Ground'; |
|
| 1194 | + } elseif ($typec == 'DEL') { |
|
| 1195 | + $data['type'] = 'Delivery'; |
|
| 1196 | + } elseif ($typec == 'DEP') { |
|
| 1197 | + $data['type'] = 'Departure'; |
|
| 1198 | + } elseif ($typec == 'FSS') { |
|
| 1199 | + $data['type'] = 'Flight Service Station'; |
|
| 1200 | + } elseif ($typec == 'CTR') { |
|
| 1201 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1202 | + } else { |
|
| 1203 | + $data['type'] = 'Observer'; |
|
| 1204 | + } |
|
| 1205 | + if (isset($ATC)) { |
|
| 1206 | + 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']); |
|
| 1207 | + } |
|
| 895 | 1208 | } |
| 896 | 1209 | unset($data); |
| 897 | 1210 | } |
@@ -901,7 +1214,9 @@ discard block |
||
| 901 | 1214 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 902 | 1215 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 903 | 1216 | //$buffer = $Common->getData($hosts[$id]); |
| 904 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1217 | + if ($globalDebug) { |
|
| 1218 | + echo 'Get Data...'."\n"; |
|
| 1219 | + } |
|
| 905 | 1220 | $buffer = $Common->getData($value['host']); |
| 906 | 1221 | $all_data = json_decode($buffer,true); |
| 907 | 1222 | if ($buffer != '' && is_array($all_data)) { |
@@ -909,10 +1224,16 @@ discard block |
||
| 909 | 1224 | foreach ($all_data as $line) { |
| 910 | 1225 | $data = array(); |
| 911 | 1226 | //$data['id'] = $line['id']; // id not usable |
| 912 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1227 | + if (isset($line['pilotid'])) { |
|
| 1228 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1229 | + } |
|
| 913 | 1230 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 914 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 915 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1231 | + if (isset($line['pilotname'])) { |
|
| 1232 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1233 | + } |
|
| 1234 | + if (isset($line['pilotid'])) { |
|
| 1235 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1236 | + } |
|
| 916 | 1237 | $data['ident'] = $line['flightnum']; // ident |
| 917 | 1238 | $data['altitude'] = $line['alt']; // altitude |
| 918 | 1239 | $data['speed'] = $line['gs']; // speed |
@@ -930,27 +1251,41 @@ discard block |
||
| 930 | 1251 | $data['arrival_airport_icao'] = $line['arricao']; |
| 931 | 1252 | $data['arrival_airport_time'] = $line['arrtime']; |
| 932 | 1253 | $data['registration'] = $line['aircraft']; |
| 933 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1254 | + if (isset($line['route'])) { |
|
| 1255 | + $data['waypoints'] = $line['route']; |
|
| 1256 | + } |
|
| 1257 | + // route |
|
| 934 | 1258 | if (isset($line['aircraftname'])) { |
| 935 | 1259 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 936 | 1260 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 937 | 1261 | $aircraft_data = explode('-',$line['aircraftname']); |
| 938 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 939 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 940 | - else { |
|
| 1262 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1263 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1264 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1265 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1266 | + } else { |
|
| 941 | 1267 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 942 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 943 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1268 | + if (isset($aircraft_data[1])) { |
|
| 1269 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1270 | + } else { |
|
| 1271 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1272 | + } |
|
| 944 | 1273 | } |
| 945 | 1274 | } |
| 946 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1275 | + if (isset($line['route'])) { |
|
| 1276 | + $data['waypoints'] = $line['route']; |
|
| 1277 | + } |
|
| 947 | 1278 | $data['id_source'] = $id_source; |
| 948 | 1279 | $data['format_source'] = 'phpvmacars'; |
| 949 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1280 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1281 | + $data['source_name'] = $value['name']; |
|
| 1282 | + } |
|
| 950 | 1283 | $SI->add($data); |
| 951 | 1284 | unset($data); |
| 952 | 1285 | } |
| 953 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1286 | + if ($globalDebug) { |
|
| 1287 | + echo 'No more data...'."\n"; |
|
| 1288 | + } |
|
| 954 | 1289 | unset($buffer); |
| 955 | 1290 | unset($all_data); |
| 956 | 1291 | } |
@@ -958,7 +1293,9 @@ discard block |
||
| 958 | 1293 | $last_exec[$id]['last'] = time(); |
| 959 | 1294 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 960 | 1295 | //$buffer = $Common->getData($hosts[$id]); |
| 961 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1296 | + if ($globalDebug) { |
|
| 1297 | + echo 'Get Data...'."\n"; |
|
| 1298 | + } |
|
| 962 | 1299 | $buffer = $Common->getData($value['host']); |
| 963 | 1300 | $all_data = json_decode($buffer,true); |
| 964 | 1301 | if ($buffer != '' && is_array($all_data)) { |
@@ -987,15 +1324,22 @@ discard block |
||
| 987 | 1324 | $data['arrival_airport_icao'] = $line['arrival']; |
| 988 | 1325 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 989 | 1326 | //$data['registration'] = $line['aircraft']; |
| 990 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1327 | + if (isset($line['route'])) { |
|
| 1328 | + $data['waypoints'] = $line['route']; |
|
| 1329 | + } |
|
| 1330 | + // route |
|
| 991 | 1331 | $data['aircraft_icao'] = $line['plane_type']; |
| 992 | 1332 | $data['id_source'] = $id_source; |
| 993 | 1333 | $data['format_source'] = 'vam'; |
| 994 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1334 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1335 | + $data['source_name'] = $value['name']; |
|
| 1336 | + } |
|
| 995 | 1337 | $SI->add($data); |
| 996 | 1338 | unset($data); |
| 997 | 1339 | } |
| 998 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1340 | + if ($globalDebug) { |
|
| 1341 | + echo 'No more data...'."\n"; |
|
| 1342 | + } |
|
| 999 | 1343 | unset($buffer); |
| 1000 | 1344 | unset($all_data); |
| 1001 | 1345 | } |
@@ -1003,7 +1347,9 @@ discard block |
||
| 1003 | 1347 | $last_exec[$id]['last'] = time(); |
| 1004 | 1348 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1005 | 1349 | } 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' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1006 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1350 | + if (function_exists('pcntl_fork')) { |
|
| 1351 | + pcntl_signal_dispatch(); |
|
| 1352 | + } |
|
| 1007 | 1353 | //$last_exec[$id]['last'] = time(); |
| 1008 | 1354 | |
| 1009 | 1355 | //$read = array( $sockets[$id] ); |
@@ -1011,7 +1357,9 @@ discard block |
||
| 1011 | 1357 | $write = NULL; |
| 1012 | 1358 | $e = NULL; |
| 1013 | 1359 | $n = socket_select($read, $write, $e, $timeout); |
| 1014 | - if ($e != NULL) var_dump($e); |
|
| 1360 | + if ($e != NULL) { |
|
| 1361 | + var_dump($e); |
|
| 1362 | + } |
|
| 1015 | 1363 | if ($n > 0) { |
| 1016 | 1364 | $reset = 0; |
| 1017 | 1365 | foreach ($read as $nb => $r) { |
@@ -1032,12 +1380,16 @@ discard block |
||
| 1032 | 1380 | //$SI::del(); |
| 1033 | 1381 | if ($format == 'vrstcp') { |
| 1034 | 1382 | $buffer = explode('},{',$buffer); |
| 1035 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1383 | + } else { |
|
| 1384 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1385 | + } |
|
| 1036 | 1386 | // SBS format is CSV format |
| 1037 | 1387 | if ($buffer !== FALSE && $buffer != '') { |
| 1038 | 1388 | $tt[$format] = 0; |
| 1039 | 1389 | if ($format == 'acarssbs3') { |
| 1040 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1390 | + if ($globalDebug) { |
|
| 1391 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1392 | + } |
|
| 1041 | 1393 | $ACARS->add(trim($buffer)); |
| 1042 | 1394 | $ACARS->deleteLiveAcarsData(); |
| 1043 | 1395 | } elseif ($format == 'raw') { |
@@ -1046,25 +1398,55 @@ discard block |
||
| 1046 | 1398 | if (is_array($data)) { |
| 1047 | 1399 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1048 | 1400 | $data['format_source'] = 'raw'; |
| 1049 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1050 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1051 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1401 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1402 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1403 | + } |
|
| 1404 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1405 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1406 | + } |
|
| 1407 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1408 | + $SI->add($data); |
|
| 1409 | + } |
|
| 1052 | 1410 | } |
| 1053 | 1411 | } elseif ($format == 'ais') { |
| 1054 | 1412 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1055 | 1413 | $data = array(); |
| 1056 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1057 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1058 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1059 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1060 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1061 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1062 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1063 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1064 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1065 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1066 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1067 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1414 | + if (isset($ais_data['ident'])) { |
|
| 1415 | + $data['ident'] = $ais_data['ident']; |
|
| 1416 | + } |
|
| 1417 | + if (isset($ais_data['mmsi'])) { |
|
| 1418 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 1419 | + } |
|
| 1420 | + if (isset($ais_data['speed'])) { |
|
| 1421 | + $data['speed'] = $ais_data['speed']; |
|
| 1422 | + } |
|
| 1423 | + if (isset($ais_data['heading'])) { |
|
| 1424 | + $data['heading'] = $ais_data['heading']; |
|
| 1425 | + } |
|
| 1426 | + if (isset($ais_data['latitude'])) { |
|
| 1427 | + $data['latitude'] = $ais_data['latitude']; |
|
| 1428 | + } |
|
| 1429 | + if (isset($ais_data['longitude'])) { |
|
| 1430 | + $data['longitude'] = $ais_data['longitude']; |
|
| 1431 | + } |
|
| 1432 | + if (isset($ais_data['status'])) { |
|
| 1433 | + $data['status'] = $ais_data['status']; |
|
| 1434 | + } |
|
| 1435 | + if (isset($ais_data['type'])) { |
|
| 1436 | + $data['type'] = $ais_data['type']; |
|
| 1437 | + } |
|
| 1438 | + if (isset($ais_data['imo'])) { |
|
| 1439 | + $data['imo'] = $ais_data['imo']; |
|
| 1440 | + } |
|
| 1441 | + if (isset($ais_data['callsign'])) { |
|
| 1442 | + $data['callsign'] = $ais_data['callsign']; |
|
| 1443 | + } |
|
| 1444 | + if (isset($ais_data['destination'])) { |
|
| 1445 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 1446 | + } |
|
| 1447 | + if (isset($ais_data['eta_ts'])) { |
|
| 1448 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1449 | + } |
|
| 1068 | 1450 | |
| 1069 | 1451 | if (isset($ais_data['timestamp'])) { |
| 1070 | 1452 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1073,7 +1455,9 @@ discard block |
||
| 1073 | 1455 | } |
| 1074 | 1456 | $data['format_source'] = 'aisnmea'; |
| 1075 | 1457 | $data['id_source'] = $id_source; |
| 1076 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1458 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 1459 | + $MI->add($data); |
|
| 1460 | + } |
|
| 1077 | 1461 | unset($data); |
| 1078 | 1462 | } elseif ($format == 'flightgearsp') { |
| 1079 | 1463 | //echo $buffer."\n"; |
@@ -1091,11 +1475,15 @@ discard block |
||
| 1091 | 1475 | $data['speed'] = round($line[5]*1.94384); |
| 1092 | 1476 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1093 | 1477 | $data['format_source'] = 'flightgearsp'; |
| 1094 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1478 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1479 | + $SI->add($data); |
|
| 1480 | + } |
|
| 1095 | 1481 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1096 | 1482 | } |
| 1097 | 1483 | } elseif ($format == 'acars') { |
| 1098 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1484 | + if ($globalDebug) { |
|
| 1485 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1486 | + } |
|
| 1099 | 1487 | $ACARS->add(trim($buffer)); |
| 1100 | 1488 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1101 | 1489 | $ACARS->deleteLiveAcarsData(); |
@@ -1116,7 +1504,9 @@ discard block |
||
| 1116 | 1504 | $aircraft_type = $line[10]; |
| 1117 | 1505 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1118 | 1506 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1119 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1507 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1508 | + $SI->add($data); |
|
| 1509 | + } |
|
| 1120 | 1510 | } |
| 1121 | 1511 | } |
| 1122 | 1512 | } elseif ($format == 'beast') { |
@@ -1126,27 +1516,59 @@ discard block |
||
| 1126 | 1516 | foreach($buffer as $all_data) { |
| 1127 | 1517 | $line = json_decode('{'.$all_data.'}',true); |
| 1128 | 1518 | $data = array(); |
| 1129 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1130 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1131 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1132 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1133 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1134 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1135 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1519 | + if (isset($line['Icao'])) { |
|
| 1520 | + $data['hex'] = $line['Icao']; |
|
| 1521 | + } |
|
| 1522 | + // hex |
|
| 1523 | + if (isset($line['Call'])) { |
|
| 1524 | + $data['ident'] = $line['Call']; |
|
| 1525 | + } |
|
| 1526 | + // ident |
|
| 1527 | + if (isset($line['Alt'])) { |
|
| 1528 | + $data['altitude'] = $line['Alt']; |
|
| 1529 | + } |
|
| 1530 | + // altitude |
|
| 1531 | + if (isset($line['Spd'])) { |
|
| 1532 | + $data['speed'] = $line['Spd']; |
|
| 1533 | + } |
|
| 1534 | + // speed |
|
| 1535 | + if (isset($line['Trak'])) { |
|
| 1536 | + $data['heading'] = $line['Trak']; |
|
| 1537 | + } |
|
| 1538 | + // heading |
|
| 1539 | + if (isset($line['Lat'])) { |
|
| 1540 | + $data['latitude'] = $line['Lat']; |
|
| 1541 | + } |
|
| 1542 | + // lat |
|
| 1543 | + if (isset($line['Long'])) { |
|
| 1544 | + $data['longitude'] = $line['Long']; |
|
| 1545 | + } |
|
| 1546 | + // long |
|
| 1136 | 1547 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1137 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1548 | + if (isset($line['Sqk'])) { |
|
| 1549 | + $data['squawk'] = $line['Sqk']; |
|
| 1550 | + } |
|
| 1551 | + // squawk |
|
| 1138 | 1552 | $data['emergency'] = ''; // emergency |
| 1139 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1553 | + if (isset($line['Reg'])) { |
|
| 1554 | + $data['registration'] = $line['Reg']; |
|
| 1555 | + } |
|
| 1140 | 1556 | /* |
| 1141 | 1557 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1142 | 1558 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1143 | 1559 | */ |
| 1144 | 1560 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1145 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1561 | + if (isset($line['Type'])) { |
|
| 1562 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1563 | + } |
|
| 1146 | 1564 | $data['format_source'] = 'vrstcp'; |
| 1147 | 1565 | $data['id_source'] = $id_source; |
| 1148 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1149 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 1566 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1567 | + $data['source_name'] = $value['name']; |
|
| 1568 | + } |
|
| 1569 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 1570 | + $SI->add($data); |
|
| 1571 | + } |
|
| 1150 | 1572 | unset($data); |
| 1151 | 1573 | } |
| 1152 | 1574 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1159,21 +1581,43 @@ discard block |
||
| 1159 | 1581 | $data['hex'] = $lined['hexid']; |
| 1160 | 1582 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1161 | 1583 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1162 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1163 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1164 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1165 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1166 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1167 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1168 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1584 | + if (isset($lined['ident'])) { |
|
| 1585 | + $data['ident'] = $lined['ident']; |
|
| 1586 | + } |
|
| 1587 | + if (isset($lined['lat'])) { |
|
| 1588 | + $data['latitude'] = $lined['lat']; |
|
| 1589 | + } |
|
| 1590 | + if (isset($lined['lon'])) { |
|
| 1591 | + $data['longitude'] = $lined['lon']; |
|
| 1592 | + } |
|
| 1593 | + if (isset($lined['speed'])) { |
|
| 1594 | + $data['speed'] = $lined['speed']; |
|
| 1595 | + } |
|
| 1596 | + if (isset($lined['squawk'])) { |
|
| 1597 | + $data['squawk'] = $lined['squawk']; |
|
| 1598 | + } |
|
| 1599 | + if (isset($lined['alt'])) { |
|
| 1600 | + $data['altitude'] = $lined['alt']; |
|
| 1601 | + } |
|
| 1602 | + if (isset($lined['heading'])) { |
|
| 1603 | + $data['heading'] = $lined['heading']; |
|
| 1604 | + } |
|
| 1169 | 1605 | $data['id_source'] = $id_source; |
| 1170 | 1606 | $data['format_source'] = 'tsv'; |
| 1171 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1172 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1173 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1607 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1608 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1609 | + } |
|
| 1610 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1611 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1612 | + } |
|
| 1613 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1614 | + $SI->add($data); |
|
| 1615 | + } |
|
| 1174 | 1616 | unset($lined); |
| 1175 | 1617 | unset($data); |
| 1176 | - } else $error = true; |
|
| 1618 | + } else { |
|
| 1619 | + $error = true; |
|
| 1620 | + } |
|
| 1177 | 1621 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1178 | 1622 | if ($aprs_connect == 0) { |
| 1179 | 1623 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1199,49 +1643,82 @@ discard block |
||
| 1199 | 1643 | $aprs_last_tx = time(); |
| 1200 | 1644 | $data = array(); |
| 1201 | 1645 | //print_r($line); |
| 1202 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1203 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1204 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1646 | + if (isset($line['address'])) { |
|
| 1647 | + $data['hex'] = $line['address']; |
|
| 1648 | + } |
|
| 1649 | + if (isset($line['timestamp'])) { |
|
| 1650 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1651 | + } else { |
|
| 1652 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1653 | + } |
|
| 1205 | 1654 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1206 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1655 | + if (isset($line['ident'])) { |
|
| 1656 | + $data['ident'] = $line['ident']; |
|
| 1657 | + } |
|
| 1207 | 1658 | $data['latitude'] = $line['latitude']; |
| 1208 | 1659 | $data['longitude'] = $line['longitude']; |
| 1209 | 1660 | //$data['verticalrate'] = $line[16]; |
| 1210 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1211 | - else $data['speed'] = 0; |
|
| 1212 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1213 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1214 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1215 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1661 | + if (isset($line['speed'])) { |
|
| 1662 | + $data['speed'] = $line['speed']; |
|
| 1663 | + } else { |
|
| 1664 | + $data['speed'] = 0; |
|
| 1665 | + } |
|
| 1666 | + if (isset($line['altitude'])) { |
|
| 1667 | + $data['altitude'] = $line['altitude']; |
|
| 1668 | + } |
|
| 1669 | + if (isset($line['comment'])) { |
|
| 1670 | + $data['comment'] = $line['comment']; |
|
| 1671 | + } |
|
| 1672 | + if (isset($line['symbol'])) { |
|
| 1673 | + $data['type'] = $line['symbol']; |
|
| 1674 | + } |
|
| 1675 | + if (isset($line['heading'])) { |
|
| 1676 | + $data['heading'] = $line['heading']; |
|
| 1677 | + } |
|
| 1216 | 1678 | //else $data['heading'] = 0; |
| 1217 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1218 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 1679 | + if (isset($line['stealth'])) { |
|
| 1680 | + $data['aircraft_type'] = $line['stealth']; |
|
| 1681 | + } |
|
| 1682 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
| 1683 | + $data['noarchive'] = true; |
|
| 1684 | + } |
|
| 1219 | 1685 | $data['id_source'] = $id_source; |
| 1220 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1221 | - else $data['format_source'] = 'aprs'; |
|
| 1686 | + if (isset($line['format_source'])) { |
|
| 1687 | + $data['format_source'] = $line['format_source']; |
|
| 1688 | + } else { |
|
| 1689 | + $data['format_source'] = 'aprs'; |
|
| 1690 | + } |
|
| 1222 | 1691 | $data['source_name'] = $line['source']; |
| 1223 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1224 | - else $data['source_type'] = 'flarm'; |
|
| 1225 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1692 | + if (isset($line['source_type'])) { |
|
| 1693 | + $data['source_type'] = $line['source_type']; |
|
| 1694 | + } else { |
|
| 1695 | + $data['source_type'] = 'flarm'; |
|
| 1696 | + } |
|
| 1697 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1698 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1699 | + } |
|
| 1226 | 1700 | $currentdate = date('Y-m-d H:i:s'); |
| 1227 | 1701 | $aprsdate = strtotime($data['datetime']); |
| 1228 | 1702 | // Accept data if time <= system time + 20s |
| 1229 | 1703 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1230 | 1704 | $send = $SI->add($data); |
| 1231 | 1705 | } elseif (isset($line['stealth'])) { |
| 1232 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1233 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1706 | + if ($line['stealth'] != 0) { |
|
| 1707 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1708 | + } else { |
|
| 1709 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1710 | + } |
|
| 1234 | 1711 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
| 1235 | 1712 | } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1236 | 1713 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1237 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 1714 | + if (isset($globalTracker) && $globalTracker) { |
|
| 1715 | + $send = $TI->add($data); |
|
| 1716 | + } |
|
| 1238 | 1717 | } |
| 1239 | 1718 | unset($data); |
| 1240 | - } |
|
| 1241 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1719 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1242 | 1720 | echo '!! Weather Station not yet supported'."\n"; |
| 1243 | - } |
|
| 1244 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
| 1721 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
| 1245 | 1722 | echo '!! Car & Trucks not yet supported'."\n"; |
| 1246 | 1723 | } |
| 1247 | 1724 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1274,25 +1751,42 @@ discard block |
||
| 1274 | 1751 | $data['ground'] = $line[21]; |
| 1275 | 1752 | $data['emergency'] = $line[19]; |
| 1276 | 1753 | $data['format_source'] = 'sbs'; |
| 1277 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1278 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1754 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1755 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1756 | + } |
|
| 1757 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1758 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1759 | + } |
|
| 1279 | 1760 | $data['id_source'] = $id_source; |
| 1280 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1281 | - else $error = true; |
|
| 1761 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1762 | + $send = $SI->add($data); |
|
| 1763 | + } else { |
|
| 1764 | + $error = true; |
|
| 1765 | + } |
|
| 1282 | 1766 | unset($data); |
| 1283 | - } else $error = true; |
|
| 1767 | + } else { |
|
| 1768 | + $error = true; |
|
| 1769 | + } |
|
| 1284 | 1770 | if ($error) { |
| 1285 | 1771 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1286 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 1772 | + if ($globalDebug) { |
|
| 1773 | + echo "Not a message. Ignoring... \n"; |
|
| 1774 | + } |
|
| 1287 | 1775 | } else { |
| 1288 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 1776 | + if ($globalDebug) { |
|
| 1777 | + echo "Wrong line format. Ignoring... \n"; |
|
| 1778 | + } |
|
| 1289 | 1779 | if ($globalDebug) { |
| 1290 | 1780 | echo $buffer; |
| 1291 | 1781 | print_r($line); |
| 1292 | 1782 | } |
| 1293 | 1783 | //socket_close($r); |
| 1294 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1295 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 1784 | + if ($globalDebug) { |
|
| 1785 | + echo "Reconnect after an error...\n"; |
|
| 1786 | + } |
|
| 1787 | + if ($format == 'aprs') { |
|
| 1788 | + $aprs_connect = 0; |
|
| 1789 | + } |
|
| 1296 | 1790 | $sourceer[$nb] = $globalSources[$nb]; |
| 1297 | 1791 | connect_all($sourceer); |
| 1298 | 1792 | $sourceer = array(); |
@@ -1300,10 +1794,14 @@ discard block |
||
| 1300 | 1794 | } |
| 1301 | 1795 | } |
| 1302 | 1796 | // Sleep for xxx microseconds |
| 1303 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 1797 | + if (isset($globalSBSSleep)) { |
|
| 1798 | + usleep($globalSBSSleep); |
|
| 1799 | + } |
|
| 1304 | 1800 | } else { |
| 1305 | 1801 | if ($format == 'flightgearmp') { |
| 1306 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1802 | + if ($globalDebug) { |
|
| 1803 | + echo "Reconnect FlightGear MP..."; |
|
| 1804 | + } |
|
| 1307 | 1805 | //@socket_close($r); |
| 1308 | 1806 | sleep($globalMinFetch); |
| 1309 | 1807 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1312,10 +1810,15 @@ discard block |
||
| 1312 | 1810 | break; |
| 1313 | 1811 | |
| 1314 | 1812 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1315 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1316 | - else $tt[$format] = 0; |
|
| 1813 | + if (isset($tt[$format])) { |
|
| 1814 | + $tt[$format]++; |
|
| 1815 | + } else { |
|
| 1816 | + $tt[$format] = 0; |
|
| 1817 | + } |
|
| 1317 | 1818 | if ($tt[$format] > 30) { |
| 1318 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 1819 | + if ($globalDebug) { |
|
| 1820 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 1821 | + } |
|
| 1319 | 1822 | //@socket_close($r); |
| 1320 | 1823 | sleep(2); |
| 1321 | 1824 | $aprs_connect = 0; |
@@ -1332,11 +1835,17 @@ discard block |
||
| 1332 | 1835 | } else { |
| 1333 | 1836 | $error = socket_strerror(socket_last_error()); |
| 1334 | 1837 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1335 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1336 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 1838 | + if ($globalDebug) { |
|
| 1839 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1840 | + } |
|
| 1841 | + if (isset($globalDebug)) { |
|
| 1842 | + echo "Restarting...\n"; |
|
| 1843 | + } |
|
| 1337 | 1844 | // Restart the script if possible |
| 1338 | 1845 | if (is_array($sockets)) { |
| 1339 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1846 | + if ($globalDebug) { |
|
| 1847 | + echo "Shutdown all sockets..."; |
|
| 1848 | + } |
|
| 1340 | 1849 | |
| 1341 | 1850 | foreach ($sockets as $sock) { |
| 1342 | 1851 | @socket_shutdown($sock,2); |
@@ -1344,21 +1853,33 @@ discard block |
||
| 1344 | 1853 | } |
| 1345 | 1854 | |
| 1346 | 1855 | } |
| 1347 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 1856 | + if ($globalDebug) { |
|
| 1857 | + echo "Restart all connections..."; |
|
| 1858 | + } |
|
| 1348 | 1859 | sleep(2); |
| 1349 | 1860 | $time = time(); |
| 1350 | 1861 | //connect_all($hosts); |
| 1351 | 1862 | $aprs_connect = 0; |
| 1352 | - if ($reset%5 == 0) sleep(20); |
|
| 1353 | - if ($reset%10 == 0) sleep(100); |
|
| 1354 | - if ($reset%20 == 0) sleep(200); |
|
| 1355 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 1863 | + if ($reset%5 == 0) { |
|
| 1864 | + sleep(20); |
|
| 1865 | + } |
|
| 1866 | + if ($reset%10 == 0) { |
|
| 1867 | + sleep(100); |
|
| 1868 | + } |
|
| 1869 | + if ($reset%20 == 0) { |
|
| 1870 | + sleep(200); |
|
| 1871 | + } |
|
| 1872 | + if ($reset > 100) { |
|
| 1873 | + exit('Too many attempts...'); |
|
| 1874 | + } |
|
| 1356 | 1875 | connect_all($globalSources); |
| 1357 | 1876 | } |
| 1358 | 1877 | } |
| 1359 | 1878 | } |
| 1360 | 1879 | if ($globalDaemon === false) { |
| 1361 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1880 | + if ($globalDebug) { |
|
| 1881 | + echo 'Check all...'."\n"; |
|
| 1882 | + } |
|
| 1362 | 1883 | $SI->checkAll(); |
| 1363 | 1884 | } |
| 1364 | 1885 | } |