@@ -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,133 +419,133 @@ 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(); |
|
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 | 484 | } elseif ($value['format'] === 'aisnmeatxt' && |
485 | - ( |
|
485 | + ( |
|
486 | 486 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
487 | 487 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
488 | - ) |
|
488 | + ) |
|
489 | 489 | ) { |
490 | - date_default_timezone_set('CET'); |
|
491 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
492 | - date_default_timezone_set('UTC'); |
|
493 | - if ($buffer != '') $reset = 0; |
|
494 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
495 | - $buffer = explode('\n',$buffer); |
|
496 | - foreach ($buffer as $line) { |
|
490 | + date_default_timezone_set('CET'); |
|
491 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
492 | + date_default_timezone_set('UTC'); |
|
493 | + if ($buffer != '') $reset = 0; |
|
494 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
495 | + $buffer = explode('\n',$buffer); |
|
496 | + foreach ($buffer as $line) { |
|
497 | 497 | if ($line != '') { |
498 | - //echo "'".$line."'\n"; |
|
499 | - $add = false; |
|
500 | - $ais_data = $AIS->parse_line(trim($line)); |
|
501 | - $data = array(); |
|
502 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
503 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
504 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
505 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
506 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
507 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
508 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
509 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
510 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
511 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
512 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
513 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
514 | - if (isset($ais_data['timestamp'])) { |
|
498 | + //echo "'".$line."'\n"; |
|
499 | + $add = false; |
|
500 | + $ais_data = $AIS->parse_line(trim($line)); |
|
501 | + $data = array(); |
|
502 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
503 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
504 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
505 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
506 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
507 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
508 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
509 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
510 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
511 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
512 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
513 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
514 | + if (isset($ais_data['timestamp'])) { |
|
515 | 515 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
516 | 516 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
517 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
518 | - $add = true; |
|
517 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
518 | + $add = true; |
|
519 | 519 | } |
520 | - } else { |
|
520 | + } else { |
|
521 | 521 | $data['datetime'] = date('Y-m-d H:i:s'); |
522 | 522 | $add = true; |
523 | - } |
|
524 | - $data['format_source'] = 'aisnmeatxt'; |
|
525 | - $data['id_source'] = $id_source; |
|
526 | - //print_r($data); |
|
527 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
528 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
529 | - unset($data); |
|
523 | + } |
|
524 | + $data['format_source'] = 'aisnmeatxt'; |
|
525 | + $data['id_source'] = $id_source; |
|
526 | + //print_r($data); |
|
527 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
528 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
529 | + unset($data); |
|
530 | 530 | } |
531 | - } |
|
532 | - $last_exec[$id]['last'] = time(); |
|
531 | + } |
|
532 | + $last_exec[$id]['last'] = time(); |
|
533 | 533 | } elseif ($value['format'] === 'aisnmeahttp') { |
534 | - $arr = $httpfeeds; |
|
535 | - $w = $e = null; |
|
534 | + $arr = $httpfeeds; |
|
535 | + $w = $e = null; |
|
536 | 536 | |
537 | - if (isset($arr[$id])) { |
|
537 | + if (isset($arr[$id])) { |
|
538 | 538 | $nn = stream_select($arr,$w,$e,$timeout); |
539 | 539 | if ($nn > 0) { |
540 | - foreach ($httpfeeds as $feed) { |
|
540 | + foreach ($httpfeeds as $feed) { |
|
541 | 541 | $buffer = stream_get_line($feed,2000,"\n"); |
542 | 542 | if ($buffer === FALSE) { |
543 | - connect_all($globalSources); |
|
543 | + connect_all($globalSources); |
|
544 | 544 | } |
545 | 545 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
546 | 546 | $buffer = explode('\n',$buffer); |
547 | 547 | foreach ($buffer as $line) { |
548 | - if ($line != '') { |
|
548 | + if ($line != '') { |
|
549 | 549 | $ais_data = $AIS->parse_line(trim($line)); |
550 | 550 | $data = array(); |
551 | 551 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -563,117 +563,117 @@ discard block |
||
563 | 563 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
564 | 564 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
565 | 565 | if (isset($ais_data['timestamp'])) { |
566 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
566 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
567 | 567 | } else { |
568 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
568 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
569 | 569 | } |
570 | 570 | $data['format_source'] = 'aisnmeahttp'; |
571 | 571 | $data['id_source'] = $id_source; |
572 | 572 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
573 | 573 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
574 | 574 | unset($data); |
575 | - } |
|
575 | + } |
|
576 | + } |
|
576 | 577 | } |
577 | - } |
|
578 | 578 | } else { |
579 | - $format = $value['format']; |
|
580 | - if (isset($tt[$format])) $tt[$format]++; |
|
581 | - else $tt[$format] = 0; |
|
582 | - if ($tt[$format] > 30) { |
|
579 | + $format = $value['format']; |
|
580 | + if (isset($tt[$format])) $tt[$format]++; |
|
581 | + else $tt[$format] = 0; |
|
582 | + if ($tt[$format] > 30) { |
|
583 | 583 | if ($globalDebug) echo 'Reconnect...'."\n"; |
584 | 584 | sleep(2); |
585 | 585 | //$sourceeen[] = $value; |
586 | 586 | //connect_all($sourceeen); |
587 | 587 | //$sourceeen = array(); |
588 | 588 | connect_all($globalSources); |
589 | - } |
|
589 | + } |
|
590 | + } |
|
590 | 591 | } |
591 | - } |
|
592 | 592 | } elseif ($value['format'] === 'myshiptracking' && |
593 | - ( |
|
593 | + ( |
|
594 | 594 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
595 | 595 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
596 | - ) |
|
596 | + ) |
|
597 | 597 | ) { |
598 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
599 | - if ($buffer != '') { |
|
598 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
599 | + if ($buffer != '') { |
|
600 | 600 | //echo $buffer; |
601 | 601 | $all_data = json_decode($buffer,true); |
602 | 602 | //print_r($all_data); |
603 | 603 | if (isset($all_data[0]['DATA'])) { |
604 | - foreach ($all_data[0]['DATA'] as $line) { |
|
604 | + foreach ($all_data[0]['DATA'] as $line) { |
|
605 | 605 | if ($line != '') { |
606 | - $data = array(); |
|
607 | - $data['ident'] = $line['NAME']; |
|
608 | - $data['mmsi'] = $line['MMSI']; |
|
609 | - if (strlen($data['mmsi']) > 9) { |
|
606 | + $data = array(); |
|
607 | + $data['ident'] = $line['NAME']; |
|
608 | + $data['mmsi'] = $line['MMSI']; |
|
609 | + if (strlen($data['mmsi']) > 9) { |
|
610 | 610 | $data['mmsi'] = substr($data['mmsi'],-9); |
611 | - } |
|
612 | - $data['speed'] = $line['SOG']; |
|
613 | - $data['heading'] = $line['COG']; |
|
614 | - $data['latitude'] = $line['LAT']; |
|
615 | - $data['longitude'] = $line['LNG']; |
|
616 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
617 | - //$data['type_id'] = $line['TYPE']; |
|
618 | - $data['imo'] = $line['IMO']; |
|
619 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
620 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
621 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
622 | - $data['format_source'] = 'myshiptracking'; |
|
623 | - $data['id_source'] = $id_source; |
|
624 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
625 | - $MI->add($data); |
|
626 | - unset($data); |
|
611 | + } |
|
612 | + $data['speed'] = $line['SOG']; |
|
613 | + $data['heading'] = $line['COG']; |
|
614 | + $data['latitude'] = $line['LAT']; |
|
615 | + $data['longitude'] = $line['LNG']; |
|
616 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
617 | + //$data['type_id'] = $line['TYPE']; |
|
618 | + $data['imo'] = $line['IMO']; |
|
619 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
620 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
621 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
622 | + $data['format_source'] = 'myshiptracking'; |
|
623 | + $data['id_source'] = $id_source; |
|
624 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
625 | + $MI->add($data); |
|
626 | + unset($data); |
|
627 | + } |
|
627 | 628 | } |
628 | - } |
|
629 | 629 | } |
630 | - } |
|
631 | - $last_exec[$id]['last'] = time(); |
|
630 | + } |
|
631 | + $last_exec[$id]['last'] = time(); |
|
632 | 632 | } elseif ($value['format'] === 'boatbeaconapp' && |
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(str_replace('{timestamp}',time(),$value['host'])); |
|
639 | - if ($buffer != '') { |
|
638 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
639 | + if ($buffer != '') { |
|
640 | 640 | $all_data = json_decode($buffer,true); |
641 | 641 | if (isset($all_data[0]['mmsi'])) { |
642 | - foreach ($all_data as $line) { |
|
642 | + foreach ($all_data as $line) { |
|
643 | 643 | if ($line != '') { |
644 | - $data = array(); |
|
645 | - $data['ident'] = $line['shipname']; |
|
646 | - $data['callsign'] = $line['callsign']; |
|
647 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
648 | - $data['speed'] = $line['sog']; |
|
649 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
650 | - $data['latitude'] = $line['latitude']; |
|
651 | - $data['longitude'] = $line['longitude']; |
|
652 | - $data['type_id'] = $line['shiptype']; |
|
653 | - $data['arrival_code'] = $line['destination']; |
|
654 | - $data['datetime'] = $line['time']; |
|
655 | - $data['format_source'] = 'boatbeaconapp'; |
|
656 | - $data['id_source'] = $id_source; |
|
657 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
658 | - $MI->add($data); |
|
659 | - unset($data); |
|
644 | + $data = array(); |
|
645 | + $data['ident'] = $line['shipname']; |
|
646 | + $data['callsign'] = $line['callsign']; |
|
647 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
648 | + $data['speed'] = $line['sog']; |
|
649 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
650 | + $data['latitude'] = $line['latitude']; |
|
651 | + $data['longitude'] = $line['longitude']; |
|
652 | + $data['type_id'] = $line['shiptype']; |
|
653 | + $data['arrival_code'] = $line['destination']; |
|
654 | + $data['datetime'] = $line['time']; |
|
655 | + $data['format_source'] = 'boatbeaconapp'; |
|
656 | + $data['id_source'] = $id_source; |
|
657 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
658 | + $MI->add($data); |
|
659 | + unset($data); |
|
660 | + } |
|
660 | 661 | } |
661 | - } |
|
662 | 662 | } |
663 | 663 | |
664 | - } |
|
665 | - $last_exec[$id]['last'] = time(); |
|
664 | + } |
|
665 | + $last_exec[$id]['last'] = time(); |
|
666 | 666 | } elseif ($value['format'] === 'boatnerd' && |
667 | - ( |
|
667 | + ( |
|
668 | 668 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
669 | 669 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
670 | - ) |
|
670 | + ) |
|
671 | 671 | ) { |
672 | - $buffer = $Common->getData($value['host']); |
|
673 | - if ($buffer != '') { |
|
672 | + $buffer = $Common->getData($value['host']); |
|
673 | + if ($buffer != '') { |
|
674 | 674 | $all_data = json_decode($buffer,true); |
675 | 675 | if (isset($all_data['features'][0]['id'])) { |
676 | - foreach ($all_data['features'] as $line) { |
|
676 | + foreach ($all_data['features'] as $line) { |
|
677 | 677 | print_r($line); |
678 | 678 | $data = array(); |
679 | 679 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -693,76 +693,76 @@ discard block |
||
693 | 693 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
694 | 694 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
695 | 695 | unset($data); |
696 | - } |
|
696 | + } |
|
697 | 697 | } |
698 | 698 | |
699 | - } |
|
700 | - $last_exec[$id]['last'] = time(); |
|
699 | + } |
|
700 | + $last_exec[$id]['last'] = time(); |
|
701 | 701 | } elseif ($value['format'] === 'shipplotter' && |
702 | - ( |
|
702 | + ( |
|
703 | 703 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
704 | 704 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
705 | - ) |
|
705 | + ) |
|
706 | 706 | ) { |
707 | - if ($globalDebug) echo 'download...'; |
|
708 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
709 | - if ($globalDebug) echo 'done !'."\n"; |
|
710 | - // FIXME: Need more work |
|
711 | - if ($buffer != '') $reset = 0; |
|
712 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
713 | - $buffer = explode('\n',$buffer); |
|
714 | - foreach ($buffer as $line) { |
|
707 | + if ($globalDebug) echo 'download...'; |
|
708 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
709 | + if ($globalDebug) echo 'done !'."\n"; |
|
710 | + // FIXME: Need more work |
|
711 | + if ($buffer != '') $reset = 0; |
|
712 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
713 | + $buffer = explode('\n',$buffer); |
|
714 | + foreach ($buffer as $line) { |
|
715 | 715 | if ($line != '') { |
716 | - $data = array(); |
|
717 | - //echo $line."\n"; |
|
718 | - $data['mmsi'] = (int)substr($line,0,9); |
|
719 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
720 | - $data['status_id'] = substr($line,21,2); |
|
721 | - $data['type_id'] = substr($line,24,3); |
|
722 | - $data['latitude'] = substr($line,29,9); |
|
723 | - $data['longitude'] = substr($line,41,9); |
|
724 | - $data['speed'] = round(substr($line,51,5)); |
|
725 | - //$data['course'] = substr($line,57,5); |
|
726 | - $data['heading'] = round(substr($line,63,3)); |
|
727 | - //$data['draft'] = substr($line,67,4); |
|
728 | - //$data['length'] = substr($line,72,3); |
|
729 | - //$data['beam'] = substr($line,76,2); |
|
730 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
731 | - //$data['callsign'] = trim(substr($line,100,7); |
|
732 | - $data['arrival_code'] = substr($line,108,20); |
|
733 | - //$data['etaDate'] = substr($line,129,5); |
|
734 | - //$data['etaTime'] = substr($line,135,5); |
|
735 | - $data['format_source'] = 'shipplotter'; |
|
736 | - $data['id_source'] = $id_source; |
|
737 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
738 | - //print_r($data); |
|
739 | - //echo 'Add...'."\n"; |
|
740 | - $MI->add($data); |
|
741 | - unset($data); |
|
716 | + $data = array(); |
|
717 | + //echo $line."\n"; |
|
718 | + $data['mmsi'] = (int)substr($line,0,9); |
|
719 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
720 | + $data['status_id'] = substr($line,21,2); |
|
721 | + $data['type_id'] = substr($line,24,3); |
|
722 | + $data['latitude'] = substr($line,29,9); |
|
723 | + $data['longitude'] = substr($line,41,9); |
|
724 | + $data['speed'] = round(substr($line,51,5)); |
|
725 | + //$data['course'] = substr($line,57,5); |
|
726 | + $data['heading'] = round(substr($line,63,3)); |
|
727 | + //$data['draft'] = substr($line,67,4); |
|
728 | + //$data['length'] = substr($line,72,3); |
|
729 | + //$data['beam'] = substr($line,76,2); |
|
730 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
731 | + //$data['callsign'] = trim(substr($line,100,7); |
|
732 | + $data['arrival_code'] = substr($line,108,20); |
|
733 | + //$data['etaDate'] = substr($line,129,5); |
|
734 | + //$data['etaTime'] = substr($line,135,5); |
|
735 | + $data['format_source'] = 'shipplotter'; |
|
736 | + $data['id_source'] = $id_source; |
|
737 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
738 | + //print_r($data); |
|
739 | + //echo 'Add...'."\n"; |
|
740 | + $MI->add($data); |
|
741 | + unset($data); |
|
742 | 742 | } |
743 | - } |
|
744 | - $last_exec[$id]['last'] = time(); |
|
743 | + } |
|
744 | + $last_exec[$id]['last'] = time(); |
|
745 | 745 | } elseif ($value['format'] === 'sailaway' && |
746 | - ( |
|
746 | + ( |
|
747 | 747 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
748 | 748 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
749 | - ) |
|
749 | + ) |
|
750 | 750 | ) { |
751 | - if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
751 | + if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
752 | 752 | $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); |
753 | 753 | //echo $authsailaway; |
754 | 754 | preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie); |
755 | 755 | if (isset($setcookie[1][0])) { |
756 | - $sailaway_authcookie = $setcookie[1][0]; |
|
756 | + $sailaway_authcookie = $setcookie[1][0]; |
|
757 | + } |
|
757 | 758 | } |
758 | - } |
|
759 | 759 | |
760 | - if ($globalDebug) echo '! Download... '; |
|
761 | - for ($i =0; $i <= 1; $i++) { |
|
760 | + if ($globalDebug) echo '! Download... '; |
|
761 | + for ($i =0; $i <= 1; $i++) { |
|
762 | 762 | if ($globalDebug) echo 'Racetype: '.$i.' '; |
763 | 763 | $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
764 | - if ($globalDebug) echo 'done'."\n"; |
|
765 | - if ($buffer != '') { |
|
764 | + if ($globalDebug) echo 'done'."\n"; |
|
765 | + if ($buffer != '') { |
|
766 | 766 | $all_data = json_decode($buffer,true); |
767 | 767 | if (isset($all_data['missions'])) { |
768 | 768 | foreach ($all_data['missions'] as $mission) { |
@@ -781,19 +781,19 @@ discard block |
||
781 | 781 | //print_r($race_data); |
782 | 782 | unset($racebuffer); |
783 | 783 | if (isset($race_data['mission'])) { |
784 | - $datar = array(); |
|
785 | - $datar['id'] = $mission['misnr']; |
|
786 | - $datar['desc'] = $race_data['mission']['misdescr']; |
|
787 | - $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
788 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
789 | - $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
790 | - $markers = array(); |
|
791 | - foreach ($race_data['mission']['course'] as $course) { |
|
784 | + $datar = array(); |
|
785 | + $datar['id'] = $mission['misnr']; |
|
786 | + $datar['desc'] = $race_data['mission']['misdescr']; |
|
787 | + $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
788 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
789 | + $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
790 | + $markers = array(); |
|
791 | + foreach ($race_data['mission']['course'] as $course) { |
|
792 | 792 | $markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']); |
793 | - } |
|
794 | - $datar['markers'] = json_encode($markers); |
|
795 | - //print_r($datar); |
|
796 | - $MI->race_add($datar); |
|
793 | + } |
|
794 | + $datar['markers'] = json_encode($markers); |
|
795 | + //print_r($datar); |
|
796 | + $MI->race_add($datar); |
|
797 | 797 | } |
798 | 798 | } |
799 | 799 | if ($bufferm != '') { |
@@ -857,34 +857,34 @@ discard block |
||
857 | 857 | } |
858 | 858 | } |
859 | 859 | } |
860 | - } |
|
861 | - } |
|
862 | - $last_exec[$id]['last'] = time(); |
|
860 | + } |
|
861 | + } |
|
862 | + $last_exec[$id]['last'] = time(); |
|
863 | 863 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
864 | 864 | } elseif ( |
865 | - ( |
|
865 | + ( |
|
866 | 866 | $value['format'] === 'whazzup' && |
867 | 867 | ( |
868 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
869 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
868 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
869 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
870 | 870 | ) |
871 | - ) || ( |
|
871 | + ) || ( |
|
872 | 872 | $value['format'] === 'vatsimtxt' && |
873 | 873 | ( |
874 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
875 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
874 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
875 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
876 | + ) |
|
876 | 877 | ) |
877 | - ) |
|
878 | 878 | ) { |
879 | - //$buffer = $Common->getData($hosts[$id]); |
|
880 | - $buffer = $Common->getData($value['host']); |
|
881 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
882 | - $buffer = explode('\n',$buffer); |
|
883 | - $reset = 0; |
|
884 | - foreach ($buffer as $line) { |
|
885 | - if ($line != '') { |
|
886 | - $line = explode(':', $line); |
|
887 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
879 | + //$buffer = $Common->getData($hosts[$id]); |
|
880 | + $buffer = $Common->getData($value['host']); |
|
881 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
882 | + $buffer = explode('\n',$buffer); |
|
883 | + $reset = 0; |
|
884 | + foreach ($buffer as $line) { |
|
885 | + if ($line != '') { |
|
886 | + $line = explode(':', $line); |
|
887 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
888 | 888 | $data = array(); |
889 | 889 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
890 | 890 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -897,37 +897,37 @@ discard block |
||
897 | 897 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
898 | 898 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
899 | 899 | $data['latitude'] = $line[5]; // lat |
900 | - $data['longitude'] = $line[6]; // long |
|
901 | - $data['verticalrate'] = ''; // vertical rate |
|
902 | - $data['squawk'] = ''; // squawk |
|
903 | - $data['emergency'] = ''; // emergency |
|
904 | - $data['waypoints'] = $line[30]; |
|
900 | + $data['longitude'] = $line[6]; // long |
|
901 | + $data['verticalrate'] = ''; // vertical rate |
|
902 | + $data['squawk'] = ''; // squawk |
|
903 | + $data['emergency'] = ''; // emergency |
|
904 | + $data['waypoints'] = $line[30]; |
|
905 | 905 | $data['datetime'] = date('Y-m-d H:i:s'); |
906 | 906 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
907 | 907 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
908 | - $data['departure_airport_icao'] = $line[11]; |
|
909 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
910 | - $data['arrival_airport_icao'] = $line[13]; |
|
908 | + $data['departure_airport_icao'] = $line[11]; |
|
909 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
910 | + $data['arrival_airport_icao'] = $line[13]; |
|
911 | 911 | $data['frequency'] = $line[4]; |
912 | 912 | $data['type'] = $line[18]; |
913 | 913 | $data['range'] = $line[19]; |
914 | 914 | if (isset($line[35])) $data['info'] = $line[35]; |
915 | - $data['id_source'] = $id_source; |
|
916 | - //$data['arrival_airport_time'] = ; |
|
917 | - if ($line[9] != '') { |
|
918 | - $aircraft_data = explode('/',$line[9]); |
|
919 | - if (isset($aircraft_data[1])) { |
|
920 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
921 | - } |
|
922 | - } |
|
923 | - /* |
|
915 | + $data['id_source'] = $id_source; |
|
916 | + //$data['arrival_airport_time'] = ; |
|
917 | + if ($line[9] != '') { |
|
918 | + $aircraft_data = explode('/',$line[9]); |
|
919 | + if (isset($aircraft_data[1])) { |
|
920 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
921 | + } |
|
922 | + } |
|
923 | + /* |
|
924 | 924 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
925 | 925 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
926 | 926 | */ |
927 | - $data['format_source'] = $value['format']; |
|
927 | + $data['format_source'] = $value['format']; |
|
928 | 928 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
929 | 929 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
930 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
930 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
931 | 931 | elseif ($line[3] === 'ATC') { |
932 | 932 | //print_r($data); |
933 | 933 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -948,21 +948,21 @@ discard block |
||
948 | 948 | 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']); |
949 | 949 | } |
950 | 950 | } |
951 | - unset($data); |
|
952 | - } |
|
953 | - } |
|
954 | - } |
|
955 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
956 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
957 | - $last_exec[$id]['last'] = time(); |
|
958 | - } elseif ($value['format'] === 'airwhere' && |
|
959 | - ( |
|
960 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
961 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
962 | - ) |
|
963 | - ) { |
|
964 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
965 | - if ($buffer != '') { |
|
951 | + unset($data); |
|
952 | + } |
|
953 | + } |
|
954 | + } |
|
955 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
956 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
957 | + $last_exec[$id]['last'] = time(); |
|
958 | + } elseif ($value['format'] === 'airwhere' && |
|
959 | + ( |
|
960 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
961 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
962 | + ) |
|
963 | + ) { |
|
964 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
965 | + if ($buffer != '') { |
|
966 | 966 | $all_data = simplexml_load_string($buffer); |
967 | 967 | foreach($all_data->children() as $childdata) { |
968 | 968 | $data = array(); |
@@ -984,10 +984,10 @@ discard block |
||
984 | 984 | $SI->add($data); |
985 | 985 | unset($data); |
986 | 986 | } |
987 | - } |
|
988 | - $Source->deleteOldLocationByType('gs'); |
|
989 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
990 | - if ($buffer != '') { |
|
987 | + } |
|
988 | + $Source->deleteOldLocationByType('gs'); |
|
989 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
990 | + if ($buffer != '') { |
|
991 | 991 | $all_data = simplexml_load_string($buffer); |
992 | 992 | foreach($all_data->children() as $childdata) { |
993 | 993 | $data = array(); |
@@ -1005,8 +1005,8 @@ discard block |
||
1005 | 1005 | } |
1006 | 1006 | unset($data); |
1007 | 1007 | } |
1008 | - } |
|
1009 | - $last_exec[$id]['last'] = time(); |
|
1008 | + } |
|
1009 | + $last_exec[$id]['last'] = time(); |
|
1010 | 1010 | /* |
1011 | 1011 | } if ($value['format'] === 'aircraftlistjson') { |
1012 | 1012 | print_r($globalSources); |
@@ -1014,17 +1014,17 @@ discard block |
||
1014 | 1014 | echo $globalMinFetch; |
1015 | 1015 | */ |
1016 | 1016 | } elseif ($value['format'] === 'aircraftlistjson' && |
1017 | - ( |
|
1017 | + ( |
|
1018 | 1018 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1019 | 1019 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1020 | - ) |
|
1020 | + ) |
|
1021 | 1021 | ) { |
1022 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
1023 | - if ($buffer != '') { |
|
1024 | - $all_data = json_decode($buffer,true); |
|
1022 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
1023 | + if ($buffer != '') { |
|
1024 | + $all_data = json_decode($buffer,true); |
|
1025 | 1025 | if (isset($all_data['acList'])) { |
1026 | - $reset = 0; |
|
1027 | - foreach ($all_data['acList'] as $line) { |
|
1026 | + $reset = 0; |
|
1027 | + foreach ($all_data['acList'] as $line) { |
|
1028 | 1028 | $data = array(); |
1029 | 1029 | $data['hex'] = $line['Icao']; // hex |
1030 | 1030 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1047,10 +1047,10 @@ discard block |
||
1047 | 1047 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1048 | 1048 | if (isset($data['latitude'])) $SI->add($data); |
1049 | 1049 | unset($data); |
1050 | - } |
|
1050 | + } |
|
1051 | 1051 | } elseif (is_array($all_data)) { |
1052 | - $reset = 0; |
|
1053 | - foreach ($all_data as $line) { |
|
1052 | + $reset = 0; |
|
1053 | + foreach ($all_data as $line) { |
|
1054 | 1054 | $data = array(); |
1055 | 1055 | $data['hex'] = $line['hex']; // hex |
1056 | 1056 | $data['ident'] = $line['flight']; // ident |
@@ -1070,291 +1070,291 @@ discard block |
||
1070 | 1070 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1071 | 1071 | $SI->add($data); |
1072 | 1072 | unset($data); |
1073 | - } |
|
1073 | + } |
|
1074 | 1074 | } |
1075 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1076 | - //$last_exec['aircraftlistjson'] = time(); |
|
1077 | - $last_exec[$id]['last'] = time(); |
|
1078 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
1079 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
1080 | - ( |
|
1081 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1082 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1083 | - ) |
|
1084 | - ) { |
|
1085 | - $buffer = $Common->getData($value['host']); |
|
1086 | - $all_data = json_decode($buffer,true); |
|
1087 | - if (isset($all_data['planes'])) { |
|
1075 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
1076 | + //$last_exec['aircraftlistjson'] = time(); |
|
1077 | + $last_exec[$id]['last'] = time(); |
|
1078 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
1079 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
1080 | + ( |
|
1081 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1082 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1083 | + ) |
|
1084 | + ) { |
|
1085 | + $buffer = $Common->getData($value['host']); |
|
1086 | + $all_data = json_decode($buffer,true); |
|
1087 | + if (isset($all_data['planes'])) { |
|
1088 | 1088 | $reset = 0; |
1089 | 1089 | foreach ($all_data['planes'] as $key => $line) { |
1090 | - $data = array(); |
|
1091 | - $data['hex'] = $key; // hex |
|
1092 | - $data['ident'] = $line[3]; // ident |
|
1093 | - $data['altitude'] = $line[6]; // altitude |
|
1094 | - $data['speed'] = $line[8]; // speed |
|
1095 | - $data['heading'] = $line[7]; // heading |
|
1096 | - $data['latitude'] = $line[4]; // lat |
|
1097 | - $data['longitude'] = $line[5]; // long |
|
1098 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
1099 | - $data['squawk'] = $line[10]; // squawk |
|
1100 | - $data['emergency'] = ''; // emergency |
|
1101 | - $data['registration'] = $line[2]; |
|
1102 | - $data['aircraft_icao'] = $line[0]; |
|
1103 | - $deparr = explode('-',$line[1]); |
|
1104 | - if (count($deparr) === 2) { |
|
1090 | + $data = array(); |
|
1091 | + $data['hex'] = $key; // hex |
|
1092 | + $data['ident'] = $line[3]; // ident |
|
1093 | + $data['altitude'] = $line[6]; // altitude |
|
1094 | + $data['speed'] = $line[8]; // speed |
|
1095 | + $data['heading'] = $line[7]; // heading |
|
1096 | + $data['latitude'] = $line[4]; // lat |
|
1097 | + $data['longitude'] = $line[5]; // long |
|
1098 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
1099 | + $data['squawk'] = $line[10]; // squawk |
|
1100 | + $data['emergency'] = ''; // emergency |
|
1101 | + $data['registration'] = $line[2]; |
|
1102 | + $data['aircraft_icao'] = $line[0]; |
|
1103 | + $deparr = explode('-',$line[1]); |
|
1104 | + if (count($deparr) === 2) { |
|
1105 | 1105 | $data['departure_airport_icao'] = $deparr[0]; |
1106 | 1106 | $data['arrival_airport_icao'] = $deparr[1]; |
1107 | - } |
|
1108 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
1109 | - $data['format_source'] = 'planeupdatefaa'; |
|
1110 | - $data['id_source'] = $id_source; |
|
1111 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1112 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1113 | - $SI->add($data); |
|
1114 | - unset($data); |
|
1107 | + } |
|
1108 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
1109 | + $data['format_source'] = 'planeupdatefaa'; |
|
1110 | + $data['id_source'] = $id_source; |
|
1111 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1112 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1113 | + $SI->add($data); |
|
1114 | + unset($data); |
|
1115 | + } |
|
1115 | 1116 | } |
1116 | - } |
|
1117 | - //$last_exec['planeupdatefaa'] = time(); |
|
1118 | - $last_exec[$id]['last'] = time(); |
|
1117 | + //$last_exec['planeupdatefaa'] = time(); |
|
1118 | + $last_exec[$id]['last'] = time(); |
|
1119 | 1119 | } elseif ($value['format'] === 'opensky' && |
1120 | - ( |
|
1120 | + ( |
|
1121 | 1121 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1122 | 1122 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1123 | - ) |
|
1123 | + ) |
|
1124 | 1124 | ) { |
1125 | - $buffer = $Common->getData($value['host']); |
|
1126 | - $all_data = json_decode($buffer,true); |
|
1127 | - if (isset($all_data['states'])) { |
|
1125 | + $buffer = $Common->getData($value['host']); |
|
1126 | + $all_data = json_decode($buffer,true); |
|
1127 | + if (isset($all_data['states'])) { |
|
1128 | 1128 | $reset = 0; |
1129 | 1129 | foreach ($all_data['states'] as $key => $line) { |
1130 | - $data = array(); |
|
1131 | - $data['hex'] = $line[0]; // hex |
|
1132 | - $data['ident'] = trim($line[1]); // ident |
|
1133 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1134 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
1135 | - $data['heading'] = round($line[10]); // heading |
|
1136 | - $data['latitude'] = $line[6]; // lat |
|
1137 | - $data['longitude'] = $line[5]; // long |
|
1138 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
1139 | - //$data['squawk'] = $line[10]; // squawk |
|
1140 | - //$data['emergency'] = ''; // emergency |
|
1141 | - //$data['registration'] = $line[2]; |
|
1142 | - //$data['aircraft_icao'] = $line[0]; |
|
1143 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1144 | - $data['format_source'] = 'opensky'; |
|
1145 | - $data['id_source'] = $id_source; |
|
1146 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1147 | - $SI->add($data); |
|
1148 | - unset($data); |
|
1130 | + $data = array(); |
|
1131 | + $data['hex'] = $line[0]; // hex |
|
1132 | + $data['ident'] = trim($line[1]); // ident |
|
1133 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1134 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
1135 | + $data['heading'] = round($line[10]); // heading |
|
1136 | + $data['latitude'] = $line[6]; // lat |
|
1137 | + $data['longitude'] = $line[5]; // long |
|
1138 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
1139 | + //$data['squawk'] = $line[10]; // squawk |
|
1140 | + //$data['emergency'] = ''; // emergency |
|
1141 | + //$data['registration'] = $line[2]; |
|
1142 | + //$data['aircraft_icao'] = $line[0]; |
|
1143 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1144 | + $data['format_source'] = 'opensky'; |
|
1145 | + $data['id_source'] = $id_source; |
|
1146 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1147 | + $SI->add($data); |
|
1148 | + unset($data); |
|
1149 | 1149 | } |
1150 | - } |
|
1151 | - //$last_exec['planeupdatefaa'] = time(); |
|
1152 | - $last_exec[$id]['last'] = time(); |
|
1150 | + } |
|
1151 | + //$last_exec['planeupdatefaa'] = time(); |
|
1152 | + $last_exec[$id]['last'] = time(); |
|
1153 | 1153 | } elseif ($value['format'] === 'aircraftjson' && |
1154 | - ( |
|
1154 | + ( |
|
1155 | 1155 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1156 | 1156 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1157 | - ) |
|
1157 | + ) |
|
1158 | 1158 | ) { |
1159 | - $buffer = $Common->getData($value['host']); |
|
1160 | - $all_data = json_decode($buffer,true); |
|
1161 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1159 | + $buffer = $Common->getData($value['host']); |
|
1160 | + $all_data = json_decode($buffer,true); |
|
1161 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1162 | 1162 | $reset = 0; |
1163 | 1163 | foreach ($all_data['aircraft'] as $key => $line) { |
1164 | - $data = array(); |
|
1165 | - // add support for ground vehicule with ~ in front of hex |
|
1166 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1167 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1168 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1169 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1170 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1171 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1172 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1173 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1174 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1175 | - //$data['emergency'] = ''; // emergency |
|
1176 | - //$data['registration'] = $line[2]; |
|
1177 | - //$data['aircraft_icao'] = $line[0]; |
|
1178 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1179 | - $data['format_source'] = 'aircraftjson'; |
|
1180 | - $data['id_source'] = $id_source; |
|
1181 | - if (isset($value['name']) && $value['name'] != '') { |
|
1182 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1183 | - else $data['source_name'] = $value['name']; |
|
1184 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1185 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1186 | - $SI->add($data); |
|
1187 | - unset($data); |
|
1164 | + $data = array(); |
|
1165 | + // add support for ground vehicule with ~ in front of hex |
|
1166 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1167 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1168 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1169 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1170 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1171 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1172 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1173 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1174 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1175 | + //$data['emergency'] = ''; // emergency |
|
1176 | + //$data['registration'] = $line[2]; |
|
1177 | + //$data['aircraft_icao'] = $line[0]; |
|
1178 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1179 | + $data['format_source'] = 'aircraftjson'; |
|
1180 | + $data['id_source'] = $id_source; |
|
1181 | + if (isset($value['name']) && $value['name'] != '') { |
|
1182 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1183 | + else $data['source_name'] = $value['name']; |
|
1184 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1185 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1186 | + $SI->add($data); |
|
1187 | + unset($data); |
|
1188 | + } |
|
1188 | 1189 | } |
1189 | - } |
|
1190 | - //$last_exec['planeupdatefaa'] = time(); |
|
1191 | - $last_exec[$id]['last'] = time(); |
|
1190 | + //$last_exec['planeupdatefaa'] = time(); |
|
1191 | + $last_exec[$id]['last'] = time(); |
|
1192 | 1192 | } elseif ($value['format'] === 'planefinderclient' && |
1193 | - ( |
|
1193 | + ( |
|
1194 | 1194 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1195 | 1195 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1196 | - ) |
|
1196 | + ) |
|
1197 | 1197 | ) { |
1198 | - $buffer = $Common->getData($value['host']); |
|
1199 | - $all_data = json_decode($buffer,true); |
|
1200 | - if (isset($all_data['aircraft'])) { |
|
1198 | + $buffer = $Common->getData($value['host']); |
|
1199 | + $all_data = json_decode($buffer,true); |
|
1200 | + if (isset($all_data['aircraft'])) { |
|
1201 | 1201 | $reset = 0; |
1202 | 1202 | foreach ($all_data['aircraft'] as $key => $line) { |
1203 | - $data = array(); |
|
1204 | - $data['hex'] = $key; // hex |
|
1205 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1206 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1207 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1208 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1209 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1210 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1211 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1212 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1213 | - //$data['emergency'] = ''; // emergency |
|
1214 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1215 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1216 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1217 | - $data['format_source'] = 'planefinderclient'; |
|
1218 | - $data['id_source'] = $id_source; |
|
1219 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1220 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1221 | - $SI->add($data); |
|
1222 | - unset($data); |
|
1203 | + $data = array(); |
|
1204 | + $data['hex'] = $key; // hex |
|
1205 | + if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1206 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1207 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1208 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1209 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1210 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1211 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1212 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1213 | + //$data['emergency'] = ''; // emergency |
|
1214 | + if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1215 | + if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1216 | + $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1217 | + $data['format_source'] = 'planefinderclient'; |
|
1218 | + $data['id_source'] = $id_source; |
|
1219 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1220 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1221 | + $SI->add($data); |
|
1222 | + unset($data); |
|
1223 | 1223 | } |
1224 | - } |
|
1225 | - $last_exec[$id]['last'] = time(); |
|
1224 | + } |
|
1225 | + $last_exec[$id]['last'] = time(); |
|
1226 | 1226 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1227 | 1227 | } elseif ($value['format'] === 'fr24json' && |
1228 | - ( |
|
1228 | + ( |
|
1229 | 1229 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1230 | 1230 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1231 | - ) |
|
1231 | + ) |
|
1232 | 1232 | ) { |
1233 | - //$buffer = $Common->getData($hosts[$id]); |
|
1234 | - $buffer = $Common->getData($value['host']); |
|
1235 | - $all_data = json_decode($buffer,true); |
|
1236 | - if (!empty($all_data)) $reset = 0; |
|
1237 | - foreach ($all_data as $key => $line) { |
|
1233 | + //$buffer = $Common->getData($hosts[$id]); |
|
1234 | + $buffer = $Common->getData($value['host']); |
|
1235 | + $all_data = json_decode($buffer,true); |
|
1236 | + if (!empty($all_data)) $reset = 0; |
|
1237 | + foreach ($all_data as $key => $line) { |
|
1238 | 1238 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1239 | - $data = array(); |
|
1240 | - $data['hex'] = $line[0]; |
|
1241 | - $data['ident'] = $line[16]; //$line[13] |
|
1242 | - $data['altitude'] = $line[4]; // altitude |
|
1243 | - $data['speed'] = $line[5]; // speed |
|
1244 | - $data['heading'] = $line[3]; // heading |
|
1245 | - $data['latitude'] = $line[1]; // lat |
|
1246 | - $data['longitude'] = $line[2]; // long |
|
1247 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1248 | - $data['squawk'] = $line[6]; // squawk |
|
1249 | - $data['aircraft_icao'] = $line[8]; |
|
1250 | - $data['registration'] = $line[9]; |
|
1251 | - $data['departure_airport_iata'] = $line[11]; |
|
1252 | - $data['arrival_airport_iata'] = $line[12]; |
|
1253 | - $data['emergency'] = ''; // emergency |
|
1254 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1255 | - $data['format_source'] = 'fr24json'; |
|
1256 | - $data['id_source'] = $id_source; |
|
1257 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1258 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1259 | - $SI->add($data); |
|
1260 | - unset($data); |
|
1239 | + $data = array(); |
|
1240 | + $data['hex'] = $line[0]; |
|
1241 | + $data['ident'] = $line[16]; //$line[13] |
|
1242 | + $data['altitude'] = $line[4]; // altitude |
|
1243 | + $data['speed'] = $line[5]; // speed |
|
1244 | + $data['heading'] = $line[3]; // heading |
|
1245 | + $data['latitude'] = $line[1]; // lat |
|
1246 | + $data['longitude'] = $line[2]; // long |
|
1247 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1248 | + $data['squawk'] = $line[6]; // squawk |
|
1249 | + $data['aircraft_icao'] = $line[8]; |
|
1250 | + $data['registration'] = $line[9]; |
|
1251 | + $data['departure_airport_iata'] = $line[11]; |
|
1252 | + $data['arrival_airport_iata'] = $line[12]; |
|
1253 | + $data['emergency'] = ''; // emergency |
|
1254 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1255 | + $data['format_source'] = 'fr24json'; |
|
1256 | + $data['id_source'] = $id_source; |
|
1257 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1258 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1259 | + $SI->add($data); |
|
1260 | + unset($data); |
|
1261 | 1261 | } |
1262 | - } |
|
1263 | - //$last_exec['fr24json'] = time(); |
|
1264 | - $last_exec[$id]['last'] = time(); |
|
1262 | + } |
|
1263 | + //$last_exec['fr24json'] = time(); |
|
1264 | + $last_exec[$id]['last'] = time(); |
|
1265 | 1265 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1266 | 1266 | } elseif ($value['format'] === 'radarvirtueljson' && |
1267 | - ( |
|
1267 | + ( |
|
1268 | 1268 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1269 | 1269 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1270 | - ) |
|
1270 | + ) |
|
1271 | 1271 | ) { |
1272 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1273 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1274 | - //echo $buffer; |
|
1275 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1276 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1277 | - $all_data = json_decode($buffer,true); |
|
1278 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1272 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1273 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1274 | + //echo $buffer; |
|
1275 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1276 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1277 | + $all_data = json_decode($buffer,true); |
|
1278 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1279 | 1279 | die(json_last_error_msg()); |
1280 | - } |
|
1281 | - if (isset($all_data['mrkrs'])) { |
|
1280 | + } |
|
1281 | + if (isset($all_data['mrkrs'])) { |
|
1282 | 1282 | $reset = 0; |
1283 | 1283 | foreach ($all_data['mrkrs'] as $key => $line) { |
1284 | - if (isset($line['inf'])) { |
|
1284 | + if (isset($line['inf'])) { |
|
1285 | 1285 | $data = array(); |
1286 | 1286 | $data['hex'] = $line['inf']['ia']; |
1287 | 1287 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1288 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1289 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1290 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1291 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1292 | - $data['longitude'] = $line['pt'][1]; // long |
|
1293 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1294 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1295 | - //$data['aircraft_icao'] = $line[8]; |
|
1296 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1288 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1289 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1290 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1291 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1292 | + $data['longitude'] = $line['pt'][1]; // long |
|
1293 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1294 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1295 | + //$data['aircraft_icao'] = $line[8]; |
|
1296 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1297 | 1297 | //$data['departure_airport_iata'] = $line[11]; |
1298 | 1298 | //$data['arrival_airport_iata'] = $line[12]; |
1299 | - //$data['emergency'] = ''; // emergency |
|
1299 | + //$data['emergency'] = ''; // emergency |
|
1300 | 1300 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1301 | - $data['format_source'] = 'radarvirtueljson'; |
|
1302 | - $data['id_source'] = $id_source; |
|
1301 | + $data['format_source'] = 'radarvirtueljson'; |
|
1302 | + $data['id_source'] = $id_source; |
|
1303 | 1303 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1304 | 1304 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1305 | 1305 | $SI->add($data); |
1306 | 1306 | unset($data); |
1307 | - } |
|
1307 | + } |
|
1308 | 1308 | } |
1309 | - } |
|
1310 | - //$last_exec['radarvirtueljson'] = time(); |
|
1311 | - $last_exec[$id]['last'] = time(); |
|
1309 | + } |
|
1310 | + //$last_exec['radarvirtueljson'] = time(); |
|
1311 | + $last_exec[$id]['last'] = time(); |
|
1312 | 1312 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1313 | 1313 | } elseif ($value['format'] === 'pirepsjson' && |
1314 | - ( |
|
1314 | + ( |
|
1315 | 1315 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1316 | 1316 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1317 | - ) |
|
1317 | + ) |
|
1318 | 1318 | ) { |
1319 | - //$buffer = $Common->getData($hosts[$id]); |
|
1320 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1321 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1319 | + //$buffer = $Common->getData($hosts[$id]); |
|
1320 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1321 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1322 | 1322 | |
1323 | - if (isset($all_data['pireps'])) { |
|
1323 | + if (isset($all_data['pireps'])) { |
|
1324 | 1324 | $reset = 0; |
1325 | - foreach ($all_data['pireps'] as $line) { |
|
1326 | - $data = array(); |
|
1327 | - $data['id'] = $line['id']; |
|
1328 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1329 | - $data['ident'] = $line['callsign']; // ident |
|
1330 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1331 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1332 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1333 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1334 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1335 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1336 | - $data['latitude'] = $line['lat']; // lat |
|
1337 | - $data['longitude'] = $line['lon']; // long |
|
1338 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1339 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1340 | - //$data['emergency'] = ''; // emergency |
|
1341 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1342 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1343 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1344 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1345 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1346 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1347 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1348 | - else $data['info'] = ''; |
|
1349 | - $data['format_source'] = 'pireps'; |
|
1350 | - $data['id_source'] = $id_source; |
|
1351 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1352 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1353 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1354 | - if ($line['icon'] === 'plane') { |
|
1325 | + foreach ($all_data['pireps'] as $line) { |
|
1326 | + $data = array(); |
|
1327 | + $data['id'] = $line['id']; |
|
1328 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1329 | + $data['ident'] = $line['callsign']; // ident |
|
1330 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1331 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1332 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1333 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1334 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1335 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1336 | + $data['latitude'] = $line['lat']; // lat |
|
1337 | + $data['longitude'] = $line['lon']; // long |
|
1338 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1339 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1340 | + //$data['emergency'] = ''; // emergency |
|
1341 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1342 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1343 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1344 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1345 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1346 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1347 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1348 | + else $data['info'] = ''; |
|
1349 | + $data['format_source'] = 'pireps'; |
|
1350 | + $data['id_source'] = $id_source; |
|
1351 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1352 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1353 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1354 | + if ($line['icon'] === 'plane') { |
|
1355 | 1355 | $SI->add($data); |
1356 | - // print_r($data); |
|
1357 | - } elseif ($line['icon'] === 'ct') { |
|
1356 | + // print_r($data); |
|
1357 | + } elseif ($line['icon'] === 'ct') { |
|
1358 | 1358 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1359 | 1359 | $data['info'] = str_replace('&sect;','',$data['info']); |
1360 | 1360 | $typec = substr($data['ident'],-3); |
@@ -1369,209 +1369,209 @@ discard block |
||
1369 | 1369 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1370 | 1370 | else $data['type'] = 'Observer'; |
1371 | 1371 | 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']); |
1372 | - } |
|
1373 | - unset($data); |
|
1372 | + } |
|
1373 | + unset($data); |
|
1374 | 1374 | } |
1375 | - } |
|
1376 | - //$last_exec['pirepsjson'] = time(); |
|
1377 | - $last_exec[$id]['last'] = time(); |
|
1375 | + } |
|
1376 | + //$last_exec['pirepsjson'] = time(); |
|
1377 | + $last_exec[$id]['last'] = time(); |
|
1378 | 1378 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1379 | 1379 | } elseif ($value['format'] === 'phpvmacars' && |
1380 | - ( |
|
1380 | + ( |
|
1381 | 1381 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1382 | 1382 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1383 | - ) |
|
1383 | + ) |
|
1384 | 1384 | ) { |
1385 | - //$buffer = $Common->getData($hosts[$id]); |
|
1386 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1387 | - $buffer = $Common->getData($value['host']); |
|
1388 | - $all_data = json_decode($buffer,true); |
|
1389 | - if ($buffer != '' && is_array($all_data)) { |
|
1385 | + //$buffer = $Common->getData($hosts[$id]); |
|
1386 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1387 | + $buffer = $Common->getData($value['host']); |
|
1388 | + $all_data = json_decode($buffer,true); |
|
1389 | + if ($buffer != '' && is_array($all_data)) { |
|
1390 | 1390 | $reset = 0; |
1391 | 1391 | foreach ($all_data as $line) { |
1392 | - $data = array(); |
|
1393 | - //$data['id'] = $line['id']; // id not usable |
|
1394 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1395 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1396 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1397 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1398 | - $data['ident'] = $line['flightnum']; // ident |
|
1399 | - $data['altitude'] = $line['alt']; // altitude |
|
1400 | - $data['speed'] = $line['gs']; // speed |
|
1401 | - $data['heading'] = $line['heading']; // heading |
|
1402 | - $data['latitude'] = $line['lat']; // lat |
|
1403 | - $data['longitude'] = $line['lng']; // long |
|
1404 | - $data['verticalrate'] = ''; // verticale rate |
|
1405 | - $data['squawk'] = ''; // squawk |
|
1406 | - $data['emergency'] = ''; // emergency |
|
1407 | - //$data['datetime'] = $line['lastupdate']; |
|
1408 | - //$data['last_update'] = $line['lastupdate']; |
|
1409 | - if (isset($value['timezone'])) { |
|
1410 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1411 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1412 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1413 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1414 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1415 | - $data['departure_airport_time'] = $line['deptime']; |
|
1416 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1417 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1418 | - if (isset($line['registration'])) { |
|
1419 | - $data['registration'] = $line['registration']; |
|
1420 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1421 | - } else $data['registration'] = $line['aircraft']; |
|
1422 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1423 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1424 | - if (isset($line['aircraftname'])) { |
|
1392 | + $data = array(); |
|
1393 | + //$data['id'] = $line['id']; // id not usable |
|
1394 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1395 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1396 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1397 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1398 | + $data['ident'] = $line['flightnum']; // ident |
|
1399 | + $data['altitude'] = $line['alt']; // altitude |
|
1400 | + $data['speed'] = $line['gs']; // speed |
|
1401 | + $data['heading'] = $line['heading']; // heading |
|
1402 | + $data['latitude'] = $line['lat']; // lat |
|
1403 | + $data['longitude'] = $line['lng']; // long |
|
1404 | + $data['verticalrate'] = ''; // verticale rate |
|
1405 | + $data['squawk'] = ''; // squawk |
|
1406 | + $data['emergency'] = ''; // emergency |
|
1407 | + //$data['datetime'] = $line['lastupdate']; |
|
1408 | + //$data['last_update'] = $line['lastupdate']; |
|
1409 | + if (isset($value['timezone'])) { |
|
1410 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1411 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1412 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1413 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1414 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1415 | + $data['departure_airport_time'] = $line['deptime']; |
|
1416 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1417 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1418 | + if (isset($line['registration'])) { |
|
1419 | + $data['registration'] = $line['registration']; |
|
1420 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1421 | + } else $data['registration'] = $line['aircraft']; |
|
1422 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1423 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1424 | + if (isset($line['aircraftname'])) { |
|
1425 | 1425 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1426 | 1426 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1427 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1428 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1429 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1430 | - else { |
|
1431 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1432 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1433 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1434 | - } |
|
1435 | - } |
|
1436 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1437 | - $data['id_source'] = $id_source; |
|
1438 | - $data['format_source'] = 'phpvmacars'; |
|
1439 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1440 | - $SI->add($data); |
|
1441 | - unset($data); |
|
1427 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1428 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1429 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1430 | + else { |
|
1431 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1432 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1433 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1434 | + } |
|
1435 | + } |
|
1436 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1437 | + $data['id_source'] = $id_source; |
|
1438 | + $data['format_source'] = 'phpvmacars'; |
|
1439 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1440 | + $SI->add($data); |
|
1441 | + unset($data); |
|
1442 | 1442 | } |
1443 | 1443 | if ($globalDebug) echo 'No more data...'."\n"; |
1444 | 1444 | unset($buffer); |
1445 | 1445 | unset($all_data); |
1446 | - } |
|
1447 | - //$last_exec['phpvmacars'] = time(); |
|
1448 | - $last_exec[$id]['last'] = time(); |
|
1446 | + } |
|
1447 | + //$last_exec['phpvmacars'] = time(); |
|
1448 | + $last_exec[$id]['last'] = time(); |
|
1449 | 1449 | } elseif ($value['format'] === 'vaos' && |
1450 | - ( |
|
1450 | + ( |
|
1451 | 1451 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1452 | 1452 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1453 | - ) |
|
1453 | + ) |
|
1454 | 1454 | ) { |
1455 | - //$buffer = $Common->getData($hosts[$id]); |
|
1456 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1457 | - $buffer = $Common->getData($value['host']); |
|
1458 | - $all_data = json_decode($buffer,true); |
|
1459 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1455 | + //$buffer = $Common->getData($hosts[$id]); |
|
1456 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1457 | + $buffer = $Common->getData($value['host']); |
|
1458 | + $all_data = json_decode($buffer,true); |
|
1459 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1460 | 1460 | $reset = 0; |
1461 | 1461 | foreach ($all_data['ACARSData'] as $line) { |
1462 | - //print_r($line); |
|
1463 | - $data = array(); |
|
1464 | - //$data['id'] = $line['id']; // id not usable |
|
1465 | - $data['id'] = $line['id']; |
|
1466 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1467 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1468 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1469 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1470 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1471 | - $data['altitude'] = $line['altitude']; // altitude |
|
1472 | - $data['speed'] = $line['groundspeed']; // speed |
|
1473 | - $data['heading'] = $line['heading']; // heading |
|
1474 | - $data['latitude'] = $line['lat']; // lat |
|
1475 | - $data['longitude'] = $line['lon']; // long |
|
1476 | - //$data['verticalrate'] = ''; // verticale rate |
|
1477 | - //$data['squawk'] = ''; // squawk |
|
1478 | - //$data['emergency'] = ''; // emergency |
|
1479 | - if (isset($value['timezone'])) { |
|
1480 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1481 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1482 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1483 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1462 | + //print_r($line); |
|
1463 | + $data = array(); |
|
1464 | + //$data['id'] = $line['id']; // id not usable |
|
1465 | + $data['id'] = $line['id']; |
|
1466 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1467 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1468 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1469 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1470 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1471 | + $data['altitude'] = $line['altitude']; // altitude |
|
1472 | + $data['speed'] = $line['groundspeed']; // speed |
|
1473 | + $data['heading'] = $line['heading']; // heading |
|
1474 | + $data['latitude'] = $line['lat']; // lat |
|
1475 | + $data['longitude'] = $line['lon']; // long |
|
1476 | + //$data['verticalrate'] = ''; // verticale rate |
|
1477 | + //$data['squawk'] = ''; // squawk |
|
1478 | + //$data['emergency'] = ''; // emergency |
|
1479 | + if (isset($value['timezone'])) { |
|
1480 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1481 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1482 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1483 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1484 | 1484 | |
1485 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1486 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1487 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1488 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1489 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1485 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1486 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1487 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1488 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1489 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1490 | 1490 | |
1491 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1492 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1493 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1491 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1492 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1493 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1494 | 1494 | |
1495 | - $data['id_source'] = $id_source; |
|
1496 | - $data['format_source'] = 'vaos'; |
|
1497 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1498 | - $SI->add($data); |
|
1499 | - unset($data); |
|
1495 | + $data['id_source'] = $id_source; |
|
1496 | + $data['format_source'] = 'vaos'; |
|
1497 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1498 | + $SI->add($data); |
|
1499 | + unset($data); |
|
1500 | 1500 | } |
1501 | 1501 | if ($globalDebug) echo 'No more data...'."\n"; |
1502 | 1502 | unset($buffer); |
1503 | 1503 | unset($all_data); |
1504 | - } |
|
1505 | - //$last_exec['phpvmacars'] = time(); |
|
1506 | - $last_exec[$id]['last'] = time(); |
|
1504 | + } |
|
1505 | + //$last_exec['phpvmacars'] = time(); |
|
1506 | + $last_exec[$id]['last'] = time(); |
|
1507 | 1507 | } elseif ($value['format'] === 'vam' && |
1508 | - ( |
|
1508 | + ( |
|
1509 | 1509 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1510 | 1510 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1511 | - ) |
|
1511 | + ) |
|
1512 | 1512 | ) { |
1513 | - //$buffer = $Common->getData($hosts[$id]); |
|
1514 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1515 | - $buffer = $Common->getData($value['host']); |
|
1516 | - $all_data = json_decode($buffer,true); |
|
1517 | - if ($buffer != '' && is_array($all_data)) { |
|
1513 | + //$buffer = $Common->getData($hosts[$id]); |
|
1514 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1515 | + $buffer = $Common->getData($value['host']); |
|
1516 | + $all_data = json_decode($buffer,true); |
|
1517 | + if ($buffer != '' && is_array($all_data)) { |
|
1518 | 1518 | $reset = 0; |
1519 | 1519 | foreach ($all_data as $line) { |
1520 | - $data = array(); |
|
1521 | - //$data['id'] = $line['id']; // id not usable |
|
1522 | - $data['id'] = trim($line['flight_id']); |
|
1523 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1524 | - $data['pilot_name'] = $line['pilot_name']; |
|
1525 | - $data['pilot_id'] = $line['pilot_id']; |
|
1526 | - $data['ident'] = trim($line['callsign']); // ident |
|
1527 | - $data['altitude'] = $line['altitude']; // altitude |
|
1528 | - $data['speed'] = $line['gs']; // speed |
|
1529 | - $data['heading'] = $line['heading']; // heading |
|
1530 | - $data['latitude'] = $line['latitude']; // lat |
|
1531 | - $data['longitude'] = $line['longitude']; // long |
|
1532 | - $data['verticalrate'] = ''; // verticale rate |
|
1533 | - $data['squawk'] = ''; // squawk |
|
1534 | - $data['emergency'] = ''; // emergency |
|
1535 | - //$data['datetime'] = $line['lastupdate']; |
|
1536 | - $data['last_update'] = $line['last_update']; |
|
1537 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1538 | - $data['departure_airport_icao'] = $line['departure']; |
|
1539 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1540 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1541 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1542 | - //$data['registration'] = $line['aircraft']; |
|
1543 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1544 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1545 | - $data['id_source'] = $id_source; |
|
1546 | - $data['format_source'] = 'vam'; |
|
1547 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1548 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1549 | - $SI->add($data); |
|
1550 | - unset($data); |
|
1520 | + $data = array(); |
|
1521 | + //$data['id'] = $line['id']; // id not usable |
|
1522 | + $data['id'] = trim($line['flight_id']); |
|
1523 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1524 | + $data['pilot_name'] = $line['pilot_name']; |
|
1525 | + $data['pilot_id'] = $line['pilot_id']; |
|
1526 | + $data['ident'] = trim($line['callsign']); // ident |
|
1527 | + $data['altitude'] = $line['altitude']; // altitude |
|
1528 | + $data['speed'] = $line['gs']; // speed |
|
1529 | + $data['heading'] = $line['heading']; // heading |
|
1530 | + $data['latitude'] = $line['latitude']; // lat |
|
1531 | + $data['longitude'] = $line['longitude']; // long |
|
1532 | + $data['verticalrate'] = ''; // verticale rate |
|
1533 | + $data['squawk'] = ''; // squawk |
|
1534 | + $data['emergency'] = ''; // emergency |
|
1535 | + //$data['datetime'] = $line['lastupdate']; |
|
1536 | + $data['last_update'] = $line['last_update']; |
|
1537 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1538 | + $data['departure_airport_icao'] = $line['departure']; |
|
1539 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1540 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1541 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1542 | + //$data['registration'] = $line['aircraft']; |
|
1543 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1544 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1545 | + $data['id_source'] = $id_source; |
|
1546 | + $data['format_source'] = 'vam'; |
|
1547 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1548 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1549 | + $SI->add($data); |
|
1550 | + unset($data); |
|
1551 | 1551 | } |
1552 | 1552 | if ($globalDebug) echo 'No more data...'."\n"; |
1553 | 1553 | unset($buffer); |
1554 | 1554 | unset($all_data); |
1555 | - } |
|
1556 | - //$last_exec['phpvmacars'] = time(); |
|
1557 | - $last_exec[$id]['last'] = time(); |
|
1555 | + } |
|
1556 | + //$last_exec['phpvmacars'] = time(); |
|
1557 | + $last_exec[$id]['last'] = time(); |
|
1558 | 1558 | } elseif ($value['format'] === 'blitzortung' && |
1559 | - ( |
|
1559 | + ( |
|
1560 | 1560 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1561 | 1561 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1562 | - ) |
|
1562 | + ) |
|
1563 | 1563 | ) { |
1564 | - //$buffer = $Common->getData($hosts[$id]); |
|
1565 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1566 | - $buffer = $Common->getData($value['host']); |
|
1567 | - $all_data = json_decode($buffer,true); |
|
1568 | - if ($buffer != '') { |
|
1564 | + //$buffer = $Common->getData($hosts[$id]); |
|
1565 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1566 | + $buffer = $Common->getData($value['host']); |
|
1567 | + $all_data = json_decode($buffer,true); |
|
1568 | + if ($buffer != '') { |
|
1569 | 1569 | $Source->deleteLocationBySource('blitzortung'); |
1570 | 1570 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1571 | 1571 | $buffer = explode('\n',$buffer); |
1572 | 1572 | foreach ($buffer as $buffer_line) { |
1573 | - $line = json_decode($buffer_line,true); |
|
1574 | - if (isset($line['time'])) { |
|
1573 | + $line = json_decode($buffer_line,true); |
|
1574 | + if (isset($line['time'])) { |
|
1575 | 1575 | $data = array(); |
1576 | 1576 | $data['altitude'] = $line['alt']; // altitude |
1577 | 1577 | $data['latitude'] = $line['lat']; // lat |
@@ -1583,92 +1583,92 @@ discard block |
||
1583 | 1583 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1584 | 1584 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1585 | 1585 | unset($data); |
1586 | - } |
|
1586 | + } |
|
1587 | 1587 | } |
1588 | 1588 | if ($globalDebug) echo 'No more data...'."\n"; |
1589 | 1589 | unset($buffer); |
1590 | - } |
|
1591 | - $last_exec[$id]['last'] = time(); |
|
1590 | + } |
|
1591 | + $last_exec[$id]['last'] = time(); |
|
1592 | 1592 | } elseif ($value['format'] === 'acarsjson') { |
1593 | - $arr = $httpfeeds; |
|
1594 | - $w = $e = null; |
|
1595 | - if (isset($arr[$id])) { |
|
1596 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
1597 | - if ($nn > 0) { |
|
1598 | - foreach ($httpfeeds as $feed) { |
|
1599 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
1600 | - if ($buffer === FALSE) { |
|
1601 | - connect_all($globalSources); |
|
1602 | - } |
|
1603 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1604 | - $buffer = explode('\n',$buffer); |
|
1605 | - foreach ($buffer as $line) { |
|
1606 | - if ($line != '') { |
|
1607 | - $line = json_decode($line, true); |
|
1608 | - if (!empty($line)) { |
|
1609 | - $ACARS->add($line['text'], array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => $line['text'])); |
|
1610 | - $ACARS->deleteLiveAcarsData(); |
|
1611 | - } |
|
1612 | - } |
|
1613 | - } |
|
1614 | - } |
|
1615 | - } else { |
|
1616 | - $format = $value['format']; |
|
1617 | - if (isset($tt[$format])) $tt[$format]++; |
|
1618 | - else $tt[$format] = 0; |
|
1619 | - if ($tt[$format] > 30) { |
|
1620 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
1621 | - sleep(2); |
|
1622 | - //$sourceeen[] = $value; |
|
1623 | - //connect_all($sourceeen); |
|
1624 | - //$sourceeen = array(); |
|
1625 | - connect_all($globalSources); |
|
1626 | - } |
|
1627 | - } |
|
1628 | - } |
|
1593 | + $arr = $httpfeeds; |
|
1594 | + $w = $e = null; |
|
1595 | + if (isset($arr[$id])) { |
|
1596 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
1597 | + if ($nn > 0) { |
|
1598 | + foreach ($httpfeeds as $feed) { |
|
1599 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
1600 | + if ($buffer === FALSE) { |
|
1601 | + connect_all($globalSources); |
|
1602 | + } |
|
1603 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1604 | + $buffer = explode('\n',$buffer); |
|
1605 | + foreach ($buffer as $line) { |
|
1606 | + if ($line != '') { |
|
1607 | + $line = json_decode($line, true); |
|
1608 | + if (!empty($line)) { |
|
1609 | + $ACARS->add($line['text'], array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => $line['text'])); |
|
1610 | + $ACARS->deleteLiveAcarsData(); |
|
1611 | + } |
|
1612 | + } |
|
1613 | + } |
|
1614 | + } |
|
1615 | + } else { |
|
1616 | + $format = $value['format']; |
|
1617 | + if (isset($tt[$format])) $tt[$format]++; |
|
1618 | + else $tt[$format] = 0; |
|
1619 | + if ($tt[$format] > 30) { |
|
1620 | + if ($globalDebug) echo 'Reconnect...'."\n"; |
|
1621 | + sleep(2); |
|
1622 | + //$sourceeen[] = $value; |
|
1623 | + //connect_all($sourceeen); |
|
1624 | + //$sourceeen = array(); |
|
1625 | + connect_all($globalSources); |
|
1626 | + } |
|
1627 | + } |
|
1628 | + } |
|
1629 | 1629 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
1630 | 1630 | } 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') { |
1631 | - //$last_exec[$id]['last'] = time(); |
|
1632 | - //$read = array( $sockets[$id] ); |
|
1633 | - $read = $sockets; |
|
1634 | - $write = NULL; |
|
1635 | - $e = NULL; |
|
1636 | - $n = socket_select($read, $write, $e, $timeout); |
|
1637 | - if ($e != NULL) var_dump($e); |
|
1638 | - if ($n > 0) { |
|
1631 | + //$last_exec[$id]['last'] = time(); |
|
1632 | + //$read = array( $sockets[$id] ); |
|
1633 | + $read = $sockets; |
|
1634 | + $write = NULL; |
|
1635 | + $e = NULL; |
|
1636 | + $n = socket_select($read, $write, $e, $timeout); |
|
1637 | + if ($e != NULL) var_dump($e); |
|
1638 | + if ($n > 0) { |
|
1639 | 1639 | $reset = 0; |
1640 | 1640 | foreach ($read as $nb => $r) { |
1641 | - //$value = $formats[$nb]; |
|
1642 | - $format = $globalSources[$nb]['format']; |
|
1643 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1641 | + //$value = $formats[$nb]; |
|
1642 | + $format = $globalSources[$nb]['format']; |
|
1643 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1644 | 1644 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1645 | - } elseif ($format === 'vrstcp') { |
|
1645 | + } elseif ($format === 'vrstcp') { |
|
1646 | 1646 | $buffer = @socket_read($r, 6000); |
1647 | - } else { |
|
1647 | + } else { |
|
1648 | 1648 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1649 | - } |
|
1650 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1651 | - //echo $buffer."\n"; |
|
1652 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1653 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1654 | - $error = false; |
|
1655 | - //$SI::del(); |
|
1656 | - if ($buffer !== FALSE) { |
|
1649 | + } |
|
1650 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1651 | + //echo $buffer."\n"; |
|
1652 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1653 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1654 | + $error = false; |
|
1655 | + //$SI::del(); |
|
1656 | + if ($buffer !== FALSE) { |
|
1657 | 1657 | if ($format === 'vrstcp') { |
1658 | - $buffer = explode('},{',$buffer); |
|
1658 | + $buffer = explode('},{',$buffer); |
|
1659 | 1659 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1660 | - } |
|
1661 | - // SBS format is CSV format |
|
1662 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1660 | + } |
|
1661 | + // SBS format is CSV format |
|
1662 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1663 | 1663 | $tt[$format] = 0; |
1664 | 1664 | if ($format === 'acarssbs3') { |
1665 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1666 | - $ACARS->add(trim($buffer)); |
|
1667 | - $ACARS->deleteLiveAcarsData(); |
|
1665 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1666 | + $ACARS->add(trim($buffer)); |
|
1667 | + $ACARS->deleteLiveAcarsData(); |
|
1668 | 1668 | } elseif ($format === 'raw') { |
1669 | - // AVR format |
|
1670 | - $data = $SBS->parse($buffer); |
|
1671 | - if (is_array($data)) { |
|
1669 | + // AVR format |
|
1670 | + $data = $SBS->parse($buffer); |
|
1671 | + if (is_array($data)) { |
|
1672 | 1672 | //if (!empty($data)) print_r($data); |
1673 | 1673 | $data['datetime'] = date('Y-m-d H:i:s'); |
1674 | 1674 | $data['format_source'] = 'raw'; |
@@ -1678,39 +1678,39 @@ discard block |
||
1678 | 1678 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1679 | 1679 | $SI->add($data); |
1680 | 1680 | unset($data); |
1681 | - } |
|
1681 | + } |
|
1682 | 1682 | } elseif ($format === 'ais') { |
1683 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1684 | - $data = array(); |
|
1685 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1686 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1687 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1688 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1689 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1690 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1691 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1692 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1693 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1694 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1695 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1696 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1697 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1698 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1699 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1700 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1683 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1684 | + $data = array(); |
|
1685 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1686 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1687 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1688 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1689 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1690 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1691 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1692 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1693 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1694 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1695 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1696 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1697 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1698 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1699 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1700 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1701 | 1701 | |
1702 | - if (isset($ais_data['timestamp'])) { |
|
1702 | + if (isset($ais_data['timestamp'])) { |
|
1703 | 1703 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1704 | - } else { |
|
1704 | + } else { |
|
1705 | 1705 | $data['datetime'] = date('Y-m-d H:i:s'); |
1706 | - } |
|
1707 | - $data['format_source'] = 'aisnmea'; |
|
1708 | - $data['id_source'] = $id_source; |
|
1709 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1710 | - unset($data); |
|
1711 | - } elseif ($format === 'flightgearsp') { |
|
1712 | - //echo $buffer."\n"; |
|
1713 | - if (strlen($buffer) > 5) { |
|
1706 | + } |
|
1707 | + $data['format_source'] = 'aisnmea'; |
|
1708 | + $data['id_source'] = $id_source; |
|
1709 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1710 | + unset($data); |
|
1711 | + } elseif ($format === 'flightgearsp') { |
|
1712 | + //echo $buffer."\n"; |
|
1713 | + if (strlen($buffer) > 5) { |
|
1714 | 1714 | $line = explode(',',$buffer); |
1715 | 1715 | $data = array(); |
1716 | 1716 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1727,38 +1727,38 @@ discard block |
||
1727 | 1727 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1728 | 1728 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1729 | 1729 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1730 | - } |
|
1731 | - } elseif ($format === 'acars') { |
|
1732 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1733 | - $ACARS->add(trim($buffer)); |
|
1734 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1735 | - $ACARS->deleteLiveAcarsData(); |
|
1730 | + } |
|
1731 | + } elseif ($format === 'acars') { |
|
1732 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1733 | + $ACARS->add(trim($buffer)); |
|
1734 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1735 | + $ACARS->deleteLiveAcarsData(); |
|
1736 | 1736 | } elseif ($format === 'flightgearmp') { |
1737 | - if (substr($buffer,0,1) != '#') { |
|
1737 | + if (substr($buffer,0,1) != '#') { |
|
1738 | 1738 | $data = array(); |
1739 | 1739 | //echo $buffer."\n"; |
1740 | 1740 | $line = explode(' ',$buffer); |
1741 | 1741 | if (count($line) === 11) { |
1742 | - $userserver = explode('@',$line[0]); |
|
1743 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1744 | - $data['ident'] = $userserver[0]; |
|
1745 | - $data['registration'] = $userserver[0]; |
|
1746 | - $data['latitude'] = $line[4]; |
|
1747 | - $data['longitude'] = $line[5]; |
|
1748 | - $data['altitude'] = $line[6]; |
|
1749 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1750 | - $aircraft_type = $line[10]; |
|
1751 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1752 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1753 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1754 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1742 | + $userserver = explode('@',$line[0]); |
|
1743 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1744 | + $data['ident'] = $userserver[0]; |
|
1745 | + $data['registration'] = $userserver[0]; |
|
1746 | + $data['latitude'] = $line[4]; |
|
1747 | + $data['longitude'] = $line[5]; |
|
1748 | + $data['altitude'] = $line[6]; |
|
1749 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1750 | + $aircraft_type = $line[10]; |
|
1751 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1752 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1753 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1754 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1755 | + } |
|
1755 | 1756 | } |
1756 | - } |
|
1757 | 1757 | } elseif ($format === 'beast') { |
1758 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1759 | - die; |
|
1758 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1759 | + die; |
|
1760 | 1760 | } elseif ($format === 'vrstcp') { |
1761 | - foreach($buffer as $all_data) { |
|
1761 | + foreach($buffer as $all_data) { |
|
1762 | 1762 | $line = json_decode('{'.$all_data.'}',true); |
1763 | 1763 | $data = array(); |
1764 | 1764 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1778,158 +1778,158 @@ discard block |
||
1778 | 1778 | */ |
1779 | 1779 | $data['datetime'] = date('Y-m-d H:i:s'); |
1780 | 1780 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1781 | - $data['format_source'] = 'vrstcp'; |
|
1781 | + $data['format_source'] = 'vrstcp'; |
|
1782 | 1782 | $data['id_source'] = $id_source; |
1783 | 1783 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1784 | 1784 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1785 | 1785 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1786 | 1786 | unset($data); |
1787 | - } |
|
1787 | + } |
|
1788 | 1788 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
1789 | - $line = explode("\t", $buffer); |
|
1790 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1789 | + $line = explode("\t", $buffer); |
|
1790 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1791 | 1791 | $key = $line[$k]; |
1792 | - $lined[$key] = $line[$k+1]; |
|
1793 | - } |
|
1794 | - if (count($lined) > 3) { |
|
1795 | - $data['hex'] = $lined['hexid']; |
|
1796 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1797 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1798 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1799 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1800 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1801 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1802 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1803 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1804 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1805 | - $data['id_source'] = $id_source; |
|
1806 | - $data['format_source'] = 'tsv'; |
|
1807 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1808 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1792 | + $lined[$key] = $line[$k+1]; |
|
1793 | + } |
|
1794 | + if (count($lined) > 3) { |
|
1795 | + $data['hex'] = $lined['hexid']; |
|
1796 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1797 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1798 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1799 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1800 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1801 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1802 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1803 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1804 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1805 | + $data['id_source'] = $id_source; |
|
1806 | + $data['format_source'] = 'tsv'; |
|
1807 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1808 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1809 | 1809 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1810 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1811 | - unset($lined); |
|
1812 | - unset($data); |
|
1813 | - } else $error = true; |
|
1810 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1811 | + unset($lined); |
|
1812 | + unset($data); |
|
1813 | + } else $error = true; |
|
1814 | 1814 | } elseif ($format === 'aprs' && $use_aprs) { |
1815 | - if ($aprs_connect === 0) { |
|
1815 | + if ($aprs_connect === 0) { |
|
1816 | 1816 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1817 | 1817 | $aprs_connect = 1; |
1818 | - } |
|
1818 | + } |
|
1819 | 1819 | |
1820 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1820 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1821 | 1821 | $aprs_last_tx = time(); |
1822 | 1822 | $data_aprs = "# Keep alive"; |
1823 | 1823 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1824 | - } |
|
1824 | + } |
|
1825 | 1825 | |
1826 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1827 | - //echo 'APRS data : '.$buffer."\n"; |
|
1828 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1829 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1830 | - //echo $buffer."\n"; |
|
1831 | - date_default_timezone_set('UTC'); |
|
1832 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1826 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1827 | + //echo 'APRS data : '.$buffer."\n"; |
|
1828 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1829 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1830 | + //echo $buffer."\n"; |
|
1831 | + date_default_timezone_set('UTC'); |
|
1832 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1833 | 1833 | $line = $APRS->parse($buffer); |
1834 | 1834 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1835 | 1835 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1836 | - $aprs_last_tx = time(); |
|
1837 | - $data = array(); |
|
1838 | - //print_r($line); |
|
1839 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1840 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1841 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1842 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1843 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1844 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1845 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1846 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1847 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1848 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1849 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1850 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1851 | - $data['latitude'] = $line['latitude']; |
|
1852 | - $data['longitude'] = $line['longitude']; |
|
1853 | - //$data['verticalrate'] = $line[16]; |
|
1854 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1855 | - //else $data['speed'] = 0; |
|
1856 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1857 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1858 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1859 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1836 | + $aprs_last_tx = time(); |
|
1837 | + $data = array(); |
|
1838 | + //print_r($line); |
|
1839 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1840 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1841 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1842 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1843 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1844 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1845 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1846 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1847 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1848 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1849 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1850 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1851 | + $data['latitude'] = $line['latitude']; |
|
1852 | + $data['longitude'] = $line['longitude']; |
|
1853 | + //$data['verticalrate'] = $line[16]; |
|
1854 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1855 | + //else $data['speed'] = 0; |
|
1856 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1857 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1858 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1859 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1860 | 1860 | |
1861 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1862 | - //else echo 'No heading...'."\n"; |
|
1863 | - //else $data['heading'] = 0; |
|
1864 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1865 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1866 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1867 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1868 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1869 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1870 | - $data['id_source'] = $id_source; |
|
1871 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1872 | - else $data['format_source'] = 'aprs'; |
|
1873 | - $data['source_name'] = $line['source']; |
|
1874 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1875 | - else $data['source_type'] = 'flarm'; |
|
1876 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1877 | - $currentdate = date('Y-m-d H:i:s'); |
|
1878 | - $aprsdate = strtotime($data['datetime']); |
|
1879 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1880 | - // Accept data if time <= system time + 20s |
|
1881 | - //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'])))) { |
|
1882 | - if ( |
|
1861 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1862 | + //else echo 'No heading...'."\n"; |
|
1863 | + //else $data['heading'] = 0; |
|
1864 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1865 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1866 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1867 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1868 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1869 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1870 | + $data['id_source'] = $id_source; |
|
1871 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1872 | + else $data['format_source'] = 'aprs'; |
|
1873 | + $data['source_name'] = $line['source']; |
|
1874 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1875 | + else $data['source_type'] = 'flarm'; |
|
1876 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1877 | + $currentdate = date('Y-m-d H:i:s'); |
|
1878 | + $aprsdate = strtotime($data['datetime']); |
|
1879 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1880 | + // Accept data if time <= system time + 20s |
|
1881 | + //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'])))) { |
|
1882 | + if ( |
|
1883 | 1883 | ($data['source_type'] === 'modes') || |
1884 | 1884 | isset($line['stealth']) && |
1885 | 1885 | (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && |
1886 | 1886 | ($line['stealth'] === 0 || $line['stealth'] == '') && |
1887 | 1887 | (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1888 | 1888 | $send = $SI->add($data); |
1889 | - } elseif ($data['source_type'] === 'ais') { |
|
1889 | + } elseif ($data['source_type'] === 'ais') { |
|
1890 | 1890 | $data['type'] = ''; |
1891 | 1891 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1892 | - } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
1892 | + } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
1893 | 1893 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1894 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1895 | - //$line['symbol'] === 'Balloon' || |
|
1896 | - $line['symbol'] === 'Glider' || |
|
1897 | - $line['symbol'] === 'No. Plane' || |
|
1898 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1899 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1900 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1901 | - $send = $SI->add($data); |
|
1902 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1903 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1904 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
1905 | - $send = $MI->add($data); |
|
1906 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1907 | - $line['symbol'] === 'Car' || |
|
1908 | - $line['symbol'] === 'Ambulance' || |
|
1909 | - $line['symbol'] === 'Van' || |
|
1910 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1911 | - $line['symbol'] === 'Motorcycle' || |
|
1912 | - $line['symbol'] === 'Tractor' || |
|
1913 | - $line['symbol'] === 'Police' || |
|
1914 | - $line['symbol'] === 'Bike' || |
|
1915 | - $line['symbol'] === 'Jogger' || |
|
1916 | - $line['symbol'] === 'Horse' || |
|
1917 | - $line['symbol'] === 'Bus' || |
|
1918 | - $line['symbol'] === 'Jeep' || |
|
1919 | - $line['symbol'] === 'Recreational Vehicle' || |
|
1920 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1921 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
1922 | - $line['symbol'] === 'Firetruck' || |
|
1923 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1924 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1925 | - $line['symbol'] === 'SUV' || |
|
1926 | - $line['symbol'] === 'Snowmobile' || |
|
1927 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
1928 | - //} 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') { |
|
1894 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1895 | + //$line['symbol'] === 'Balloon' || |
|
1896 | + $line['symbol'] === 'Glider' || |
|
1897 | + $line['symbol'] === 'No. Plane' || |
|
1898 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1899 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1900 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1901 | + $send = $SI->add($data); |
|
1902 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1903 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1904 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
1905 | + $send = $MI->add($data); |
|
1906 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1907 | + $line['symbol'] === 'Car' || |
|
1908 | + $line['symbol'] === 'Ambulance' || |
|
1909 | + $line['symbol'] === 'Van' || |
|
1910 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1911 | + $line['symbol'] === 'Motorcycle' || |
|
1912 | + $line['symbol'] === 'Tractor' || |
|
1913 | + $line['symbol'] === 'Police' || |
|
1914 | + $line['symbol'] === 'Bike' || |
|
1915 | + $line['symbol'] === 'Jogger' || |
|
1916 | + $line['symbol'] === 'Horse' || |
|
1917 | + $line['symbol'] === 'Bus' || |
|
1918 | + $line['symbol'] === 'Jeep' || |
|
1919 | + $line['symbol'] === 'Recreational Vehicle' || |
|
1920 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1921 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
1922 | + $line['symbol'] === 'Firetruck' || |
|
1923 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1924 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1925 | + $line['symbol'] === 'SUV' || |
|
1926 | + $line['symbol'] === 'Snowmobile' || |
|
1927 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
1928 | + //} 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') { |
|
1929 | 1929 | // } 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') { |
1930 | 1930 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1931 | 1931 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1932 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1932 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1933 | 1933 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1934 | 1934 | $Source->deleteOldLocationByType('gs'); |
1935 | 1935 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1937,7 +1937,7 @@ discard block |
||
1937 | 1937 | } else { |
1938 | 1938 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1939 | 1939 | } |
1940 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1940 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1941 | 1941 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1942 | 1942 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1943 | 1943 | $Source->deleteOldLocationByType('wx'); |
@@ -1947,7 +1947,7 @@ discard block |
||
1947 | 1947 | } else { |
1948 | 1948 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1949 | 1949 | } |
1950 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1950 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1951 | 1951 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1952 | 1952 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1953 | 1953 | $Source->deleteOldLocationByType('lightning'); |
@@ -1956,11 +1956,11 @@ discard block |
||
1956 | 1956 | } else { |
1957 | 1957 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1958 | 1958 | } |
1959 | - } elseif ($globalDebug) { |
|
1960 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1961 | - print_r($line); |
|
1962 | - } |
|
1963 | - unset($data); |
|
1959 | + } elseif ($globalDebug) { |
|
1960 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1961 | + print_r($line); |
|
1962 | + } |
|
1963 | + unset($data); |
|
1964 | 1964 | } |
1965 | 1965 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1966 | 1966 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1979,13 +1979,13 @@ discard block |
||
1979 | 1979 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1980 | 1980 | $globalSources[$nb]['last_weather_clean'] = time(); |
1981 | 1981 | } |
1982 | - } |
|
1982 | + } |
|
1983 | 1983 | } else { |
1984 | - $line = explode(',', $buffer); |
|
1985 | - //print_r($line); |
|
1986 | - if (count($line) > 20) { |
|
1987 | - $data['hex'] = $line[4]; |
|
1988 | - /* |
|
1984 | + $line = explode(',', $buffer); |
|
1985 | + //print_r($line); |
|
1986 | + if (count($line) > 20) { |
|
1987 | + $data['hex'] = $line[4]; |
|
1988 | + /* |
|
1989 | 1989 | $data['datetime'] = $line[6].' '.$line[7]; |
1990 | 1990 | date_default_timezone_set($globalTimezone); |
1991 | 1991 | $datetime = new DateTime($data['datetime']); |
@@ -1993,31 +1993,31 @@ discard block |
||
1993 | 1993 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1994 | 1994 | date_default_timezone_set('UTC'); |
1995 | 1995 | */ |
1996 | - // Force datetime to current UTC datetime |
|
1997 | - date_default_timezone_set('UTC'); |
|
1998 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1999 | - $data['ident'] = trim($line[10]); |
|
2000 | - $data['latitude'] = $line[14]; |
|
2001 | - $data['longitude'] = $line[15]; |
|
2002 | - $data['verticalrate'] = $line[16]; |
|
2003 | - $data['emergency'] = $line[20]; |
|
2004 | - $data['speed'] = $line[12]; |
|
2005 | - $data['squawk'] = $line[17]; |
|
2006 | - $data['altitude'] = $line[11]; |
|
2007 | - $data['heading'] = $line[13]; |
|
2008 | - $data['ground'] = $line[21]; |
|
2009 | - $data['emergency'] = $line[19]; |
|
2010 | - $data['format_source'] = 'sbs'; |
|
1996 | + // Force datetime to current UTC datetime |
|
1997 | + date_default_timezone_set('UTC'); |
|
1998 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1999 | + $data['ident'] = trim($line[10]); |
|
2000 | + $data['latitude'] = $line[14]; |
|
2001 | + $data['longitude'] = $line[15]; |
|
2002 | + $data['verticalrate'] = $line[16]; |
|
2003 | + $data['emergency'] = $line[20]; |
|
2004 | + $data['speed'] = $line[12]; |
|
2005 | + $data['squawk'] = $line[17]; |
|
2006 | + $data['altitude'] = $line[11]; |
|
2007 | + $data['heading'] = $line[13]; |
|
2008 | + $data['ground'] = $line[21]; |
|
2009 | + $data['emergency'] = $line[19]; |
|
2010 | + $data['format_source'] = 'sbs'; |
|
2011 | 2011 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
2012 | 2012 | elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
2013 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2013 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2014 | 2014 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
2015 | - $data['id_source'] = $id_source; |
|
2016 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2017 | - else $error = true; |
|
2018 | - unset($data); |
|
2019 | - } else $error = true; |
|
2020 | - if ($error) { |
|
2015 | + $data['id_source'] = $id_source; |
|
2016 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2017 | + else $error = true; |
|
2018 | + unset($data); |
|
2019 | + } else $error = true; |
|
2020 | + if ($error) { |
|
2021 | 2021 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
2022 | 2022 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
2023 | 2023 | } else { |
@@ -2033,13 +2033,13 @@ discard block |
||
2033 | 2033 | connect_all($sourceer); |
2034 | 2034 | $sourceer = array(); |
2035 | 2035 | } |
2036 | - } |
|
2036 | + } |
|
2037 | 2037 | } |
2038 | 2038 | // Sleep for xxx microseconds |
2039 | 2039 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
2040 | - } else { |
|
2040 | + } else { |
|
2041 | 2041 | if ($format === 'flightgearmp') { |
2042 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2042 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2043 | 2043 | //@socket_close($r); |
2044 | 2044 | sleep($globalMinFetch); |
2045 | 2045 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2048,9 +2048,9 @@ discard block |
||
2048 | 2048 | break; |
2049 | 2049 | |
2050 | 2050 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
2051 | - if (isset($tt[$format])) $tt[$format]++; |
|
2052 | - else $tt[$format] = 0; |
|
2053 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
2051 | + if (isset($tt[$format])) $tt[$format]++; |
|
2052 | + else $tt[$format] = 0; |
|
2053 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
2054 | 2054 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
2055 | 2055 | //@socket_close($r); |
2056 | 2056 | sleep(2); |
@@ -2061,24 +2061,24 @@ discard block |
||
2061 | 2061 | //connect_all($globalSources); |
2062 | 2062 | $tt[$format]=0; |
2063 | 2063 | break; |
2064 | - } |
|
2065 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
2064 | + } |
|
2065 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
2066 | + } |
|
2066 | 2067 | } |
2067 | - } |
|
2068 | 2068 | } |
2069 | - } else { |
|
2069 | + } else { |
|
2070 | 2070 | $error = socket_strerror(socket_last_error()); |
2071 | 2071 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
2072 | 2072 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
2073 | 2073 | if (isset($globalDebug)) echo "Restarting...\n"; |
2074 | 2074 | // Restart the script if possible |
2075 | 2075 | if (is_array($sockets)) { |
2076 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2076 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
2077 | 2077 | |
2078 | - foreach ($sockets as $sock) { |
|
2078 | + foreach ($sockets as $sock) { |
|
2079 | 2079 | @socket_shutdown($sock,2); |
2080 | 2080 | @socket_close($sock); |
2081 | - } |
|
2081 | + } |
|
2082 | 2082 | |
2083 | 2083 | } |
2084 | 2084 | if ($globalDebug) echo "Waiting..."; |
@@ -2093,15 +2093,15 @@ discard block |
||
2093 | 2093 | if ($globalDebug) echo "Restart all connections..."; |
2094 | 2094 | connect_all($globalSources); |
2095 | 2095 | } |
2096 | - } |
|
2096 | + } |
|
2097 | 2097 | } |
2098 | 2098 | if ($globalDaemon === false) { |
2099 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
2100 | - if (isset($SI)) $SI->checkAll(); |
|
2101 | - if (isset($TI)) $TI->checkAll(); |
|
2102 | - if (isset($MI)) $MI->checkAll(); |
|
2099 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
2100 | + if (isset($SI)) $SI->checkAll(); |
|
2101 | + if (isset($TI)) $TI->checkAll(); |
|
2102 | + if (isset($MI)) $MI->checkAll(); |
|
2103 | + } |
|
2103 | 2104 | } |
2104 | - } |
|
2105 | 2105 | } |
2106 | 2106 | |
2107 | 2107 | ?> |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | - * Change IATA to ICAO value for ident |
|
36 | - * |
|
37 | - * @param String $ident ident |
|
38 | - * @return String the icao |
|
39 | - */ |
|
35 | + * Change IATA to ICAO value for ident |
|
36 | + * |
|
37 | + * @param String $ident ident |
|
38 | + * @return String the icao |
|
39 | + */ |
|
40 | 40 | public function ident2icao($ident) { |
41 | 41 | if (substr($ident,0,2) == 'AF') { |
42 | 42 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | - * Deletes all info in the live table |
|
56 | - * |
|
57 | - * @return String success or false |
|
58 | - * |
|
59 | - */ |
|
55 | + * Deletes all info in the live table |
|
56 | + * |
|
57 | + * @return String success or false |
|
58 | + * |
|
59 | + */ |
|
60 | 60 | public function deleteLiveAcarsData() |
61 | 61 | { |
62 | 62 | global $globalDBdriver; |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * Deletes all info in the archive table |
|
80 | - * |
|
81 | - * @return String success or false |
|
82 | - * |
|
83 | - */ |
|
79 | + * Deletes all info in the archive table |
|
80 | + * |
|
81 | + * @return String success or false |
|
82 | + * |
|
83 | + */ |
|
84 | 84 | public function deleteArchiveAcarsData() |
85 | 85 | { |
86 | 86 | global $globalACARSArchiveKeepMonths, $globalDBdriver; |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * Parse ACARS data |
|
105 | - * |
|
106 | - * @param String ACARS data in acarsdec data |
|
107 | - * |
|
108 | - * @return array |
|
109 | - */ |
|
103 | + /** |
|
104 | + * Parse ACARS data |
|
105 | + * |
|
106 | + * @param String ACARS data in acarsdec data |
|
107 | + * |
|
108 | + * @return array |
|
109 | + */ |
|
110 | 110 | public function parse($data) { |
111 | 111 | global $globalDebug; |
112 | 112 | //$Image = new Image($this->db); |
@@ -736,11 +736,11 @@ discard block |
||
736 | 736 | } |
737 | 737 | |
738 | 738 | /** |
739 | - * Add ACARS data |
|
740 | - * |
|
741 | - * @param String ACARS data in acarsdec data |
|
742 | - * |
|
743 | - */ |
|
739 | + * Add ACARS data |
|
740 | + * |
|
741 | + * @param String ACARS data in acarsdec data |
|
742 | + * |
|
743 | + */ |
|
744 | 744 | public function add($data,$message = array()) { |
745 | 745 | global $globalDebug, $globalACARSArchive; |
746 | 746 | $Image = new Image($this->db); |
@@ -787,18 +787,18 @@ discard block |
||
787 | 787 | } |
788 | 788 | } |
789 | 789 | |
790 | - /** |
|
791 | - * Add Live ACARS data in DB |
|
792 | - * |
|
793 | - * @param String $ident ident |
|
794 | - * @param String $registration Registration of the aircraft |
|
795 | - * @param String $label Label of the ACARS message |
|
796 | - * @param String $block_id Block id of the ACARS message |
|
797 | - * @param String $msg_no Number of the ACARS message |
|
798 | - * @param String $message ACARS message |
|
799 | - * @param string $decode |
|
800 | - * @return bool |
|
801 | - */ |
|
790 | + /** |
|
791 | + * Add Live ACARS data in DB |
|
792 | + * |
|
793 | + * @param String $ident ident |
|
794 | + * @param String $registration Registration of the aircraft |
|
795 | + * @param String $label Label of the ACARS message |
|
796 | + * @param String $block_id Block id of the ACARS message |
|
797 | + * @param String $msg_no Number of the ACARS message |
|
798 | + * @param String $message ACARS message |
|
799 | + * @param string $decode |
|
800 | + * @return bool |
|
801 | + */ |
|
802 | 802 | public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
803 | 803 | global $globalDebug; |
804 | 804 | date_default_timezone_set('UTC'); |
@@ -836,18 +836,18 @@ discard block |
||
836 | 836 | return false; |
837 | 837 | } |
838 | 838 | |
839 | - /** |
|
840 | - * Add Archive ACARS data in DB |
|
841 | - * |
|
842 | - * @param String $ident ident |
|
843 | - * @param String $registration Registration of the aircraft |
|
844 | - * @param String $label Label of the ACARS message |
|
845 | - * @param String $block_id Block id of the ACARS message |
|
846 | - * @param String $msg_no Number of the ACARS message |
|
847 | - * @param String $message ACARS message |
|
848 | - * @param string $decode |
|
849 | - * @return string |
|
850 | - */ |
|
839 | + /** |
|
840 | + * Add Archive ACARS data in DB |
|
841 | + * |
|
842 | + * @param String $ident ident |
|
843 | + * @param String $registration Registration of the aircraft |
|
844 | + * @param String $label Label of the ACARS message |
|
845 | + * @param String $block_id Block id of the ACARS message |
|
846 | + * @param String $msg_no Number of the ACARS message |
|
847 | + * @param String $message ACARS message |
|
848 | + * @param string $decode |
|
849 | + * @return string |
|
850 | + */ |
|
851 | 851 | public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
852 | 852 | global $globalDebug; |
853 | 853 | date_default_timezone_set('UTC'); |
@@ -879,11 +879,11 @@ discard block |
||
879 | 879 | } |
880 | 880 | |
881 | 881 | /** |
882 | - * Get Message title from label from DB |
|
883 | - * |
|
884 | - * @param String $label |
|
885 | - * @return String Return ACARS title |
|
886 | - */ |
|
882 | + * Get Message title from label from DB |
|
883 | + * |
|
884 | + * @param String $label |
|
885 | + * @return String Return ACARS title |
|
886 | + */ |
|
887 | 887 | public function getTitlefromLabel($label) { |
888 | 888 | $Connection = new Connection($this->db); |
889 | 889 | $this->db = $Connection->db; |
@@ -902,10 +902,10 @@ discard block |
||
902 | 902 | } |
903 | 903 | |
904 | 904 | /** |
905 | - * List all Message title & label from DB |
|
906 | - * |
|
907 | - * @return array Return ACARS data in array |
|
908 | - */ |
|
905 | + * List all Message title & label from DB |
|
906 | + * |
|
907 | + * @return array Return ACARS data in array |
|
908 | + */ |
|
909 | 909 | public function getAllTitleLabel() { |
910 | 910 | $query = "SELECT * FROM acars_label ORDER BY title"; |
911 | 911 | $query_values = array(); |
@@ -922,11 +922,11 @@ discard block |
||
922 | 922 | } |
923 | 923 | |
924 | 924 | /** |
925 | - * Get Live ACARS data from DB |
|
926 | - * |
|
927 | - * @param String $ident |
|
928 | - * @return array Return ACARS data in array |
|
929 | - */ |
|
925 | + * Get Live ACARS data from DB |
|
926 | + * |
|
927 | + * @param String $ident |
|
928 | + * @return array Return ACARS data in array |
|
929 | + */ |
|
930 | 930 | public function getLiveAcarsData($ident) { |
931 | 931 | $query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC"; |
932 | 932 | $query_values = array(':ident' => $ident); |
@@ -942,13 +942,13 @@ discard block |
||
942 | 942 | else return array(); |
943 | 943 | } |
944 | 944 | |
945 | - /** |
|
946 | - * Get Latest ACARS data from DB |
|
947 | - * |
|
948 | - * @param string $limit |
|
949 | - * @param string $label |
|
950 | - * @return array Return ACARS data in array |
|
951 | - */ |
|
945 | + /** |
|
946 | + * Get Latest ACARS data from DB |
|
947 | + * |
|
948 | + * @param string $limit |
|
949 | + * @param string $label |
|
950 | + * @return array Return ACARS data in array |
|
951 | + */ |
|
952 | 952 | public function getLatestAcarsData($limit = '',$label = '') { |
953 | 953 | global $globalURL; |
954 | 954 | $Image = new Image($this->db); |
@@ -1036,13 +1036,13 @@ discard block |
||
1036 | 1036 | else return array(); |
1037 | 1037 | } |
1038 | 1038 | |
1039 | - /** |
|
1040 | - * Get Archive ACARS data from DB |
|
1041 | - * |
|
1042 | - * @param string $limit |
|
1043 | - * @param string $label |
|
1044 | - * @return array Return ACARS data in array |
|
1045 | - */ |
|
1039 | + /** |
|
1040 | + * Get Archive ACARS data from DB |
|
1041 | + * |
|
1042 | + * @param string $limit |
|
1043 | + * @param string $label |
|
1044 | + * @return array Return ACARS data in array |
|
1045 | + */ |
|
1046 | 1046 | public function getArchiveAcarsData($limit = '',$label = '') { |
1047 | 1047 | global $globalURL; |
1048 | 1048 | $Image = new Image($this->db); |
@@ -1131,17 +1131,17 @@ discard block |
||
1131 | 1131 | } else return array(); |
1132 | 1132 | } |
1133 | 1133 | |
1134 | - /** |
|
1135 | - * Add ModeS data to DB |
|
1136 | - * |
|
1137 | - * @param String $ident ident |
|
1138 | - * @param String $registration Registration of the aircraft |
|
1139 | - * @param String $icao |
|
1140 | - * @param String $ICAOTypeCode |
|
1141 | - * @param string $latitude |
|
1142 | - * @param string $longitude |
|
1143 | - * @return string |
|
1144 | - */ |
|
1134 | + /** |
|
1135 | + * Add ModeS data to DB |
|
1136 | + * |
|
1137 | + * @param String $ident ident |
|
1138 | + * @param String $registration Registration of the aircraft |
|
1139 | + * @param String $icao |
|
1140 | + * @param String $ICAOTypeCode |
|
1141 | + * @param string $latitude |
|
1142 | + * @param string $longitude |
|
1143 | + * @return string |
|
1144 | + */ |
|
1145 | 1145 | public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
1146 | 1146 | global $globalDebug, $globalDBdriver; |
1147 | 1147 | $ident = trim($ident); |