@@ -15,65 +15,65 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) { |
18 | - require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | 19 | } |
20 | 20 | if (isset($globalMarine) && $globalMarine) { |
21 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
22 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
22 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | if (!isset($globalDebug)) $globalDebug = FALSE; |
26 | 26 | |
27 | 27 | if ($globalInstalled === FALSE) { |
28 | - echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
|
29 | - sleep(5); |
|
30 | - die(); |
|
28 | + echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
|
29 | + sleep(5); |
|
30 | + die(); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | // Check if schema is at latest version |
35 | 35 | $Connection = new Connection(); |
36 | 36 | if ($Connection->connectionExists() === false) { |
37 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
38 | - exit(); |
|
37 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
38 | + exit(); |
|
39 | 39 | } |
40 | 40 | if ($Connection->latest() === false) { |
41 | - echo "You MUST update to latest schema. Use your web browser to run install/index.php"; |
|
42 | - exit(); |
|
41 | + echo "You MUST update to latest schema. Use your web browser to run install/index.php"; |
|
42 | + exit(); |
|
43 | 43 | } |
44 | 44 | if (PHP_SAPI != 'cli') { |
45 | - echo "This script MUST be called from console, not a web browser."; |
|
45 | + echo "This script MUST be called from console, not a web browser."; |
|
46 | 46 | // exit(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | // This is to be compatible with old version of settings.php |
50 | 50 | if (!isset($globalSources)) { |
51 | - if (isset($globalSBS1Hosts)) { |
|
52 | - //$hosts = $globalSBS1Hosts; |
|
53 | - foreach ($globalSBS1Hosts as $host) { |
|
54 | - $globalSources[] = array('host' => $host); |
|
55 | - } |
|
56 | - } else { |
|
57 | - if (!isset($globalSBS1Host)) { |
|
58 | - echo '$globalSources MUST be defined !'; |
|
59 | - die; |
|
51 | + if (isset($globalSBS1Hosts)) { |
|
52 | + //$hosts = $globalSBS1Hosts; |
|
53 | + foreach ($globalSBS1Hosts as $host) { |
|
54 | + $globalSources[] = array('host' => $host); |
|
55 | + } |
|
56 | + } else { |
|
57 | + if (!isset($globalSBS1Host)) { |
|
58 | + echo '$globalSources MUST be defined !'; |
|
59 | + die; |
|
60 | 60 | } |
61 | 61 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
62 | 62 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
63 | - } |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
67 | 67 | //if (isset($options['s'])) $hosts = array($options['s']); |
68 | 68 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
69 | 69 | if (isset($options['s'])) { |
70 | - $globalSources = array(); |
|
71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
72 | - else $globalSources[] = array('host' => $options['s']); |
|
70 | + $globalSources = array(); |
|
71 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
72 | + else $globalSources[] = array('host' => $options['s']); |
|
73 | 73 | } elseif (isset($options['source'])) { |
74 | - $globalSources = array(); |
|
75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
76 | - else $globalSources[] = array('host' => $options['source']); |
|
74 | + $globalSources = array(); |
|
75 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
76 | + else $globalSources[] = array('host' => $options['source']); |
|
77 | 77 | } |
78 | 78 | if (isset($options['aprsserverhost'])) { |
79 | 79 | $globalServerAPRS = TRUE; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
113 | 113 | else $id_source = 1; |
114 | 114 | if (isset($globalServer) && $globalServer) { |
115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
116 | - $SI=new SpotterServer(); |
|
115 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
116 | + $SI=new SpotterServer(); |
|
117 | 117 | /* |
118 | 118 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
119 | 119 | $SI = new adsb2aprs(); |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | |
124 | 124 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
125 | 125 | if (isset($globalMarine) && $globalMarine) { |
126 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
127 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
126 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
127 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
131 | 131 | if (isset($globalMarine) && $globalMarine) { |
132 | - $AIS = new AIS(); |
|
133 | - $MI = new MarineImport($Connection->db); |
|
132 | + $AIS = new AIS(); |
|
133 | + $MI = new MarineImport($Connection->db); |
|
134 | 134 | } |
135 | 135 | //$APRS=new APRS($Connection->db); |
136 | 136 | $SBS=new SBS(); |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | //$servertz = system('date +%Z'); |
144 | 144 | // signal handler - playing nice with sockets and dump1090 |
145 | 145 | if (function_exists('pcntl_fork')) { |
146 | - pcntl_signal(SIGINT, function() { |
|
147 | - global $sockets; |
|
148 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
149 | - die("Bye!\n"); |
|
150 | - }); |
|
151 | - pcntl_signal_dispatch(); |
|
146 | + pcntl_signal(SIGINT, function() { |
|
147 | + global $sockets; |
|
148 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
149 | + die("Bye!\n"); |
|
150 | + }); |
|
151 | + pcntl_signal_dispatch(); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // let's try and connect |
@@ -158,46 +158,46 @@ discard block |
||
158 | 158 | $reset = 0; |
159 | 159 | |
160 | 160 | function connect_all($hosts) { |
161 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
162 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
163 | - $reset++; |
|
164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
165 | - foreach ($hosts as $id => $value) { |
|
161 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
162 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
163 | + $reset++; |
|
164 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
165 | + foreach ($hosts as $id => $value) { |
|
166 | 166 | $host = $value['host']; |
167 | 167 | $globalSources[$id]['last_exec'] = 0; |
168 | 168 | // Here we check type of source(s) |
169 | 169 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
170 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
171 | - //$formats[$id] = 'deltadbtxt'; |
|
172 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
173 | - //$last_exec['deltadbtxt'] = 0; |
|
174 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
175 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
176 | - //$formats[$id] = 'vatsimtxt'; |
|
177 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
178 | - //$last_exec['vatsimtxt'] = 0; |
|
179 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
180 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
181 | - //$formats[$id] = 'aircraftlistjson'; |
|
182 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
183 | - //$last_exec['aircraftlistjson'] = 0; |
|
184 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
185 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
186 | - //$formats[$id] = 'aircraftjson'; |
|
187 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
188 | - //$last_exec['aircraftlistjson'] = 0; |
|
189 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
190 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
191 | - //$formats[$id] = 'planefinderclient'; |
|
192 | - $globalSources[$id]['format'] = 'planefinderclient'; |
|
193 | - //$last_exec['aircraftlistjson'] = 0; |
|
194 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
195 | - } else if (preg_match('/opensky/i',$host)) { |
|
196 | - //$formats[$id] = 'aircraftlistjson'; |
|
197 | - $globalSources[$id]['format'] = 'opensky'; |
|
198 | - //$last_exec['aircraftlistjson'] = 0; |
|
199 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
200 | - /* |
|
170 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
171 | + //$formats[$id] = 'deltadbtxt'; |
|
172 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
173 | + //$last_exec['deltadbtxt'] = 0; |
|
174 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
175 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
176 | + //$formats[$id] = 'vatsimtxt'; |
|
177 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
178 | + //$last_exec['vatsimtxt'] = 0; |
|
179 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
180 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
181 | + //$formats[$id] = 'aircraftlistjson'; |
|
182 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
183 | + //$last_exec['aircraftlistjson'] = 0; |
|
184 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
185 | + } else if (preg_match('/aircraft.json$/i',$host)) { |
|
186 | + //$formats[$id] = 'aircraftjson'; |
|
187 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
188 | + //$last_exec['aircraftlistjson'] = 0; |
|
189 | + if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
190 | + } else if (preg_match('/aircraft$/i',$host)) { |
|
191 | + //$formats[$id] = 'planefinderclient'; |
|
192 | + $globalSources[$id]['format'] = 'planefinderclient'; |
|
193 | + //$last_exec['aircraftlistjson'] = 0; |
|
194 | + if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
195 | + } else if (preg_match('/opensky/i',$host)) { |
|
196 | + //$formats[$id] = 'aircraftlistjson'; |
|
197 | + $globalSources[$id]['format'] = 'opensky'; |
|
198 | + //$last_exec['aircraftlistjson'] = 0; |
|
199 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
200 | + /* |
|
201 | 201 | // Disabled for now, site change source format |
202 | 202 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
203 | 203 | //$formats[$id] = 'radarvirtueljson'; |
@@ -209,128 +209,128 @@ discard block |
||
209 | 209 | exit(0); |
210 | 210 | } |
211 | 211 | */ |
212 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
213 | - //$formats[$id] = 'planeupdatefaa'; |
|
214 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
215 | - //$last_exec['planeupdatefaa'] = 0; |
|
216 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
217 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
218 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
219 | - exit(0); |
|
220 | - } |
|
221 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
222 | - //$formats[$id] = 'phpvmacars'; |
|
223 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
224 | - //$last_exec['phpvmacars'] = 0; |
|
225 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
226 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
227 | - //$formats[$id] = 'phpvmacars'; |
|
228 | - $globalSources[$id]['format'] = 'vaos'; |
|
229 | - //$last_exec['phpvmacars'] = 0; |
|
230 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
231 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
232 | - //$formats[$id] = 'phpvmacars'; |
|
233 | - $globalSources[$id]['format'] = 'vam'; |
|
234 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
235 | - } else if (preg_match('/whazzup/i',$host)) { |
|
236 | - //$formats[$id] = 'whazzup'; |
|
237 | - $globalSources[$id]['format'] = 'whazzup'; |
|
238 | - //$last_exec['whazzup'] = 0; |
|
239 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
240 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
241 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
242 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
243 | - } else if (preg_match('/airwhere/i',$host)) { |
|
244 | - $globalSources[$id]['format'] = 'airwhere'; |
|
245 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
246 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
247 | - //$formats[$id] = 'pirepsjson'; |
|
248 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
249 | - //$last_exec['pirepsjson'] = 0; |
|
250 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
251 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
252 | - //$formats[$id] = 'fr24json'; |
|
253 | - $globalSources[$id]['format'] = 'fr24json'; |
|
254 | - //$last_exec['fr24json'] = 0; |
|
255 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
256 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
257 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
258 | - exit(0); |
|
259 | - } |
|
260 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
261 | - //$formats[$id] = 'fr24json'; |
|
262 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
263 | - //$last_exec['fr24json'] = 0; |
|
264 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
265 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
266 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
267 | - exit(0); |
|
268 | - } |
|
269 | - //} else if (preg_match('/10001/',$host)) { |
|
270 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
271 | - //$formats[$id] = 'tsv'; |
|
272 | - $globalSources[$id]['format'] = 'tsv'; |
|
273 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
274 | - } |
|
275 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
276 | - if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
277 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
278 | - if ($idf !== false) { |
|
279 | - $httpfeeds[$id] = $idf; |
|
280 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
281 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
282 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
283 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
284 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
285 | - $hostport = explode(':',$host); |
|
286 | - if (isset($hostport[1])) { |
|
212 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
213 | + //$formats[$id] = 'planeupdatefaa'; |
|
214 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
215 | + //$last_exec['planeupdatefaa'] = 0; |
|
216 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
217 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
218 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
219 | + exit(0); |
|
220 | + } |
|
221 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
222 | + //$formats[$id] = 'phpvmacars'; |
|
223 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
224 | + //$last_exec['phpvmacars'] = 0; |
|
225 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
226 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
227 | + //$formats[$id] = 'phpvmacars'; |
|
228 | + $globalSources[$id]['format'] = 'vaos'; |
|
229 | + //$last_exec['phpvmacars'] = 0; |
|
230 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
231 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
232 | + //$formats[$id] = 'phpvmacars'; |
|
233 | + $globalSources[$id]['format'] = 'vam'; |
|
234 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
235 | + } else if (preg_match('/whazzup/i',$host)) { |
|
236 | + //$formats[$id] = 'whazzup'; |
|
237 | + $globalSources[$id]['format'] = 'whazzup'; |
|
238 | + //$last_exec['whazzup'] = 0; |
|
239 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
240 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
241 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
242 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
243 | + } else if (preg_match('/airwhere/i',$host)) { |
|
244 | + $globalSources[$id]['format'] = 'airwhere'; |
|
245 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
246 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
247 | + //$formats[$id] = 'pirepsjson'; |
|
248 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
249 | + //$last_exec['pirepsjson'] = 0; |
|
250 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
251 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
252 | + //$formats[$id] = 'fr24json'; |
|
253 | + $globalSources[$id]['format'] = 'fr24json'; |
|
254 | + //$last_exec['fr24json'] = 0; |
|
255 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
256 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
257 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
258 | + exit(0); |
|
259 | + } |
|
260 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
261 | + //$formats[$id] = 'fr24json'; |
|
262 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
263 | + //$last_exec['fr24json'] = 0; |
|
264 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
265 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
266 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
267 | + exit(0); |
|
268 | + } |
|
269 | + //} else if (preg_match('/10001/',$host)) { |
|
270 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
271 | + //$formats[$id] = 'tsv'; |
|
272 | + $globalSources[$id]['format'] = 'tsv'; |
|
273 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
274 | + } |
|
275 | + } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
276 | + if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
277 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
278 | + if ($idf !== false) { |
|
279 | + $httpfeeds[$id] = $idf; |
|
280 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
281 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
282 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
283 | + elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
284 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
285 | + $hostport = explode(':',$host); |
|
286 | + if (isset($hostport[1])) { |
|
287 | 287 | $port = $hostport[1]; |
288 | 288 | $hostn = $hostport[0]; |
289 | - } else { |
|
289 | + } else { |
|
290 | 290 | $port = $globalSources[$id]['port']; |
291 | 291 | $hostn = $globalSources[$id]['host']; |
292 | - } |
|
293 | - $Common = new Common(); |
|
294 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
295 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
296 | - } else { |
|
297 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
298 | - } |
|
299 | - if ($s) { |
|
300 | - $sockets[$id] = $s; |
|
301 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
302 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
292 | + } |
|
293 | + $Common = new Common(); |
|
294 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
295 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
296 | + } else { |
|
297 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
298 | + } |
|
299 | + if ($s) { |
|
300 | + $sockets[$id] = $s; |
|
301 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
302 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
303 | 303 | //$formats[$id] = 'aprs'; |
304 | 304 | $globalSources[$id]['format'] = 'aprs'; |
305 | 305 | //$aprs_connect = 0; |
306 | 306 | //$use_aprs = true; |
307 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
307 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
308 | 308 | $globalSources[$id]['format'] = 'vrstcp'; |
309 | - } elseif ($port == '10001') { |
|
310 | - //$formats[$id] = 'tsv'; |
|
311 | - $globalSources[$id]['format'] = 'tsv'; |
|
312 | - } elseif ($port == '30002') { |
|
313 | - //$formats[$id] = 'raw'; |
|
314 | - $globalSources[$id]['format'] = 'raw'; |
|
315 | - } elseif ($port == '5001') { |
|
316 | - //$formats[$id] = 'raw'; |
|
317 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
318 | - } elseif ($port == '30005') { |
|
309 | + } elseif ($port == '10001') { |
|
310 | + //$formats[$id] = 'tsv'; |
|
311 | + $globalSources[$id]['format'] = 'tsv'; |
|
312 | + } elseif ($port == '30002') { |
|
313 | + //$formats[$id] = 'raw'; |
|
314 | + $globalSources[$id]['format'] = 'raw'; |
|
315 | + } elseif ($port == '5001') { |
|
316 | + //$formats[$id] = 'raw'; |
|
317 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
318 | + } elseif ($port == '30005') { |
|
319 | 319 | // Not yet supported |
320 | - //$formats[$id] = 'beast'; |
|
321 | - $globalSources[$id]['format'] = 'beast'; |
|
322 | - //} else $formats[$id] = 'sbs'; |
|
323 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
324 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
320 | + //$formats[$id] = 'beast'; |
|
321 | + $globalSources[$id]['format'] = 'beast'; |
|
322 | + //} else $formats[$id] = 'sbs'; |
|
323 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
324 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
325 | 325 | } |
326 | 326 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
327 | - } else { |
|
327 | + } else { |
|
328 | 328 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
329 | 329 | sleep(10); |
330 | 330 | connect_all($hosts); |
331 | - } |
|
332 | - } |
|
333 | - } |
|
331 | + } |
|
332 | + } |
|
333 | + } |
|
334 | 334 | } |
335 | 335 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
336 | 336 | |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | //connect_all($globalSources); |
354 | 354 | |
355 | 355 | if (isset($globalProxy) && $globalProxy) { |
356 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
356 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
357 | 357 | } else { |
358 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
358 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | // APRS Configuration |
@@ -364,21 +364,21 @@ discard block |
||
364 | 364 | die; |
365 | 365 | } |
366 | 366 | foreach ($globalSources as $key => $source) { |
367 | - if (!isset($source['format'])) { |
|
368 | - $globalSources[$key]['format'] = 'auto'; |
|
369 | - } |
|
370 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
371 | - unset($globalSources[$key]); |
|
372 | - } |
|
367 | + if (!isset($source['format'])) { |
|
368 | + $globalSources[$key]['format'] = 'auto'; |
|
369 | + } |
|
370 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
371 | + unset($globalSources[$key]); |
|
372 | + } |
|
373 | 373 | } |
374 | 374 | connect_all($globalSources); |
375 | 375 | foreach ($globalSources as $key => $source) { |
376 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
376 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
377 | 377 | $aprs_connect = 0; |
378 | 378 | $use_aprs = true; |
379 | 379 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
380 | 380 | break; |
381 | - } |
|
381 | + } |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | if ($use_aprs) { |
@@ -419,173 +419,173 @@ discard block |
||
419 | 419 | |
420 | 420 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
421 | 421 | while ($i > 0) { |
422 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
422 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
423 | 423 | |
424 | - if (!$globalDaemon) $i = $endtime-time(); |
|
425 | - // Delete old ATC |
|
426 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
424 | + if (!$globalDaemon) $i = $endtime-time(); |
|
425 | + // Delete old ATC |
|
426 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
427 | 427 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
428 | - $ATC->deleteOldATC(); |
|
429 | - } |
|
428 | + $ATC->deleteOldATC(); |
|
429 | + } |
|
430 | 430 | |
431 | - if (count($last_exec) == count($globalSources)) { |
|
431 | + if (count($last_exec) == count($globalSources)) { |
|
432 | 432 | $max = $globalMinFetch; |
433 | 433 | foreach ($last_exec as $last) { |
434 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
434 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
435 | 435 | } |
436 | 436 | if ($max < $globalMinFetch) { |
437 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
438 | - sleep($globalMinFetch-$max+2); |
|
437 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
438 | + sleep($globalMinFetch-$max+2); |
|
439 | + } |
|
439 | 440 | } |
440 | - } |
|
441 | 441 | |
442 | 442 | |
443 | - //foreach ($formats as $id => $value) { |
|
444 | - foreach ($globalSources as $id => $value) { |
|
443 | + //foreach ($formats as $id => $value) { |
|
444 | + foreach ($globalSources as $id => $value) { |
|
445 | 445 | date_default_timezone_set('UTC'); |
446 | 446 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
447 | 447 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
448 | 448 | if ($value['format'] === 'deltadbtxt' && |
449 | - ( |
|
449 | + ( |
|
450 | 450 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
451 | 451 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
452 | - ) |
|
452 | + ) |
|
453 | 453 | ) { |
454 | - //$buffer = $Common->getData($hosts[$id]); |
|
455 | - $buffer = $Common->getData($value['host']); |
|
456 | - if ($buffer != '') $reset = 0; |
|
457 | - $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
458 | - $buffer = explode('\n', $buffer); |
|
459 | - foreach ($buffer as $line) { |
|
460 | - if ($line != '' && count($line) > 7) { |
|
461 | - $line = explode(',', $line); |
|
462 | - $data = array(); |
|
463 | - $data['hex'] = $line[1]; // hex |
|
464 | - $data['ident'] = $line[2]; // ident |
|
465 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
466 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
467 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
468 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
469 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
470 | - $data['verticalrate'] = ''; // vertical rate |
|
471 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
472 | - $data['emergency'] = ''; // emergency |
|
473 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
474 | - $data['format_source'] = 'deltadbtxt'; |
|
475 | - $data['id_source'] = $id_source; |
|
476 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
477 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
478 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
479 | - $SI->add($data); |
|
480 | - unset($data); |
|
481 | - } |
|
482 | - } |
|
483 | - $last_exec[$id]['last'] = time(); |
|
484 | - } elseif ($value['format'] === 'radarcapejson' && |
|
485 | - ( |
|
486 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
487 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
488 | - ) |
|
489 | - ) { |
|
490 | - //$buffer = $Common->getData($hosts[$id]); |
|
491 | - $buffer = $Common->getData($value['host']); |
|
492 | - if ($buffer != '') { |
|
493 | - $all_data = json_decode($buffer,true); |
|
494 | - foreach ($all_data as $line) { |
|
495 | - $data = array(); |
|
496 | - $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
497 | - $data['hex'] = $line['hex']; // hex |
|
498 | - $data['ident'] = $line['fli']; // ident |
|
499 | - $data['altitude'] = $line['alt']; // altitude |
|
500 | - $data['speed'] = $line['spd']; // speed |
|
501 | - $data['heading'] = $line['trk']; // heading |
|
502 | - $data['latitude'] = $line['lat']; // lat |
|
503 | - $data['longitude'] = $line['lon']; // long |
|
504 | - $data['verticalrate'] = $line['vrt']; // vertical rate |
|
505 | - $data['squawk'] = $line['squ']; // squawk |
|
506 | - $data['ground'] = $line['gda']; // ground |
|
507 | - $data['registration'] = $line['reg']; |
|
508 | - //$data['emergency'] = ''; // emergency |
|
509 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
510 | - $data['format_source'] = 'radarcapejson'; |
|
511 | - $data['id_source'] = $id_source; |
|
512 | - if (isset($value['name']) && $value['name'] != '') { |
|
513 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
514 | - else $data['source_name'] = $value['name']; |
|
515 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
516 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
517 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
454 | + //$buffer = $Common->getData($hosts[$id]); |
|
455 | + $buffer = $Common->getData($value['host']); |
|
456 | + if ($buffer != '') $reset = 0; |
|
457 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
458 | + $buffer = explode('\n', $buffer); |
|
459 | + foreach ($buffer as $line) { |
|
460 | + if ($line != '' && count($line) > 7) { |
|
461 | + $line = explode(',', $line); |
|
462 | + $data = array(); |
|
463 | + $data['hex'] = $line[1]; // hex |
|
464 | + $data['ident'] = $line[2]; // ident |
|
465 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
466 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
467 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
468 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
469 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
470 | + $data['verticalrate'] = ''; // vertical rate |
|
471 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
472 | + $data['emergency'] = ''; // emergency |
|
473 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
474 | + $data['format_source'] = 'deltadbtxt'; |
|
475 | + $data['id_source'] = $id_source; |
|
476 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
477 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
478 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
479 | + $SI->add($data); |
|
480 | + unset($data); |
|
481 | + } |
|
482 | + } |
|
483 | + $last_exec[$id]['last'] = time(); |
|
484 | + } elseif ($value['format'] === 'radarcapejson' && |
|
485 | + ( |
|
486 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
487 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
488 | + ) |
|
489 | + ) { |
|
490 | + //$buffer = $Common->getData($hosts[$id]); |
|
491 | + $buffer = $Common->getData($value['host']); |
|
492 | + if ($buffer != '') { |
|
493 | + $all_data = json_decode($buffer,true); |
|
494 | + foreach ($all_data as $line) { |
|
495 | + $data = array(); |
|
496 | + $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
497 | + $data['hex'] = $line['hex']; // hex |
|
498 | + $data['ident'] = $line['fli']; // ident |
|
499 | + $data['altitude'] = $line['alt']; // altitude |
|
500 | + $data['speed'] = $line['spd']; // speed |
|
501 | + $data['heading'] = $line['trk']; // heading |
|
502 | + $data['latitude'] = $line['lat']; // lat |
|
503 | + $data['longitude'] = $line['lon']; // long |
|
504 | + $data['verticalrate'] = $line['vrt']; // vertical rate |
|
505 | + $data['squawk'] = $line['squ']; // squawk |
|
506 | + $data['ground'] = $line['gda']; // ground |
|
507 | + $data['registration'] = $line['reg']; |
|
508 | + //$data['emergency'] = ''; // emergency |
|
509 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
510 | + $data['format_source'] = 'radarcapejson'; |
|
511 | + $data['id_source'] = $id_source; |
|
512 | + if (isset($value['name']) && $value['name'] != '') { |
|
513 | + if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
514 | + else $data['source_name'] = $value['name']; |
|
515 | + } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
516 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
517 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
518 | 518 | |
519 | - $SI->add($data); |
|
520 | - unset($data); |
|
521 | - } |
|
522 | - } |
|
523 | - $last_exec[$id]['last'] = time(); |
|
519 | + $SI->add($data); |
|
520 | + unset($data); |
|
521 | + } |
|
522 | + } |
|
523 | + $last_exec[$id]['last'] = time(); |
|
524 | 524 | } elseif ($value['format'] === 'aisnmeatxt' && |
525 | - ( |
|
525 | + ( |
|
526 | 526 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
527 | 527 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
528 | - ) |
|
528 | + ) |
|
529 | 529 | ) { |
530 | - date_default_timezone_set('CET'); |
|
531 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
532 | - date_default_timezone_set('UTC'); |
|
533 | - if ($buffer != '') $reset = 0; |
|
534 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
535 | - $buffer = explode('\n',$buffer); |
|
536 | - foreach ($buffer as $line) { |
|
530 | + date_default_timezone_set('CET'); |
|
531 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
532 | + date_default_timezone_set('UTC'); |
|
533 | + if ($buffer != '') $reset = 0; |
|
534 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
535 | + $buffer = explode('\n',$buffer); |
|
536 | + foreach ($buffer as $line) { |
|
537 | 537 | if ($line != '') { |
538 | - //echo "'".$line."'\n"; |
|
539 | - $add = false; |
|
540 | - $ais_data = $AIS->parse_line(trim($line)); |
|
541 | - $data = array(); |
|
542 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
543 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
544 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
545 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
546 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
547 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
548 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
549 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
550 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
551 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
552 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
553 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
554 | - if (isset($ais_data['timestamp'])) { |
|
538 | + //echo "'".$line."'\n"; |
|
539 | + $add = false; |
|
540 | + $ais_data = $AIS->parse_line(trim($line)); |
|
541 | + $data = array(); |
|
542 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
543 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
544 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
545 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
546 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
547 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
548 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
549 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
550 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
551 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
552 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
553 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
554 | + if (isset($ais_data['timestamp'])) { |
|
555 | 555 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
556 | 556 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
557 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
558 | - $add = true; |
|
557 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
558 | + $add = true; |
|
559 | 559 | } |
560 | - } else { |
|
560 | + } else { |
|
561 | 561 | $data['datetime'] = date('Y-m-d H:i:s'); |
562 | 562 | $add = true; |
563 | - } |
|
564 | - $data['format_source'] = 'aisnmeatxt'; |
|
565 | - $data['id_source'] = $id_source; |
|
566 | - //print_r($data); |
|
567 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
568 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
569 | - unset($data); |
|
563 | + } |
|
564 | + $data['format_source'] = 'aisnmeatxt'; |
|
565 | + $data['id_source'] = $id_source; |
|
566 | + //print_r($data); |
|
567 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
568 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
569 | + unset($data); |
|
570 | 570 | } |
571 | - } |
|
572 | - $last_exec[$id]['last'] = time(); |
|
571 | + } |
|
572 | + $last_exec[$id]['last'] = time(); |
|
573 | 573 | } elseif ($value['format'] === 'aisnmeahttp') { |
574 | - $arr = $httpfeeds; |
|
575 | - $w = $e = null; |
|
574 | + $arr = $httpfeeds; |
|
575 | + $w = $e = null; |
|
576 | 576 | |
577 | - if (isset($arr[$id])) { |
|
577 | + if (isset($arr[$id])) { |
|
578 | 578 | $nn = stream_select($arr,$w,$e,$timeout); |
579 | 579 | if ($nn > 0) { |
580 | - foreach ($httpfeeds as $feed) { |
|
580 | + foreach ($httpfeeds as $feed) { |
|
581 | 581 | $buffer = stream_get_line($feed,2000,"\n"); |
582 | 582 | if ($buffer === FALSE) { |
583 | - connect_all($globalSources); |
|
583 | + connect_all($globalSources); |
|
584 | 584 | } |
585 | 585 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
586 | 586 | $buffer = explode('\n',$buffer); |
587 | 587 | foreach ($buffer as $line) { |
588 | - if ($line != '') { |
|
588 | + if ($line != '') { |
|
589 | 589 | $ais_data = $AIS->parse_line(trim($line)); |
590 | 590 | $data = array(); |
591 | 591 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -603,117 +603,117 @@ discard block |
||
603 | 603 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
604 | 604 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
605 | 605 | if (isset($ais_data['timestamp'])) { |
606 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
606 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
607 | 607 | } else { |
608 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
608 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
609 | 609 | } |
610 | 610 | $data['format_source'] = 'aisnmeahttp'; |
611 | 611 | $data['id_source'] = $id_source; |
612 | 612 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
613 | 613 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
614 | 614 | unset($data); |
615 | - } |
|
615 | + } |
|
616 | + } |
|
616 | 617 | } |
617 | - } |
|
618 | 618 | } else { |
619 | - $format = $value['format']; |
|
620 | - if (isset($tt[$format])) $tt[$format]++; |
|
621 | - else $tt[$format] = 0; |
|
622 | - if ($tt[$format] > 30) { |
|
619 | + $format = $value['format']; |
|
620 | + if (isset($tt[$format])) $tt[$format]++; |
|
621 | + else $tt[$format] = 0; |
|
622 | + if ($tt[$format] > 30) { |
|
623 | 623 | if ($globalDebug) echo 'Reconnect...'."\n"; |
624 | 624 | sleep(2); |
625 | 625 | //$sourceeen[] = $value; |
626 | 626 | //connect_all($sourceeen); |
627 | 627 | //$sourceeen = array(); |
628 | 628 | connect_all($globalSources); |
629 | - } |
|
629 | + } |
|
630 | + } |
|
630 | 631 | } |
631 | - } |
|
632 | 632 | } elseif ($value['format'] === 'myshiptracking' && |
633 | - ( |
|
633 | + ( |
|
634 | 634 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
635 | 635 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
636 | - ) |
|
636 | + ) |
|
637 | 637 | ) { |
638 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
639 | - if ($buffer != '') { |
|
638 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
639 | + if ($buffer != '') { |
|
640 | 640 | //echo $buffer; |
641 | 641 | $all_data = json_decode($buffer,true); |
642 | 642 | //print_r($all_data); |
643 | 643 | if (isset($all_data[0]['DATA'])) { |
644 | - foreach ($all_data[0]['DATA'] as $line) { |
|
644 | + foreach ($all_data[0]['DATA'] as $line) { |
|
645 | 645 | if ($line != '') { |
646 | - $data = array(); |
|
647 | - $data['ident'] = $line['NAME']; |
|
648 | - $data['mmsi'] = $line['MMSI']; |
|
649 | - if (strlen($data['mmsi']) > 9) { |
|
646 | + $data = array(); |
|
647 | + $data['ident'] = $line['NAME']; |
|
648 | + $data['mmsi'] = $line['MMSI']; |
|
649 | + if (strlen($data['mmsi']) > 9) { |
|
650 | 650 | $data['mmsi'] = substr($data['mmsi'],-9); |
651 | - } |
|
652 | - $data['speed'] = $line['SOG']; |
|
653 | - $data['heading'] = $line['COG']; |
|
654 | - $data['latitude'] = $line['LAT']; |
|
655 | - $data['longitude'] = $line['LNG']; |
|
656 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
657 | - //$data['type_id'] = $line['TYPE']; |
|
658 | - $data['imo'] = $line['IMO']; |
|
659 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
660 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
661 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
662 | - $data['format_source'] = 'myshiptracking'; |
|
663 | - $data['id_source'] = $id_source; |
|
664 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
665 | - $MI->add($data); |
|
666 | - unset($data); |
|
651 | + } |
|
652 | + $data['speed'] = $line['SOG']; |
|
653 | + $data['heading'] = $line['COG']; |
|
654 | + $data['latitude'] = $line['LAT']; |
|
655 | + $data['longitude'] = $line['LNG']; |
|
656 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
657 | + //$data['type_id'] = $line['TYPE']; |
|
658 | + $data['imo'] = $line['IMO']; |
|
659 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
660 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
661 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
662 | + $data['format_source'] = 'myshiptracking'; |
|
663 | + $data['id_source'] = $id_source; |
|
664 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
665 | + $MI->add($data); |
|
666 | + unset($data); |
|
667 | + } |
|
667 | 668 | } |
668 | - } |
|
669 | 669 | } |
670 | - } |
|
671 | - $last_exec[$id]['last'] = time(); |
|
670 | + } |
|
671 | + $last_exec[$id]['last'] = time(); |
|
672 | 672 | } elseif ($value['format'] === 'boatbeaconapp' && |
673 | - ( |
|
673 | + ( |
|
674 | 674 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
675 | 675 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
676 | - ) |
|
676 | + ) |
|
677 | 677 | ) { |
678 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
679 | - if ($buffer != '') { |
|
678 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
679 | + if ($buffer != '') { |
|
680 | 680 | $all_data = json_decode($buffer,true); |
681 | 681 | if (isset($all_data[0]['mmsi'])) { |
682 | - foreach ($all_data as $line) { |
|
682 | + foreach ($all_data as $line) { |
|
683 | 683 | if ($line != '') { |
684 | - $data = array(); |
|
685 | - $data['ident'] = $line['shipname']; |
|
686 | - $data['callsign'] = $line['callsign']; |
|
687 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
688 | - $data['speed'] = $line['sog']; |
|
689 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
690 | - $data['latitude'] = $line['latitude']; |
|
691 | - $data['longitude'] = $line['longitude']; |
|
692 | - $data['type_id'] = $line['shiptype']; |
|
693 | - $data['arrival_code'] = $line['destination']; |
|
694 | - $data['datetime'] = $line['time']; |
|
695 | - $data['format_source'] = 'boatbeaconapp'; |
|
696 | - $data['id_source'] = $id_source; |
|
697 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
698 | - $MI->add($data); |
|
699 | - unset($data); |
|
684 | + $data = array(); |
|
685 | + $data['ident'] = $line['shipname']; |
|
686 | + $data['callsign'] = $line['callsign']; |
|
687 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
688 | + $data['speed'] = $line['sog']; |
|
689 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
690 | + $data['latitude'] = $line['latitude']; |
|
691 | + $data['longitude'] = $line['longitude']; |
|
692 | + $data['type_id'] = $line['shiptype']; |
|
693 | + $data['arrival_code'] = $line['destination']; |
|
694 | + $data['datetime'] = $line['time']; |
|
695 | + $data['format_source'] = 'boatbeaconapp'; |
|
696 | + $data['id_source'] = $id_source; |
|
697 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
698 | + $MI->add($data); |
|
699 | + unset($data); |
|
700 | + } |
|
700 | 701 | } |
701 | - } |
|
702 | 702 | } |
703 | 703 | |
704 | - } |
|
705 | - $last_exec[$id]['last'] = time(); |
|
704 | + } |
|
705 | + $last_exec[$id]['last'] = time(); |
|
706 | 706 | } elseif ($value['format'] === 'boatnerd' && |
707 | - ( |
|
707 | + ( |
|
708 | 708 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
709 | 709 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
710 | - ) |
|
710 | + ) |
|
711 | 711 | ) { |
712 | - $buffer = $Common->getData($value['host']); |
|
713 | - if ($buffer != '') { |
|
712 | + $buffer = $Common->getData($value['host']); |
|
713 | + if ($buffer != '') { |
|
714 | 714 | $all_data = json_decode($buffer,true); |
715 | 715 | if (isset($all_data['features'][0]['id'])) { |
716 | - foreach ($all_data['features'] as $line) { |
|
716 | + foreach ($all_data['features'] as $line) { |
|
717 | 717 | print_r($line); |
718 | 718 | $data = array(); |
719 | 719 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -733,76 +733,76 @@ discard block |
||
733 | 733 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
734 | 734 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
735 | 735 | unset($data); |
736 | - } |
|
736 | + } |
|
737 | 737 | } |
738 | 738 | |
739 | - } |
|
740 | - $last_exec[$id]['last'] = time(); |
|
739 | + } |
|
740 | + $last_exec[$id]['last'] = time(); |
|
741 | 741 | } elseif ($value['format'] === 'shipplotter' && |
742 | - ( |
|
742 | + ( |
|
743 | 743 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
744 | 744 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
745 | - ) |
|
745 | + ) |
|
746 | 746 | ) { |
747 | - if ($globalDebug) echo 'download...'; |
|
748 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
749 | - if ($globalDebug) echo 'done !'."\n"; |
|
750 | - // FIXME: Need more work |
|
751 | - if ($buffer != '') $reset = 0; |
|
752 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
753 | - $buffer = explode('\n',$buffer); |
|
754 | - foreach ($buffer as $line) { |
|
747 | + if ($globalDebug) echo 'download...'; |
|
748 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
749 | + if ($globalDebug) echo 'done !'."\n"; |
|
750 | + // FIXME: Need more work |
|
751 | + if ($buffer != '') $reset = 0; |
|
752 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
753 | + $buffer = explode('\n',$buffer); |
|
754 | + foreach ($buffer as $line) { |
|
755 | 755 | if ($line != '') { |
756 | - $data = array(); |
|
757 | - //echo $line."\n"; |
|
758 | - $data['mmsi'] = (int)substr($line,0,9); |
|
759 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
760 | - $data['status_id'] = substr($line,21,2); |
|
761 | - $data['type_id'] = substr($line,24,3); |
|
762 | - $data['latitude'] = substr($line,29,9); |
|
763 | - $data['longitude'] = substr($line,41,9); |
|
764 | - $data['speed'] = round(substr($line,51,5)); |
|
765 | - //$data['course'] = substr($line,57,5); |
|
766 | - $data['heading'] = round(substr($line,63,3)); |
|
767 | - //$data['draft'] = substr($line,67,4); |
|
768 | - //$data['length'] = substr($line,72,3); |
|
769 | - //$data['beam'] = substr($line,76,2); |
|
770 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
771 | - //$data['callsign'] = trim(substr($line,100,7); |
|
772 | - $data['arrival_code'] = substr($line,108,20); |
|
773 | - //$data['etaDate'] = substr($line,129,5); |
|
774 | - //$data['etaTime'] = substr($line,135,5); |
|
775 | - $data['format_source'] = 'shipplotter'; |
|
776 | - $data['id_source'] = $id_source; |
|
777 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
778 | - //print_r($data); |
|
779 | - //echo 'Add...'."\n"; |
|
780 | - $MI->add($data); |
|
781 | - unset($data); |
|
756 | + $data = array(); |
|
757 | + //echo $line."\n"; |
|
758 | + $data['mmsi'] = (int)substr($line,0,9); |
|
759 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
760 | + $data['status_id'] = substr($line,21,2); |
|
761 | + $data['type_id'] = substr($line,24,3); |
|
762 | + $data['latitude'] = substr($line,29,9); |
|
763 | + $data['longitude'] = substr($line,41,9); |
|
764 | + $data['speed'] = round(substr($line,51,5)); |
|
765 | + //$data['course'] = substr($line,57,5); |
|
766 | + $data['heading'] = round(substr($line,63,3)); |
|
767 | + //$data['draft'] = substr($line,67,4); |
|
768 | + //$data['length'] = substr($line,72,3); |
|
769 | + //$data['beam'] = substr($line,76,2); |
|
770 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
771 | + //$data['callsign'] = trim(substr($line,100,7); |
|
772 | + $data['arrival_code'] = substr($line,108,20); |
|
773 | + //$data['etaDate'] = substr($line,129,5); |
|
774 | + //$data['etaTime'] = substr($line,135,5); |
|
775 | + $data['format_source'] = 'shipplotter'; |
|
776 | + $data['id_source'] = $id_source; |
|
777 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
778 | + //print_r($data); |
|
779 | + //echo 'Add...'."\n"; |
|
780 | + $MI->add($data); |
|
781 | + unset($data); |
|
782 | 782 | } |
783 | - } |
|
784 | - $last_exec[$id]['last'] = time(); |
|
783 | + } |
|
784 | + $last_exec[$id]['last'] = time(); |
|
785 | 785 | } elseif ($value['format'] === 'sailaway' && |
786 | - ( |
|
786 | + ( |
|
787 | 787 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
788 | 788 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
789 | - ) |
|
789 | + ) |
|
790 | 790 | ) { |
791 | - if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
791 | + if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
792 | 792 | $authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true); |
793 | 793 | //echo $authsailaway; |
794 | 794 | preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie); |
795 | 795 | if (isset($setcookie[1][0])) { |
796 | - $sailaway_authcookie = $setcookie[1][0]; |
|
796 | + $sailaway_authcookie = $setcookie[1][0]; |
|
797 | + } |
|
797 | 798 | } |
798 | - } |
|
799 | 799 | |
800 | - if ($globalDebug) echo '! Download... '; |
|
801 | - for ($i =0; $i <= 1; $i++) { |
|
800 | + if ($globalDebug) echo '! Download... '; |
|
801 | + for ($i =0; $i <= 1; $i++) { |
|
802 | 802 | if ($globalDebug) echo 'Racetype: '.$i.' '; |
803 | 803 | $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
804 | - if ($globalDebug) echo 'done'."\n"; |
|
805 | - if ($buffer != '') { |
|
804 | + if ($globalDebug) echo 'done'."\n"; |
|
805 | + if ($buffer != '') { |
|
806 | 806 | $all_data = json_decode($buffer,true); |
807 | 807 | if (isset($all_data['missions'])) { |
808 | 808 | foreach ($all_data['missions'] as $mission) { |
@@ -821,19 +821,19 @@ discard block |
||
821 | 821 | //print_r($race_data); |
822 | 822 | unset($racebuffer); |
823 | 823 | if (isset($race_data['mission'])) { |
824 | - $datar = array(); |
|
825 | - $datar['id'] = $mission['misnr']; |
|
826 | - $datar['desc'] = $race_data['mission']['misdescr']; |
|
827 | - $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
828 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
829 | - $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
830 | - $markers = array(); |
|
831 | - foreach ($race_data['mission']['course'] as $course) { |
|
824 | + $datar = array(); |
|
825 | + $datar['id'] = $mission['misnr']; |
|
826 | + $datar['desc'] = $race_data['mission']['misdescr']; |
|
827 | + $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
828 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
829 | + $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
830 | + $markers = array(); |
|
831 | + foreach ($race_data['mission']['course'] as $course) { |
|
832 | 832 | $markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']); |
833 | - } |
|
834 | - $datar['markers'] = json_encode($markers); |
|
835 | - //print_r($datar); |
|
836 | - $MI->race_add($datar); |
|
833 | + } |
|
834 | + $datar['markers'] = json_encode($markers); |
|
835 | + //print_r($datar); |
|
836 | + $MI->race_add($datar); |
|
837 | 837 | } |
838 | 838 | } |
839 | 839 | if ($bufferm != '') { |
@@ -897,34 +897,34 @@ discard block |
||
897 | 897 | } |
898 | 898 | } |
899 | 899 | } |
900 | - } |
|
901 | - } |
|
902 | - $last_exec[$id]['last'] = time(); |
|
900 | + } |
|
901 | + } |
|
902 | + $last_exec[$id]['last'] = time(); |
|
903 | 903 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
904 | 904 | } elseif ( |
905 | - ( |
|
905 | + ( |
|
906 | 906 | $value['format'] === 'whazzup' && |
907 | 907 | ( |
908 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
909 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
908 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
909 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
910 | 910 | ) |
911 | - ) || ( |
|
911 | + ) || ( |
|
912 | 912 | $value['format'] === 'vatsimtxt' && |
913 | 913 | ( |
914 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
915 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
914 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
915 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
916 | + ) |
|
916 | 917 | ) |
917 | - ) |
|
918 | 918 | ) { |
919 | - //$buffer = $Common->getData($hosts[$id]); |
|
920 | - $buffer = $Common->getData($value['host']); |
|
921 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
922 | - $buffer = explode('\n',$buffer); |
|
923 | - $reset = 0; |
|
924 | - foreach ($buffer as $line) { |
|
925 | - if ($line != '') { |
|
926 | - $line = explode(':', $line); |
|
927 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
919 | + //$buffer = $Common->getData($hosts[$id]); |
|
920 | + $buffer = $Common->getData($value['host']); |
|
921 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
922 | + $buffer = explode('\n',$buffer); |
|
923 | + $reset = 0; |
|
924 | + foreach ($buffer as $line) { |
|
925 | + if ($line != '') { |
|
926 | + $line = explode(':', $line); |
|
927 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
928 | 928 | $data = array(); |
929 | 929 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
930 | 930 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -937,37 +937,37 @@ discard block |
||
937 | 937 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
938 | 938 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
939 | 939 | $data['latitude'] = $line[5]; // lat |
940 | - $data['longitude'] = $line[6]; // long |
|
941 | - $data['verticalrate'] = ''; // vertical rate |
|
942 | - $data['squawk'] = ''; // squawk |
|
943 | - $data['emergency'] = ''; // emergency |
|
944 | - $data['waypoints'] = $line[30]; |
|
940 | + $data['longitude'] = $line[6]; // long |
|
941 | + $data['verticalrate'] = ''; // vertical rate |
|
942 | + $data['squawk'] = ''; // squawk |
|
943 | + $data['emergency'] = ''; // emergency |
|
944 | + $data['waypoints'] = $line[30]; |
|
945 | 945 | $data['datetime'] = date('Y-m-d H:i:s'); |
946 | 946 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
947 | 947 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
948 | - $data['departure_airport_icao'] = $line[11]; |
|
949 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
950 | - $data['arrival_airport_icao'] = $line[13]; |
|
948 | + $data['departure_airport_icao'] = $line[11]; |
|
949 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
950 | + $data['arrival_airport_icao'] = $line[13]; |
|
951 | 951 | $data['frequency'] = $line[4]; |
952 | 952 | $data['type'] = $line[18]; |
953 | 953 | $data['range'] = $line[19]; |
954 | 954 | if (isset($line[35])) $data['info'] = $line[35]; |
955 | - $data['id_source'] = $id_source; |
|
956 | - //$data['arrival_airport_time'] = ; |
|
957 | - if ($line[9] != '') { |
|
958 | - $aircraft_data = explode('/',$line[9]); |
|
959 | - if (isset($aircraft_data[1])) { |
|
960 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
961 | - } |
|
962 | - } |
|
963 | - /* |
|
955 | + $data['id_source'] = $id_source; |
|
956 | + //$data['arrival_airport_time'] = ; |
|
957 | + if ($line[9] != '') { |
|
958 | + $aircraft_data = explode('/',$line[9]); |
|
959 | + if (isset($aircraft_data[1])) { |
|
960 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
961 | + } |
|
962 | + } |
|
963 | + /* |
|
964 | 964 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
965 | 965 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
966 | 966 | */ |
967 | - $data['format_source'] = $value['format']; |
|
967 | + $data['format_source'] = $value['format']; |
|
968 | 968 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
969 | 969 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
970 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
970 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
971 | 971 | elseif ($line[3] === 'ATC') { |
972 | 972 | //print_r($data); |
973 | 973 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -988,21 +988,21 @@ discard block |
||
988 | 988 | 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']); |
989 | 989 | } |
990 | 990 | } |
991 | - unset($data); |
|
992 | - } |
|
993 | - } |
|
994 | - } |
|
995 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
996 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
997 | - $last_exec[$id]['last'] = time(); |
|
998 | - } elseif ($value['format'] === 'airwhere' && |
|
999 | - ( |
|
1000 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1001 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1002 | - ) |
|
1003 | - ) { |
|
1004 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
1005 | - if ($buffer != '') { |
|
991 | + unset($data); |
|
992 | + } |
|
993 | + } |
|
994 | + } |
|
995 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
996 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
997 | + $last_exec[$id]['last'] = time(); |
|
998 | + } elseif ($value['format'] === 'airwhere' && |
|
999 | + ( |
|
1000 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1001 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1002 | + ) |
|
1003 | + ) { |
|
1004 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
1005 | + if ($buffer != '') { |
|
1006 | 1006 | $all_data = simplexml_load_string($buffer); |
1007 | 1007 | foreach($all_data->children() as $childdata) { |
1008 | 1008 | $data = array(); |
@@ -1024,10 +1024,10 @@ discard block |
||
1024 | 1024 | $SI->add($data); |
1025 | 1025 | unset($data); |
1026 | 1026 | } |
1027 | - } |
|
1028 | - $Source->deleteOldLocationByType('gs'); |
|
1029 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
1030 | - if ($buffer != '') { |
|
1027 | + } |
|
1028 | + $Source->deleteOldLocationByType('gs'); |
|
1029 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
1030 | + if ($buffer != '') { |
|
1031 | 1031 | $all_data = simplexml_load_string($buffer); |
1032 | 1032 | foreach($all_data->children() as $childdata) { |
1033 | 1033 | $data = array(); |
@@ -1045,8 +1045,8 @@ discard block |
||
1045 | 1045 | } |
1046 | 1046 | unset($data); |
1047 | 1047 | } |
1048 | - } |
|
1049 | - $last_exec[$id]['last'] = time(); |
|
1048 | + } |
|
1049 | + $last_exec[$id]['last'] = time(); |
|
1050 | 1050 | /* |
1051 | 1051 | } if ($value['format'] === 'aircraftlistjson') { |
1052 | 1052 | print_r($globalSources); |
@@ -1054,17 +1054,17 @@ discard block |
||
1054 | 1054 | echo $globalMinFetch; |
1055 | 1055 | */ |
1056 | 1056 | } elseif ($value['format'] === 'aircraftlistjson' && |
1057 | - ( |
|
1057 | + ( |
|
1058 | 1058 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1059 | 1059 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1060 | - ) |
|
1060 | + ) |
|
1061 | 1061 | ) { |
1062 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
1063 | - if ($buffer != '') { |
|
1064 | - $all_data = json_decode($buffer,true); |
|
1062 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
1063 | + if ($buffer != '') { |
|
1064 | + $all_data = json_decode($buffer,true); |
|
1065 | 1065 | if (isset($all_data['acList'])) { |
1066 | - $reset = 0; |
|
1067 | - foreach ($all_data['acList'] as $line) { |
|
1066 | + $reset = 0; |
|
1067 | + foreach ($all_data['acList'] as $line) { |
|
1068 | 1068 | $data = array(); |
1069 | 1069 | $data['hex'] = $line['Icao']; // hex |
1070 | 1070 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1087,10 +1087,10 @@ discard block |
||
1087 | 1087 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1088 | 1088 | if (isset($data['latitude'])) $SI->add($data); |
1089 | 1089 | unset($data); |
1090 | - } |
|
1090 | + } |
|
1091 | 1091 | } elseif (is_array($all_data)) { |
1092 | - $reset = 0; |
|
1093 | - foreach ($all_data as $line) { |
|
1092 | + $reset = 0; |
|
1093 | + foreach ($all_data as $line) { |
|
1094 | 1094 | $data = array(); |
1095 | 1095 | $data['hex'] = $line['hex']; // hex |
1096 | 1096 | $data['ident'] = $line['flight']; // ident |
@@ -1110,291 +1110,291 @@ discard block |
||
1110 | 1110 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1111 | 1111 | $SI->add($data); |
1112 | 1112 | unset($data); |
1113 | - } |
|
1113 | + } |
|
1114 | 1114 | } |
1115 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1116 | - //$last_exec['aircraftlistjson'] = time(); |
|
1117 | - $last_exec[$id]['last'] = time(); |
|
1118 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
1119 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
1120 | - ( |
|
1121 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1122 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1123 | - ) |
|
1124 | - ) { |
|
1125 | - $buffer = $Common->getData($value['host']); |
|
1126 | - $all_data = json_decode($buffer,true); |
|
1127 | - if (isset($all_data['planes'])) { |
|
1115 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
1116 | + //$last_exec['aircraftlistjson'] = time(); |
|
1117 | + $last_exec[$id]['last'] = time(); |
|
1118 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
1119 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
1120 | + ( |
|
1121 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1122 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1123 | + ) |
|
1124 | + ) { |
|
1125 | + $buffer = $Common->getData($value['host']); |
|
1126 | + $all_data = json_decode($buffer,true); |
|
1127 | + if (isset($all_data['planes'])) { |
|
1128 | 1128 | $reset = 0; |
1129 | 1129 | foreach ($all_data['planes'] as $key => $line) { |
1130 | - $data = array(); |
|
1131 | - $data['hex'] = $key; // hex |
|
1132 | - $data['ident'] = $line[3]; // ident |
|
1133 | - $data['altitude'] = $line[6]; // altitude |
|
1134 | - $data['speed'] = $line[8]; // speed |
|
1135 | - $data['heading'] = $line[7]; // heading |
|
1136 | - $data['latitude'] = $line[4]; // lat |
|
1137 | - $data['longitude'] = $line[5]; // long |
|
1138 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
1139 | - $data['squawk'] = $line[10]; // squawk |
|
1140 | - $data['emergency'] = ''; // emergency |
|
1141 | - $data['registration'] = $line[2]; |
|
1142 | - $data['aircraft_icao'] = $line[0]; |
|
1143 | - $deparr = explode('-',$line[1]); |
|
1144 | - if (count($deparr) === 2) { |
|
1130 | + $data = array(); |
|
1131 | + $data['hex'] = $key; // hex |
|
1132 | + $data['ident'] = $line[3]; // ident |
|
1133 | + $data['altitude'] = $line[6]; // altitude |
|
1134 | + $data['speed'] = $line[8]; // speed |
|
1135 | + $data['heading'] = $line[7]; // heading |
|
1136 | + $data['latitude'] = $line[4]; // lat |
|
1137 | + $data['longitude'] = $line[5]; // long |
|
1138 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
1139 | + $data['squawk'] = $line[10]; // squawk |
|
1140 | + $data['emergency'] = ''; // emergency |
|
1141 | + $data['registration'] = $line[2]; |
|
1142 | + $data['aircraft_icao'] = $line[0]; |
|
1143 | + $deparr = explode('-',$line[1]); |
|
1144 | + if (count($deparr) === 2) { |
|
1145 | 1145 | $data['departure_airport_icao'] = $deparr[0]; |
1146 | 1146 | $data['arrival_airport_icao'] = $deparr[1]; |
1147 | - } |
|
1148 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
1149 | - $data['format_source'] = 'planeupdatefaa'; |
|
1150 | - $data['id_source'] = $id_source; |
|
1151 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1152 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1153 | - $SI->add($data); |
|
1154 | - unset($data); |
|
1147 | + } |
|
1148 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
1149 | + $data['format_source'] = 'planeupdatefaa'; |
|
1150 | + $data['id_source'] = $id_source; |
|
1151 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1152 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1153 | + $SI->add($data); |
|
1154 | + unset($data); |
|
1155 | + } |
|
1155 | 1156 | } |
1156 | - } |
|
1157 | - //$last_exec['planeupdatefaa'] = time(); |
|
1158 | - $last_exec[$id]['last'] = time(); |
|
1157 | + //$last_exec['planeupdatefaa'] = time(); |
|
1158 | + $last_exec[$id]['last'] = time(); |
|
1159 | 1159 | } elseif ($value['format'] === 'opensky' && |
1160 | - ( |
|
1160 | + ( |
|
1161 | 1161 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1162 | 1162 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1163 | - ) |
|
1163 | + ) |
|
1164 | 1164 | ) { |
1165 | - $buffer = $Common->getData($value['host']); |
|
1166 | - $all_data = json_decode($buffer,true); |
|
1167 | - if (isset($all_data['states'])) { |
|
1165 | + $buffer = $Common->getData($value['host']); |
|
1166 | + $all_data = json_decode($buffer,true); |
|
1167 | + if (isset($all_data['states'])) { |
|
1168 | 1168 | $reset = 0; |
1169 | 1169 | foreach ($all_data['states'] as $key => $line) { |
1170 | - $data = array(); |
|
1171 | - $data['hex'] = $line[0]; // hex |
|
1172 | - $data['ident'] = trim($line[1]); // ident |
|
1173 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1174 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
1175 | - $data['heading'] = round($line[10]); // heading |
|
1176 | - $data['latitude'] = $line[6]; // lat |
|
1177 | - $data['longitude'] = $line[5]; // long |
|
1178 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
1179 | - //$data['squawk'] = $line[10]; // squawk |
|
1180 | - //$data['emergency'] = ''; // emergency |
|
1181 | - //$data['registration'] = $line[2]; |
|
1182 | - //$data['aircraft_icao'] = $line[0]; |
|
1183 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1184 | - $data['format_source'] = 'opensky'; |
|
1185 | - $data['id_source'] = $id_source; |
|
1186 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1187 | - $SI->add($data); |
|
1188 | - unset($data); |
|
1170 | + $data = array(); |
|
1171 | + $data['hex'] = $line[0]; // hex |
|
1172 | + $data['ident'] = trim($line[1]); // ident |
|
1173 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1174 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
1175 | + $data['heading'] = round($line[10]); // heading |
|
1176 | + $data['latitude'] = $line[6]; // lat |
|
1177 | + $data['longitude'] = $line[5]; // long |
|
1178 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
1179 | + //$data['squawk'] = $line[10]; // squawk |
|
1180 | + //$data['emergency'] = ''; // emergency |
|
1181 | + //$data['registration'] = $line[2]; |
|
1182 | + //$data['aircraft_icao'] = $line[0]; |
|
1183 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1184 | + $data['format_source'] = 'opensky'; |
|
1185 | + $data['id_source'] = $id_source; |
|
1186 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1187 | + $SI->add($data); |
|
1188 | + unset($data); |
|
1189 | 1189 | } |
1190 | - } |
|
1191 | - //$last_exec['planeupdatefaa'] = time(); |
|
1192 | - $last_exec[$id]['last'] = time(); |
|
1190 | + } |
|
1191 | + //$last_exec['planeupdatefaa'] = time(); |
|
1192 | + $last_exec[$id]['last'] = time(); |
|
1193 | 1193 | } elseif ($value['format'] === 'aircraftjson' && |
1194 | - ( |
|
1194 | + ( |
|
1195 | 1195 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1196 | 1196 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1197 | - ) |
|
1197 | + ) |
|
1198 | 1198 | ) { |
1199 | - $buffer = $Common->getData($value['host']); |
|
1200 | - $all_data = json_decode($buffer,true); |
|
1201 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1199 | + $buffer = $Common->getData($value['host']); |
|
1200 | + $all_data = json_decode($buffer,true); |
|
1201 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1202 | 1202 | $reset = 0; |
1203 | 1203 | foreach ($all_data['aircraft'] as $key => $line) { |
1204 | - $data = array(); |
|
1205 | - // add support for ground vehicule with ~ in front of hex |
|
1206 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1207 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1208 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1209 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1210 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1211 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1212 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1213 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1214 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1215 | - //$data['emergency'] = ''; // emergency |
|
1216 | - //$data['registration'] = $line[2]; |
|
1217 | - //$data['aircraft_icao'] = $line[0]; |
|
1218 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1219 | - $data['format_source'] = 'aircraftjson'; |
|
1220 | - $data['id_source'] = $id_source; |
|
1221 | - if (isset($value['name']) && $value['name'] != '') { |
|
1222 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1223 | - else $data['source_name'] = $value['name']; |
|
1224 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1225 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1226 | - $SI->add($data); |
|
1227 | - unset($data); |
|
1204 | + $data = array(); |
|
1205 | + // add support for ground vehicule with ~ in front of hex |
|
1206 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1207 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1208 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1209 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1210 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1211 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1212 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1213 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1214 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1215 | + //$data['emergency'] = ''; // emergency |
|
1216 | + //$data['registration'] = $line[2]; |
|
1217 | + //$data['aircraft_icao'] = $line[0]; |
|
1218 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1219 | + $data['format_source'] = 'aircraftjson'; |
|
1220 | + $data['id_source'] = $id_source; |
|
1221 | + if (isset($value['name']) && $value['name'] != '') { |
|
1222 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1223 | + else $data['source_name'] = $value['name']; |
|
1224 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1225 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1226 | + $SI->add($data); |
|
1227 | + unset($data); |
|
1228 | + } |
|
1228 | 1229 | } |
1229 | - } |
|
1230 | - //$last_exec['planeupdatefaa'] = time(); |
|
1231 | - $last_exec[$id]['last'] = time(); |
|
1230 | + //$last_exec['planeupdatefaa'] = time(); |
|
1231 | + $last_exec[$id]['last'] = time(); |
|
1232 | 1232 | } elseif ($value['format'] === 'planefinderclient' && |
1233 | - ( |
|
1233 | + ( |
|
1234 | 1234 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1235 | 1235 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1236 | - ) |
|
1236 | + ) |
|
1237 | 1237 | ) { |
1238 | - $buffer = $Common->getData($value['host']); |
|
1239 | - $all_data = json_decode($buffer,true); |
|
1240 | - if (isset($all_data['aircraft'])) { |
|
1238 | + $buffer = $Common->getData($value['host']); |
|
1239 | + $all_data = json_decode($buffer,true); |
|
1240 | + if (isset($all_data['aircraft'])) { |
|
1241 | 1241 | $reset = 0; |
1242 | 1242 | foreach ($all_data['aircraft'] as $key => $line) { |
1243 | - $data = array(); |
|
1244 | - $data['hex'] = $key; // hex |
|
1245 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1246 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1247 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1248 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1249 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1250 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1251 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1252 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1253 | - //$data['emergency'] = ''; // emergency |
|
1254 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1255 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1256 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1257 | - $data['format_source'] = 'planefinderclient'; |
|
1258 | - $data['id_source'] = $id_source; |
|
1259 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1260 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1261 | - $SI->add($data); |
|
1262 | - unset($data); |
|
1243 | + $data = array(); |
|
1244 | + $data['hex'] = $key; // hex |
|
1245 | + if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1246 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1247 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1248 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1249 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1250 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1251 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1252 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1253 | + //$data['emergency'] = ''; // emergency |
|
1254 | + if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1255 | + if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1256 | + $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1257 | + $data['format_source'] = 'planefinderclient'; |
|
1258 | + $data['id_source'] = $id_source; |
|
1259 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1260 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1261 | + $SI->add($data); |
|
1262 | + unset($data); |
|
1263 | 1263 | } |
1264 | - } |
|
1265 | - $last_exec[$id]['last'] = time(); |
|
1264 | + } |
|
1265 | + $last_exec[$id]['last'] = time(); |
|
1266 | 1266 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1267 | 1267 | } elseif ($value['format'] === 'fr24json' && |
1268 | - ( |
|
1268 | + ( |
|
1269 | 1269 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1270 | 1270 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1271 | - ) |
|
1271 | + ) |
|
1272 | 1272 | ) { |
1273 | - //$buffer = $Common->getData($hosts[$id]); |
|
1274 | - $buffer = $Common->getData($value['host']); |
|
1275 | - $all_data = json_decode($buffer,true); |
|
1276 | - if (!empty($all_data)) $reset = 0; |
|
1277 | - foreach ($all_data as $key => $line) { |
|
1273 | + //$buffer = $Common->getData($hosts[$id]); |
|
1274 | + $buffer = $Common->getData($value['host']); |
|
1275 | + $all_data = json_decode($buffer,true); |
|
1276 | + if (!empty($all_data)) $reset = 0; |
|
1277 | + foreach ($all_data as $key => $line) { |
|
1278 | 1278 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1279 | - $data = array(); |
|
1280 | - $data['hex'] = $line[0]; |
|
1281 | - $data['ident'] = $line[16]; //$line[13] |
|
1282 | - $data['altitude'] = $line[4]; // altitude |
|
1283 | - $data['speed'] = $line[5]; // speed |
|
1284 | - $data['heading'] = $line[3]; // heading |
|
1285 | - $data['latitude'] = $line[1]; // lat |
|
1286 | - $data['longitude'] = $line[2]; // long |
|
1287 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1288 | - $data['squawk'] = $line[6]; // squawk |
|
1289 | - $data['aircraft_icao'] = $line[8]; |
|
1290 | - $data['registration'] = $line[9]; |
|
1291 | - $data['departure_airport_iata'] = $line[11]; |
|
1292 | - $data['arrival_airport_iata'] = $line[12]; |
|
1293 | - $data['emergency'] = ''; // emergency |
|
1294 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1295 | - $data['format_source'] = 'fr24json'; |
|
1296 | - $data['id_source'] = $id_source; |
|
1297 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1298 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1299 | - $SI->add($data); |
|
1300 | - unset($data); |
|
1279 | + $data = array(); |
|
1280 | + $data['hex'] = $line[0]; |
|
1281 | + $data['ident'] = $line[16]; //$line[13] |
|
1282 | + $data['altitude'] = $line[4]; // altitude |
|
1283 | + $data['speed'] = $line[5]; // speed |
|
1284 | + $data['heading'] = $line[3]; // heading |
|
1285 | + $data['latitude'] = $line[1]; // lat |
|
1286 | + $data['longitude'] = $line[2]; // long |
|
1287 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1288 | + $data['squawk'] = $line[6]; // squawk |
|
1289 | + $data['aircraft_icao'] = $line[8]; |
|
1290 | + $data['registration'] = $line[9]; |
|
1291 | + $data['departure_airport_iata'] = $line[11]; |
|
1292 | + $data['arrival_airport_iata'] = $line[12]; |
|
1293 | + $data['emergency'] = ''; // emergency |
|
1294 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1295 | + $data['format_source'] = 'fr24json'; |
|
1296 | + $data['id_source'] = $id_source; |
|
1297 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1298 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1299 | + $SI->add($data); |
|
1300 | + unset($data); |
|
1301 | 1301 | } |
1302 | - } |
|
1303 | - //$last_exec['fr24json'] = time(); |
|
1304 | - $last_exec[$id]['last'] = time(); |
|
1302 | + } |
|
1303 | + //$last_exec['fr24json'] = time(); |
|
1304 | + $last_exec[$id]['last'] = time(); |
|
1305 | 1305 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1306 | 1306 | } elseif ($value['format'] === 'radarvirtueljson' && |
1307 | - ( |
|
1307 | + ( |
|
1308 | 1308 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1309 | 1309 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1310 | - ) |
|
1310 | + ) |
|
1311 | 1311 | ) { |
1312 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1313 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1314 | - //echo $buffer; |
|
1315 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1316 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1317 | - $all_data = json_decode($buffer,true); |
|
1318 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1312 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1313 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1314 | + //echo $buffer; |
|
1315 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1316 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1317 | + $all_data = json_decode($buffer,true); |
|
1318 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1319 | 1319 | die(json_last_error_msg()); |
1320 | - } |
|
1321 | - if (isset($all_data['mrkrs'])) { |
|
1320 | + } |
|
1321 | + if (isset($all_data['mrkrs'])) { |
|
1322 | 1322 | $reset = 0; |
1323 | 1323 | foreach ($all_data['mrkrs'] as $key => $line) { |
1324 | - if (isset($line['inf'])) { |
|
1324 | + if (isset($line['inf'])) { |
|
1325 | 1325 | $data = array(); |
1326 | 1326 | $data['hex'] = $line['inf']['ia']; |
1327 | 1327 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1328 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1329 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1330 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1331 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1332 | - $data['longitude'] = $line['pt'][1]; // long |
|
1333 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1334 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1335 | - //$data['aircraft_icao'] = $line[8]; |
|
1336 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1328 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1329 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1330 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1331 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1332 | + $data['longitude'] = $line['pt'][1]; // long |
|
1333 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1334 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1335 | + //$data['aircraft_icao'] = $line[8]; |
|
1336 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1337 | 1337 | //$data['departure_airport_iata'] = $line[11]; |
1338 | 1338 | //$data['arrival_airport_iata'] = $line[12]; |
1339 | - //$data['emergency'] = ''; // emergency |
|
1339 | + //$data['emergency'] = ''; // emergency |
|
1340 | 1340 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1341 | - $data['format_source'] = 'radarvirtueljson'; |
|
1342 | - $data['id_source'] = $id_source; |
|
1341 | + $data['format_source'] = 'radarvirtueljson'; |
|
1342 | + $data['id_source'] = $id_source; |
|
1343 | 1343 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1344 | 1344 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1345 | 1345 | $SI->add($data); |
1346 | 1346 | unset($data); |
1347 | - } |
|
1347 | + } |
|
1348 | 1348 | } |
1349 | - } |
|
1350 | - //$last_exec['radarvirtueljson'] = time(); |
|
1351 | - $last_exec[$id]['last'] = time(); |
|
1349 | + } |
|
1350 | + //$last_exec['radarvirtueljson'] = time(); |
|
1351 | + $last_exec[$id]['last'] = time(); |
|
1352 | 1352 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1353 | 1353 | } elseif ($value['format'] === 'pirepsjson' && |
1354 | - ( |
|
1354 | + ( |
|
1355 | 1355 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1356 | 1356 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1357 | - ) |
|
1357 | + ) |
|
1358 | 1358 | ) { |
1359 | - //$buffer = $Common->getData($hosts[$id]); |
|
1360 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1361 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1359 | + //$buffer = $Common->getData($hosts[$id]); |
|
1360 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1361 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1362 | 1362 | |
1363 | - if (isset($all_data['pireps'])) { |
|
1363 | + if (isset($all_data['pireps'])) { |
|
1364 | 1364 | $reset = 0; |
1365 | - foreach ($all_data['pireps'] as $line) { |
|
1366 | - $data = array(); |
|
1367 | - $data['id'] = $line['id']; |
|
1368 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1369 | - $data['ident'] = $line['callsign']; // ident |
|
1370 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1371 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1372 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1373 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1374 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1375 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1376 | - $data['latitude'] = $line['lat']; // lat |
|
1377 | - $data['longitude'] = $line['lon']; // long |
|
1378 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1379 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1380 | - //$data['emergency'] = ''; // emergency |
|
1381 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1382 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1383 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1384 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1385 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1386 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1387 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1388 | - else $data['info'] = ''; |
|
1389 | - $data['format_source'] = 'pireps'; |
|
1390 | - $data['id_source'] = $id_source; |
|
1391 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1392 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1393 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1394 | - if ($line['icon'] === 'plane') { |
|
1365 | + foreach ($all_data['pireps'] as $line) { |
|
1366 | + $data = array(); |
|
1367 | + $data['id'] = $line['id']; |
|
1368 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1369 | + $data['ident'] = $line['callsign']; // ident |
|
1370 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1371 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1372 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1373 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1374 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1375 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1376 | + $data['latitude'] = $line['lat']; // lat |
|
1377 | + $data['longitude'] = $line['lon']; // long |
|
1378 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1379 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1380 | + //$data['emergency'] = ''; // emergency |
|
1381 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1382 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1383 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1384 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1385 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1386 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1387 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1388 | + else $data['info'] = ''; |
|
1389 | + $data['format_source'] = 'pireps'; |
|
1390 | + $data['id_source'] = $id_source; |
|
1391 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1392 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1393 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1394 | + if ($line['icon'] === 'plane') { |
|
1395 | 1395 | $SI->add($data); |
1396 | - // print_r($data); |
|
1397 | - } elseif ($line['icon'] === 'ct') { |
|
1396 | + // print_r($data); |
|
1397 | + } elseif ($line['icon'] === 'ct') { |
|
1398 | 1398 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1399 | 1399 | $data['info'] = str_replace('&sect;','',$data['info']); |
1400 | 1400 | $typec = substr($data['ident'],-3); |
@@ -1409,209 +1409,209 @@ discard block |
||
1409 | 1409 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1410 | 1410 | else $data['type'] = 'Observer'; |
1411 | 1411 | 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']); |
1412 | - } |
|
1413 | - unset($data); |
|
1412 | + } |
|
1413 | + unset($data); |
|
1414 | 1414 | } |
1415 | - } |
|
1416 | - //$last_exec['pirepsjson'] = time(); |
|
1417 | - $last_exec[$id]['last'] = time(); |
|
1415 | + } |
|
1416 | + //$last_exec['pirepsjson'] = time(); |
|
1417 | + $last_exec[$id]['last'] = time(); |
|
1418 | 1418 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1419 | 1419 | } elseif ($value['format'] === 'phpvmacars' && |
1420 | - ( |
|
1420 | + ( |
|
1421 | 1421 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1422 | 1422 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1423 | - ) |
|
1423 | + ) |
|
1424 | 1424 | ) { |
1425 | - //$buffer = $Common->getData($hosts[$id]); |
|
1426 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1427 | - $buffer = $Common->getData($value['host']); |
|
1428 | - $all_data = json_decode($buffer,true); |
|
1429 | - if ($buffer != '' && is_array($all_data)) { |
|
1425 | + //$buffer = $Common->getData($hosts[$id]); |
|
1426 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1427 | + $buffer = $Common->getData($value['host']); |
|
1428 | + $all_data = json_decode($buffer,true); |
|
1429 | + if ($buffer != '' && is_array($all_data)) { |
|
1430 | 1430 | $reset = 0; |
1431 | 1431 | foreach ($all_data as $line) { |
1432 | - $data = array(); |
|
1433 | - //$data['id'] = $line['id']; // id not usable |
|
1434 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1435 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1436 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1437 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1438 | - $data['ident'] = $line['flightnum']; // ident |
|
1439 | - $data['altitude'] = $line['alt']; // altitude |
|
1440 | - $data['speed'] = $line['gs']; // speed |
|
1441 | - $data['heading'] = $line['heading']; // heading |
|
1442 | - $data['latitude'] = $line['lat']; // lat |
|
1443 | - $data['longitude'] = $line['lng']; // long |
|
1444 | - $data['verticalrate'] = ''; // verticale rate |
|
1445 | - $data['squawk'] = ''; // squawk |
|
1446 | - $data['emergency'] = ''; // emergency |
|
1447 | - //$data['datetime'] = $line['lastupdate']; |
|
1448 | - //$data['last_update'] = $line['lastupdate']; |
|
1449 | - if (isset($value['timezone'])) { |
|
1450 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1451 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1452 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1453 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1454 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1455 | - $data['departure_airport_time'] = $line['deptime']; |
|
1456 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1457 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1458 | - if (isset($line['registration'])) { |
|
1459 | - $data['registration'] = $line['registration']; |
|
1460 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1461 | - } else $data['registration'] = $line['aircraft']; |
|
1462 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1463 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1464 | - if (isset($line['aircraftname'])) { |
|
1432 | + $data = array(); |
|
1433 | + //$data['id'] = $line['id']; // id not usable |
|
1434 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1435 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1436 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1437 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1438 | + $data['ident'] = $line['flightnum']; // ident |
|
1439 | + $data['altitude'] = $line['alt']; // altitude |
|
1440 | + $data['speed'] = $line['gs']; // speed |
|
1441 | + $data['heading'] = $line['heading']; // heading |
|
1442 | + $data['latitude'] = $line['lat']; // lat |
|
1443 | + $data['longitude'] = $line['lng']; // long |
|
1444 | + $data['verticalrate'] = ''; // verticale rate |
|
1445 | + $data['squawk'] = ''; // squawk |
|
1446 | + $data['emergency'] = ''; // emergency |
|
1447 | + //$data['datetime'] = $line['lastupdate']; |
|
1448 | + //$data['last_update'] = $line['lastupdate']; |
|
1449 | + if (isset($value['timezone'])) { |
|
1450 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1451 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1452 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1453 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1454 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1455 | + $data['departure_airport_time'] = $line['deptime']; |
|
1456 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1457 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1458 | + if (isset($line['registration'])) { |
|
1459 | + $data['registration'] = $line['registration']; |
|
1460 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1461 | + } else $data['registration'] = $line['aircraft']; |
|
1462 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1463 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1464 | + if (isset($line['aircraftname'])) { |
|
1465 | 1465 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1466 | 1466 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1467 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1468 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1469 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1470 | - else { |
|
1471 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1472 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1473 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1474 | - } |
|
1475 | - } |
|
1476 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1477 | - $data['id_source'] = $id_source; |
|
1478 | - $data['format_source'] = 'phpvmacars'; |
|
1479 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1480 | - $SI->add($data); |
|
1481 | - unset($data); |
|
1467 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1468 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1469 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1470 | + else { |
|
1471 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1472 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1473 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1474 | + } |
|
1475 | + } |
|
1476 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1477 | + $data['id_source'] = $id_source; |
|
1478 | + $data['format_source'] = 'phpvmacars'; |
|
1479 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1480 | + $SI->add($data); |
|
1481 | + unset($data); |
|
1482 | 1482 | } |
1483 | 1483 | if ($globalDebug) echo 'No more data...'."\n"; |
1484 | 1484 | unset($buffer); |
1485 | 1485 | unset($all_data); |
1486 | - } |
|
1487 | - //$last_exec['phpvmacars'] = time(); |
|
1488 | - $last_exec[$id]['last'] = time(); |
|
1486 | + } |
|
1487 | + //$last_exec['phpvmacars'] = time(); |
|
1488 | + $last_exec[$id]['last'] = time(); |
|
1489 | 1489 | } elseif ($value['format'] === 'vaos' && |
1490 | - ( |
|
1490 | + ( |
|
1491 | 1491 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1492 | 1492 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1493 | - ) |
|
1493 | + ) |
|
1494 | 1494 | ) { |
1495 | - //$buffer = $Common->getData($hosts[$id]); |
|
1496 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1497 | - $buffer = $Common->getData($value['host']); |
|
1498 | - $all_data = json_decode($buffer,true); |
|
1499 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1495 | + //$buffer = $Common->getData($hosts[$id]); |
|
1496 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1497 | + $buffer = $Common->getData($value['host']); |
|
1498 | + $all_data = json_decode($buffer,true); |
|
1499 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1500 | 1500 | $reset = 0; |
1501 | 1501 | foreach ($all_data['ACARSData'] as $line) { |
1502 | - //print_r($line); |
|
1503 | - $data = array(); |
|
1504 | - //$data['id'] = $line['id']; // id not usable |
|
1505 | - $data['id'] = $line['id']; |
|
1506 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1507 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1508 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1509 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1510 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1511 | - $data['altitude'] = $line['altitude']; // altitude |
|
1512 | - $data['speed'] = $line['groundspeed']; // speed |
|
1513 | - $data['heading'] = $line['heading']; // heading |
|
1514 | - $data['latitude'] = $line['lat']; // lat |
|
1515 | - $data['longitude'] = $line['lon']; // long |
|
1516 | - //$data['verticalrate'] = ''; // verticale rate |
|
1517 | - //$data['squawk'] = ''; // squawk |
|
1518 | - //$data['emergency'] = ''; // emergency |
|
1519 | - if (isset($value['timezone'])) { |
|
1520 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1521 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1522 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1523 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1502 | + //print_r($line); |
|
1503 | + $data = array(); |
|
1504 | + //$data['id'] = $line['id']; // id not usable |
|
1505 | + $data['id'] = $line['id']; |
|
1506 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1507 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1508 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1509 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1510 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1511 | + $data['altitude'] = $line['altitude']; // altitude |
|
1512 | + $data['speed'] = $line['groundspeed']; // speed |
|
1513 | + $data['heading'] = $line['heading']; // heading |
|
1514 | + $data['latitude'] = $line['lat']; // lat |
|
1515 | + $data['longitude'] = $line['lon']; // long |
|
1516 | + //$data['verticalrate'] = ''; // verticale rate |
|
1517 | + //$data['squawk'] = ''; // squawk |
|
1518 | + //$data['emergency'] = ''; // emergency |
|
1519 | + if (isset($value['timezone'])) { |
|
1520 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1521 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1522 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1523 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1524 | 1524 | |
1525 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1526 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1527 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1528 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1529 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1525 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1526 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1527 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1528 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1529 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1530 | 1530 | |
1531 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1532 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1533 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1531 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1532 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1533 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1534 | 1534 | |
1535 | - $data['id_source'] = $id_source; |
|
1536 | - $data['format_source'] = 'vaos'; |
|
1537 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1538 | - $SI->add($data); |
|
1539 | - unset($data); |
|
1535 | + $data['id_source'] = $id_source; |
|
1536 | + $data['format_source'] = 'vaos'; |
|
1537 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1538 | + $SI->add($data); |
|
1539 | + unset($data); |
|
1540 | 1540 | } |
1541 | 1541 | if ($globalDebug) echo 'No more data...'."\n"; |
1542 | 1542 | unset($buffer); |
1543 | 1543 | unset($all_data); |
1544 | - } |
|
1545 | - //$last_exec['phpvmacars'] = time(); |
|
1546 | - $last_exec[$id]['last'] = time(); |
|
1544 | + } |
|
1545 | + //$last_exec['phpvmacars'] = time(); |
|
1546 | + $last_exec[$id]['last'] = time(); |
|
1547 | 1547 | } elseif ($value['format'] === 'vam' && |
1548 | - ( |
|
1548 | + ( |
|
1549 | 1549 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1550 | 1550 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1551 | - ) |
|
1551 | + ) |
|
1552 | 1552 | ) { |
1553 | - //$buffer = $Common->getData($hosts[$id]); |
|
1554 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1555 | - $buffer = $Common->getData($value['host']); |
|
1556 | - $all_data = json_decode($buffer,true); |
|
1557 | - if ($buffer != '' && is_array($all_data)) { |
|
1553 | + //$buffer = $Common->getData($hosts[$id]); |
|
1554 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1555 | + $buffer = $Common->getData($value['host']); |
|
1556 | + $all_data = json_decode($buffer,true); |
|
1557 | + if ($buffer != '' && is_array($all_data)) { |
|
1558 | 1558 | $reset = 0; |
1559 | 1559 | foreach ($all_data as $line) { |
1560 | - $data = array(); |
|
1561 | - //$data['id'] = $line['id']; // id not usable |
|
1562 | - $data['id'] = trim($line['flight_id']); |
|
1563 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1564 | - $data['pilot_name'] = $line['pilot_name']; |
|
1565 | - $data['pilot_id'] = $line['pilot_id']; |
|
1566 | - $data['ident'] = trim($line['callsign']); // ident |
|
1567 | - $data['altitude'] = $line['altitude']; // altitude |
|
1568 | - $data['speed'] = $line['gs']; // speed |
|
1569 | - $data['heading'] = $line['heading']; // heading |
|
1570 | - $data['latitude'] = $line['latitude']; // lat |
|
1571 | - $data['longitude'] = $line['longitude']; // long |
|
1572 | - $data['verticalrate'] = ''; // verticale rate |
|
1573 | - $data['squawk'] = ''; // squawk |
|
1574 | - $data['emergency'] = ''; // emergency |
|
1575 | - //$data['datetime'] = $line['lastupdate']; |
|
1576 | - $data['last_update'] = $line['last_update']; |
|
1577 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1578 | - $data['departure_airport_icao'] = $line['departure']; |
|
1579 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1580 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1581 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1582 | - //$data['registration'] = $line['aircraft']; |
|
1583 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1584 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1585 | - $data['id_source'] = $id_source; |
|
1586 | - $data['format_source'] = 'vam'; |
|
1587 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1588 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1589 | - $SI->add($data); |
|
1590 | - unset($data); |
|
1560 | + $data = array(); |
|
1561 | + //$data['id'] = $line['id']; // id not usable |
|
1562 | + $data['id'] = trim($line['flight_id']); |
|
1563 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1564 | + $data['pilot_name'] = $line['pilot_name']; |
|
1565 | + $data['pilot_id'] = $line['pilot_id']; |
|
1566 | + $data['ident'] = trim($line['callsign']); // ident |
|
1567 | + $data['altitude'] = $line['altitude']; // altitude |
|
1568 | + $data['speed'] = $line['gs']; // speed |
|
1569 | + $data['heading'] = $line['heading']; // heading |
|
1570 | + $data['latitude'] = $line['latitude']; // lat |
|
1571 | + $data['longitude'] = $line['longitude']; // long |
|
1572 | + $data['verticalrate'] = ''; // verticale rate |
|
1573 | + $data['squawk'] = ''; // squawk |
|
1574 | + $data['emergency'] = ''; // emergency |
|
1575 | + //$data['datetime'] = $line['lastupdate']; |
|
1576 | + $data['last_update'] = $line['last_update']; |
|
1577 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1578 | + $data['departure_airport_icao'] = $line['departure']; |
|
1579 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1580 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1581 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1582 | + //$data['registration'] = $line['aircraft']; |
|
1583 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1584 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1585 | + $data['id_source'] = $id_source; |
|
1586 | + $data['format_source'] = 'vam'; |
|
1587 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1588 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1589 | + $SI->add($data); |
|
1590 | + unset($data); |
|
1591 | 1591 | } |
1592 | 1592 | if ($globalDebug) echo 'No more data...'."\n"; |
1593 | 1593 | unset($buffer); |
1594 | 1594 | unset($all_data); |
1595 | - } |
|
1596 | - //$last_exec['phpvmacars'] = time(); |
|
1597 | - $last_exec[$id]['last'] = time(); |
|
1595 | + } |
|
1596 | + //$last_exec['phpvmacars'] = time(); |
|
1597 | + $last_exec[$id]['last'] = time(); |
|
1598 | 1598 | } elseif ($value['format'] === 'blitzortung' && |
1599 | - ( |
|
1599 | + ( |
|
1600 | 1600 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1601 | 1601 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1602 | - ) |
|
1602 | + ) |
|
1603 | 1603 | ) { |
1604 | - //$buffer = $Common->getData($hosts[$id]); |
|
1605 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1606 | - $buffer = $Common->getData($value['host']); |
|
1607 | - $all_data = json_decode($buffer,true); |
|
1608 | - if ($buffer != '') { |
|
1604 | + //$buffer = $Common->getData($hosts[$id]); |
|
1605 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1606 | + $buffer = $Common->getData($value['host']); |
|
1607 | + $all_data = json_decode($buffer,true); |
|
1608 | + if ($buffer != '') { |
|
1609 | 1609 | $Source->deleteLocationBySource('blitzortung'); |
1610 | 1610 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1611 | 1611 | $buffer = explode('\n',$buffer); |
1612 | 1612 | foreach ($buffer as $buffer_line) { |
1613 | - $line = json_decode($buffer_line,true); |
|
1614 | - if (isset($line['time'])) { |
|
1613 | + $line = json_decode($buffer_line,true); |
|
1614 | + if (isset($line['time'])) { |
|
1615 | 1615 | $data = array(); |
1616 | 1616 | $data['altitude'] = $line['alt']; // altitude |
1617 | 1617 | $data['latitude'] = $line['lat']; // lat |
@@ -1623,92 +1623,92 @@ discard block |
||
1623 | 1623 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1624 | 1624 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1625 | 1625 | unset($data); |
1626 | - } |
|
1626 | + } |
|
1627 | 1627 | } |
1628 | 1628 | if ($globalDebug) echo 'No more data...'."\n"; |
1629 | 1629 | unset($buffer); |
1630 | - } |
|
1631 | - $last_exec[$id]['last'] = time(); |
|
1630 | + } |
|
1631 | + $last_exec[$id]['last'] = time(); |
|
1632 | 1632 | } elseif ($value['format'] === 'acarsjson') { |
1633 | - $arr = $httpfeeds; |
|
1634 | - $w = $e = null; |
|
1635 | - if (isset($arr[$id])) { |
|
1636 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
1637 | - if ($nn > 0) { |
|
1638 | - foreach ($httpfeeds as $feed) { |
|
1639 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
1640 | - if ($buffer === FALSE) { |
|
1641 | - connect_all($globalSources); |
|
1642 | - } |
|
1643 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1644 | - $buffer = explode('\n',$buffer); |
|
1645 | - foreach ($buffer as $line) { |
|
1646 | - if ($line != '') { |
|
1647 | - $line = json_decode($line, true); |
|
1648 | - if (!empty($line)) { |
|
1649 | - $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
1650 | - $ACARS->deleteLiveAcarsData(); |
|
1651 | - } |
|
1652 | - } |
|
1653 | - } |
|
1654 | - } |
|
1655 | - } else { |
|
1656 | - $format = $value['format']; |
|
1657 | - if (isset($tt[$format])) $tt[$format]++; |
|
1658 | - else $tt[$format] = 0; |
|
1659 | - if ($tt[$format] > 30) { |
|
1660 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
1661 | - sleep(2); |
|
1662 | - //$sourceeen[] = $value; |
|
1663 | - //connect_all($sourceeen); |
|
1664 | - //$sourceeen = array(); |
|
1665 | - connect_all($globalSources); |
|
1666 | - } |
|
1667 | - } |
|
1668 | - } |
|
1633 | + $arr = $httpfeeds; |
|
1634 | + $w = $e = null; |
|
1635 | + if (isset($arr[$id])) { |
|
1636 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
1637 | + if ($nn > 0) { |
|
1638 | + foreach ($httpfeeds as $feed) { |
|
1639 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
1640 | + if ($buffer === FALSE) { |
|
1641 | + connect_all($globalSources); |
|
1642 | + } |
|
1643 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1644 | + $buffer = explode('\n',$buffer); |
|
1645 | + foreach ($buffer as $line) { |
|
1646 | + if ($line != '') { |
|
1647 | + $line = json_decode($line, true); |
|
1648 | + if (!empty($line)) { |
|
1649 | + $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
1650 | + $ACARS->deleteLiveAcarsData(); |
|
1651 | + } |
|
1652 | + } |
|
1653 | + } |
|
1654 | + } |
|
1655 | + } else { |
|
1656 | + $format = $value['format']; |
|
1657 | + if (isset($tt[$format])) $tt[$format]++; |
|
1658 | + else $tt[$format] = 0; |
|
1659 | + if ($tt[$format] > 30) { |
|
1660 | + if ($globalDebug) echo 'Reconnect...'."\n"; |
|
1661 | + sleep(2); |
|
1662 | + //$sourceeen[] = $value; |
|
1663 | + //connect_all($sourceeen); |
|
1664 | + //$sourceeen = array(); |
|
1665 | + connect_all($globalSources); |
|
1666 | + } |
|
1667 | + } |
|
1668 | + } |
|
1669 | 1669 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
1670 | 1670 | } 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') { |
1671 | - //$last_exec[$id]['last'] = time(); |
|
1672 | - //$read = array( $sockets[$id] ); |
|
1673 | - $read = $sockets; |
|
1674 | - $write = NULL; |
|
1675 | - $e = NULL; |
|
1676 | - $n = socket_select($read, $write, $e, $timeout); |
|
1677 | - if ($e != NULL) var_dump($e); |
|
1678 | - if ($n > 0) { |
|
1671 | + //$last_exec[$id]['last'] = time(); |
|
1672 | + //$read = array( $sockets[$id] ); |
|
1673 | + $read = $sockets; |
|
1674 | + $write = NULL; |
|
1675 | + $e = NULL; |
|
1676 | + $n = socket_select($read, $write, $e, $timeout); |
|
1677 | + if ($e != NULL) var_dump($e); |
|
1678 | + if ($n > 0) { |
|
1679 | 1679 | $reset = 0; |
1680 | 1680 | foreach ($read as $nb => $r) { |
1681 | - //$value = $formats[$nb]; |
|
1682 | - $format = $globalSources[$nb]['format']; |
|
1683 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1681 | + //$value = $formats[$nb]; |
|
1682 | + $format = $globalSources[$nb]['format']; |
|
1683 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1684 | 1684 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1685 | - } elseif ($format === 'vrstcp') { |
|
1685 | + } elseif ($format === 'vrstcp') { |
|
1686 | 1686 | $buffer = @socket_read($r, 6000); |
1687 | - } else { |
|
1687 | + } else { |
|
1688 | 1688 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1689 | - } |
|
1690 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1691 | - //echo $buffer."\n"; |
|
1692 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1693 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1694 | - $error = false; |
|
1695 | - //$SI::del(); |
|
1696 | - if ($buffer !== FALSE) { |
|
1689 | + } |
|
1690 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1691 | + //echo $buffer."\n"; |
|
1692 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1693 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1694 | + $error = false; |
|
1695 | + //$SI::del(); |
|
1696 | + if ($buffer !== FALSE) { |
|
1697 | 1697 | if ($format === 'vrstcp') { |
1698 | - $buffer = explode('},{',$buffer); |
|
1698 | + $buffer = explode('},{',$buffer); |
|
1699 | 1699 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1700 | - } |
|
1701 | - // SBS format is CSV format |
|
1702 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1700 | + } |
|
1701 | + // SBS format is CSV format |
|
1702 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1703 | 1703 | $tt[$format] = 0; |
1704 | 1704 | if ($format === 'acarssbs3') { |
1705 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1706 | - $ACARS->add(trim($buffer)); |
|
1707 | - $ACARS->deleteLiveAcarsData(); |
|
1705 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1706 | + $ACARS->add(trim($buffer)); |
|
1707 | + $ACARS->deleteLiveAcarsData(); |
|
1708 | 1708 | } elseif ($format === 'raw') { |
1709 | - // AVR format |
|
1710 | - $data = $SBS->parse($buffer); |
|
1711 | - if (is_array($data)) { |
|
1709 | + // AVR format |
|
1710 | + $data = $SBS->parse($buffer); |
|
1711 | + if (is_array($data)) { |
|
1712 | 1712 | //if (!empty($data)) print_r($data); |
1713 | 1713 | $data['datetime'] = date('Y-m-d H:i:s'); |
1714 | 1714 | $data['format_source'] = 'raw'; |
@@ -1718,39 +1718,39 @@ discard block |
||
1718 | 1718 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1719 | 1719 | $SI->add($data); |
1720 | 1720 | unset($data); |
1721 | - } |
|
1721 | + } |
|
1722 | 1722 | } elseif ($format === 'ais') { |
1723 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1724 | - $data = array(); |
|
1725 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1726 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1727 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1728 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1729 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1730 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1731 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1732 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1733 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1734 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1735 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1736 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1737 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1738 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1739 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1740 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1723 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1724 | + $data = array(); |
|
1725 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1726 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1727 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1728 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1729 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1730 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1731 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1732 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1733 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1734 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1735 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1736 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1737 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1738 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1739 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1740 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1741 | 1741 | |
1742 | - if (isset($ais_data['timestamp'])) { |
|
1742 | + if (isset($ais_data['timestamp'])) { |
|
1743 | 1743 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1744 | - } else { |
|
1744 | + } else { |
|
1745 | 1745 | $data['datetime'] = date('Y-m-d H:i:s'); |
1746 | - } |
|
1747 | - $data['format_source'] = 'aisnmea'; |
|
1748 | - $data['id_source'] = $id_source; |
|
1749 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1750 | - unset($data); |
|
1751 | - } elseif ($format === 'flightgearsp') { |
|
1752 | - //echo $buffer."\n"; |
|
1753 | - if (strlen($buffer) > 5) { |
|
1746 | + } |
|
1747 | + $data['format_source'] = 'aisnmea'; |
|
1748 | + $data['id_source'] = $id_source; |
|
1749 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1750 | + unset($data); |
|
1751 | + } elseif ($format === 'flightgearsp') { |
|
1752 | + //echo $buffer."\n"; |
|
1753 | + if (strlen($buffer) > 5) { |
|
1754 | 1754 | $line = explode(',',$buffer); |
1755 | 1755 | $data = array(); |
1756 | 1756 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1767,38 +1767,38 @@ discard block |
||
1767 | 1767 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1768 | 1768 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1769 | 1769 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1770 | - } |
|
1771 | - } elseif ($format === 'acars') { |
|
1772 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1773 | - $ACARS->add(trim($buffer)); |
|
1774 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1775 | - $ACARS->deleteLiveAcarsData(); |
|
1770 | + } |
|
1771 | + } elseif ($format === 'acars') { |
|
1772 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1773 | + $ACARS->add(trim($buffer)); |
|
1774 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1775 | + $ACARS->deleteLiveAcarsData(); |
|
1776 | 1776 | } elseif ($format === 'flightgearmp') { |
1777 | - if (substr($buffer,0,1) != '#') { |
|
1777 | + if (substr($buffer,0,1) != '#') { |
|
1778 | 1778 | $data = array(); |
1779 | 1779 | //echo $buffer."\n"; |
1780 | 1780 | $line = explode(' ',$buffer); |
1781 | 1781 | if (count($line) === 11) { |
1782 | - $userserver = explode('@',$line[0]); |
|
1783 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1784 | - $data['ident'] = $userserver[0]; |
|
1785 | - $data['registration'] = $userserver[0]; |
|
1786 | - $data['latitude'] = $line[4]; |
|
1787 | - $data['longitude'] = $line[5]; |
|
1788 | - $data['altitude'] = $line[6]; |
|
1789 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1790 | - $aircraft_type = $line[10]; |
|
1791 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1792 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1793 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1794 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1782 | + $userserver = explode('@',$line[0]); |
|
1783 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1784 | + $data['ident'] = $userserver[0]; |
|
1785 | + $data['registration'] = $userserver[0]; |
|
1786 | + $data['latitude'] = $line[4]; |
|
1787 | + $data['longitude'] = $line[5]; |
|
1788 | + $data['altitude'] = $line[6]; |
|
1789 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1790 | + $aircraft_type = $line[10]; |
|
1791 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1792 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1793 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1794 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1795 | + } |
|
1795 | 1796 | } |
1796 | - } |
|
1797 | 1797 | } elseif ($format === 'beast') { |
1798 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1799 | - die; |
|
1798 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1799 | + die; |
|
1800 | 1800 | } elseif ($format === 'vrstcp') { |
1801 | - foreach($buffer as $all_data) { |
|
1801 | + foreach($buffer as $all_data) { |
|
1802 | 1802 | $line = json_decode('{'.$all_data.'}',true); |
1803 | 1803 | $data = array(); |
1804 | 1804 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1818,158 +1818,158 @@ discard block |
||
1818 | 1818 | */ |
1819 | 1819 | $data['datetime'] = date('Y-m-d H:i:s'); |
1820 | 1820 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1821 | - $data['format_source'] = 'vrstcp'; |
|
1821 | + $data['format_source'] = 'vrstcp'; |
|
1822 | 1822 | $data['id_source'] = $id_source; |
1823 | 1823 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1824 | 1824 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1825 | 1825 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1826 | 1826 | unset($data); |
1827 | - } |
|
1827 | + } |
|
1828 | 1828 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
1829 | - $line = explode("\t", $buffer); |
|
1830 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1829 | + $line = explode("\t", $buffer); |
|
1830 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1831 | 1831 | $key = $line[$k]; |
1832 | - $lined[$key] = $line[$k+1]; |
|
1833 | - } |
|
1834 | - if (count($lined) > 3) { |
|
1835 | - $data['hex'] = $lined['hexid']; |
|
1836 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1837 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1838 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1839 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1840 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1841 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1842 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1843 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1844 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1845 | - $data['id_source'] = $id_source; |
|
1846 | - $data['format_source'] = 'tsv'; |
|
1847 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1848 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1832 | + $lined[$key] = $line[$k+1]; |
|
1833 | + } |
|
1834 | + if (count($lined) > 3) { |
|
1835 | + $data['hex'] = $lined['hexid']; |
|
1836 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1837 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1838 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1839 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1840 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1841 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1842 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1843 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1844 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1845 | + $data['id_source'] = $id_source; |
|
1846 | + $data['format_source'] = 'tsv'; |
|
1847 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1848 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1849 | 1849 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1850 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1851 | - unset($lined); |
|
1852 | - unset($data); |
|
1853 | - } else $error = true; |
|
1850 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1851 | + unset($lined); |
|
1852 | + unset($data); |
|
1853 | + } else $error = true; |
|
1854 | 1854 | } elseif ($format === 'aprs' && $use_aprs) { |
1855 | - if ($aprs_connect === 0) { |
|
1855 | + if ($aprs_connect === 0) { |
|
1856 | 1856 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1857 | 1857 | $aprs_connect = 1; |
1858 | - } |
|
1858 | + } |
|
1859 | 1859 | |
1860 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1860 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1861 | 1861 | $aprs_last_tx = time(); |
1862 | 1862 | $data_aprs = "# Keep alive"; |
1863 | 1863 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1864 | - } |
|
1864 | + } |
|
1865 | 1865 | |
1866 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1867 | - //echo 'APRS data : '.$buffer."\n"; |
|
1868 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1869 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1870 | - //echo $buffer."\n"; |
|
1871 | - date_default_timezone_set('UTC'); |
|
1872 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1866 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1867 | + //echo 'APRS data : '.$buffer."\n"; |
|
1868 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1869 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1870 | + //echo $buffer."\n"; |
|
1871 | + date_default_timezone_set('UTC'); |
|
1872 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1873 | 1873 | $line = $APRS->parse($buffer); |
1874 | 1874 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1875 | 1875 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1876 | - $aprs_last_tx = time(); |
|
1877 | - $data = array(); |
|
1878 | - //print_r($line); |
|
1879 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1880 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1881 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1882 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1883 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1884 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1885 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1886 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1887 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1888 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1889 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1890 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1891 | - $data['latitude'] = $line['latitude']; |
|
1892 | - $data['longitude'] = $line['longitude']; |
|
1893 | - //$data['verticalrate'] = $line[16]; |
|
1894 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1895 | - //else $data['speed'] = 0; |
|
1896 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1897 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1898 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1899 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1876 | + $aprs_last_tx = time(); |
|
1877 | + $data = array(); |
|
1878 | + //print_r($line); |
|
1879 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1880 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1881 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1882 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1883 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1884 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1885 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1886 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1887 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1888 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1889 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1890 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1891 | + $data['latitude'] = $line['latitude']; |
|
1892 | + $data['longitude'] = $line['longitude']; |
|
1893 | + //$data['verticalrate'] = $line[16]; |
|
1894 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1895 | + //else $data['speed'] = 0; |
|
1896 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1897 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1898 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1899 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1900 | 1900 | |
1901 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1902 | - //else echo 'No heading...'."\n"; |
|
1903 | - //else $data['heading'] = 0; |
|
1904 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1905 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1906 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1907 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1908 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1909 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1910 | - $data['id_source'] = $id_source; |
|
1911 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1912 | - else $data['format_source'] = 'aprs'; |
|
1913 | - $data['source_name'] = $line['source']; |
|
1914 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1915 | - else $data['source_type'] = 'flarm'; |
|
1916 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1917 | - $currentdate = date('Y-m-d H:i:s'); |
|
1918 | - $aprsdate = strtotime($data['datetime']); |
|
1919 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1920 | - // Accept data if time <= system time + 20s |
|
1921 | - //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'])))) { |
|
1922 | - if ( |
|
1901 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1902 | + //else echo 'No heading...'."\n"; |
|
1903 | + //else $data['heading'] = 0; |
|
1904 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1905 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1906 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1907 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1908 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1909 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1910 | + $data['id_source'] = $id_source; |
|
1911 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1912 | + else $data['format_source'] = 'aprs'; |
|
1913 | + $data['source_name'] = $line['source']; |
|
1914 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1915 | + else $data['source_type'] = 'flarm'; |
|
1916 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1917 | + $currentdate = date('Y-m-d H:i:s'); |
|
1918 | + $aprsdate = strtotime($data['datetime']); |
|
1919 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1920 | + // Accept data if time <= system time + 20s |
|
1921 | + //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'])))) { |
|
1922 | + if ( |
|
1923 | 1923 | ($data['source_type'] === 'modes') || |
1924 | 1924 | isset($line['stealth']) && |
1925 | 1925 | (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && |
1926 | 1926 | ($line['stealth'] === 0 || $line['stealth'] == '') && |
1927 | 1927 | (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1928 | 1928 | $send = $SI->add($data); |
1929 | - } elseif ($data['source_type'] === 'ais') { |
|
1929 | + } elseif ($data['source_type'] === 'ais') { |
|
1930 | 1930 | $data['type'] = ''; |
1931 | 1931 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1932 | - } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
1932 | + } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
1933 | 1933 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1934 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1935 | - //$line['symbol'] === 'Balloon' || |
|
1936 | - $line['symbol'] === 'Glider' || |
|
1937 | - $line['symbol'] === 'No. Plane' || |
|
1938 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1939 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1940 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1941 | - $send = $SI->add($data); |
|
1942 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1943 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1944 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
1945 | - $send = $MI->add($data); |
|
1946 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1947 | - $line['symbol'] === 'Car' || |
|
1948 | - $line['symbol'] === 'Ambulance' || |
|
1949 | - $line['symbol'] === 'Van' || |
|
1950 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1951 | - $line['symbol'] === 'Motorcycle' || |
|
1952 | - $line['symbol'] === 'Tractor' || |
|
1953 | - $line['symbol'] === 'Police' || |
|
1954 | - $line['symbol'] === 'Bike' || |
|
1955 | - $line['symbol'] === 'Jogger' || |
|
1956 | - $line['symbol'] === 'Horse' || |
|
1957 | - $line['symbol'] === 'Bus' || |
|
1958 | - $line['symbol'] === 'Jeep' || |
|
1959 | - $line['symbol'] === 'Recreational Vehicle' || |
|
1960 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1961 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
1962 | - $line['symbol'] === 'Firetruck' || |
|
1963 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1964 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1965 | - $line['symbol'] === 'SUV' || |
|
1966 | - $line['symbol'] === 'Snowmobile' || |
|
1967 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
1968 | - //} 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') { |
|
1934 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1935 | + //$line['symbol'] === 'Balloon' || |
|
1936 | + $line['symbol'] === 'Glider' || |
|
1937 | + $line['symbol'] === 'No. Plane' || |
|
1938 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1939 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1940 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1941 | + $send = $SI->add($data); |
|
1942 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1943 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1944 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
1945 | + $send = $MI->add($data); |
|
1946 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1947 | + $line['symbol'] === 'Car' || |
|
1948 | + $line['symbol'] === 'Ambulance' || |
|
1949 | + $line['symbol'] === 'Van' || |
|
1950 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1951 | + $line['symbol'] === 'Motorcycle' || |
|
1952 | + $line['symbol'] === 'Tractor' || |
|
1953 | + $line['symbol'] === 'Police' || |
|
1954 | + $line['symbol'] === 'Bike' || |
|
1955 | + $line['symbol'] === 'Jogger' || |
|
1956 | + $line['symbol'] === 'Horse' || |
|
1957 | + $line['symbol'] === 'Bus' || |
|
1958 | + $line['symbol'] === 'Jeep' || |
|
1959 | + $line['symbol'] === 'Recreational Vehicle' || |
|
1960 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1961 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
1962 | + $line['symbol'] === 'Firetruck' || |
|
1963 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1964 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1965 | + $line['symbol'] === 'SUV' || |
|
1966 | + $line['symbol'] === 'Snowmobile' || |
|
1967 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
1968 | + //} 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') { |
|
1969 | 1969 | // } 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') { |
1970 | 1970 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1971 | 1971 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1972 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1972 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1973 | 1973 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1974 | 1974 | $Source->deleteOldLocationByType('gs'); |
1975 | 1975 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | } else { |
1978 | 1978 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1979 | 1979 | } |
1980 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1980 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1981 | 1981 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1982 | 1982 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1983 | 1983 | $Source->deleteOldLocationByType('wx'); |
@@ -1987,7 +1987,7 @@ discard block |
||
1987 | 1987 | } else { |
1988 | 1988 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1989 | 1989 | } |
1990 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1990 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1991 | 1991 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1992 | 1992 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1993 | 1993 | $Source->deleteOldLocationByType('lightning'); |
@@ -1996,11 +1996,11 @@ discard block |
||
1996 | 1996 | } else { |
1997 | 1997 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1998 | 1998 | } |
1999 | - } elseif ($globalDebug) { |
|
2000 | - echo '/!\ Not added: '.$buffer."\n"; |
|
2001 | - print_r($line); |
|
2002 | - } |
|
2003 | - unset($data); |
|
1999 | + } elseif ($globalDebug) { |
|
2000 | + echo '/!\ Not added: '.$buffer."\n"; |
|
2001 | + print_r($line); |
|
2002 | + } |
|
2003 | + unset($data); |
|
2004 | 2004 | } |
2005 | 2005 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
2006 | 2006 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -2019,13 +2019,13 @@ discard block |
||
2019 | 2019 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
2020 | 2020 | $globalSources[$nb]['last_weather_clean'] = time(); |
2021 | 2021 | } |
2022 | - } |
|
2022 | + } |
|
2023 | 2023 | } else { |
2024 | - $line = explode(',', $buffer); |
|
2025 | - //print_r($line); |
|
2026 | - if (count($line) > 20) { |
|
2027 | - $data['hex'] = $line[4]; |
|
2028 | - /* |
|
2024 | + $line = explode(',', $buffer); |
|
2025 | + //print_r($line); |
|
2026 | + if (count($line) > 20) { |
|
2027 | + $data['hex'] = $line[4]; |
|
2028 | + /* |
|
2029 | 2029 | $data['datetime'] = $line[6].' '.$line[7]; |
2030 | 2030 | date_default_timezone_set($globalTimezone); |
2031 | 2031 | $datetime = new DateTime($data['datetime']); |
@@ -2033,31 +2033,31 @@ discard block |
||
2033 | 2033 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
2034 | 2034 | date_default_timezone_set('UTC'); |
2035 | 2035 | */ |
2036 | - // Force datetime to current UTC datetime |
|
2037 | - date_default_timezone_set('UTC'); |
|
2038 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
2039 | - $data['ident'] = trim($line[10]); |
|
2040 | - $data['latitude'] = $line[14]; |
|
2041 | - $data['longitude'] = $line[15]; |
|
2042 | - $data['verticalrate'] = $line[16]; |
|
2043 | - $data['emergency'] = $line[20]; |
|
2044 | - $data['speed'] = $line[12]; |
|
2045 | - $data['squawk'] = $line[17]; |
|
2046 | - $data['altitude'] = $line[11]; |
|
2047 | - $data['heading'] = $line[13]; |
|
2048 | - $data['ground'] = $line[21]; |
|
2049 | - $data['emergency'] = $line[19]; |
|
2050 | - $data['format_source'] = 'sbs'; |
|
2036 | + // Force datetime to current UTC datetime |
|
2037 | + date_default_timezone_set('UTC'); |
|
2038 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2039 | + $data['ident'] = trim($line[10]); |
|
2040 | + $data['latitude'] = $line[14]; |
|
2041 | + $data['longitude'] = $line[15]; |
|
2042 | + $data['verticalrate'] = $line[16]; |
|
2043 | + $data['emergency'] = $line[20]; |
|
2044 | + $data['speed'] = $line[12]; |
|
2045 | + $data['squawk'] = $line[17]; |
|
2046 | + $data['altitude'] = $line[11]; |
|
2047 | + $data['heading'] = $line[13]; |
|
2048 | + $data['ground'] = $line[21]; |
|
2049 | + $data['emergency'] = $line[19]; |
|
2050 | + $data['format_source'] = 'sbs'; |
|
2051 | 2051 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
2052 | 2052 | elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
2053 | 2053 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
2054 | 2054 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
2055 | - $data['id_source'] = $id_source; |
|
2056 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2057 | - else $error = true; |
|
2058 | - unset($data); |
|
2059 | - } else $error = true; |
|
2060 | - if ($error) { |
|
2055 | + $data['id_source'] = $id_source; |
|
2056 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2057 | + else $error = true; |
|
2058 | + unset($data); |
|
2059 | + } else $error = true; |
|
2060 | + if ($error) { |
|
2061 | 2061 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
2062 | 2062 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
2063 | 2063 | } else { |
@@ -2073,13 +2073,13 @@ discard block |
||
2073 | 2073 | connect_all($sourceer); |
2074 | 2074 | $sourceer = array(); |
2075 | 2075 | } |
2076 | - } |
|
2076 | + } |
|
2077 | 2077 | } |
2078 | 2078 | // Sleep for xxx microseconds |
2079 | 2079 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
2080 | - } else { |
|
2080 | + } else { |
|
2081 | 2081 | if ($format === 'flightgearmp') { |
2082 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2082 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2083 | 2083 | //@socket_close($r); |
2084 | 2084 | sleep($globalMinFetch); |
2085 | 2085 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2088,9 +2088,9 @@ discard block |
||
2088 | 2088 | break; |
2089 | 2089 | |
2090 | 2090 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
2091 | - if (isset($tt[$format])) $tt[$format]++; |
|
2092 | - else $tt[$format] = 0; |
|
2093 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
2091 | + if (isset($tt[$format])) $tt[$format]++; |
|
2092 | + else $tt[$format] = 0; |
|
2093 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
2094 | 2094 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
2095 | 2095 | //@socket_close($r); |
2096 | 2096 | sleep(2); |
@@ -2101,24 +2101,24 @@ discard block |
||
2101 | 2101 | //connect_all($globalSources); |
2102 | 2102 | $tt[$format]=0; |
2103 | 2103 | break; |
2104 | - } |
|
2105 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
2104 | + } |
|
2105 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
2106 | + } |
|
2106 | 2107 | } |
2107 | - } |
|
2108 | 2108 | } |
2109 | - } else { |
|
2109 | + } else { |
|
2110 | 2110 | $error = socket_strerror(socket_last_error()); |
2111 | 2111 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
2112 | 2112 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
2113 | 2113 | if (isset($globalDebug)) echo "Restarting...\n"; |
2114 | 2114 | // Restart the script if possible |
2115 | 2115 | if (is_array($sockets)) { |
2116 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2116 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
2117 | 2117 | |
2118 | - foreach ($sockets as $sock) { |
|
2118 | + foreach ($sockets as $sock) { |
|
2119 | 2119 | @socket_shutdown($sock,2); |
2120 | 2120 | @socket_close($sock); |
2121 | - } |
|
2121 | + } |
|
2122 | 2122 | |
2123 | 2123 | } |
2124 | 2124 | if ($globalDebug) echo "Waiting..."; |
@@ -2133,15 +2133,15 @@ discard block |
||
2133 | 2133 | if ($globalDebug) echo "Restart all connections..."; |
2134 | 2134 | connect_all($globalSources); |
2135 | 2135 | } |
2136 | - } |
|
2136 | + } |
|
2137 | 2137 | } |
2138 | 2138 | if ($globalDaemon === false) { |
2139 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
2140 | - if (isset($SI)) $SI->checkAll(); |
|
2141 | - if (isset($TI)) $TI->checkAll(); |
|
2142 | - if (isset($MI)) $MI->checkAll(); |
|
2139 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
2140 | + if (isset($SI)) $SI->checkAll(); |
|
2141 | + if (isset($TI)) $TI->checkAll(); |
|
2142 | + if (isset($MI)) $MI->checkAll(); |
|
2143 | + } |
|
2143 | 2144 | } |
2144 | - } |
|
2145 | 2145 | } |
2146 | 2146 | |
2147 | 2147 | ?> |