@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,42 +25,42 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->latest() === false) { |
28 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
29 | - exit(); |
|
28 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if (PHP_SAPI != 'cli') { |
32 | - echo "This script MUST be called from console, not a web browser."; |
|
32 | + echo "This script MUST be called from console, not a web browser."; |
|
33 | 33 | // exit(); |
34 | 34 | } |
35 | 35 | |
36 | 36 | // This is to be compatible with old version of settings.php |
37 | 37 | if (!isset($globalSources)) { |
38 | - if (isset($globalSBS1Hosts)) { |
|
39 | - //$hosts = $globalSBS1Hosts; |
|
40 | - foreach ($globalSBS1Hosts as $host) { |
|
41 | - $globalSources[] = array('host' => $host); |
|
42 | - } |
|
43 | - } else { |
|
44 | - if (!isset($globalSBS1Host)) { |
|
45 | - echo '$globalSources MUST be defined !'; |
|
46 | - die; |
|
38 | + if (isset($globalSBS1Hosts)) { |
|
39 | + //$hosts = $globalSBS1Hosts; |
|
40 | + foreach ($globalSBS1Hosts as $host) { |
|
41 | + $globalSources[] = array('host' => $host); |
|
42 | + } |
|
43 | + } else { |
|
44 | + if (!isset($globalSBS1Host)) { |
|
45 | + echo '$globalSources MUST be defined !'; |
|
46 | + die; |
|
47 | 47 | } |
48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
49 | 49 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
50 | - } |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 56 | if (isset($options['s'])) { |
57 | - $globalSources = array(); |
|
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | - else $globalSources[] = array('host' => $options['s']); |
|
57 | + $globalSources = array(); |
|
58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | + else $globalSources[] = array('host' => $options['s']); |
|
60 | 60 | } elseif (isset($options['source'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['source']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['source']); |
|
64 | 64 | } |
65 | 65 | if (isset($options['aprsserverhost'])) { |
66 | 66 | $globalServerAPRS = TRUE; |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
76 | 76 | else $id_source = 1; |
77 | 77 | if (isset($globalServer) && $globalServer) { |
78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
79 | - $SI=new SpotterServer(); |
|
78 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
79 | + $SI=new SpotterServer(); |
|
80 | 80 | /* |
81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 82 | $SI = new adsb2aprs(); |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | } else $SI=new SpotterImport($Connection->db); |
86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
87 | 87 | if (isset($globalMarine) && $globalMarine) { |
88 | - $AIS = new AIS(); |
|
89 | - $MI = new MarineImport($Connection->db); |
|
88 | + $AIS = new AIS(); |
|
89 | + $MI = new MarineImport($Connection->db); |
|
90 | 90 | } |
91 | 91 | //$APRS=new APRS($Connection->db); |
92 | 92 | $SBS=new SBS(); |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | //$servertz = system('date +%Z'); |
98 | 98 | // signal handler - playing nice with sockets and dump1090 |
99 | 99 | if (function_exists('pcntl_fork')) { |
100 | - pcntl_signal(SIGINT, function() { |
|
101 | - global $sockets; |
|
102 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
103 | - die("Bye!\n"); |
|
104 | - }); |
|
105 | - pcntl_signal_dispatch(); |
|
100 | + pcntl_signal(SIGINT, function() { |
|
101 | + global $sockets; |
|
102 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
103 | + die("Bye!\n"); |
|
104 | + }); |
|
105 | + pcntl_signal_dispatch(); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // let's try and connect |
@@ -112,36 +112,36 @@ discard block |
||
112 | 112 | $reset = 0; |
113 | 113 | |
114 | 114 | function connect_all($hosts) { |
115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
117 | - $reset++; |
|
118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
119 | - foreach ($hosts as $id => $value) { |
|
115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
116 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
117 | + $reset++; |
|
118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
119 | + foreach ($hosts as $id => $value) { |
|
120 | 120 | $host = $value['host']; |
121 | 121 | $globalSources[$id]['last_exec'] = 0; |
122 | 122 | // Here we check type of source(s) |
123 | 123 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
125 | - //$formats[$id] = 'deltadbtxt'; |
|
126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
127 | - //$last_exec['deltadbtxt'] = 0; |
|
128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
130 | - //$formats[$id] = 'vatsimtxt'; |
|
131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
132 | - //$last_exec['vatsimtxt'] = 0; |
|
133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
135 | - //$formats[$id] = 'aircraftlistjson'; |
|
136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
137 | - //$last_exec['aircraftlistjson'] = 0; |
|
138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
139 | - } else if (preg_match('/opensky/i',$host)) { |
|
140 | - //$formats[$id] = 'aircraftlistjson'; |
|
141 | - $globalSources[$id]['format'] = 'opensky'; |
|
142 | - //$last_exec['aircraftlistjson'] = 0; |
|
143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
144 | - /* |
|
124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
125 | + //$formats[$id] = 'deltadbtxt'; |
|
126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
127 | + //$last_exec['deltadbtxt'] = 0; |
|
128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
130 | + //$formats[$id] = 'vatsimtxt'; |
|
131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
132 | + //$last_exec['vatsimtxt'] = 0; |
|
133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
135 | + //$formats[$id] = 'aircraftlistjson'; |
|
136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
137 | + //$last_exec['aircraftlistjson'] = 0; |
|
138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
139 | + } else if (preg_match('/opensky/i',$host)) { |
|
140 | + //$formats[$id] = 'aircraftlistjson'; |
|
141 | + $globalSources[$id]['format'] = 'opensky'; |
|
142 | + //$last_exec['aircraftlistjson'] = 0; |
|
143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
144 | + /* |
|
145 | 145 | // Disabled for now, site change source format |
146 | 146 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
147 | 147 | //$formats[$id] = 'radarvirtueljson'; |
@@ -153,121 +153,121 @@ discard block |
||
153 | 153 | exit(0); |
154 | 154 | } |
155 | 155 | */ |
156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
157 | - //$formats[$id] = 'planeupdatefaa'; |
|
158 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
159 | - //$last_exec['planeupdatefaa'] = 0; |
|
160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
161 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
162 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
163 | - exit(0); |
|
164 | - } |
|
165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
166 | - //$formats[$id] = 'phpvmacars'; |
|
167 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
168 | - //$last_exec['phpvmacars'] = 0; |
|
169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
171 | - //$formats[$id] = 'phpvmacars'; |
|
172 | - $globalSources[$id]['format'] = 'vam'; |
|
173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
175 | - //$formats[$id] = 'whazzup'; |
|
176 | - $globalSources[$id]['format'] = 'whazzup'; |
|
177 | - //$last_exec['whazzup'] = 0; |
|
178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
179 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
180 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
181 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
182 | - } else if (preg_match('/airwhere/i',$host)) { |
|
183 | - $globalSources[$id]['format'] = 'airwhere'; |
|
184 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
185 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
186 | - //$formats[$id] = 'pirepsjson'; |
|
187 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
188 | - //$last_exec['pirepsjson'] = 0; |
|
189 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
190 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
191 | - //$formats[$id] = 'fr24json'; |
|
192 | - $globalSources[$id]['format'] = 'fr24json'; |
|
193 | - //$last_exec['fr24json'] = 0; |
|
194 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
195 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
196 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
197 | - exit(0); |
|
198 | - } |
|
199 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
200 | - //$formats[$id] = 'fr24json'; |
|
201 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
202 | - //$last_exec['fr24json'] = 0; |
|
203 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
204 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
205 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
206 | - exit(0); |
|
207 | - } |
|
208 | - //} else if (preg_match('/10001/',$host)) { |
|
209 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
210 | - //$formats[$id] = 'tsv'; |
|
211 | - $globalSources[$id]['format'] = 'tsv'; |
|
212 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
213 | - } |
|
214 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
215 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
216 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
217 | - if ($idf !== false) { |
|
218 | - $httpfeeds[$id] = $idf; |
|
219 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
220 | - } |
|
221 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
222 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
223 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
224 | - $hostport = explode(':',$host); |
|
225 | - if (isset($hostport[1])) { |
|
156 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
157 | + //$formats[$id] = 'planeupdatefaa'; |
|
158 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
159 | + //$last_exec['planeupdatefaa'] = 0; |
|
160 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
161 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
162 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
163 | + exit(0); |
|
164 | + } |
|
165 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
166 | + //$formats[$id] = 'phpvmacars'; |
|
167 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
168 | + //$last_exec['phpvmacars'] = 0; |
|
169 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
170 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
171 | + //$formats[$id] = 'phpvmacars'; |
|
172 | + $globalSources[$id]['format'] = 'vam'; |
|
173 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
174 | + } else if (preg_match('/whazzup/i',$host)) { |
|
175 | + //$formats[$id] = 'whazzup'; |
|
176 | + $globalSources[$id]['format'] = 'whazzup'; |
|
177 | + //$last_exec['whazzup'] = 0; |
|
178 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
179 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
180 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
181 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
182 | + } else if (preg_match('/airwhere/i',$host)) { |
|
183 | + $globalSources[$id]['format'] = 'airwhere'; |
|
184 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
185 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
186 | + //$formats[$id] = 'pirepsjson'; |
|
187 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
188 | + //$last_exec['pirepsjson'] = 0; |
|
189 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
190 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
191 | + //$formats[$id] = 'fr24json'; |
|
192 | + $globalSources[$id]['format'] = 'fr24json'; |
|
193 | + //$last_exec['fr24json'] = 0; |
|
194 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
195 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
196 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
197 | + exit(0); |
|
198 | + } |
|
199 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
200 | + //$formats[$id] = 'fr24json'; |
|
201 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
202 | + //$last_exec['fr24json'] = 0; |
|
203 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
204 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
205 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
206 | + exit(0); |
|
207 | + } |
|
208 | + //} else if (preg_match('/10001/',$host)) { |
|
209 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
210 | + //$formats[$id] = 'tsv'; |
|
211 | + $globalSources[$id]['format'] = 'tsv'; |
|
212 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
213 | + } |
|
214 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
215 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
216 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
217 | + if ($idf !== false) { |
|
218 | + $httpfeeds[$id] = $idf; |
|
219 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
220 | + } |
|
221 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
222 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
223 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
224 | + $hostport = explode(':',$host); |
|
225 | + if (isset($hostport[1])) { |
|
226 | 226 | $port = $hostport[1]; |
227 | 227 | $hostn = $hostport[0]; |
228 | - } else { |
|
228 | + } else { |
|
229 | 229 | $port = $globalSources[$id]['port']; |
230 | 230 | $hostn = $globalSources[$id]['host']; |
231 | - } |
|
232 | - $Common = new Common(); |
|
233 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
234 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
235 | - } else { |
|
236 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
237 | - } |
|
238 | - if ($s) { |
|
239 | - $sockets[$id] = $s; |
|
240 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
241 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
231 | + } |
|
232 | + $Common = new Common(); |
|
233 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
234 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
235 | + } else { |
|
236 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
237 | + } |
|
238 | + if ($s) { |
|
239 | + $sockets[$id] = $s; |
|
240 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
241 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
242 | 242 | //$formats[$id] = 'aprs'; |
243 | 243 | $globalSources[$id]['format'] = 'aprs'; |
244 | 244 | //$aprs_connect = 0; |
245 | 245 | //$use_aprs = true; |
246 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
246 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
247 | 247 | $globalSources[$id]['format'] = 'vrstcp'; |
248 | - } elseif ($port == '10001') { |
|
249 | - //$formats[$id] = 'tsv'; |
|
250 | - $globalSources[$id]['format'] = 'tsv'; |
|
251 | - } elseif ($port == '30002') { |
|
252 | - //$formats[$id] = 'raw'; |
|
253 | - $globalSources[$id]['format'] = 'raw'; |
|
254 | - } elseif ($port == '5001') { |
|
255 | - //$formats[$id] = 'raw'; |
|
256 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
257 | - } elseif ($port == '30005') { |
|
248 | + } elseif ($port == '10001') { |
|
249 | + //$formats[$id] = 'tsv'; |
|
250 | + $globalSources[$id]['format'] = 'tsv'; |
|
251 | + } elseif ($port == '30002') { |
|
252 | + //$formats[$id] = 'raw'; |
|
253 | + $globalSources[$id]['format'] = 'raw'; |
|
254 | + } elseif ($port == '5001') { |
|
255 | + //$formats[$id] = 'raw'; |
|
256 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
257 | + } elseif ($port == '30005') { |
|
258 | 258 | // Not yet supported |
259 | - //$formats[$id] = 'beast'; |
|
260 | - $globalSources[$id]['format'] = 'beast'; |
|
261 | - //} else $formats[$id] = 'sbs'; |
|
262 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
263 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
259 | + //$formats[$id] = 'beast'; |
|
260 | + $globalSources[$id]['format'] = 'beast'; |
|
261 | + //} else $formats[$id] = 'sbs'; |
|
262 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
263 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
264 | 264 | } |
265 | 265 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
266 | - } else { |
|
266 | + } else { |
|
267 | 267 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
268 | - } |
|
269 | - } |
|
270 | - } |
|
268 | + } |
|
269 | + } |
|
270 | + } |
|
271 | 271 | } |
272 | 272 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
273 | 273 | |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | //connect_all($globalSources); |
291 | 291 | |
292 | 292 | if (isset($globalProxy) && $globalProxy) { |
293 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
293 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
294 | 294 | } else { |
295 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
295 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | // APRS Configuration |
@@ -301,21 +301,21 @@ discard block |
||
301 | 301 | die; |
302 | 302 | } |
303 | 303 | foreach ($globalSources as $key => $source) { |
304 | - if (!isset($source['format'])) { |
|
305 | - $globalSources[$key]['format'] = 'auto'; |
|
306 | - } |
|
307 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
308 | - unset($globalSources[$key]); |
|
309 | - } |
|
304 | + if (!isset($source['format'])) { |
|
305 | + $globalSources[$key]['format'] = 'auto'; |
|
306 | + } |
|
307 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
308 | + unset($globalSources[$key]); |
|
309 | + } |
|
310 | 310 | } |
311 | 311 | connect_all($globalSources); |
312 | 312 | foreach ($globalSources as $key => $source) { |
313 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
313 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
314 | 314 | $aprs_connect = 0; |
315 | 315 | $use_aprs = true; |
316 | 316 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
317 | 317 | break; |
318 | - } |
|
318 | + } |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | if ($use_aprs) { |
@@ -356,115 +356,115 @@ discard block |
||
356 | 356 | |
357 | 357 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
358 | 358 | while ($i > 0) { |
359 | - if (!$globalDaemon) $i = $endtime-time(); |
|
360 | - // Delete old ATC |
|
361 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
359 | + if (!$globalDaemon) $i = $endtime-time(); |
|
360 | + // Delete old ATC |
|
361 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
362 | 362 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
363 | - $ATC->deleteOldATC(); |
|
364 | - } |
|
363 | + $ATC->deleteOldATC(); |
|
364 | + } |
|
365 | 365 | |
366 | - if (count($last_exec) == count($globalSources)) { |
|
366 | + if (count($last_exec) == count($globalSources)) { |
|
367 | 367 | $max = $globalMinFetch; |
368 | 368 | foreach ($last_exec as $last) { |
369 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
369 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
370 | 370 | } |
371 | 371 | if ($max != $globalMinFetch) { |
372 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
373 | - sleep($globalMinFetch-$max+2); |
|
372 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
373 | + sleep($globalMinFetch-$max+2); |
|
374 | + } |
|
374 | 375 | } |
375 | - } |
|
376 | 376 | |
377 | 377 | |
378 | - //foreach ($formats as $id => $value) { |
|
379 | - foreach ($globalSources as $id => $value) { |
|
378 | + //foreach ($formats as $id => $value) { |
|
379 | + foreach ($globalSources as $id => $value) { |
|
380 | 380 | date_default_timezone_set('UTC'); |
381 | 381 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
382 | 382 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
383 | - //$buffer = $Common->getData($hosts[$id]); |
|
384 | - $buffer = $Common->getData($value['host']); |
|
385 | - if ($buffer != '') $reset = 0; |
|
386 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
387 | - $buffer = explode('\n',$buffer); |
|
388 | - foreach ($buffer as $line) { |
|
389 | - if ($line != '' && count($line) > 7) { |
|
390 | - $line = explode(',', $line); |
|
391 | - $data = array(); |
|
392 | - $data['hex'] = $line[1]; // hex |
|
393 | - $data['ident'] = $line[2]; // ident |
|
394 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
395 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
396 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
397 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
398 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
399 | - $data['verticalrate'] = ''; // vertical rate |
|
400 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
401 | - $data['emergency'] = ''; // emergency |
|
402 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
403 | - $data['format_source'] = 'deltadbtxt'; |
|
404 | - $data['id_source'] = $id_source; |
|
405 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
406 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
407 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
408 | - $SI->add($data); |
|
409 | - unset($data); |
|
410 | - } |
|
411 | - } |
|
412 | - $last_exec[$id]['last'] = time(); |
|
383 | + //$buffer = $Common->getData($hosts[$id]); |
|
384 | + $buffer = $Common->getData($value['host']); |
|
385 | + if ($buffer != '') $reset = 0; |
|
386 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
387 | + $buffer = explode('\n',$buffer); |
|
388 | + foreach ($buffer as $line) { |
|
389 | + if ($line != '' && count($line) > 7) { |
|
390 | + $line = explode(',', $line); |
|
391 | + $data = array(); |
|
392 | + $data['hex'] = $line[1]; // hex |
|
393 | + $data['ident'] = $line[2]; // ident |
|
394 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
395 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
396 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
397 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
398 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
399 | + $data['verticalrate'] = ''; // vertical rate |
|
400 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
401 | + $data['emergency'] = ''; // emergency |
|
402 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
403 | + $data['format_source'] = 'deltadbtxt'; |
|
404 | + $data['id_source'] = $id_source; |
|
405 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
406 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
407 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
408 | + $SI->add($data); |
|
409 | + unset($data); |
|
410 | + } |
|
411 | + } |
|
412 | + $last_exec[$id]['last'] = time(); |
|
413 | 413 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
414 | - date_default_timezone_set('CET'); |
|
415 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
416 | - date_default_timezone_set('UTC'); |
|
417 | - if ($buffer != '') $reset = 0; |
|
418 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
419 | - $buffer = explode('\n',$buffer); |
|
420 | - foreach ($buffer as $line) { |
|
414 | + date_default_timezone_set('CET'); |
|
415 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
416 | + date_default_timezone_set('UTC'); |
|
417 | + if ($buffer != '') $reset = 0; |
|
418 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
419 | + $buffer = explode('\n',$buffer); |
|
420 | + foreach ($buffer as $line) { |
|
421 | 421 | if ($line != '') { |
422 | - //echo "'".$line."'\n"; |
|
423 | - $add = false; |
|
424 | - $ais_data = $AIS->parse_line(trim($line)); |
|
425 | - $data = array(); |
|
426 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
427 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
428 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
429 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
430 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
431 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
432 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
433 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
434 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
435 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
436 | - if (isset($ais_data['timestamp'])) { |
|
422 | + //echo "'".$line."'\n"; |
|
423 | + $add = false; |
|
424 | + $ais_data = $AIS->parse_line(trim($line)); |
|
425 | + $data = array(); |
|
426 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
427 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
428 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
429 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
430 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
431 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
432 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
433 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
434 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
435 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
436 | + if (isset($ais_data['timestamp'])) { |
|
437 | 437 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
438 | 438 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
439 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
440 | - $add = true; |
|
439 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
440 | + $add = true; |
|
441 | 441 | } |
442 | - } else { |
|
442 | + } else { |
|
443 | 443 | $data['datetime'] = date('Y-m-d H:i:s'); |
444 | 444 | $add = true; |
445 | - } |
|
446 | - $data['format_source'] = 'aisnmeatxt'; |
|
447 | - $data['id_source'] = $id_source; |
|
448 | - //print_r($data); |
|
449 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
450 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
451 | - unset($data); |
|
445 | + } |
|
446 | + $data['format_source'] = 'aisnmeatxt'; |
|
447 | + $data['id_source'] = $id_source; |
|
448 | + //print_r($data); |
|
449 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
450 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
451 | + unset($data); |
|
452 | 452 | } |
453 | - } |
|
454 | - $last_exec[$id]['last'] = time(); |
|
453 | + } |
|
454 | + $last_exec[$id]['last'] = time(); |
|
455 | 455 | } elseif ($value['format'] == 'aisnmeahttp') { |
456 | - $arr = $httpfeeds; |
|
457 | - $w = $e = null; |
|
456 | + $arr = $httpfeeds; |
|
457 | + $w = $e = null; |
|
458 | 458 | |
459 | - if (isset($arr[$id])) { |
|
459 | + if (isset($arr[$id])) { |
|
460 | 460 | $nn = stream_select($arr,$w,$e,$timeout); |
461 | 461 | if ($nn > 0) { |
462 | - foreach ($httpfeeds as $feed) { |
|
462 | + foreach ($httpfeeds as $feed) { |
|
463 | 463 | $buffer = stream_get_line($feed,2000,"\n"); |
464 | 464 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
465 | 465 | $buffer = explode('\n',$buffer); |
466 | 466 | foreach ($buffer as $line) { |
467 | - if ($line != '') { |
|
467 | + if ($line != '') { |
|
468 | 468 | $ais_data = $AIS->parse_line(trim($line)); |
469 | 469 | $data = array(); |
470 | 470 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -482,96 +482,96 @@ discard block |
||
482 | 482 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
483 | 483 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
484 | 484 | if (isset($ais_data['timestamp'])) { |
485 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
485 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
486 | 486 | } else { |
487 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
487 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
488 | 488 | } |
489 | 489 | $data['format_source'] = 'aisnmeahttp'; |
490 | 490 | $data['id_source'] = $id_source; |
491 | 491 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
492 | 492 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
493 | 493 | unset($data); |
494 | - } |
|
494 | + } |
|
495 | + } |
|
495 | 496 | } |
496 | - } |
|
497 | 497 | } else { |
498 | - $format = $value['format']; |
|
499 | - if (isset($tt[$format])) $tt[$format]++; |
|
500 | - else $tt[$format] = 0; |
|
501 | - if ($tt[$format] > 30) { |
|
498 | + $format = $value['format']; |
|
499 | + if (isset($tt[$format])) $tt[$format]++; |
|
500 | + else $tt[$format] = 0; |
|
501 | + if ($tt[$format] > 30) { |
|
502 | 502 | if ($globalDebug) echo 'Reconnect...'."\n"; |
503 | 503 | sleep(2); |
504 | 504 | $sourceeen[] = $value; |
505 | 505 | connect_all($sourceeen); |
506 | 506 | $sourceeen = array(); |
507 | - } |
|
507 | + } |
|
508 | + } |
|
508 | 509 | } |
509 | - } |
|
510 | 510 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
511 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
512 | - if ($buffer != '') { |
|
511 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
512 | + if ($buffer != '') { |
|
513 | 513 | //echo $buffer; |
514 | 514 | $all_data = json_decode($buffer,true); |
515 | 515 | //print_r($all_data); |
516 | 516 | if (isset($all_data[0]['DATA'])) { |
517 | - foreach ($all_data[0]['DATA'] as $line) { |
|
517 | + foreach ($all_data[0]['DATA'] as $line) { |
|
518 | 518 | if ($line != '') { |
519 | - $data = array(); |
|
520 | - $data['ident'] = $line['NAME']; |
|
521 | - $data['mmsi'] = $line['MMSI']; |
|
522 | - $data['speed'] = $line['SOG']; |
|
523 | - $data['heading'] = $line['COG']; |
|
524 | - $data['latitude'] = $line['LAT']; |
|
525 | - $data['longitude'] = $line['LNG']; |
|
526 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
527 | - $data['imo'] = $line['IMO']; |
|
528 | - //$data['arrival_code'] = $ais_data['destination']; |
|
529 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
530 | - $data['format_source'] = 'myshiptracking'; |
|
531 | - $data['id_source'] = $id_source; |
|
532 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
533 | - $MI->add($data); |
|
534 | - unset($data); |
|
519 | + $data = array(); |
|
520 | + $data['ident'] = $line['NAME']; |
|
521 | + $data['mmsi'] = $line['MMSI']; |
|
522 | + $data['speed'] = $line['SOG']; |
|
523 | + $data['heading'] = $line['COG']; |
|
524 | + $data['latitude'] = $line['LAT']; |
|
525 | + $data['longitude'] = $line['LNG']; |
|
526 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
527 | + $data['imo'] = $line['IMO']; |
|
528 | + //$data['arrival_code'] = $ais_data['destination']; |
|
529 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
530 | + $data['format_source'] = 'myshiptracking'; |
|
531 | + $data['id_source'] = $id_source; |
|
532 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
533 | + $MI->add($data); |
|
534 | + unset($data); |
|
535 | + } |
|
535 | 536 | } |
536 | - } |
|
537 | 537 | } |
538 | - } |
|
539 | - $last_exec[$id]['last'] = time(); |
|
538 | + } |
|
539 | + $last_exec[$id]['last'] = time(); |
|
540 | 540 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
541 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
542 | - if ($buffer != '') { |
|
541 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
542 | + if ($buffer != '') { |
|
543 | 543 | $all_data = json_decode($buffer,true); |
544 | 544 | if (isset($all_data[0]['mmsi'])) { |
545 | - foreach ($all_data as $line) { |
|
545 | + foreach ($all_data as $line) { |
|
546 | 546 | if ($line != '') { |
547 | - $data = array(); |
|
548 | - $data['ident'] = $line['shipname']; |
|
549 | - $data['callsign'] = $line['callsign']; |
|
550 | - $data['mmsi'] = $line['mmsi']; |
|
551 | - $data['speed'] = $line['sog']; |
|
552 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
553 | - $data['latitude'] = $line['latitude']; |
|
554 | - $data['longitude'] = $line['longitude']; |
|
555 | - $data['type_id'] = $line['shiptype']; |
|
556 | - $data['arrival_code'] = $line['destination']; |
|
557 | - $data['datetime'] = $line['time']; |
|
558 | - $data['format_source'] = 'boatbeaconapp'; |
|
559 | - $data['id_source'] = $id_source; |
|
560 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
561 | - $MI->add($data); |
|
562 | - unset($data); |
|
547 | + $data = array(); |
|
548 | + $data['ident'] = $line['shipname']; |
|
549 | + $data['callsign'] = $line['callsign']; |
|
550 | + $data['mmsi'] = $line['mmsi']; |
|
551 | + $data['speed'] = $line['sog']; |
|
552 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
553 | + $data['latitude'] = $line['latitude']; |
|
554 | + $data['longitude'] = $line['longitude']; |
|
555 | + $data['type_id'] = $line['shiptype']; |
|
556 | + $data['arrival_code'] = $line['destination']; |
|
557 | + $data['datetime'] = $line['time']; |
|
558 | + $data['format_source'] = 'boatbeaconapp'; |
|
559 | + $data['id_source'] = $id_source; |
|
560 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
561 | + $MI->add($data); |
|
562 | + unset($data); |
|
563 | + } |
|
563 | 564 | } |
564 | - } |
|
565 | 565 | } |
566 | 566 | |
567 | - } |
|
568 | - $last_exec[$id]['last'] = time(); |
|
567 | + } |
|
568 | + $last_exec[$id]['last'] = time(); |
|
569 | 569 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
570 | - $buffer = $Common->getData($value['host']); |
|
571 | - if ($buffer != '') { |
|
570 | + $buffer = $Common->getData($value['host']); |
|
571 | + if ($buffer != '') { |
|
572 | 572 | $all_data = json_decode($buffer,true); |
573 | 573 | if (isset($all_data['features'][0]['id'])) { |
574 | - foreach ($all_data['features'] as $line) { |
|
574 | + foreach ($all_data['features'] as $line) { |
|
575 | 575 | $data = array(); |
576 | 576 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
577 | 577 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -590,59 +590,59 @@ discard block |
||
590 | 590 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
591 | 591 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
592 | 592 | unset($data); |
593 | - } |
|
593 | + } |
|
594 | 594 | } |
595 | 595 | |
596 | - } |
|
597 | - $last_exec[$id]['last'] = time(); |
|
596 | + } |
|
597 | + $last_exec[$id]['last'] = time(); |
|
598 | 598 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
599 | - echo 'download...'; |
|
600 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
601 | - echo 'done !'."\n"; |
|
602 | - if ($buffer != '') $reset = 0; |
|
603 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
604 | - $buffer = explode('\n',$buffer); |
|
605 | - foreach ($buffer as $line) { |
|
599 | + echo 'download...'; |
|
600 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
601 | + echo 'done !'."\n"; |
|
602 | + if ($buffer != '') $reset = 0; |
|
603 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
604 | + $buffer = explode('\n',$buffer); |
|
605 | + foreach ($buffer as $line) { |
|
606 | 606 | if ($line != '') { |
607 | - $data = array(); |
|
608 | - $data['mmsi'] = (int)substr($line,0,9); |
|
609 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
610 | - //$data['status'] = substr($line,21,2); |
|
611 | - //$data['type'] = substr($line,24,3); |
|
612 | - $data['latitude'] = substr($line,29,9); |
|
613 | - $data['longitude'] = substr($line,41,9); |
|
614 | - $data['speed'] = round(substr($line,51,5)); |
|
615 | - //$data['course'] = substr($line,57,5); |
|
616 | - $data['heading'] = round(substr($line,63,3)); |
|
617 | - //$data['draft'] = substr($line,67,4); |
|
618 | - //$data['length'] = substr($line,72,3); |
|
619 | - //$data['beam'] = substr($line,76,2); |
|
620 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
621 | - //$data['callsign'] = trim(substr($line,100,7); |
|
622 | - //$data['dest'] = substr($line,108,20); |
|
623 | - //$data['etaDate'] = substr($line,129,5); |
|
624 | - //$data['etaTime'] = substr($line,135,5); |
|
625 | - $data['format_source'] = 'shipplotter'; |
|
626 | - $data['id_source'] = $id_source; |
|
627 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
628 | - //print_r($data); |
|
629 | - echo 'Add...'."\n"; |
|
630 | - $MI->add($data); |
|
631 | - unset($data); |
|
607 | + $data = array(); |
|
608 | + $data['mmsi'] = (int)substr($line,0,9); |
|
609 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
610 | + //$data['status'] = substr($line,21,2); |
|
611 | + //$data['type'] = substr($line,24,3); |
|
612 | + $data['latitude'] = substr($line,29,9); |
|
613 | + $data['longitude'] = substr($line,41,9); |
|
614 | + $data['speed'] = round(substr($line,51,5)); |
|
615 | + //$data['course'] = substr($line,57,5); |
|
616 | + $data['heading'] = round(substr($line,63,3)); |
|
617 | + //$data['draft'] = substr($line,67,4); |
|
618 | + //$data['length'] = substr($line,72,3); |
|
619 | + //$data['beam'] = substr($line,76,2); |
|
620 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
621 | + //$data['callsign'] = trim(substr($line,100,7); |
|
622 | + //$data['dest'] = substr($line,108,20); |
|
623 | + //$data['etaDate'] = substr($line,129,5); |
|
624 | + //$data['etaTime'] = substr($line,135,5); |
|
625 | + $data['format_source'] = 'shipplotter'; |
|
626 | + $data['id_source'] = $id_source; |
|
627 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
628 | + //print_r($data); |
|
629 | + echo 'Add...'."\n"; |
|
630 | + $MI->add($data); |
|
631 | + unset($data); |
|
632 | 632 | } |
633 | - } |
|
634 | - $last_exec[$id]['last'] = time(); |
|
633 | + } |
|
634 | + $last_exec[$id]['last'] = time(); |
|
635 | 635 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
636 | 636 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
637 | - //$buffer = $Common->getData($hosts[$id]); |
|
638 | - $buffer = $Common->getData($value['host']); |
|
639 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
640 | - $buffer = explode('\n',$buffer); |
|
641 | - $reset = 0; |
|
642 | - foreach ($buffer as $line) { |
|
643 | - if ($line != '') { |
|
644 | - $line = explode(':', $line); |
|
645 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
637 | + //$buffer = $Common->getData($hosts[$id]); |
|
638 | + $buffer = $Common->getData($value['host']); |
|
639 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
640 | + $buffer = explode('\n',$buffer); |
|
641 | + $reset = 0; |
|
642 | + foreach ($buffer as $line) { |
|
643 | + if ($line != '') { |
|
644 | + $line = explode(':', $line); |
|
645 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
646 | 646 | $data = array(); |
647 | 647 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
648 | 648 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -655,37 +655,37 @@ discard block |
||
655 | 655 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
656 | 656 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
657 | 657 | $data['latitude'] = $line[5]; // lat |
658 | - $data['longitude'] = $line[6]; // long |
|
659 | - $data['verticalrate'] = ''; // vertical rate |
|
660 | - $data['squawk'] = ''; // squawk |
|
661 | - $data['emergency'] = ''; // emergency |
|
662 | - $data['waypoints'] = $line[30]; |
|
658 | + $data['longitude'] = $line[6]; // long |
|
659 | + $data['verticalrate'] = ''; // vertical rate |
|
660 | + $data['squawk'] = ''; // squawk |
|
661 | + $data['emergency'] = ''; // emergency |
|
662 | + $data['waypoints'] = $line[30]; |
|
663 | 663 | $data['datetime'] = date('Y-m-d H:i:s'); |
664 | 664 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
665 | 665 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
666 | - $data['departure_airport_icao'] = $line[11]; |
|
667 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
668 | - $data['arrival_airport_icao'] = $line[13]; |
|
666 | + $data['departure_airport_icao'] = $line[11]; |
|
667 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
668 | + $data['arrival_airport_icao'] = $line[13]; |
|
669 | 669 | $data['frequency'] = $line[4]; |
670 | 670 | $data['type'] = $line[18]; |
671 | 671 | $data['range'] = $line[19]; |
672 | 672 | if (isset($line[35])) $data['info'] = $line[35]; |
673 | - $data['id_source'] = $id_source; |
|
674 | - //$data['arrival_airport_time'] = ; |
|
675 | - if ($line[9] != '') { |
|
676 | - $aircraft_data = explode('/',$line[9]); |
|
677 | - if (isset($aircraft_data[1])) { |
|
678 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
679 | - } |
|
680 | - } |
|
681 | - /* |
|
673 | + $data['id_source'] = $id_source; |
|
674 | + //$data['arrival_airport_time'] = ; |
|
675 | + if ($line[9] != '') { |
|
676 | + $aircraft_data = explode('/',$line[9]); |
|
677 | + if (isset($aircraft_data[1])) { |
|
678 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
679 | + } |
|
680 | + } |
|
681 | + /* |
|
682 | 682 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
683 | 683 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
684 | 684 | */ |
685 | - $data['format_source'] = $value['format']; |
|
685 | + $data['format_source'] = $value['format']; |
|
686 | 686 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
687 | 687 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
688 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
688 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
689 | 689 | elseif ($line[3] == 'ATC') { |
690 | 690 | //print_r($data); |
691 | 691 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -706,16 +706,16 @@ discard block |
||
706 | 706 | else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
707 | 707 | } |
708 | 708 | } |
709 | - unset($data); |
|
710 | - } |
|
711 | - } |
|
712 | - } |
|
713 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
714 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
715 | - $last_exec[$id]['last'] = time(); |
|
716 | - } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
717 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
718 | - if ($buffer != '') { |
|
709 | + unset($data); |
|
710 | + } |
|
711 | + } |
|
712 | + } |
|
713 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
714 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
715 | + $last_exec[$id]['last'] = time(); |
|
716 | + } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
717 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
718 | + if ($buffer != '') { |
|
719 | 719 | $all_data = simplexml_load_string($buffer); |
720 | 720 | foreach($all_data->children() as $childdata) { |
721 | 721 | $data = array(); |
@@ -737,10 +737,10 @@ discard block |
||
737 | 737 | $SI->add($data); |
738 | 738 | unset($data); |
739 | 739 | } |
740 | - } |
|
741 | - $Source->deleteOldLocationByType('gs'); |
|
742 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
743 | - if ($buffer != '') { |
|
740 | + } |
|
741 | + $Source->deleteOldLocationByType('gs'); |
|
742 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
743 | + if ($buffer != '') { |
|
744 | 744 | $all_data = simplexml_load_string($buffer); |
745 | 745 | foreach($all_data->children() as $childdata) { |
746 | 746 | $data = array(); |
@@ -758,249 +758,249 @@ discard block |
||
758 | 758 | } |
759 | 759 | unset($data); |
760 | 760 | } |
761 | - } |
|
762 | - $last_exec[$id]['last'] = time(); |
|
761 | + } |
|
762 | + $last_exec[$id]['last'] = time(); |
|
763 | 763 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
764 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
765 | - if ($buffer != '') { |
|
766 | - $all_data = json_decode($buffer,true); |
|
767 | - if (isset($all_data['acList'])) { |
|
764 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
765 | + if ($buffer != '') { |
|
766 | + $all_data = json_decode($buffer,true); |
|
767 | + if (isset($all_data['acList'])) { |
|
768 | 768 | $reset = 0; |
769 | 769 | foreach ($all_data['acList'] as $line) { |
770 | - $data = array(); |
|
771 | - $data['hex'] = $line['Icao']; // hex |
|
772 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
773 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
774 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
775 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
776 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
777 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
778 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
779 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
780 | - $data['emergency'] = ''; // emergency |
|
781 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
770 | + $data = array(); |
|
771 | + $data['hex'] = $line['Icao']; // hex |
|
772 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
773 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
774 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
775 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
776 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
777 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
778 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
779 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
780 | + $data['emergency'] = ''; // emergency |
|
781 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
782 | 782 | |
783 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
784 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
783 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
784 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
785 | 785 | |
786 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
787 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
788 | - $data['format_source'] = 'aircraftlistjson'; |
|
789 | - $data['id_source'] = $id_source; |
|
790 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
791 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
792 | - if (isset($data['latitude'])) $SI->add($data); |
|
793 | - unset($data); |
|
786 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
787 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
788 | + $data['format_source'] = 'aircraftlistjson'; |
|
789 | + $data['id_source'] = $id_source; |
|
790 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
791 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
792 | + if (isset($data['latitude'])) $SI->add($data); |
|
793 | + unset($data); |
|
794 | 794 | } |
795 | - } elseif (is_array($all_data)) { |
|
795 | + } elseif (is_array($all_data)) { |
|
796 | 796 | $reset = 0; |
797 | 797 | foreach ($all_data as $line) { |
798 | - $data = array(); |
|
799 | - $data['hex'] = $line['hex']; // hex |
|
800 | - $data['ident'] = $line['flight']; // ident |
|
801 | - $data['altitude'] = $line['altitude']; // altitude |
|
802 | - $data['speed'] = $line['speed']; // speed |
|
803 | - $data['heading'] = $line['track']; // heading |
|
804 | - $data['latitude'] = $line['lat']; // lat |
|
805 | - $data['longitude'] = $line['lon']; // long |
|
806 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
807 | - $data['squawk'] = $line['squawk']; // squawk |
|
808 | - $data['emergency'] = ''; // emergency |
|
809 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
810 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
811 | - $data['format_source'] = 'aircraftlistjson'; |
|
812 | - $data['id_source'] = $id_source; |
|
813 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
814 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
815 | - $SI->add($data); |
|
816 | - unset($data); |
|
798 | + $data = array(); |
|
799 | + $data['hex'] = $line['hex']; // hex |
|
800 | + $data['ident'] = $line['flight']; // ident |
|
801 | + $data['altitude'] = $line['altitude']; // altitude |
|
802 | + $data['speed'] = $line['speed']; // speed |
|
803 | + $data['heading'] = $line['track']; // heading |
|
804 | + $data['latitude'] = $line['lat']; // lat |
|
805 | + $data['longitude'] = $line['lon']; // long |
|
806 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
807 | + $data['squawk'] = $line['squawk']; // squawk |
|
808 | + $data['emergency'] = ''; // emergency |
|
809 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
810 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
811 | + $data['format_source'] = 'aircraftlistjson'; |
|
812 | + $data['id_source'] = $id_source; |
|
813 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
814 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
815 | + $SI->add($data); |
|
816 | + unset($data); |
|
817 | 817 | } |
818 | - } |
|
819 | - } |
|
820 | - //$last_exec['aircraftlistjson'] = time(); |
|
821 | - $last_exec[$id]['last'] = time(); |
|
822 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
823 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
824 | - $buffer = $Common->getData($value['host']); |
|
825 | - $all_data = json_decode($buffer,true); |
|
826 | - if (isset($all_data['planes'])) { |
|
818 | + } |
|
819 | + } |
|
820 | + //$last_exec['aircraftlistjson'] = time(); |
|
821 | + $last_exec[$id]['last'] = time(); |
|
822 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
823 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
824 | + $buffer = $Common->getData($value['host']); |
|
825 | + $all_data = json_decode($buffer,true); |
|
826 | + if (isset($all_data['planes'])) { |
|
827 | 827 | $reset = 0; |
828 | 828 | foreach ($all_data['planes'] as $key => $line) { |
829 | - $data = array(); |
|
830 | - $data['hex'] = $key; // hex |
|
831 | - $data['ident'] = $line[3]; // ident |
|
832 | - $data['altitude'] = $line[6]; // altitude |
|
833 | - $data['speed'] = $line[8]; // speed |
|
834 | - $data['heading'] = $line[7]; // heading |
|
835 | - $data['latitude'] = $line[4]; // lat |
|
836 | - $data['longitude'] = $line[5]; // long |
|
837 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
838 | - $data['squawk'] = $line[10]; // squawk |
|
839 | - $data['emergency'] = ''; // emergency |
|
840 | - $data['registration'] = $line[2]; |
|
841 | - $data['aircraft_icao'] = $line[0]; |
|
842 | - $deparr = explode('-',$line[1]); |
|
843 | - if (count($deparr) == 2) { |
|
829 | + $data = array(); |
|
830 | + $data['hex'] = $key; // hex |
|
831 | + $data['ident'] = $line[3]; // ident |
|
832 | + $data['altitude'] = $line[6]; // altitude |
|
833 | + $data['speed'] = $line[8]; // speed |
|
834 | + $data['heading'] = $line[7]; // heading |
|
835 | + $data['latitude'] = $line[4]; // lat |
|
836 | + $data['longitude'] = $line[5]; // long |
|
837 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
838 | + $data['squawk'] = $line[10]; // squawk |
|
839 | + $data['emergency'] = ''; // emergency |
|
840 | + $data['registration'] = $line[2]; |
|
841 | + $data['aircraft_icao'] = $line[0]; |
|
842 | + $deparr = explode('-',$line[1]); |
|
843 | + if (count($deparr) == 2) { |
|
844 | 844 | $data['departure_airport_icao'] = $deparr[0]; |
845 | 845 | $data['arrival_airport_icao'] = $deparr[1]; |
846 | - } |
|
847 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
848 | - $data['format_source'] = 'planeupdatefaa'; |
|
849 | - $data['id_source'] = $id_source; |
|
850 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
851 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
852 | - $SI->add($data); |
|
853 | - unset($data); |
|
846 | + } |
|
847 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
848 | + $data['format_source'] = 'planeupdatefaa'; |
|
849 | + $data['id_source'] = $id_source; |
|
850 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
851 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
852 | + $SI->add($data); |
|
853 | + unset($data); |
|
854 | + } |
|
854 | 855 | } |
855 | - } |
|
856 | - //$last_exec['planeupdatefaa'] = time(); |
|
857 | - $last_exec[$id]['last'] = time(); |
|
858 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
859 | - $buffer = $Common->getData($value['host']); |
|
860 | - $all_data = json_decode($buffer,true); |
|
861 | - if (isset($all_data['states'])) { |
|
856 | + //$last_exec['planeupdatefaa'] = time(); |
|
857 | + $last_exec[$id]['last'] = time(); |
|
858 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
859 | + $buffer = $Common->getData($value['host']); |
|
860 | + $all_data = json_decode($buffer,true); |
|
861 | + if (isset($all_data['states'])) { |
|
862 | 862 | $reset = 0; |
863 | 863 | foreach ($all_data['states'] as $key => $line) { |
864 | - $data = array(); |
|
865 | - $data['hex'] = $line[0]; // hex |
|
866 | - $data['ident'] = trim($line[1]); // ident |
|
867 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
868 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
869 | - $data['heading'] = round($line[10]); // heading |
|
870 | - $data['latitude'] = $line[6]; // lat |
|
871 | - $data['longitude'] = $line[5]; // long |
|
872 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
873 | - //$data['squawk'] = $line[10]; // squawk |
|
874 | - //$data['emergency'] = ''; // emergency |
|
875 | - //$data['registration'] = $line[2]; |
|
876 | - //$data['aircraft_icao'] = $line[0]; |
|
877 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
878 | - $data['format_source'] = 'opensky'; |
|
879 | - $data['id_source'] = $id_source; |
|
880 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
881 | - $SI->add($data); |
|
882 | - unset($data); |
|
864 | + $data = array(); |
|
865 | + $data['hex'] = $line[0]; // hex |
|
866 | + $data['ident'] = trim($line[1]); // ident |
|
867 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
868 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
869 | + $data['heading'] = round($line[10]); // heading |
|
870 | + $data['latitude'] = $line[6]; // lat |
|
871 | + $data['longitude'] = $line[5]; // long |
|
872 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
873 | + //$data['squawk'] = $line[10]; // squawk |
|
874 | + //$data['emergency'] = ''; // emergency |
|
875 | + //$data['registration'] = $line[2]; |
|
876 | + //$data['aircraft_icao'] = $line[0]; |
|
877 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
878 | + $data['format_source'] = 'opensky'; |
|
879 | + $data['id_source'] = $id_source; |
|
880 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
881 | + $SI->add($data); |
|
882 | + unset($data); |
|
883 | + } |
|
883 | 884 | } |
884 | - } |
|
885 | - //$last_exec['planeupdatefaa'] = time(); |
|
886 | - $last_exec[$id]['last'] = time(); |
|
887 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
888 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
889 | - //$buffer = $Common->getData($hosts[$id]); |
|
890 | - $buffer = $Common->getData($value['host']); |
|
891 | - $all_data = json_decode($buffer,true); |
|
892 | - if (!empty($all_data)) $reset = 0; |
|
893 | - foreach ($all_data as $key => $line) { |
|
885 | + //$last_exec['planeupdatefaa'] = time(); |
|
886 | + $last_exec[$id]['last'] = time(); |
|
887 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
888 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
889 | + //$buffer = $Common->getData($hosts[$id]); |
|
890 | + $buffer = $Common->getData($value['host']); |
|
891 | + $all_data = json_decode($buffer,true); |
|
892 | + if (!empty($all_data)) $reset = 0; |
|
893 | + foreach ($all_data as $key => $line) { |
|
894 | 894 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
895 | - $data = array(); |
|
896 | - $data['hex'] = $line[0]; |
|
897 | - $data['ident'] = $line[16]; //$line[13] |
|
898 | - $data['altitude'] = $line[4]; // altitude |
|
899 | - $data['speed'] = $line[5]; // speed |
|
900 | - $data['heading'] = $line[3]; // heading |
|
901 | - $data['latitude'] = $line[1]; // lat |
|
902 | - $data['longitude'] = $line[2]; // long |
|
903 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
904 | - $data['squawk'] = $line[6]; // squawk |
|
905 | - $data['aircraft_icao'] = $line[8]; |
|
906 | - $data['registration'] = $line[9]; |
|
907 | - $data['departure_airport_iata'] = $line[11]; |
|
908 | - $data['arrival_airport_iata'] = $line[12]; |
|
909 | - $data['emergency'] = ''; // emergency |
|
910 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
911 | - $data['format_source'] = 'fr24json'; |
|
912 | - $data['id_source'] = $id_source; |
|
913 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
914 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
915 | - $SI->add($data); |
|
916 | - unset($data); |
|
895 | + $data = array(); |
|
896 | + $data['hex'] = $line[0]; |
|
897 | + $data['ident'] = $line[16]; //$line[13] |
|
898 | + $data['altitude'] = $line[4]; // altitude |
|
899 | + $data['speed'] = $line[5]; // speed |
|
900 | + $data['heading'] = $line[3]; // heading |
|
901 | + $data['latitude'] = $line[1]; // lat |
|
902 | + $data['longitude'] = $line[2]; // long |
|
903 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
904 | + $data['squawk'] = $line[6]; // squawk |
|
905 | + $data['aircraft_icao'] = $line[8]; |
|
906 | + $data['registration'] = $line[9]; |
|
907 | + $data['departure_airport_iata'] = $line[11]; |
|
908 | + $data['arrival_airport_iata'] = $line[12]; |
|
909 | + $data['emergency'] = ''; // emergency |
|
910 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
911 | + $data['format_source'] = 'fr24json'; |
|
912 | + $data['id_source'] = $id_source; |
|
913 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
914 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
915 | + $SI->add($data); |
|
916 | + unset($data); |
|
917 | 917 | } |
918 | - } |
|
919 | - //$last_exec['fr24json'] = time(); |
|
920 | - $last_exec[$id]['last'] = time(); |
|
921 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
922 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
923 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
924 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
925 | - //echo $buffer; |
|
926 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
927 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
928 | - $all_data = json_decode($buffer,true); |
|
929 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
918 | + } |
|
919 | + //$last_exec['fr24json'] = time(); |
|
920 | + $last_exec[$id]['last'] = time(); |
|
921 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
922 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
923 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
924 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
925 | + //echo $buffer; |
|
926 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
927 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
928 | + $all_data = json_decode($buffer,true); |
|
929 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
930 | 930 | die(json_last_error_msg()); |
931 | - } |
|
932 | - if (isset($all_data['mrkrs'])) { |
|
931 | + } |
|
932 | + if (isset($all_data['mrkrs'])) { |
|
933 | 933 | $reset = 0; |
934 | 934 | foreach ($all_data['mrkrs'] as $key => $line) { |
935 | - if (isset($line['inf'])) { |
|
935 | + if (isset($line['inf'])) { |
|
936 | 936 | $data = array(); |
937 | 937 | $data['hex'] = $line['inf']['ia']; |
938 | 938 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
939 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
940 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
941 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
942 | - $data['latitude'] = $line['pt'][0]; // lat |
|
943 | - $data['longitude'] = $line['pt'][1]; // long |
|
944 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
945 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
946 | - //$data['aircraft_icao'] = $line[8]; |
|
947 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
939 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
940 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
941 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
942 | + $data['latitude'] = $line['pt'][0]; // lat |
|
943 | + $data['longitude'] = $line['pt'][1]; // long |
|
944 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
945 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
946 | + //$data['aircraft_icao'] = $line[8]; |
|
947 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
948 | 948 | //$data['departure_airport_iata'] = $line[11]; |
949 | 949 | //$data['arrival_airport_iata'] = $line[12]; |
950 | - //$data['emergency'] = ''; // emergency |
|
950 | + //$data['emergency'] = ''; // emergency |
|
951 | 951 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
952 | - $data['format_source'] = 'radarvirtueljson'; |
|
953 | - $data['id_source'] = $id_source; |
|
952 | + $data['format_source'] = 'radarvirtueljson'; |
|
953 | + $data['id_source'] = $id_source; |
|
954 | 954 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
955 | 955 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
956 | 956 | $SI->add($data); |
957 | 957 | unset($data); |
958 | - } |
|
958 | + } |
|
959 | + } |
|
959 | 960 | } |
960 | - } |
|
961 | - //$last_exec['radarvirtueljson'] = time(); |
|
962 | - $last_exec[$id]['last'] = time(); |
|
963 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
964 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
965 | - //$buffer = $Common->getData($hosts[$id]); |
|
966 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
967 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
961 | + //$last_exec['radarvirtueljson'] = time(); |
|
962 | + $last_exec[$id]['last'] = time(); |
|
963 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
964 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
965 | + //$buffer = $Common->getData($hosts[$id]); |
|
966 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
967 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
968 | 968 | |
969 | - if (isset($all_data['pireps'])) { |
|
969 | + if (isset($all_data['pireps'])) { |
|
970 | 970 | $reset = 0; |
971 | - foreach ($all_data['pireps'] as $line) { |
|
972 | - $data = array(); |
|
973 | - $data['id'] = $line['id']; |
|
974 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
975 | - $data['ident'] = $line['callsign']; // ident |
|
976 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
977 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
978 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
979 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
980 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
981 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
982 | - $data['latitude'] = $line['lat']; // lat |
|
983 | - $data['longitude'] = $line['lon']; // long |
|
984 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
985 | - //$data['squawk'] = $line['squawk']; // squawk |
|
986 | - //$data['emergency'] = ''; // emergency |
|
987 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
988 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
989 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
990 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
991 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
992 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
993 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
994 | - else $data['info'] = ''; |
|
995 | - $data['format_source'] = 'pireps'; |
|
996 | - $data['id_source'] = $id_source; |
|
997 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
998 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
999 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1000 | - if ($line['icon'] == 'plane') { |
|
971 | + foreach ($all_data['pireps'] as $line) { |
|
972 | + $data = array(); |
|
973 | + $data['id'] = $line['id']; |
|
974 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
975 | + $data['ident'] = $line['callsign']; // ident |
|
976 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
977 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
978 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
979 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
980 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
981 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
982 | + $data['latitude'] = $line['lat']; // lat |
|
983 | + $data['longitude'] = $line['lon']; // long |
|
984 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
985 | + //$data['squawk'] = $line['squawk']; // squawk |
|
986 | + //$data['emergency'] = ''; // emergency |
|
987 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
988 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
989 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
990 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
991 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
992 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
993 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
994 | + else $data['info'] = ''; |
|
995 | + $data['format_source'] = 'pireps'; |
|
996 | + $data['id_source'] = $id_source; |
|
997 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
998 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
999 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1000 | + if ($line['icon'] == 'plane') { |
|
1001 | 1001 | $SI->add($data); |
1002 | - // print_r($data); |
|
1003 | - } elseif ($line['icon'] == 'ct') { |
|
1002 | + // print_r($data); |
|
1003 | + } elseif ($line['icon'] == 'ct') { |
|
1004 | 1004 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1005 | 1005 | $data['info'] = str_replace('&sect;','',$data['info']); |
1006 | 1006 | $typec = substr($data['ident'],-3); |
@@ -1015,133 +1015,133 @@ discard block |
||
1015 | 1015 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1016 | 1016 | else $data['type'] = 'Observer'; |
1017 | 1017 | 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']); |
1018 | - } |
|
1019 | - unset($data); |
|
1018 | + } |
|
1019 | + unset($data); |
|
1020 | + } |
|
1020 | 1021 | } |
1021 | - } |
|
1022 | - //$last_exec['pirepsjson'] = time(); |
|
1023 | - $last_exec[$id]['last'] = time(); |
|
1024 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1025 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1026 | - //$buffer = $Common->getData($hosts[$id]); |
|
1027 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1028 | - $buffer = $Common->getData($value['host']); |
|
1029 | - $all_data = json_decode($buffer,true); |
|
1030 | - if ($buffer != '' && is_array($all_data)) { |
|
1022 | + //$last_exec['pirepsjson'] = time(); |
|
1023 | + $last_exec[$id]['last'] = time(); |
|
1024 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1025 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1026 | + //$buffer = $Common->getData($hosts[$id]); |
|
1027 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1028 | + $buffer = $Common->getData($value['host']); |
|
1029 | + $all_data = json_decode($buffer,true); |
|
1030 | + if ($buffer != '' && is_array($all_data)) { |
|
1031 | 1031 | $reset = 0; |
1032 | 1032 | foreach ($all_data as $line) { |
1033 | - $data = array(); |
|
1034 | - //$data['id'] = $line['id']; // id not usable |
|
1035 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1036 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1037 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1038 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1039 | - $data['ident'] = $line['flightnum']; // ident |
|
1040 | - $data['altitude'] = $line['alt']; // altitude |
|
1041 | - $data['speed'] = $line['gs']; // speed |
|
1042 | - $data['heading'] = $line['heading']; // heading |
|
1043 | - $data['latitude'] = $line['lat']; // lat |
|
1044 | - $data['longitude'] = $line['lng']; // long |
|
1045 | - $data['verticalrate'] = ''; // verticale rate |
|
1046 | - $data['squawk'] = ''; // squawk |
|
1047 | - $data['emergency'] = ''; // emergency |
|
1048 | - //$data['datetime'] = $line['lastupdate']; |
|
1049 | - //$data['last_update'] = $line['lastupdate']; |
|
1050 | - if (isset($value['timezone'])) { |
|
1051 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1052 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1053 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1054 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1055 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1056 | - $data['departure_airport_time'] = $line['deptime']; |
|
1057 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1058 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1059 | - $data['registration'] = $line['aircraft']; |
|
1060 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1061 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1062 | - if (isset($line['aircraftname'])) { |
|
1033 | + $data = array(); |
|
1034 | + //$data['id'] = $line['id']; // id not usable |
|
1035 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1036 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1037 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1038 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1039 | + $data['ident'] = $line['flightnum']; // ident |
|
1040 | + $data['altitude'] = $line['alt']; // altitude |
|
1041 | + $data['speed'] = $line['gs']; // speed |
|
1042 | + $data['heading'] = $line['heading']; // heading |
|
1043 | + $data['latitude'] = $line['lat']; // lat |
|
1044 | + $data['longitude'] = $line['lng']; // long |
|
1045 | + $data['verticalrate'] = ''; // verticale rate |
|
1046 | + $data['squawk'] = ''; // squawk |
|
1047 | + $data['emergency'] = ''; // emergency |
|
1048 | + //$data['datetime'] = $line['lastupdate']; |
|
1049 | + //$data['last_update'] = $line['lastupdate']; |
|
1050 | + if (isset($value['timezone'])) { |
|
1051 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1052 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1053 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1054 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1055 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1056 | + $data['departure_airport_time'] = $line['deptime']; |
|
1057 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1058 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1059 | + $data['registration'] = $line['aircraft']; |
|
1060 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1061 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1062 | + if (isset($line['aircraftname'])) { |
|
1063 | 1063 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1064 | 1064 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1065 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1066 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1067 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1068 | - else { |
|
1069 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1070 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1071 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1072 | - } |
|
1073 | - } |
|
1074 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1075 | - $data['id_source'] = $id_source; |
|
1076 | - $data['format_source'] = 'phpvmacars'; |
|
1077 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1078 | - $SI->add($data); |
|
1079 | - unset($data); |
|
1065 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1066 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1067 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1068 | + else { |
|
1069 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1070 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1071 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1072 | + } |
|
1073 | + } |
|
1074 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1075 | + $data['id_source'] = $id_source; |
|
1076 | + $data['format_source'] = 'phpvmacars'; |
|
1077 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1078 | + $SI->add($data); |
|
1079 | + unset($data); |
|
1080 | 1080 | } |
1081 | 1081 | if ($globalDebug) echo 'No more data...'."\n"; |
1082 | 1082 | unset($buffer); |
1083 | 1083 | unset($all_data); |
1084 | - } |
|
1085 | - //$last_exec['phpvmacars'] = time(); |
|
1086 | - $last_exec[$id]['last'] = time(); |
|
1087 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1088 | - //$buffer = $Common->getData($hosts[$id]); |
|
1089 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1090 | - $buffer = $Common->getData($value['host']); |
|
1091 | - $all_data = json_decode($buffer,true); |
|
1092 | - if ($buffer != '' && is_array($all_data)) { |
|
1084 | + } |
|
1085 | + //$last_exec['phpvmacars'] = time(); |
|
1086 | + $last_exec[$id]['last'] = time(); |
|
1087 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1088 | + //$buffer = $Common->getData($hosts[$id]); |
|
1089 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1090 | + $buffer = $Common->getData($value['host']); |
|
1091 | + $all_data = json_decode($buffer,true); |
|
1092 | + if ($buffer != '' && is_array($all_data)) { |
|
1093 | 1093 | $reset = 0; |
1094 | 1094 | foreach ($all_data as $line) { |
1095 | - $data = array(); |
|
1096 | - //$data['id'] = $line['id']; // id not usable |
|
1097 | - $data['id'] = trim($line['flight_id']); |
|
1098 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1099 | - $data['pilot_name'] = $line['pilot_name']; |
|
1100 | - $data['pilot_id'] = $line['pilot_id']; |
|
1101 | - $data['ident'] = trim($line['callsign']); // ident |
|
1102 | - $data['altitude'] = $line['altitude']; // altitude |
|
1103 | - $data['speed'] = $line['gs']; // speed |
|
1104 | - $data['heading'] = $line['heading']; // heading |
|
1105 | - $data['latitude'] = $line['latitude']; // lat |
|
1106 | - $data['longitude'] = $line['longitude']; // long |
|
1107 | - $data['verticalrate'] = ''; // verticale rate |
|
1108 | - $data['squawk'] = ''; // squawk |
|
1109 | - $data['emergency'] = ''; // emergency |
|
1110 | - //$data['datetime'] = $line['lastupdate']; |
|
1111 | - $data['last_update'] = $line['last_update']; |
|
1112 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113 | - $data['departure_airport_icao'] = $line['departure']; |
|
1114 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1115 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1116 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1117 | - //$data['registration'] = $line['aircraft']; |
|
1118 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1119 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1120 | - $data['id_source'] = $id_source; |
|
1121 | - $data['format_source'] = 'vam'; |
|
1122 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1123 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1124 | - $SI->add($data); |
|
1125 | - unset($data); |
|
1095 | + $data = array(); |
|
1096 | + //$data['id'] = $line['id']; // id not usable |
|
1097 | + $data['id'] = trim($line['flight_id']); |
|
1098 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1099 | + $data['pilot_name'] = $line['pilot_name']; |
|
1100 | + $data['pilot_id'] = $line['pilot_id']; |
|
1101 | + $data['ident'] = trim($line['callsign']); // ident |
|
1102 | + $data['altitude'] = $line['altitude']; // altitude |
|
1103 | + $data['speed'] = $line['gs']; // speed |
|
1104 | + $data['heading'] = $line['heading']; // heading |
|
1105 | + $data['latitude'] = $line['latitude']; // lat |
|
1106 | + $data['longitude'] = $line['longitude']; // long |
|
1107 | + $data['verticalrate'] = ''; // verticale rate |
|
1108 | + $data['squawk'] = ''; // squawk |
|
1109 | + $data['emergency'] = ''; // emergency |
|
1110 | + //$data['datetime'] = $line['lastupdate']; |
|
1111 | + $data['last_update'] = $line['last_update']; |
|
1112 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113 | + $data['departure_airport_icao'] = $line['departure']; |
|
1114 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1115 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1116 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1117 | + //$data['registration'] = $line['aircraft']; |
|
1118 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1119 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1120 | + $data['id_source'] = $id_source; |
|
1121 | + $data['format_source'] = 'vam'; |
|
1122 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1123 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1124 | + $SI->add($data); |
|
1125 | + unset($data); |
|
1126 | 1126 | } |
1127 | 1127 | if ($globalDebug) echo 'No more data...'."\n"; |
1128 | 1128 | unset($buffer); |
1129 | 1129 | unset($all_data); |
1130 | - } |
|
1131 | - //$last_exec['phpvmacars'] = time(); |
|
1132 | - $last_exec[$id]['last'] = time(); |
|
1133 | - } elseif ($value['format'] == 'blitzortung' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1134 | - //$buffer = $Common->getData($hosts[$id]); |
|
1135 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1136 | - $buffer = $Common->getData($value['host']); |
|
1137 | - $all_data = json_decode($buffer,true); |
|
1138 | - if ($buffer != '') { |
|
1130 | + } |
|
1131 | + //$last_exec['phpvmacars'] = time(); |
|
1132 | + $last_exec[$id]['last'] = time(); |
|
1133 | + } elseif ($value['format'] == 'blitzortung' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1134 | + //$buffer = $Common->getData($hosts[$id]); |
|
1135 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1136 | + $buffer = $Common->getData($value['host']); |
|
1137 | + $all_data = json_decode($buffer,true); |
|
1138 | + if ($buffer != '') { |
|
1139 | 1139 | $Source->deleteLocationBySource('blitzortung'); |
1140 | 1140 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1141 | 1141 | $buffer = explode('\n',$buffer); |
1142 | 1142 | foreach ($buffer as $buffer_line) { |
1143 | - $line = json_decode($buffer_line,true); |
|
1144 | - if (isset($line['time'])) { |
|
1143 | + $line = json_decode($buffer_line,true); |
|
1144 | + if (isset($line['time'])) { |
|
1145 | 1145 | $data = array(); |
1146 | 1146 | $data['altitude'] = $line['alt']; // altitude |
1147 | 1147 | $data['latitude'] = $line['lat']; // lat |
@@ -1153,94 +1153,94 @@ discard block |
||
1153 | 1153 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1154 | 1154 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1155 | 1155 | unset($data); |
1156 | - } |
|
1156 | + } |
|
1157 | 1157 | } |
1158 | 1158 | if ($globalDebug) echo 'No more data...'."\n"; |
1159 | 1159 | unset($buffer); |
1160 | - } |
|
1161 | - $last_exec[$id]['last'] = time(); |
|
1160 | + } |
|
1161 | + $last_exec[$id]['last'] = time(); |
|
1162 | 1162 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1163 | 1163 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1164 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1165 | - //$last_exec[$id]['last'] = time(); |
|
1164 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1165 | + //$last_exec[$id]['last'] = time(); |
|
1166 | 1166 | |
1167 | - //$read = array( $sockets[$id] ); |
|
1168 | - $read = $sockets; |
|
1169 | - $write = NULL; |
|
1170 | - $e = NULL; |
|
1171 | - $n = socket_select($read, $write, $e, $timeout); |
|
1172 | - if ($e != NULL) var_dump($e); |
|
1173 | - if ($n > 0) { |
|
1167 | + //$read = array( $sockets[$id] ); |
|
1168 | + $read = $sockets; |
|
1169 | + $write = NULL; |
|
1170 | + $e = NULL; |
|
1171 | + $n = socket_select($read, $write, $e, $timeout); |
|
1172 | + if ($e != NULL) var_dump($e); |
|
1173 | + if ($n > 0) { |
|
1174 | 1174 | $reset = 0; |
1175 | 1175 | foreach ($read as $nb => $r) { |
1176 | - //$value = $formats[$nb]; |
|
1177 | - $format = $globalSources[$nb]['format']; |
|
1178 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1176 | + //$value = $formats[$nb]; |
|
1177 | + $format = $globalSources[$nb]['format']; |
|
1178 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1179 | 1179 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1180 | - } elseif ($format == 'vrstcp') { |
|
1180 | + } elseif ($format == 'vrstcp') { |
|
1181 | 1181 | $buffer = @socket_read($r, 6000); |
1182 | - } else { |
|
1182 | + } else { |
|
1183 | 1183 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1184 | - } |
|
1185 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1186 | - //echo $buffer."\n"; |
|
1187 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1188 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1189 | - $error = false; |
|
1190 | - //$SI::del(); |
|
1191 | - if ($format == 'vrstcp') { |
|
1184 | + } |
|
1185 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1186 | + //echo $buffer."\n"; |
|
1187 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1188 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1189 | + $error = false; |
|
1190 | + //$SI::del(); |
|
1191 | + if ($format == 'vrstcp') { |
|
1192 | 1192 | $buffer = explode('},{',$buffer); |
1193 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1194 | - // SBS format is CSV format |
|
1195 | - if ($buffer !== FALSE && $buffer != '') { |
|
1193 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1194 | + // SBS format is CSV format |
|
1195 | + if ($buffer !== FALSE && $buffer != '') { |
|
1196 | 1196 | $tt[$format] = 0; |
1197 | 1197 | if ($format == 'acarssbs3') { |
1198 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1199 | - $ACARS->add(trim($buffer)); |
|
1200 | - $ACARS->deleteLiveAcarsData(); |
|
1198 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1199 | + $ACARS->add(trim($buffer)); |
|
1200 | + $ACARS->deleteLiveAcarsData(); |
|
1201 | 1201 | } elseif ($format == 'raw') { |
1202 | - // AVR format |
|
1203 | - $data = $SBS->parse($buffer); |
|
1204 | - if (is_array($data)) { |
|
1202 | + // AVR format |
|
1203 | + $data = $SBS->parse($buffer); |
|
1204 | + if (is_array($data)) { |
|
1205 | 1205 | $data['datetime'] = date('Y-m-d H:i:s'); |
1206 | 1206 | $data['format_source'] = 'raw'; |
1207 | 1207 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1208 | 1208 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1209 | 1209 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1210 | 1210 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1211 | - } |
|
1211 | + } |
|
1212 | 1212 | } elseif ($format == 'ais') { |
1213 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1214 | - $data = array(); |
|
1215 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1216 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1217 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1218 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1219 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1220 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1221 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1222 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1223 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1224 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1225 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1226 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1227 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1228 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1229 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1230 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1213 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1214 | + $data = array(); |
|
1215 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1216 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1217 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1218 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1219 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1220 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1221 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1222 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1223 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1224 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1225 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1226 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1227 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1228 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1229 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1230 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1231 | 1231 | |
1232 | - if (isset($ais_data['timestamp'])) { |
|
1232 | + if (isset($ais_data['timestamp'])) { |
|
1233 | 1233 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1234 | - } else { |
|
1234 | + } else { |
|
1235 | 1235 | $data['datetime'] = date('Y-m-d H:i:s'); |
1236 | - } |
|
1237 | - $data['format_source'] = 'aisnmea'; |
|
1238 | - $data['id_source'] = $id_source; |
|
1239 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1240 | - unset($data); |
|
1241 | - } elseif ($format == 'flightgearsp') { |
|
1242 | - //echo $buffer."\n"; |
|
1243 | - if (strlen($buffer) > 5) { |
|
1236 | + } |
|
1237 | + $data['format_source'] = 'aisnmea'; |
|
1238 | + $data['id_source'] = $id_source; |
|
1239 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1240 | + unset($data); |
|
1241 | + } elseif ($format == 'flightgearsp') { |
|
1242 | + //echo $buffer."\n"; |
|
1243 | + if (strlen($buffer) > 5) { |
|
1244 | 1244 | $line = explode(',',$buffer); |
1245 | 1245 | $data = array(); |
1246 | 1246 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1257,38 +1257,38 @@ discard block |
||
1257 | 1257 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1258 | 1258 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1259 | 1259 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1260 | - } |
|
1261 | - } elseif ($format == 'acars') { |
|
1262 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1263 | - $ACARS->add(trim($buffer)); |
|
1264 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1265 | - $ACARS->deleteLiveAcarsData(); |
|
1260 | + } |
|
1261 | + } elseif ($format == 'acars') { |
|
1262 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1263 | + $ACARS->add(trim($buffer)); |
|
1264 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1265 | + $ACARS->deleteLiveAcarsData(); |
|
1266 | 1266 | } elseif ($format == 'flightgearmp') { |
1267 | - if (substr($buffer,0,1) != '#') { |
|
1267 | + if (substr($buffer,0,1) != '#') { |
|
1268 | 1268 | $data = array(); |
1269 | 1269 | //echo $buffer."\n"; |
1270 | 1270 | $line = explode(' ',$buffer); |
1271 | 1271 | if (count($line) == 11) { |
1272 | - $userserver = explode('@',$line[0]); |
|
1273 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1274 | - $data['ident'] = $userserver[0]; |
|
1275 | - $data['registration'] = $userserver[0]; |
|
1276 | - $data['latitude'] = $line[4]; |
|
1277 | - $data['longitude'] = $line[5]; |
|
1278 | - $data['altitude'] = $line[6]; |
|
1279 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1280 | - $aircraft_type = $line[10]; |
|
1281 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1282 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1283 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1284 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1272 | + $userserver = explode('@',$line[0]); |
|
1273 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1274 | + $data['ident'] = $userserver[0]; |
|
1275 | + $data['registration'] = $userserver[0]; |
|
1276 | + $data['latitude'] = $line[4]; |
|
1277 | + $data['longitude'] = $line[5]; |
|
1278 | + $data['altitude'] = $line[6]; |
|
1279 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1280 | + $aircraft_type = $line[10]; |
|
1281 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1282 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1283 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1284 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1285 | + } |
|
1285 | 1286 | } |
1286 | - } |
|
1287 | 1287 | } elseif ($format == 'beast') { |
1288 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1289 | - die; |
|
1288 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1289 | + die; |
|
1290 | 1290 | } elseif ($format == 'vrstcp') { |
1291 | - foreach($buffer as $all_data) { |
|
1291 | + foreach($buffer as $all_data) { |
|
1292 | 1292 | $line = json_decode('{'.$all_data.'}',true); |
1293 | 1293 | $data = array(); |
1294 | 1294 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1308,148 +1308,148 @@ discard block |
||
1308 | 1308 | */ |
1309 | 1309 | $data['datetime'] = date('Y-m-d H:i:s'); |
1310 | 1310 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1311 | - $data['format_source'] = 'vrstcp'; |
|
1311 | + $data['format_source'] = 'vrstcp'; |
|
1312 | 1312 | $data['id_source'] = $id_source; |
1313 | 1313 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1314 | 1314 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1315 | 1315 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1316 | 1316 | unset($data); |
1317 | - } |
|
1317 | + } |
|
1318 | 1318 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1319 | - $line = explode("\t", $buffer); |
|
1320 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1319 | + $line = explode("\t", $buffer); |
|
1320 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1321 | 1321 | $key = $line[$k]; |
1322 | - $lined[$key] = $line[$k+1]; |
|
1323 | - } |
|
1324 | - if (count($lined) > 3) { |
|
1325 | - $data['hex'] = $lined['hexid']; |
|
1326 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1327 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1328 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1329 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1330 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1331 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1332 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1333 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1334 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1335 | - $data['id_source'] = $id_source; |
|
1336 | - $data['format_source'] = 'tsv'; |
|
1337 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1338 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1322 | + $lined[$key] = $line[$k+1]; |
|
1323 | + } |
|
1324 | + if (count($lined) > 3) { |
|
1325 | + $data['hex'] = $lined['hexid']; |
|
1326 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1327 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1328 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1329 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1330 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1331 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1332 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1333 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1334 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1335 | + $data['id_source'] = $id_source; |
|
1336 | + $data['format_source'] = 'tsv'; |
|
1337 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1338 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1339 | 1339 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1340 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1341 | - unset($lined); |
|
1342 | - unset($data); |
|
1343 | - } else $error = true; |
|
1340 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1341 | + unset($lined); |
|
1342 | + unset($data); |
|
1343 | + } else $error = true; |
|
1344 | 1344 | } elseif ($format == 'aprs' && $use_aprs) { |
1345 | - if ($aprs_connect == 0) { |
|
1345 | + if ($aprs_connect == 0) { |
|
1346 | 1346 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1347 | 1347 | $aprs_connect = 1; |
1348 | - } |
|
1348 | + } |
|
1349 | 1349 | |
1350 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1350 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1351 | 1351 | $aprs_last_tx = time(); |
1352 | 1352 | $data_aprs = "# Keep alive"; |
1353 | 1353 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1354 | - } |
|
1354 | + } |
|
1355 | 1355 | |
1356 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1357 | - //echo 'APRS data : '.$buffer."\n"; |
|
1358 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1359 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1360 | - //echo $buffer."\n"; |
|
1361 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1356 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1357 | + //echo 'APRS data : '.$buffer."\n"; |
|
1358 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1359 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1360 | + //echo $buffer."\n"; |
|
1361 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1362 | 1362 | $line = $APRS->parse($buffer); |
1363 | 1363 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1364 | 1364 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1365 | - $aprs_last_tx = time(); |
|
1366 | - $data = array(); |
|
1367 | - //print_r($line); |
|
1368 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1369 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1370 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1371 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1372 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1373 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1374 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1375 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1376 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1377 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1378 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1379 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1380 | - $data['latitude'] = $line['latitude']; |
|
1381 | - $data['longitude'] = $line['longitude']; |
|
1382 | - //$data['verticalrate'] = $line[16]; |
|
1383 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1384 | - //else $data['speed'] = 0; |
|
1385 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1386 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1387 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1388 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1389 | - //else $data['heading'] = 0; |
|
1390 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1391 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1392 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1393 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1394 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1395 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1396 | - $data['id_source'] = $id_source; |
|
1397 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1398 | - else $data['format_source'] = 'aprs'; |
|
1399 | - $data['source_name'] = $line['source']; |
|
1400 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1401 | - else $data['source_type'] = 'flarm'; |
|
1402 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1403 | - $currentdate = date('Y-m-d H:i:s'); |
|
1404 | - $aprsdate = strtotime($data['datetime']); |
|
1405 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1406 | - // Accept data if time <= system time + 20s |
|
1407 | - //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'])))) { |
|
1408 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1365 | + $aprs_last_tx = time(); |
|
1366 | + $data = array(); |
|
1367 | + //print_r($line); |
|
1368 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1369 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1370 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1371 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1372 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1373 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1374 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1375 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1376 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1377 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1378 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1379 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1380 | + $data['latitude'] = $line['latitude']; |
|
1381 | + $data['longitude'] = $line['longitude']; |
|
1382 | + //$data['verticalrate'] = $line[16]; |
|
1383 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1384 | + //else $data['speed'] = 0; |
|
1385 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1386 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1387 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1388 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1389 | + //else $data['heading'] = 0; |
|
1390 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1391 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1392 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1393 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1394 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1395 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1396 | + $data['id_source'] = $id_source; |
|
1397 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1398 | + else $data['format_source'] = 'aprs'; |
|
1399 | + $data['source_name'] = $line['source']; |
|
1400 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1401 | + else $data['source_type'] = 'flarm'; |
|
1402 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1403 | + $currentdate = date('Y-m-d H:i:s'); |
|
1404 | + $aprsdate = strtotime($data['datetime']); |
|
1405 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1406 | + // Accept data if time <= system time + 20s |
|
1407 | + //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'])))) { |
|
1408 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1409 | 1409 | $send = $SI->add($data); |
1410 | - } elseif ($data['source_type'] == 'ais') { |
|
1410 | + } elseif ($data['source_type'] == 'ais') { |
|
1411 | 1411 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1412 | - } elseif (isset($line['stealth'])) { |
|
1412 | + } elseif (isset($line['stealth'])) { |
|
1413 | 1413 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1414 | 1414 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1415 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1416 | - //$line['symbol'] == 'Balloon' || |
|
1417 | - $line['symbol'] == 'Glider' || |
|
1418 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1419 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1420 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1421 | - $send = $SI->add($data); |
|
1422 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1423 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1424 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1425 | - $send = $MI->add($data); |
|
1426 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1427 | - $line['symbol'] == 'Car' || |
|
1428 | - $line['symbol'] == 'Ambulance' || |
|
1429 | - $line['symbol'] == 'Van' || |
|
1430 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1431 | - $line['symbol'] == 'Motorcycle' || |
|
1432 | - $line['symbol'] == 'Tractor' || |
|
1433 | - $line['symbol'] == 'Police' || |
|
1434 | - $line['symbol'] == 'Bike' || |
|
1435 | - $line['symbol'] == 'Jogger' || |
|
1436 | - $line['symbol'] == 'Horse' || |
|
1437 | - $line['symbol'] == 'Bus' || |
|
1438 | - $line['symbol'] == 'Jeep' || |
|
1439 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1440 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1441 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1442 | - $line['symbol'] == 'Firetruck' || |
|
1443 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1444 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1445 | - $line['symbol'] == 'SUV' || |
|
1446 | - $line['symbol'] == 'Snowmobile' || |
|
1447 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1448 | - //} 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') { |
|
1415 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1416 | + //$line['symbol'] == 'Balloon' || |
|
1417 | + $line['symbol'] == 'Glider' || |
|
1418 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1419 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1420 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1421 | + $send = $SI->add($data); |
|
1422 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1423 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1424 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1425 | + $send = $MI->add($data); |
|
1426 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1427 | + $line['symbol'] == 'Car' || |
|
1428 | + $line['symbol'] == 'Ambulance' || |
|
1429 | + $line['symbol'] == 'Van' || |
|
1430 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1431 | + $line['symbol'] == 'Motorcycle' || |
|
1432 | + $line['symbol'] == 'Tractor' || |
|
1433 | + $line['symbol'] == 'Police' || |
|
1434 | + $line['symbol'] == 'Bike' || |
|
1435 | + $line['symbol'] == 'Jogger' || |
|
1436 | + $line['symbol'] == 'Horse' || |
|
1437 | + $line['symbol'] == 'Bus' || |
|
1438 | + $line['symbol'] == 'Jeep' || |
|
1439 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1440 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1441 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1442 | + $line['symbol'] == 'Firetruck' || |
|
1443 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1444 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1445 | + $line['symbol'] == 'SUV' || |
|
1446 | + $line['symbol'] == 'Snowmobile' || |
|
1447 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1448 | + //} 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') { |
|
1449 | 1449 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1450 | 1450 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1451 | 1451 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1452 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1452 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1453 | 1453 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1454 | 1454 | $Source->deleteOldLocationByType('gs'); |
1455 | 1455 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | } else { |
1458 | 1458 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1459 | 1459 | } |
1460 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1460 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1461 | 1461 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1462 | 1462 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1463 | 1463 | $Source->deleteOldLocationByType('wx'); |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | } else { |
1468 | 1468 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1469 | 1469 | } |
1470 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
1470 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
1471 | 1471 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1472 | 1472 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1473 | 1473 | $Source->deleteOldLocationByType('lightning'); |
@@ -1476,11 +1476,11 @@ discard block |
||
1476 | 1476 | } else { |
1477 | 1477 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1478 | 1478 | } |
1479 | - } elseif ($globalDebug) { |
|
1480 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1481 | - print_r($line); |
|
1482 | - } |
|
1483 | - unset($data); |
|
1479 | + } elseif ($globalDebug) { |
|
1480 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1481 | + print_r($line); |
|
1482 | + } |
|
1483 | + unset($data); |
|
1484 | 1484 | } |
1485 | 1485 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1486 | 1486 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1499,12 +1499,12 @@ discard block |
||
1499 | 1499 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1500 | 1500 | $globalSources[$nb]['last_weather_clean'] = time(); |
1501 | 1501 | } |
1502 | - } |
|
1502 | + } |
|
1503 | 1503 | } else { |
1504 | - $line = explode(',', $buffer); |
|
1505 | - if (count($line) > 20) { |
|
1506 | - $data['hex'] = $line[4]; |
|
1507 | - /* |
|
1504 | + $line = explode(',', $buffer); |
|
1505 | + if (count($line) > 20) { |
|
1506 | + $data['hex'] = $line[4]; |
|
1507 | + /* |
|
1508 | 1508 | $data['datetime'] = $line[6].' '.$line[7]; |
1509 | 1509 | date_default_timezone_set($globalTimezone); |
1510 | 1510 | $datetime = new DateTime($data['datetime']); |
@@ -1512,30 +1512,30 @@ discard block |
||
1512 | 1512 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1513 | 1513 | date_default_timezone_set('UTC'); |
1514 | 1514 | */ |
1515 | - // Force datetime to current UTC datetime |
|
1516 | - date_default_timezone_set('UTC'); |
|
1517 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1518 | - $data['ident'] = trim($line[10]); |
|
1519 | - $data['latitude'] = $line[14]; |
|
1520 | - $data['longitude'] = $line[15]; |
|
1521 | - $data['verticalrate'] = $line[16]; |
|
1522 | - $data['emergency'] = $line[20]; |
|
1523 | - $data['speed'] = $line[12]; |
|
1524 | - $data['squawk'] = $line[17]; |
|
1525 | - $data['altitude'] = $line[11]; |
|
1526 | - $data['heading'] = $line[13]; |
|
1527 | - $data['ground'] = $line[21]; |
|
1528 | - $data['emergency'] = $line[19]; |
|
1529 | - $data['format_source'] = 'sbs'; |
|
1515 | + // Force datetime to current UTC datetime |
|
1516 | + date_default_timezone_set('UTC'); |
|
1517 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1518 | + $data['ident'] = trim($line[10]); |
|
1519 | + $data['latitude'] = $line[14]; |
|
1520 | + $data['longitude'] = $line[15]; |
|
1521 | + $data['verticalrate'] = $line[16]; |
|
1522 | + $data['emergency'] = $line[20]; |
|
1523 | + $data['speed'] = $line[12]; |
|
1524 | + $data['squawk'] = $line[17]; |
|
1525 | + $data['altitude'] = $line[11]; |
|
1526 | + $data['heading'] = $line[13]; |
|
1527 | + $data['ground'] = $line[21]; |
|
1528 | + $data['emergency'] = $line[19]; |
|
1529 | + $data['format_source'] = 'sbs'; |
|
1530 | 1530 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1531 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1531 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1532 | 1532 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1533 | - $data['id_source'] = $id_source; |
|
1534 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1535 | - else $error = true; |
|
1536 | - unset($data); |
|
1537 | - } else $error = true; |
|
1538 | - if ($error) { |
|
1533 | + $data['id_source'] = $id_source; |
|
1534 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1535 | + else $error = true; |
|
1536 | + unset($data); |
|
1537 | + } else $error = true; |
|
1538 | + if ($error) { |
|
1539 | 1539 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1540 | 1540 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1541 | 1541 | } else { |
@@ -1551,13 +1551,13 @@ discard block |
||
1551 | 1551 | connect_all($sourceer); |
1552 | 1552 | $sourceer = array(); |
1553 | 1553 | } |
1554 | - } |
|
1554 | + } |
|
1555 | 1555 | } |
1556 | 1556 | // Sleep for xxx microseconds |
1557 | 1557 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1558 | - } else { |
|
1558 | + } else { |
|
1559 | 1559 | if ($format == 'flightgearmp') { |
1560 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1560 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1561 | 1561 | //@socket_close($r); |
1562 | 1562 | sleep($globalMinFetch); |
1563 | 1563 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1566,9 +1566,9 @@ discard block |
||
1566 | 1566 | break; |
1567 | 1567 | |
1568 | 1568 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1569 | - if (isset($tt[$format])) $tt[$format]++; |
|
1570 | - else $tt[$format] = 0; |
|
1571 | - if ($tt[$format] > 30) { |
|
1569 | + if (isset($tt[$format])) $tt[$format]++; |
|
1570 | + else $tt[$format] = 0; |
|
1571 | + if ($tt[$format] > 30) { |
|
1572 | 1572 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1573 | 1573 | //@socket_close($r); |
1574 | 1574 | sleep(2); |
@@ -1579,23 +1579,23 @@ discard block |
||
1579 | 1579 | //connect_all($globalSources); |
1580 | 1580 | $tt[$format]=0; |
1581 | 1581 | break; |
1582 | - } |
|
1582 | + } |
|
1583 | + } |
|
1583 | 1584 | } |
1584 | - } |
|
1585 | 1585 | } |
1586 | - } else { |
|
1586 | + } else { |
|
1587 | 1587 | $error = socket_strerror(socket_last_error()); |
1588 | 1588 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1589 | 1589 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1590 | 1590 | if (isset($globalDebug)) echo "Restarting...\n"; |
1591 | 1591 | // Restart the script if possible |
1592 | 1592 | if (is_array($sockets)) { |
1593 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1593 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1594 | 1594 | |
1595 | - foreach ($sockets as $sock) { |
|
1595 | + foreach ($sockets as $sock) { |
|
1596 | 1596 | @socket_shutdown($sock,2); |
1597 | 1597 | @socket_close($sock); |
1598 | - } |
|
1598 | + } |
|
1599 | 1599 | |
1600 | 1600 | } |
1601 | 1601 | if ($globalDebug) echo "Waiting..."; |
@@ -1610,15 +1610,15 @@ discard block |
||
1610 | 1610 | if ($globalDebug) echo "Restart all connections..."; |
1611 | 1611 | connect_all($globalSources); |
1612 | 1612 | } |
1613 | - } |
|
1613 | + } |
|
1614 | 1614 | } |
1615 | 1615 | if ($globalDaemon === false) { |
1616 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1617 | - if (isset($SI)) $SI->checkAll(); |
|
1618 | - if (isset($TI)) $TI->checkAll(); |
|
1619 | - if (isset($MI)) $MI->checkAll(); |
|
1616 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1617 | + if (isset($SI)) $SI->checkAll(); |
|
1618 | + if (isset($TI)) $TI->checkAll(); |
|
1619 | + if (isset($MI)) $MI->checkAll(); |
|
1620 | + } |
|
1620 | 1621 | } |
1621 | - } |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | 1624 | ?> |