@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,46 +25,46 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->connectionExists() === false) { |
28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | - exit(); |
|
28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if ($Connection->latest() === false) { |
32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | - exit(); |
|
32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | + exit(); |
|
34 | 34 | } |
35 | 35 | if (PHP_SAPI != 'cli') { |
36 | - echo "This script MUST be called from console, not a web browser."; |
|
36 | + echo "This script MUST be called from console, not a web browser."; |
|
37 | 37 | // exit(); |
38 | 38 | } |
39 | 39 | |
40 | 40 | // This is to be compatible with old version of settings.php |
41 | 41 | if (!isset($globalSources)) { |
42 | - if (isset($globalSBS1Hosts)) { |
|
43 | - //$hosts = $globalSBS1Hosts; |
|
44 | - foreach ($globalSBS1Hosts as $host) { |
|
45 | - $globalSources[] = array('host' => $host); |
|
46 | - } |
|
47 | - } else { |
|
48 | - if (!isset($globalSBS1Host)) { |
|
49 | - echo '$globalSources MUST be defined !'; |
|
50 | - die; |
|
42 | + if (isset($globalSBS1Hosts)) { |
|
43 | + //$hosts = $globalSBS1Hosts; |
|
44 | + foreach ($globalSBS1Hosts as $host) { |
|
45 | + $globalSources[] = array('host' => $host); |
|
46 | + } |
|
47 | + } else { |
|
48 | + if (!isset($globalSBS1Host)) { |
|
49 | + echo '$globalSources MUST be defined !'; |
|
50 | + die; |
|
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $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')); |
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['s']); |
|
64 | 64 | } elseif (isset($options['source'])) { |
65 | - $globalSources = array(); |
|
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
65 | + $globalSources = array(); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | + else $globalSources[] = array('host' => $options['source']); |
|
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
70 | 70 | $globalServerAPRS = TRUE; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
104 | 104 | else $id_source = 1; |
105 | 105 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | - $SI=new SpotterServer(); |
|
106 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | + $SI=new SpotterServer(); |
|
108 | 108 | /* |
109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 110 | $SI = new adsb2aprs(); |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | |
115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
116 | 116 | if (isset($globalMarine) && $globalMarine) { |
117 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
117 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
122 | 122 | if (isset($globalMarine) && $globalMarine) { |
123 | - $AIS = new AIS(); |
|
124 | - $MI = new MarineImport($Connection->db); |
|
123 | + $AIS = new AIS(); |
|
124 | + $MI = new MarineImport($Connection->db); |
|
125 | 125 | } |
126 | 126 | //$APRS=new APRS($Connection->db); |
127 | 127 | $SBS=new SBS(); |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | //$servertz = system('date +%Z'); |
135 | 135 | // signal handler - playing nice with sockets and dump1090 |
136 | 136 | if (function_exists('pcntl_fork')) { |
137 | - pcntl_signal(SIGINT, function() { |
|
138 | - global $sockets; |
|
139 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | - die("Bye!\n"); |
|
141 | - }); |
|
142 | - pcntl_signal_dispatch(); |
|
137 | + pcntl_signal(SIGINT, function() { |
|
138 | + global $sockets; |
|
139 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | + die("Bye!\n"); |
|
141 | + }); |
|
142 | + pcntl_signal_dispatch(); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // let's try and connect |
@@ -149,41 +149,41 @@ discard block |
||
149 | 149 | $reset = 0; |
150 | 150 | |
151 | 151 | function connect_all($hosts) { |
152 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | - $reset++; |
|
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | - foreach ($hosts as $id => $value) { |
|
152 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | + $reset++; |
|
155 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | + foreach ($hosts as $id => $value) { |
|
157 | 157 | $host = $value['host']; |
158 | 158 | $globalSources[$id]['last_exec'] = 0; |
159 | 159 | // Here we check type of source(s) |
160 | 160 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | - //$formats[$id] = 'deltadbtxt'; |
|
163 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | - //$last_exec['deltadbtxt'] = 0; |
|
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | - //$formats[$id] = 'vatsimtxt'; |
|
168 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | - //$last_exec['vatsimtxt'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | - //$formats[$id] = 'aircraftlistjson'; |
|
173 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | - //$last_exec['aircraftlistjson'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
177 | - //$formats[$id] = 'aircraftjson'; |
|
178 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
179 | - //$last_exec['aircraftlistjson'] = 0; |
|
180 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
181 | - } else if (preg_match('/opensky/i',$host)) { |
|
182 | - //$formats[$id] = 'aircraftlistjson'; |
|
183 | - $globalSources[$id]['format'] = 'opensky'; |
|
184 | - //$last_exec['aircraftlistjson'] = 0; |
|
185 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
186 | - /* |
|
161 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | + //$formats[$id] = 'deltadbtxt'; |
|
163 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | + //$last_exec['deltadbtxt'] = 0; |
|
165 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | + //$formats[$id] = 'vatsimtxt'; |
|
168 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | + //$last_exec['vatsimtxt'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | + //$formats[$id] = 'aircraftlistjson'; |
|
173 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | + //$last_exec['aircraftlistjson'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | + } else if (preg_match('/aircraft.json$/i',$host)) { |
|
177 | + //$formats[$id] = 'aircraftjson'; |
|
178 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
179 | + //$last_exec['aircraftlistjson'] = 0; |
|
180 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
181 | + } else if (preg_match('/opensky/i',$host)) { |
|
182 | + //$formats[$id] = 'aircraftlistjson'; |
|
183 | + $globalSources[$id]['format'] = 'opensky'; |
|
184 | + //$last_exec['aircraftlistjson'] = 0; |
|
185 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
186 | + /* |
|
187 | 187 | // Disabled for now, site change source format |
188 | 188 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
189 | 189 | //$formats[$id] = 'radarvirtueljson'; |
@@ -195,125 +195,125 @@ discard block |
||
195 | 195 | exit(0); |
196 | 196 | } |
197 | 197 | */ |
198 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
199 | - //$formats[$id] = 'planeupdatefaa'; |
|
200 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
201 | - //$last_exec['planeupdatefaa'] = 0; |
|
202 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
203 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
204 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
205 | - exit(0); |
|
206 | - } |
|
207 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
208 | - //$formats[$id] = 'phpvmacars'; |
|
209 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
210 | - //$last_exec['phpvmacars'] = 0; |
|
211 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
212 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
213 | - //$formats[$id] = 'phpvmacars'; |
|
214 | - $globalSources[$id]['format'] = 'vaos'; |
|
215 | - //$last_exec['phpvmacars'] = 0; |
|
216 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
217 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
218 | - //$formats[$id] = 'phpvmacars'; |
|
219 | - $globalSources[$id]['format'] = 'vam'; |
|
220 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
221 | - } else if (preg_match('/whazzup/i',$host)) { |
|
222 | - //$formats[$id] = 'whazzup'; |
|
223 | - $globalSources[$id]['format'] = 'whazzup'; |
|
224 | - //$last_exec['whazzup'] = 0; |
|
225 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
226 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
227 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
228 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
229 | - } else if (preg_match('/airwhere/i',$host)) { |
|
230 | - $globalSources[$id]['format'] = 'airwhere'; |
|
231 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
232 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
233 | - //$formats[$id] = 'pirepsjson'; |
|
234 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
235 | - //$last_exec['pirepsjson'] = 0; |
|
236 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
237 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
238 | - //$formats[$id] = 'fr24json'; |
|
239 | - $globalSources[$id]['format'] = 'fr24json'; |
|
240 | - //$last_exec['fr24json'] = 0; |
|
241 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
242 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
243 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
244 | - exit(0); |
|
245 | - } |
|
246 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
247 | - //$formats[$id] = 'fr24json'; |
|
248 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
249 | - //$last_exec['fr24json'] = 0; |
|
250 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
251 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
252 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
253 | - exit(0); |
|
254 | - } |
|
255 | - //} else if (preg_match('/10001/',$host)) { |
|
256 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
257 | - //$formats[$id] = 'tsv'; |
|
258 | - $globalSources[$id]['format'] = 'tsv'; |
|
259 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
260 | - } |
|
261 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
262 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
263 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
264 | - if ($idf !== false) { |
|
265 | - $httpfeeds[$id] = $idf; |
|
266 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
267 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
268 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
269 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
270 | - $hostport = explode(':',$host); |
|
271 | - if (isset($hostport[1])) { |
|
198 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
199 | + //$formats[$id] = 'planeupdatefaa'; |
|
200 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
201 | + //$last_exec['planeupdatefaa'] = 0; |
|
202 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
203 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
204 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
205 | + exit(0); |
|
206 | + } |
|
207 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
208 | + //$formats[$id] = 'phpvmacars'; |
|
209 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
210 | + //$last_exec['phpvmacars'] = 0; |
|
211 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
212 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
213 | + //$formats[$id] = 'phpvmacars'; |
|
214 | + $globalSources[$id]['format'] = 'vaos'; |
|
215 | + //$last_exec['phpvmacars'] = 0; |
|
216 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
217 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
218 | + //$formats[$id] = 'phpvmacars'; |
|
219 | + $globalSources[$id]['format'] = 'vam'; |
|
220 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
221 | + } else if (preg_match('/whazzup/i',$host)) { |
|
222 | + //$formats[$id] = 'whazzup'; |
|
223 | + $globalSources[$id]['format'] = 'whazzup'; |
|
224 | + //$last_exec['whazzup'] = 0; |
|
225 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
226 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
227 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
228 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
229 | + } else if (preg_match('/airwhere/i',$host)) { |
|
230 | + $globalSources[$id]['format'] = 'airwhere'; |
|
231 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
232 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
233 | + //$formats[$id] = 'pirepsjson'; |
|
234 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
235 | + //$last_exec['pirepsjson'] = 0; |
|
236 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
237 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
238 | + //$formats[$id] = 'fr24json'; |
|
239 | + $globalSources[$id]['format'] = 'fr24json'; |
|
240 | + //$last_exec['fr24json'] = 0; |
|
241 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
242 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
243 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
244 | + exit(0); |
|
245 | + } |
|
246 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
247 | + //$formats[$id] = 'fr24json'; |
|
248 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
249 | + //$last_exec['fr24json'] = 0; |
|
250 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
251 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
252 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
253 | + exit(0); |
|
254 | + } |
|
255 | + //} else if (preg_match('/10001/',$host)) { |
|
256 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
257 | + //$formats[$id] = 'tsv'; |
|
258 | + $globalSources[$id]['format'] = 'tsv'; |
|
259 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
260 | + } |
|
261 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
262 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
263 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
264 | + if ($idf !== false) { |
|
265 | + $httpfeeds[$id] = $idf; |
|
266 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
267 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
268 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
269 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
270 | + $hostport = explode(':',$host); |
|
271 | + if (isset($hostport[1])) { |
|
272 | 272 | $port = $hostport[1]; |
273 | 273 | $hostn = $hostport[0]; |
274 | - } else { |
|
274 | + } else { |
|
275 | 275 | $port = $globalSources[$id]['port']; |
276 | 276 | $hostn = $globalSources[$id]['host']; |
277 | - } |
|
278 | - $Common = new Common(); |
|
279 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
280 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
281 | - } else { |
|
282 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
283 | - } |
|
284 | - if ($s) { |
|
285 | - $sockets[$id] = $s; |
|
286 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
287 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
277 | + } |
|
278 | + $Common = new Common(); |
|
279 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
280 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
281 | + } else { |
|
282 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
283 | + } |
|
284 | + if ($s) { |
|
285 | + $sockets[$id] = $s; |
|
286 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
287 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
288 | 288 | //$formats[$id] = 'aprs'; |
289 | 289 | $globalSources[$id]['format'] = 'aprs'; |
290 | 290 | //$aprs_connect = 0; |
291 | 291 | //$use_aprs = true; |
292 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
292 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
293 | 293 | $globalSources[$id]['format'] = 'vrstcp'; |
294 | - } elseif ($port == '10001') { |
|
295 | - //$formats[$id] = 'tsv'; |
|
296 | - $globalSources[$id]['format'] = 'tsv'; |
|
297 | - } elseif ($port == '30002') { |
|
298 | - //$formats[$id] = 'raw'; |
|
299 | - $globalSources[$id]['format'] = 'raw'; |
|
300 | - } elseif ($port == '5001') { |
|
301 | - //$formats[$id] = 'raw'; |
|
302 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
303 | - } elseif ($port == '30005') { |
|
294 | + } elseif ($port == '10001') { |
|
295 | + //$formats[$id] = 'tsv'; |
|
296 | + $globalSources[$id]['format'] = 'tsv'; |
|
297 | + } elseif ($port == '30002') { |
|
298 | + //$formats[$id] = 'raw'; |
|
299 | + $globalSources[$id]['format'] = 'raw'; |
|
300 | + } elseif ($port == '5001') { |
|
301 | + //$formats[$id] = 'raw'; |
|
302 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
303 | + } elseif ($port == '30005') { |
|
304 | 304 | // Not yet supported |
305 | - //$formats[$id] = 'beast'; |
|
306 | - $globalSources[$id]['format'] = 'beast'; |
|
307 | - //} else $formats[$id] = 'sbs'; |
|
308 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
309 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
305 | + //$formats[$id] = 'beast'; |
|
306 | + $globalSources[$id]['format'] = 'beast'; |
|
307 | + //} else $formats[$id] = 'sbs'; |
|
308 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
309 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
310 | 310 | } |
311 | 311 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
312 | - } else { |
|
312 | + } else { |
|
313 | 313 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
314 | - } |
|
315 | - } |
|
316 | - } |
|
314 | + } |
|
315 | + } |
|
316 | + } |
|
317 | 317 | } |
318 | 318 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
319 | 319 | |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | //connect_all($globalSources); |
337 | 337 | |
338 | 338 | if (isset($globalProxy) && $globalProxy) { |
339 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
339 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
340 | 340 | } else { |
341 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
341 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | // APRS Configuration |
@@ -347,21 +347,21 @@ discard block |
||
347 | 347 | die; |
348 | 348 | } |
349 | 349 | foreach ($globalSources as $key => $source) { |
350 | - if (!isset($source['format'])) { |
|
351 | - $globalSources[$key]['format'] = 'auto'; |
|
352 | - } |
|
353 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
354 | - unset($globalSources[$key]); |
|
355 | - } |
|
350 | + if (!isset($source['format'])) { |
|
351 | + $globalSources[$key]['format'] = 'auto'; |
|
352 | + } |
|
353 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
354 | + unset($globalSources[$key]); |
|
355 | + } |
|
356 | 356 | } |
357 | 357 | connect_all($globalSources); |
358 | 358 | foreach ($globalSources as $key => $source) { |
359 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
359 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
360 | 360 | $aprs_connect = 0; |
361 | 361 | $use_aprs = true; |
362 | 362 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
363 | 363 | break; |
364 | - } |
|
364 | + } |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | if ($use_aprs) { |
@@ -402,133 +402,133 @@ discard block |
||
402 | 402 | |
403 | 403 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
404 | 404 | while ($i > 0) { |
405 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
405 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
406 | 406 | |
407 | - if (!$globalDaemon) $i = $endtime-time(); |
|
408 | - // Delete old ATC |
|
409 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
407 | + if (!$globalDaemon) $i = $endtime-time(); |
|
408 | + // Delete old ATC |
|
409 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
410 | 410 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
411 | - $ATC->deleteOldATC(); |
|
412 | - } |
|
411 | + $ATC->deleteOldATC(); |
|
412 | + } |
|
413 | 413 | |
414 | - if (count($last_exec) == count($globalSources)) { |
|
414 | + if (count($last_exec) == count($globalSources)) { |
|
415 | 415 | $max = $globalMinFetch; |
416 | 416 | foreach ($last_exec as $last) { |
417 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
417 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
418 | 418 | } |
419 | 419 | if ($max < $globalMinFetch) { |
420 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
421 | - sleep($globalMinFetch-$max+2); |
|
420 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
421 | + sleep($globalMinFetch-$max+2); |
|
422 | + } |
|
422 | 423 | } |
423 | - } |
|
424 | 424 | |
425 | 425 | |
426 | - //foreach ($formats as $id => $value) { |
|
427 | - foreach ($globalSources as $id => $value) { |
|
426 | + //foreach ($formats as $id => $value) { |
|
427 | + foreach ($globalSources as $id => $value) { |
|
428 | 428 | date_default_timezone_set('UTC'); |
429 | 429 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
430 | 430 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
431 | 431 | if ($value['format'] === 'deltadbtxt' && |
432 | - ( |
|
432 | + ( |
|
433 | 433 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
434 | 434 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
435 | - ) |
|
435 | + ) |
|
436 | 436 | ) { |
437 | - //$buffer = $Common->getData($hosts[$id]); |
|
438 | - $buffer = $Common->getData($value['host']); |
|
439 | - if ($buffer != '') $reset = 0; |
|
440 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
441 | - $buffer = explode('\n',$buffer); |
|
442 | - foreach ($buffer as $line) { |
|
443 | - if ($line != '' && count($line) > 7) { |
|
444 | - $line = explode(',', $line); |
|
445 | - $data = array(); |
|
446 | - $data['hex'] = $line[1]; // hex |
|
447 | - $data['ident'] = $line[2]; // ident |
|
448 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
449 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
450 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
451 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
452 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
453 | - $data['verticalrate'] = ''; // vertical rate |
|
454 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
455 | - $data['emergency'] = ''; // emergency |
|
456 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
457 | - $data['format_source'] = 'deltadbtxt'; |
|
458 | - $data['id_source'] = $id_source; |
|
459 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
460 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
461 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
462 | - $SI->add($data); |
|
463 | - unset($data); |
|
464 | - } |
|
465 | - } |
|
466 | - $last_exec[$id]['last'] = time(); |
|
437 | + //$buffer = $Common->getData($hosts[$id]); |
|
438 | + $buffer = $Common->getData($value['host']); |
|
439 | + if ($buffer != '') $reset = 0; |
|
440 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
441 | + $buffer = explode('\n',$buffer); |
|
442 | + foreach ($buffer as $line) { |
|
443 | + if ($line != '' && count($line) > 7) { |
|
444 | + $line = explode(',', $line); |
|
445 | + $data = array(); |
|
446 | + $data['hex'] = $line[1]; // hex |
|
447 | + $data['ident'] = $line[2]; // ident |
|
448 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
449 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
450 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
451 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
452 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
453 | + $data['verticalrate'] = ''; // vertical rate |
|
454 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
455 | + $data['emergency'] = ''; // emergency |
|
456 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
457 | + $data['format_source'] = 'deltadbtxt'; |
|
458 | + $data['id_source'] = $id_source; |
|
459 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
460 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
461 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
462 | + $SI->add($data); |
|
463 | + unset($data); |
|
464 | + } |
|
465 | + } |
|
466 | + $last_exec[$id]['last'] = time(); |
|
467 | 467 | } elseif ($value['format'] === 'aisnmeatxt' && |
468 | - ( |
|
468 | + ( |
|
469 | 469 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
470 | 470 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
471 | - ) |
|
471 | + ) |
|
472 | 472 | ) { |
473 | - date_default_timezone_set('CET'); |
|
474 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
475 | - date_default_timezone_set('UTC'); |
|
476 | - if ($buffer != '') $reset = 0; |
|
477 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
478 | - $buffer = explode('\n',$buffer); |
|
479 | - foreach ($buffer as $line) { |
|
473 | + date_default_timezone_set('CET'); |
|
474 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
475 | + date_default_timezone_set('UTC'); |
|
476 | + if ($buffer != '') $reset = 0; |
|
477 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
478 | + $buffer = explode('\n',$buffer); |
|
479 | + foreach ($buffer as $line) { |
|
480 | 480 | if ($line != '') { |
481 | - //echo "'".$line."'\n"; |
|
482 | - $add = false; |
|
483 | - $ais_data = $AIS->parse_line(trim($line)); |
|
484 | - $data = array(); |
|
485 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
486 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
487 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
488 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
489 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
490 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
491 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
492 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
493 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
494 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
495 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
496 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
497 | - if (isset($ais_data['timestamp'])) { |
|
481 | + //echo "'".$line."'\n"; |
|
482 | + $add = false; |
|
483 | + $ais_data = $AIS->parse_line(trim($line)); |
|
484 | + $data = array(); |
|
485 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
486 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
487 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
488 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
489 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
490 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
491 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
492 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
493 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
494 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
495 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
496 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
497 | + if (isset($ais_data['timestamp'])) { |
|
498 | 498 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
499 | 499 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
500 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
501 | - $add = true; |
|
500 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
501 | + $add = true; |
|
502 | 502 | } |
503 | - } else { |
|
503 | + } else { |
|
504 | 504 | $data['datetime'] = date('Y-m-d H:i:s'); |
505 | 505 | $add = true; |
506 | - } |
|
507 | - $data['format_source'] = 'aisnmeatxt'; |
|
508 | - $data['id_source'] = $id_source; |
|
509 | - //print_r($data); |
|
510 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
511 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
512 | - unset($data); |
|
506 | + } |
|
507 | + $data['format_source'] = 'aisnmeatxt'; |
|
508 | + $data['id_source'] = $id_source; |
|
509 | + //print_r($data); |
|
510 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
511 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
512 | + unset($data); |
|
513 | 513 | } |
514 | - } |
|
515 | - $last_exec[$id]['last'] = time(); |
|
514 | + } |
|
515 | + $last_exec[$id]['last'] = time(); |
|
516 | 516 | } elseif ($value['format'] === 'aisnmeahttp') { |
517 | - $arr = $httpfeeds; |
|
518 | - $w = $e = null; |
|
517 | + $arr = $httpfeeds; |
|
518 | + $w = $e = null; |
|
519 | 519 | |
520 | - if (isset($arr[$id])) { |
|
520 | + if (isset($arr[$id])) { |
|
521 | 521 | $nn = stream_select($arr,$w,$e,$timeout); |
522 | 522 | if ($nn > 0) { |
523 | - foreach ($httpfeeds as $feed) { |
|
523 | + foreach ($httpfeeds as $feed) { |
|
524 | 524 | $buffer = stream_get_line($feed,2000,"\n"); |
525 | 525 | if ($buffer === FALSE) { |
526 | - connect_all($globalSources); |
|
526 | + connect_all($globalSources); |
|
527 | 527 | } |
528 | 528 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
529 | 529 | $buffer = explode('\n',$buffer); |
530 | 530 | foreach ($buffer as $line) { |
531 | - if ($line != '') { |
|
531 | + if ($line != '') { |
|
532 | 532 | $ais_data = $AIS->parse_line(trim($line)); |
533 | 533 | $data = array(); |
534 | 534 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -546,117 +546,117 @@ discard block |
||
546 | 546 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
547 | 547 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
548 | 548 | if (isset($ais_data['timestamp'])) { |
549 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
549 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
550 | 550 | } else { |
551 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
551 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
552 | 552 | } |
553 | 553 | $data['format_source'] = 'aisnmeahttp'; |
554 | 554 | $data['id_source'] = $id_source; |
555 | 555 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
556 | 556 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
557 | 557 | unset($data); |
558 | - } |
|
558 | + } |
|
559 | + } |
|
559 | 560 | } |
560 | - } |
|
561 | 561 | } else { |
562 | - $format = $value['format']; |
|
563 | - if (isset($tt[$format])) $tt[$format]++; |
|
564 | - else $tt[$format] = 0; |
|
565 | - if ($tt[$format] > 30) { |
|
562 | + $format = $value['format']; |
|
563 | + if (isset($tt[$format])) $tt[$format]++; |
|
564 | + else $tt[$format] = 0; |
|
565 | + if ($tt[$format] > 30) { |
|
566 | 566 | if ($globalDebug) echo 'Reconnect...'."\n"; |
567 | 567 | sleep(2); |
568 | 568 | //$sourceeen[] = $value; |
569 | 569 | //connect_all($sourceeen); |
570 | 570 | //$sourceeen = array(); |
571 | 571 | connect_all($globalSources); |
572 | - } |
|
572 | + } |
|
573 | + } |
|
573 | 574 | } |
574 | - } |
|
575 | 575 | } elseif ($value['format'] === 'myshiptracking' && |
576 | - ( |
|
576 | + ( |
|
577 | 577 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
578 | 578 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
579 | - ) |
|
579 | + ) |
|
580 | 580 | ) { |
581 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
582 | - if ($buffer != '') { |
|
581 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
582 | + if ($buffer != '') { |
|
583 | 583 | //echo $buffer; |
584 | 584 | $all_data = json_decode($buffer,true); |
585 | 585 | //print_r($all_data); |
586 | 586 | if (isset($all_data[0]['DATA'])) { |
587 | - foreach ($all_data[0]['DATA'] as $line) { |
|
587 | + foreach ($all_data[0]['DATA'] as $line) { |
|
588 | 588 | if ($line != '') { |
589 | - $data = array(); |
|
590 | - $data['ident'] = $line['NAME']; |
|
591 | - $data['mmsi'] = $line['MMSI']; |
|
592 | - if (strlen($data['mmsi']) > 9) { |
|
589 | + $data = array(); |
|
590 | + $data['ident'] = $line['NAME']; |
|
591 | + $data['mmsi'] = $line['MMSI']; |
|
592 | + if (strlen($data['mmsi']) > 9) { |
|
593 | 593 | $data['mmsi'] = substr($data['mmsi'],-9); |
594 | - } |
|
595 | - $data['speed'] = $line['SOG']; |
|
596 | - $data['heading'] = $line['COG']; |
|
597 | - $data['latitude'] = $line['LAT']; |
|
598 | - $data['longitude'] = $line['LNG']; |
|
599 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
600 | - //$data['type_id'] = $line['TYPE']; |
|
601 | - $data['imo'] = $line['IMO']; |
|
602 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
603 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
604 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
605 | - $data['format_source'] = 'myshiptracking'; |
|
606 | - $data['id_source'] = $id_source; |
|
607 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
608 | - $MI->add($data); |
|
609 | - unset($data); |
|
594 | + } |
|
595 | + $data['speed'] = $line['SOG']; |
|
596 | + $data['heading'] = $line['COG']; |
|
597 | + $data['latitude'] = $line['LAT']; |
|
598 | + $data['longitude'] = $line['LNG']; |
|
599 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
600 | + //$data['type_id'] = $line['TYPE']; |
|
601 | + $data['imo'] = $line['IMO']; |
|
602 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
603 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
604 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
605 | + $data['format_source'] = 'myshiptracking'; |
|
606 | + $data['id_source'] = $id_source; |
|
607 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
608 | + $MI->add($data); |
|
609 | + unset($data); |
|
610 | 610 | } |
611 | - } |
|
611 | + } |
|
612 | + } |
|
612 | 613 | } |
613 | - } |
|
614 | - $last_exec[$id]['last'] = time(); |
|
614 | + $last_exec[$id]['last'] = time(); |
|
615 | 615 | } elseif ($value['format'] === 'boatbeaconapp' && |
616 | - ( |
|
616 | + ( |
|
617 | 617 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
618 | 618 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
619 | - ) |
|
619 | + ) |
|
620 | 620 | ) { |
621 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
622 | - if ($buffer != '') { |
|
621 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
622 | + if ($buffer != '') { |
|
623 | 623 | $all_data = json_decode($buffer,true); |
624 | 624 | if (isset($all_data[0]['mmsi'])) { |
625 | - foreach ($all_data as $line) { |
|
625 | + foreach ($all_data as $line) { |
|
626 | 626 | if ($line != '') { |
627 | - $data = array(); |
|
628 | - $data['ident'] = $line['shipname']; |
|
629 | - $data['callsign'] = $line['callsign']; |
|
630 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
631 | - $data['speed'] = $line['sog']; |
|
632 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
633 | - $data['latitude'] = $line['latitude']; |
|
634 | - $data['longitude'] = $line['longitude']; |
|
635 | - $data['type_id'] = $line['shiptype']; |
|
636 | - $data['arrival_code'] = $line['destination']; |
|
637 | - $data['datetime'] = $line['time']; |
|
638 | - $data['format_source'] = 'boatbeaconapp'; |
|
639 | - $data['id_source'] = $id_source; |
|
640 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
641 | - $MI->add($data); |
|
642 | - unset($data); |
|
627 | + $data = array(); |
|
628 | + $data['ident'] = $line['shipname']; |
|
629 | + $data['callsign'] = $line['callsign']; |
|
630 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
631 | + $data['speed'] = $line['sog']; |
|
632 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
633 | + $data['latitude'] = $line['latitude']; |
|
634 | + $data['longitude'] = $line['longitude']; |
|
635 | + $data['type_id'] = $line['shiptype']; |
|
636 | + $data['arrival_code'] = $line['destination']; |
|
637 | + $data['datetime'] = $line['time']; |
|
638 | + $data['format_source'] = 'boatbeaconapp'; |
|
639 | + $data['id_source'] = $id_source; |
|
640 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
641 | + $MI->add($data); |
|
642 | + unset($data); |
|
643 | + } |
|
643 | 644 | } |
644 | - } |
|
645 | 645 | } |
646 | 646 | |
647 | - } |
|
648 | - $last_exec[$id]['last'] = time(); |
|
647 | + } |
|
648 | + $last_exec[$id]['last'] = time(); |
|
649 | 649 | } elseif ($value['format'] === 'boatnerd' && |
650 | - ( |
|
650 | + ( |
|
651 | 651 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
652 | 652 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
653 | - ) |
|
653 | + ) |
|
654 | 654 | ) { |
655 | - $buffer = $Common->getData($value['host']); |
|
656 | - if ($buffer != '') { |
|
655 | + $buffer = $Common->getData($value['host']); |
|
656 | + if ($buffer != '') { |
|
657 | 657 | $all_data = json_decode($buffer,true); |
658 | 658 | if (isset($all_data['features'][0]['id'])) { |
659 | - foreach ($all_data['features'] as $line) { |
|
659 | + foreach ($all_data['features'] as $line) { |
|
660 | 660 | print_r($line); |
661 | 661 | $data = array(); |
662 | 662 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -676,80 +676,80 @@ discard block |
||
676 | 676 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
677 | 677 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
678 | 678 | unset($data); |
679 | - } |
|
679 | + } |
|
680 | 680 | } |
681 | 681 | |
682 | - } |
|
683 | - $last_exec[$id]['last'] = time(); |
|
682 | + } |
|
683 | + $last_exec[$id]['last'] = time(); |
|
684 | 684 | } elseif ($value['format'] === 'shipplotter' && |
685 | - ( |
|
685 | + ( |
|
686 | 686 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
687 | 687 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
688 | - ) |
|
688 | + ) |
|
689 | 689 | ) { |
690 | - echo 'download...'; |
|
691 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
692 | - echo 'done !'."\n"; |
|
693 | - // FIXME: Need more work |
|
694 | - if ($buffer != '') $reset = 0; |
|
695 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
696 | - $buffer = explode('\n',$buffer); |
|
697 | - foreach ($buffer as $line) { |
|
690 | + echo 'download...'; |
|
691 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
692 | + echo 'done !'."\n"; |
|
693 | + // FIXME: Need more work |
|
694 | + if ($buffer != '') $reset = 0; |
|
695 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
696 | + $buffer = explode('\n',$buffer); |
|
697 | + foreach ($buffer as $line) { |
|
698 | 698 | if ($line != '') { |
699 | - $data = array(); |
|
700 | - echo $line."\n"; |
|
701 | - $data['mmsi'] = (int)substr($line,0,9); |
|
702 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
703 | - $data['status_id'] = substr($line,21,2); |
|
704 | - $data['type_id'] = substr($line,24,3); |
|
705 | - $data['latitude'] = substr($line,29,9); |
|
706 | - $data['longitude'] = substr($line,41,9); |
|
707 | - $data['speed'] = round(substr($line,51,5)); |
|
708 | - //$data['course'] = substr($line,57,5); |
|
709 | - $data['heading'] = round(substr($line,63,3)); |
|
710 | - //$data['draft'] = substr($line,67,4); |
|
711 | - //$data['length'] = substr($line,72,3); |
|
712 | - //$data['beam'] = substr($line,76,2); |
|
713 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
714 | - //$data['callsign'] = trim(substr($line,100,7); |
|
715 | - $data['arrival_code'] = substr($line,108,20); |
|
716 | - //$data['etaDate'] = substr($line,129,5); |
|
717 | - //$data['etaTime'] = substr($line,135,5); |
|
718 | - $data['format_source'] = 'shipplotter'; |
|
719 | - $data['id_source'] = $id_source; |
|
720 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
721 | - //print_r($data); |
|
722 | - echo 'Add...'."\n"; |
|
723 | - $MI->add($data); |
|
724 | - unset($data); |
|
699 | + $data = array(); |
|
700 | + echo $line."\n"; |
|
701 | + $data['mmsi'] = (int)substr($line,0,9); |
|
702 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
703 | + $data['status_id'] = substr($line,21,2); |
|
704 | + $data['type_id'] = substr($line,24,3); |
|
705 | + $data['latitude'] = substr($line,29,9); |
|
706 | + $data['longitude'] = substr($line,41,9); |
|
707 | + $data['speed'] = round(substr($line,51,5)); |
|
708 | + //$data['course'] = substr($line,57,5); |
|
709 | + $data['heading'] = round(substr($line,63,3)); |
|
710 | + //$data['draft'] = substr($line,67,4); |
|
711 | + //$data['length'] = substr($line,72,3); |
|
712 | + //$data['beam'] = substr($line,76,2); |
|
713 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
714 | + //$data['callsign'] = trim(substr($line,100,7); |
|
715 | + $data['arrival_code'] = substr($line,108,20); |
|
716 | + //$data['etaDate'] = substr($line,129,5); |
|
717 | + //$data['etaTime'] = substr($line,135,5); |
|
718 | + $data['format_source'] = 'shipplotter'; |
|
719 | + $data['id_source'] = $id_source; |
|
720 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
721 | + //print_r($data); |
|
722 | + echo 'Add...'."\n"; |
|
723 | + $MI->add($data); |
|
724 | + unset($data); |
|
725 | 725 | } |
726 | - } |
|
727 | - $last_exec[$id]['last'] = time(); |
|
726 | + } |
|
727 | + $last_exec[$id]['last'] = time(); |
|
728 | 728 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
729 | 729 | } elseif ( |
730 | - ( |
|
730 | + ( |
|
731 | 731 | $value['format'] === 'whazzup' && |
732 | 732 | ( |
733 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
734 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
733 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
734 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
735 | 735 | ) |
736 | - ) || ( |
|
736 | + ) || ( |
|
737 | 737 | $value['format'] === 'vatsimtxt' && |
738 | 738 | ( |
739 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
740 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
739 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
740 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
741 | + ) |
|
741 | 742 | ) |
742 | - ) |
|
743 | 743 | ) { |
744 | - //$buffer = $Common->getData($hosts[$id]); |
|
745 | - $buffer = $Common->getData($value['host']); |
|
746 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
747 | - $buffer = explode('\n',$buffer); |
|
748 | - $reset = 0; |
|
749 | - foreach ($buffer as $line) { |
|
750 | - if ($line != '') { |
|
751 | - $line = explode(':', $line); |
|
752 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
744 | + //$buffer = $Common->getData($hosts[$id]); |
|
745 | + $buffer = $Common->getData($value['host']); |
|
746 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
747 | + $buffer = explode('\n',$buffer); |
|
748 | + $reset = 0; |
|
749 | + foreach ($buffer as $line) { |
|
750 | + if ($line != '') { |
|
751 | + $line = explode(':', $line); |
|
752 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
753 | 753 | $data = array(); |
754 | 754 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
755 | 755 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -762,37 +762,37 @@ discard block |
||
762 | 762 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
763 | 763 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
764 | 764 | $data['latitude'] = $line[5]; // lat |
765 | - $data['longitude'] = $line[6]; // long |
|
766 | - $data['verticalrate'] = ''; // vertical rate |
|
767 | - $data['squawk'] = ''; // squawk |
|
768 | - $data['emergency'] = ''; // emergency |
|
769 | - $data['waypoints'] = $line[30]; |
|
765 | + $data['longitude'] = $line[6]; // long |
|
766 | + $data['verticalrate'] = ''; // vertical rate |
|
767 | + $data['squawk'] = ''; // squawk |
|
768 | + $data['emergency'] = ''; // emergency |
|
769 | + $data['waypoints'] = $line[30]; |
|
770 | 770 | $data['datetime'] = date('Y-m-d H:i:s'); |
771 | 771 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
772 | 772 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
773 | - $data['departure_airport_icao'] = $line[11]; |
|
774 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
775 | - $data['arrival_airport_icao'] = $line[13]; |
|
773 | + $data['departure_airport_icao'] = $line[11]; |
|
774 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
775 | + $data['arrival_airport_icao'] = $line[13]; |
|
776 | 776 | $data['frequency'] = $line[4]; |
777 | 777 | $data['type'] = $line[18]; |
778 | 778 | $data['range'] = $line[19]; |
779 | 779 | if (isset($line[35])) $data['info'] = $line[35]; |
780 | - $data['id_source'] = $id_source; |
|
781 | - //$data['arrival_airport_time'] = ; |
|
782 | - if ($line[9] != '') { |
|
783 | - $aircraft_data = explode('/',$line[9]); |
|
784 | - if (isset($aircraft_data[1])) { |
|
785 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
786 | - } |
|
787 | - } |
|
788 | - /* |
|
780 | + $data['id_source'] = $id_source; |
|
781 | + //$data['arrival_airport_time'] = ; |
|
782 | + if ($line[9] != '') { |
|
783 | + $aircraft_data = explode('/',$line[9]); |
|
784 | + if (isset($aircraft_data[1])) { |
|
785 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
786 | + } |
|
787 | + } |
|
788 | + /* |
|
789 | 789 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
790 | 790 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
791 | 791 | */ |
792 | - $data['format_source'] = $value['format']; |
|
792 | + $data['format_source'] = $value['format']; |
|
793 | 793 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
794 | 794 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
795 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
795 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
796 | 796 | elseif ($line[3] === 'ATC') { |
797 | 797 | //print_r($data); |
798 | 798 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -813,21 +813,21 @@ discard block |
||
813 | 813 | 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']); |
814 | 814 | } |
815 | 815 | } |
816 | - unset($data); |
|
817 | - } |
|
818 | - } |
|
819 | - } |
|
820 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
821 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
822 | - $last_exec[$id]['last'] = time(); |
|
823 | - } elseif ($value['format'] === 'airwhere' && |
|
824 | - ( |
|
825 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
826 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
827 | - ) |
|
828 | - ) { |
|
829 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
830 | - if ($buffer != '') { |
|
816 | + unset($data); |
|
817 | + } |
|
818 | + } |
|
819 | + } |
|
820 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
821 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
822 | + $last_exec[$id]['last'] = time(); |
|
823 | + } elseif ($value['format'] === 'airwhere' && |
|
824 | + ( |
|
825 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
826 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
827 | + ) |
|
828 | + ) { |
|
829 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
830 | + if ($buffer != '') { |
|
831 | 831 | $all_data = simplexml_load_string($buffer); |
832 | 832 | foreach($all_data->children() as $childdata) { |
833 | 833 | $data = array(); |
@@ -849,10 +849,10 @@ discard block |
||
849 | 849 | $SI->add($data); |
850 | 850 | unset($data); |
851 | 851 | } |
852 | - } |
|
853 | - $Source->deleteOldLocationByType('gs'); |
|
854 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
855 | - if ($buffer != '') { |
|
852 | + } |
|
853 | + $Source->deleteOldLocationByType('gs'); |
|
854 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
855 | + if ($buffer != '') { |
|
856 | 856 | $all_data = simplexml_load_string($buffer); |
857 | 857 | foreach($all_data->children() as $childdata) { |
858 | 858 | $data = array(); |
@@ -870,8 +870,8 @@ discard block |
||
870 | 870 | } |
871 | 871 | unset($data); |
872 | 872 | } |
873 | - } |
|
874 | - $last_exec[$id]['last'] = time(); |
|
873 | + } |
|
874 | + $last_exec[$id]['last'] = time(); |
|
875 | 875 | /* |
876 | 876 | } if ($value['format'] === 'aircraftlistjson') { |
877 | 877 | print_r($globalSources); |
@@ -879,17 +879,17 @@ discard block |
||
879 | 879 | echo $globalMinFetch; |
880 | 880 | */ |
881 | 881 | } elseif ($value['format'] === 'aircraftlistjson' && |
882 | - ( |
|
882 | + ( |
|
883 | 883 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
884 | 884 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
885 | - ) |
|
885 | + ) |
|
886 | 886 | ) { |
887 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
888 | - if ($buffer != '') { |
|
889 | - $all_data = json_decode($buffer,true); |
|
887 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
888 | + if ($buffer != '') { |
|
889 | + $all_data = json_decode($buffer,true); |
|
890 | 890 | if (isset($all_data['acList'])) { |
891 | - $reset = 0; |
|
892 | - foreach ($all_data['acList'] as $line) { |
|
891 | + $reset = 0; |
|
892 | + foreach ($all_data['acList'] as $line) { |
|
893 | 893 | $data = array(); |
894 | 894 | $data['hex'] = $line['Icao']; // hex |
895 | 895 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -912,10 +912,10 @@ discard block |
||
912 | 912 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
913 | 913 | if (isset($data['latitude'])) $SI->add($data); |
914 | 914 | unset($data); |
915 | - } |
|
915 | + } |
|
916 | 916 | } elseif (is_array($all_data)) { |
917 | - $reset = 0; |
|
918 | - foreach ($all_data as $line) { |
|
917 | + $reset = 0; |
|
918 | + foreach ($all_data as $line) { |
|
919 | 919 | $data = array(); |
920 | 920 | $data['hex'] = $line['hex']; // hex |
921 | 921 | $data['ident'] = $line['flight']; // ident |
@@ -935,252 +935,252 @@ discard block |
||
935 | 935 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
936 | 936 | $SI->add($data); |
937 | 937 | unset($data); |
938 | - } |
|
938 | + } |
|
939 | 939 | } |
940 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
941 | - //$last_exec['aircraftlistjson'] = time(); |
|
942 | - $last_exec[$id]['last'] = time(); |
|
943 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
944 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
945 | - ( |
|
946 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
947 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
948 | - ) |
|
949 | - ) { |
|
950 | - $buffer = $Common->getData($value['host']); |
|
951 | - $all_data = json_decode($buffer,true); |
|
952 | - if (isset($all_data['planes'])) { |
|
940 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
941 | + //$last_exec['aircraftlistjson'] = time(); |
|
942 | + $last_exec[$id]['last'] = time(); |
|
943 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
944 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
945 | + ( |
|
946 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
947 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
948 | + ) |
|
949 | + ) { |
|
950 | + $buffer = $Common->getData($value['host']); |
|
951 | + $all_data = json_decode($buffer,true); |
|
952 | + if (isset($all_data['planes'])) { |
|
953 | 953 | $reset = 0; |
954 | 954 | foreach ($all_data['planes'] as $key => $line) { |
955 | - $data = array(); |
|
956 | - $data['hex'] = $key; // hex |
|
957 | - $data['ident'] = $line[3]; // ident |
|
958 | - $data['altitude'] = $line[6]; // altitude |
|
959 | - $data['speed'] = $line[8]; // speed |
|
960 | - $data['heading'] = $line[7]; // heading |
|
961 | - $data['latitude'] = $line[4]; // lat |
|
962 | - $data['longitude'] = $line[5]; // long |
|
963 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
964 | - $data['squawk'] = $line[10]; // squawk |
|
965 | - $data['emergency'] = ''; // emergency |
|
966 | - $data['registration'] = $line[2]; |
|
967 | - $data['aircraft_icao'] = $line[0]; |
|
968 | - $deparr = explode('-',$line[1]); |
|
969 | - if (count($deparr) === 2) { |
|
955 | + $data = array(); |
|
956 | + $data['hex'] = $key; // hex |
|
957 | + $data['ident'] = $line[3]; // ident |
|
958 | + $data['altitude'] = $line[6]; // altitude |
|
959 | + $data['speed'] = $line[8]; // speed |
|
960 | + $data['heading'] = $line[7]; // heading |
|
961 | + $data['latitude'] = $line[4]; // lat |
|
962 | + $data['longitude'] = $line[5]; // long |
|
963 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
964 | + $data['squawk'] = $line[10]; // squawk |
|
965 | + $data['emergency'] = ''; // emergency |
|
966 | + $data['registration'] = $line[2]; |
|
967 | + $data['aircraft_icao'] = $line[0]; |
|
968 | + $deparr = explode('-',$line[1]); |
|
969 | + if (count($deparr) === 2) { |
|
970 | 970 | $data['departure_airport_icao'] = $deparr[0]; |
971 | 971 | $data['arrival_airport_icao'] = $deparr[1]; |
972 | - } |
|
973 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
974 | - $data['format_source'] = 'planeupdatefaa'; |
|
975 | - $data['id_source'] = $id_source; |
|
976 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
977 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
978 | - $SI->add($data); |
|
979 | - unset($data); |
|
972 | + } |
|
973 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
974 | + $data['format_source'] = 'planeupdatefaa'; |
|
975 | + $data['id_source'] = $id_source; |
|
976 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
977 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
978 | + $SI->add($data); |
|
979 | + unset($data); |
|
980 | 980 | } |
981 | - } |
|
982 | - //$last_exec['planeupdatefaa'] = time(); |
|
983 | - $last_exec[$id]['last'] = time(); |
|
981 | + } |
|
982 | + //$last_exec['planeupdatefaa'] = time(); |
|
983 | + $last_exec[$id]['last'] = time(); |
|
984 | 984 | } elseif ($value['format'] === 'opensky' && |
985 | - ( |
|
985 | + ( |
|
986 | 986 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
987 | 987 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
988 | - ) |
|
988 | + ) |
|
989 | 989 | ) { |
990 | - $buffer = $Common->getData($value['host']); |
|
991 | - $all_data = json_decode($buffer,true); |
|
992 | - if (isset($all_data['states'])) { |
|
990 | + $buffer = $Common->getData($value['host']); |
|
991 | + $all_data = json_decode($buffer,true); |
|
992 | + if (isset($all_data['states'])) { |
|
993 | 993 | $reset = 0; |
994 | 994 | foreach ($all_data['states'] as $key => $line) { |
995 | - $data = array(); |
|
996 | - $data['hex'] = $line[0]; // hex |
|
997 | - $data['ident'] = trim($line[1]); // ident |
|
998 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
999 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
1000 | - $data['heading'] = round($line[10]); // heading |
|
1001 | - $data['latitude'] = $line[6]; // lat |
|
1002 | - $data['longitude'] = $line[5]; // long |
|
1003 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
1004 | - //$data['squawk'] = $line[10]; // squawk |
|
1005 | - //$data['emergency'] = ''; // emergency |
|
1006 | - //$data['registration'] = $line[2]; |
|
1007 | - //$data['aircraft_icao'] = $line[0]; |
|
1008 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1009 | - $data['format_source'] = 'opensky'; |
|
1010 | - $data['id_source'] = $id_source; |
|
1011 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1012 | - $SI->add($data); |
|
1013 | - unset($data); |
|
995 | + $data = array(); |
|
996 | + $data['hex'] = $line[0]; // hex |
|
997 | + $data['ident'] = trim($line[1]); // ident |
|
998 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
999 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
1000 | + $data['heading'] = round($line[10]); // heading |
|
1001 | + $data['latitude'] = $line[6]; // lat |
|
1002 | + $data['longitude'] = $line[5]; // long |
|
1003 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
1004 | + //$data['squawk'] = $line[10]; // squawk |
|
1005 | + //$data['emergency'] = ''; // emergency |
|
1006 | + //$data['registration'] = $line[2]; |
|
1007 | + //$data['aircraft_icao'] = $line[0]; |
|
1008 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1009 | + $data['format_source'] = 'opensky'; |
|
1010 | + $data['id_source'] = $id_source; |
|
1011 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1012 | + $SI->add($data); |
|
1013 | + unset($data); |
|
1014 | 1014 | } |
1015 | - } |
|
1016 | - //$last_exec['planeupdatefaa'] = time(); |
|
1017 | - $last_exec[$id]['last'] = time(); |
|
1015 | + } |
|
1016 | + //$last_exec['planeupdatefaa'] = time(); |
|
1017 | + $last_exec[$id]['last'] = time(); |
|
1018 | 1018 | } elseif ($value['format'] === 'aircraftjson' && |
1019 | - ( |
|
1019 | + ( |
|
1020 | 1020 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1021 | 1021 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1022 | - ) |
|
1022 | + ) |
|
1023 | 1023 | ) { |
1024 | - $buffer = $Common->getData($value['host']); |
|
1025 | - $all_data = json_decode($buffer,true); |
|
1026 | - if (isset($all_data['aircraft'])) { |
|
1024 | + $buffer = $Common->getData($value['host']); |
|
1025 | + $all_data = json_decode($buffer,true); |
|
1026 | + if (isset($all_data['aircraft'])) { |
|
1027 | 1027 | $reset = 0; |
1028 | 1028 | foreach ($all_data['aircraft'] as $key => $line) { |
1029 | - $data = array(); |
|
1030 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1031 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1032 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1033 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1034 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1035 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1036 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1037 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1038 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1039 | - //$data['emergency'] = ''; // emergency |
|
1040 | - //$data['registration'] = $line[2]; |
|
1041 | - //$data['aircraft_icao'] = $line[0]; |
|
1042 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1043 | - $data['format_source'] = 'aircraftjson'; |
|
1044 | - $data['id_source'] = $id_source; |
|
1045 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1046 | - $SI->add($data); |
|
1047 | - unset($data); |
|
1029 | + $data = array(); |
|
1030 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1031 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1032 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1033 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1034 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1035 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1036 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1037 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1038 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1039 | + //$data['emergency'] = ''; // emergency |
|
1040 | + //$data['registration'] = $line[2]; |
|
1041 | + //$data['aircraft_icao'] = $line[0]; |
|
1042 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1043 | + $data['format_source'] = 'aircraftjson'; |
|
1044 | + $data['id_source'] = $id_source; |
|
1045 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1046 | + $SI->add($data); |
|
1047 | + unset($data); |
|
1048 | 1048 | } |
1049 | - } |
|
1050 | - //$last_exec['planeupdatefaa'] = time(); |
|
1051 | - $last_exec[$id]['last'] = time(); |
|
1049 | + } |
|
1050 | + //$last_exec['planeupdatefaa'] = time(); |
|
1051 | + $last_exec[$id]['last'] = time(); |
|
1052 | 1052 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1053 | 1053 | } elseif ($value['format'] === 'fr24json' && |
1054 | - ( |
|
1054 | + ( |
|
1055 | 1055 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1056 | 1056 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1057 | - ) |
|
1057 | + ) |
|
1058 | 1058 | ) { |
1059 | - //$buffer = $Common->getData($hosts[$id]); |
|
1060 | - $buffer = $Common->getData($value['host']); |
|
1061 | - $all_data = json_decode($buffer,true); |
|
1062 | - if (!empty($all_data)) $reset = 0; |
|
1063 | - foreach ($all_data as $key => $line) { |
|
1059 | + //$buffer = $Common->getData($hosts[$id]); |
|
1060 | + $buffer = $Common->getData($value['host']); |
|
1061 | + $all_data = json_decode($buffer,true); |
|
1062 | + if (!empty($all_data)) $reset = 0; |
|
1063 | + foreach ($all_data as $key => $line) { |
|
1064 | 1064 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1065 | - $data = array(); |
|
1066 | - $data['hex'] = $line[0]; |
|
1067 | - $data['ident'] = $line[16]; //$line[13] |
|
1068 | - $data['altitude'] = $line[4]; // altitude |
|
1069 | - $data['speed'] = $line[5]; // speed |
|
1070 | - $data['heading'] = $line[3]; // heading |
|
1071 | - $data['latitude'] = $line[1]; // lat |
|
1072 | - $data['longitude'] = $line[2]; // long |
|
1073 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1074 | - $data['squawk'] = $line[6]; // squawk |
|
1075 | - $data['aircraft_icao'] = $line[8]; |
|
1076 | - $data['registration'] = $line[9]; |
|
1077 | - $data['departure_airport_iata'] = $line[11]; |
|
1078 | - $data['arrival_airport_iata'] = $line[12]; |
|
1079 | - $data['emergency'] = ''; // emergency |
|
1080 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1081 | - $data['format_source'] = 'fr24json'; |
|
1082 | - $data['id_source'] = $id_source; |
|
1083 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1084 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1085 | - $SI->add($data); |
|
1086 | - unset($data); |
|
1065 | + $data = array(); |
|
1066 | + $data['hex'] = $line[0]; |
|
1067 | + $data['ident'] = $line[16]; //$line[13] |
|
1068 | + $data['altitude'] = $line[4]; // altitude |
|
1069 | + $data['speed'] = $line[5]; // speed |
|
1070 | + $data['heading'] = $line[3]; // heading |
|
1071 | + $data['latitude'] = $line[1]; // lat |
|
1072 | + $data['longitude'] = $line[2]; // long |
|
1073 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1074 | + $data['squawk'] = $line[6]; // squawk |
|
1075 | + $data['aircraft_icao'] = $line[8]; |
|
1076 | + $data['registration'] = $line[9]; |
|
1077 | + $data['departure_airport_iata'] = $line[11]; |
|
1078 | + $data['arrival_airport_iata'] = $line[12]; |
|
1079 | + $data['emergency'] = ''; // emergency |
|
1080 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1081 | + $data['format_source'] = 'fr24json'; |
|
1082 | + $data['id_source'] = $id_source; |
|
1083 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1084 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1085 | + $SI->add($data); |
|
1086 | + unset($data); |
|
1087 | + } |
|
1087 | 1088 | } |
1088 | - } |
|
1089 | - //$last_exec['fr24json'] = time(); |
|
1090 | - $last_exec[$id]['last'] = time(); |
|
1089 | + //$last_exec['fr24json'] = time(); |
|
1090 | + $last_exec[$id]['last'] = time(); |
|
1091 | 1091 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1092 | 1092 | } elseif ($value['format'] === 'radarvirtueljson' && |
1093 | - ( |
|
1093 | + ( |
|
1094 | 1094 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1095 | 1095 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1096 | - ) |
|
1096 | + ) |
|
1097 | 1097 | ) { |
1098 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1099 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1100 | - //echo $buffer; |
|
1101 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1102 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1103 | - $all_data = json_decode($buffer,true); |
|
1104 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1098 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1099 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1100 | + //echo $buffer; |
|
1101 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1102 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1103 | + $all_data = json_decode($buffer,true); |
|
1104 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1105 | 1105 | die(json_last_error_msg()); |
1106 | - } |
|
1107 | - if (isset($all_data['mrkrs'])) { |
|
1106 | + } |
|
1107 | + if (isset($all_data['mrkrs'])) { |
|
1108 | 1108 | $reset = 0; |
1109 | 1109 | foreach ($all_data['mrkrs'] as $key => $line) { |
1110 | - if (isset($line['inf'])) { |
|
1110 | + if (isset($line['inf'])) { |
|
1111 | 1111 | $data = array(); |
1112 | 1112 | $data['hex'] = $line['inf']['ia']; |
1113 | 1113 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1114 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1115 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1116 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1117 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1118 | - $data['longitude'] = $line['pt'][1]; // long |
|
1119 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1120 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1121 | - //$data['aircraft_icao'] = $line[8]; |
|
1122 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1114 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1115 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1116 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1117 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1118 | + $data['longitude'] = $line['pt'][1]; // long |
|
1119 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1120 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1121 | + //$data['aircraft_icao'] = $line[8]; |
|
1122 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1123 | 1123 | //$data['departure_airport_iata'] = $line[11]; |
1124 | 1124 | //$data['arrival_airport_iata'] = $line[12]; |
1125 | - //$data['emergency'] = ''; // emergency |
|
1125 | + //$data['emergency'] = ''; // emergency |
|
1126 | 1126 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1127 | - $data['format_source'] = 'radarvirtueljson'; |
|
1128 | - $data['id_source'] = $id_source; |
|
1127 | + $data['format_source'] = 'radarvirtueljson'; |
|
1128 | + $data['id_source'] = $id_source; |
|
1129 | 1129 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1130 | 1130 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1131 | 1131 | $SI->add($data); |
1132 | 1132 | unset($data); |
1133 | - } |
|
1133 | + } |
|
1134 | + } |
|
1134 | 1135 | } |
1135 | - } |
|
1136 | - //$last_exec['radarvirtueljson'] = time(); |
|
1137 | - $last_exec[$id]['last'] = time(); |
|
1136 | + //$last_exec['radarvirtueljson'] = time(); |
|
1137 | + $last_exec[$id]['last'] = time(); |
|
1138 | 1138 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1139 | 1139 | } elseif ($value['format'] === 'pirepsjson' && |
1140 | - ( |
|
1140 | + ( |
|
1141 | 1141 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1142 | 1142 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1143 | - ) |
|
1143 | + ) |
|
1144 | 1144 | ) { |
1145 | - //$buffer = $Common->getData($hosts[$id]); |
|
1146 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1147 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1145 | + //$buffer = $Common->getData($hosts[$id]); |
|
1146 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1147 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1148 | 1148 | |
1149 | - if (isset($all_data['pireps'])) { |
|
1149 | + if (isset($all_data['pireps'])) { |
|
1150 | 1150 | $reset = 0; |
1151 | - foreach ($all_data['pireps'] as $line) { |
|
1152 | - $data = array(); |
|
1153 | - $data['id'] = $line['id']; |
|
1154 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1155 | - $data['ident'] = $line['callsign']; // ident |
|
1156 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1157 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1158 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1159 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1160 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1161 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1162 | - $data['latitude'] = $line['lat']; // lat |
|
1163 | - $data['longitude'] = $line['lon']; // long |
|
1164 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1165 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1166 | - //$data['emergency'] = ''; // emergency |
|
1167 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1168 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1169 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1170 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1171 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1172 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1173 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1174 | - else $data['info'] = ''; |
|
1175 | - $data['format_source'] = 'pireps'; |
|
1176 | - $data['id_source'] = $id_source; |
|
1177 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1178 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1179 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1180 | - if ($line['icon'] === 'plane') { |
|
1151 | + foreach ($all_data['pireps'] as $line) { |
|
1152 | + $data = array(); |
|
1153 | + $data['id'] = $line['id']; |
|
1154 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1155 | + $data['ident'] = $line['callsign']; // ident |
|
1156 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1157 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1158 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1159 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1160 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1161 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1162 | + $data['latitude'] = $line['lat']; // lat |
|
1163 | + $data['longitude'] = $line['lon']; // long |
|
1164 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1165 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1166 | + //$data['emergency'] = ''; // emergency |
|
1167 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1168 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1169 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1170 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1171 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1172 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1173 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1174 | + else $data['info'] = ''; |
|
1175 | + $data['format_source'] = 'pireps'; |
|
1176 | + $data['id_source'] = $id_source; |
|
1177 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1178 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1179 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1180 | + if ($line['icon'] === 'plane') { |
|
1181 | 1181 | $SI->add($data); |
1182 | - // print_r($data); |
|
1183 | - } elseif ($line['icon'] === 'ct') { |
|
1182 | + // print_r($data); |
|
1183 | + } elseif ($line['icon'] === 'ct') { |
|
1184 | 1184 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1185 | 1185 | $data['info'] = str_replace('&sect;','',$data['info']); |
1186 | 1186 | $typec = substr($data['ident'],-3); |
@@ -1195,209 +1195,209 @@ discard block |
||
1195 | 1195 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1196 | 1196 | else $data['type'] = 'Observer'; |
1197 | 1197 | 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']); |
1198 | - } |
|
1199 | - unset($data); |
|
1198 | + } |
|
1199 | + unset($data); |
|
1200 | + } |
|
1200 | 1201 | } |
1201 | - } |
|
1202 | - //$last_exec['pirepsjson'] = time(); |
|
1203 | - $last_exec[$id]['last'] = time(); |
|
1202 | + //$last_exec['pirepsjson'] = time(); |
|
1203 | + $last_exec[$id]['last'] = time(); |
|
1204 | 1204 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1205 | 1205 | } elseif ($value['format'] === 'phpvmacars' && |
1206 | - ( |
|
1206 | + ( |
|
1207 | 1207 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1208 | 1208 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1209 | - ) |
|
1209 | + ) |
|
1210 | 1210 | ) { |
1211 | - //$buffer = $Common->getData($hosts[$id]); |
|
1212 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1213 | - $buffer = $Common->getData($value['host']); |
|
1214 | - $all_data = json_decode($buffer,true); |
|
1215 | - if ($buffer != '' && is_array($all_data)) { |
|
1211 | + //$buffer = $Common->getData($hosts[$id]); |
|
1212 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1213 | + $buffer = $Common->getData($value['host']); |
|
1214 | + $all_data = json_decode($buffer,true); |
|
1215 | + if ($buffer != '' && is_array($all_data)) { |
|
1216 | 1216 | $reset = 0; |
1217 | 1217 | foreach ($all_data as $line) { |
1218 | - $data = array(); |
|
1219 | - //$data['id'] = $line['id']; // id not usable |
|
1220 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1221 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1222 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1223 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1224 | - $data['ident'] = $line['flightnum']; // ident |
|
1225 | - $data['altitude'] = $line['alt']; // altitude |
|
1226 | - $data['speed'] = $line['gs']; // speed |
|
1227 | - $data['heading'] = $line['heading']; // heading |
|
1228 | - $data['latitude'] = $line['lat']; // lat |
|
1229 | - $data['longitude'] = $line['lng']; // long |
|
1230 | - $data['verticalrate'] = ''; // verticale rate |
|
1231 | - $data['squawk'] = ''; // squawk |
|
1232 | - $data['emergency'] = ''; // emergency |
|
1233 | - //$data['datetime'] = $line['lastupdate']; |
|
1234 | - //$data['last_update'] = $line['lastupdate']; |
|
1235 | - if (isset($value['timezone'])) { |
|
1236 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1237 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1238 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1239 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1240 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1241 | - $data['departure_airport_time'] = $line['deptime']; |
|
1242 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1243 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1244 | - if (isset($line['registration'])) { |
|
1245 | - $data['registration'] = $line['registration']; |
|
1246 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1247 | - } else $data['registration'] = $line['aircraft']; |
|
1248 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1249 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1250 | - if (isset($line['aircraftname'])) { |
|
1218 | + $data = array(); |
|
1219 | + //$data['id'] = $line['id']; // id not usable |
|
1220 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1221 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1222 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1223 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1224 | + $data['ident'] = $line['flightnum']; // ident |
|
1225 | + $data['altitude'] = $line['alt']; // altitude |
|
1226 | + $data['speed'] = $line['gs']; // speed |
|
1227 | + $data['heading'] = $line['heading']; // heading |
|
1228 | + $data['latitude'] = $line['lat']; // lat |
|
1229 | + $data['longitude'] = $line['lng']; // long |
|
1230 | + $data['verticalrate'] = ''; // verticale rate |
|
1231 | + $data['squawk'] = ''; // squawk |
|
1232 | + $data['emergency'] = ''; // emergency |
|
1233 | + //$data['datetime'] = $line['lastupdate']; |
|
1234 | + //$data['last_update'] = $line['lastupdate']; |
|
1235 | + if (isset($value['timezone'])) { |
|
1236 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1237 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1238 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1239 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1240 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1241 | + $data['departure_airport_time'] = $line['deptime']; |
|
1242 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1243 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1244 | + if (isset($line['registration'])) { |
|
1245 | + $data['registration'] = $line['registration']; |
|
1246 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1247 | + } else $data['registration'] = $line['aircraft']; |
|
1248 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1249 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1250 | + if (isset($line['aircraftname'])) { |
|
1251 | 1251 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1252 | 1252 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1253 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1254 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1255 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1256 | - else { |
|
1257 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1258 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1259 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1260 | - } |
|
1261 | - } |
|
1262 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1263 | - $data['id_source'] = $id_source; |
|
1264 | - $data['format_source'] = 'phpvmacars'; |
|
1265 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1266 | - $SI->add($data); |
|
1267 | - unset($data); |
|
1253 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1254 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1255 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1256 | + else { |
|
1257 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1258 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1259 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1260 | + } |
|
1261 | + } |
|
1262 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1263 | + $data['id_source'] = $id_source; |
|
1264 | + $data['format_source'] = 'phpvmacars'; |
|
1265 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1266 | + $SI->add($data); |
|
1267 | + unset($data); |
|
1268 | 1268 | } |
1269 | 1269 | if ($globalDebug) echo 'No more data...'."\n"; |
1270 | 1270 | unset($buffer); |
1271 | 1271 | unset($all_data); |
1272 | - } |
|
1273 | - //$last_exec['phpvmacars'] = time(); |
|
1274 | - $last_exec[$id]['last'] = time(); |
|
1272 | + } |
|
1273 | + //$last_exec['phpvmacars'] = time(); |
|
1274 | + $last_exec[$id]['last'] = time(); |
|
1275 | 1275 | } elseif ($value['format'] === 'vaos' && |
1276 | - ( |
|
1276 | + ( |
|
1277 | 1277 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1278 | 1278 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1279 | - ) |
|
1279 | + ) |
|
1280 | 1280 | ) { |
1281 | - //$buffer = $Common->getData($hosts[$id]); |
|
1282 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1283 | - $buffer = $Common->getData($value['host']); |
|
1284 | - $all_data = json_decode($buffer,true); |
|
1285 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1281 | + //$buffer = $Common->getData($hosts[$id]); |
|
1282 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1283 | + $buffer = $Common->getData($value['host']); |
|
1284 | + $all_data = json_decode($buffer,true); |
|
1285 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1286 | 1286 | $reset = 0; |
1287 | 1287 | foreach ($all_data['ACARSData'] as $line) { |
1288 | - //print_r($line); |
|
1289 | - $data = array(); |
|
1290 | - //$data['id'] = $line['id']; // id not usable |
|
1291 | - $data['id'] = $line['id']; |
|
1292 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1293 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1294 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1295 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1296 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1297 | - $data['altitude'] = $line['altitude']; // altitude |
|
1298 | - $data['speed'] = $line['groundspeed']; // speed |
|
1299 | - $data['heading'] = $line['heading']; // heading |
|
1300 | - $data['latitude'] = $line['lat']; // lat |
|
1301 | - $data['longitude'] = $line['lon']; // long |
|
1302 | - //$data['verticalrate'] = ''; // verticale rate |
|
1303 | - //$data['squawk'] = ''; // squawk |
|
1304 | - //$data['emergency'] = ''; // emergency |
|
1305 | - if (isset($value['timezone'])) { |
|
1306 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1307 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1308 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1309 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1288 | + //print_r($line); |
|
1289 | + $data = array(); |
|
1290 | + //$data['id'] = $line['id']; // id not usable |
|
1291 | + $data['id'] = $line['id']; |
|
1292 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1293 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1294 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1295 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1296 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1297 | + $data['altitude'] = $line['altitude']; // altitude |
|
1298 | + $data['speed'] = $line['groundspeed']; // speed |
|
1299 | + $data['heading'] = $line['heading']; // heading |
|
1300 | + $data['latitude'] = $line['lat']; // lat |
|
1301 | + $data['longitude'] = $line['lon']; // long |
|
1302 | + //$data['verticalrate'] = ''; // verticale rate |
|
1303 | + //$data['squawk'] = ''; // squawk |
|
1304 | + //$data['emergency'] = ''; // emergency |
|
1305 | + if (isset($value['timezone'])) { |
|
1306 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1307 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1308 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1309 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1310 | 1310 | |
1311 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1312 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1313 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1314 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1315 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1311 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1312 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1313 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1314 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1315 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1316 | 1316 | |
1317 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1318 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1319 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1317 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1318 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1319 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1320 | 1320 | |
1321 | - $data['id_source'] = $id_source; |
|
1322 | - $data['format_source'] = 'vaos'; |
|
1323 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1324 | - $SI->add($data); |
|
1325 | - unset($data); |
|
1321 | + $data['id_source'] = $id_source; |
|
1322 | + $data['format_source'] = 'vaos'; |
|
1323 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1324 | + $SI->add($data); |
|
1325 | + unset($data); |
|
1326 | 1326 | } |
1327 | 1327 | if ($globalDebug) echo 'No more data...'."\n"; |
1328 | 1328 | unset($buffer); |
1329 | 1329 | unset($all_data); |
1330 | - } |
|
1331 | - //$last_exec['phpvmacars'] = time(); |
|
1332 | - $last_exec[$id]['last'] = time(); |
|
1330 | + } |
|
1331 | + //$last_exec['phpvmacars'] = time(); |
|
1332 | + $last_exec[$id]['last'] = time(); |
|
1333 | 1333 | } elseif ($value['format'] === 'vam' && |
1334 | - ( |
|
1334 | + ( |
|
1335 | 1335 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1336 | 1336 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1337 | - ) |
|
1337 | + ) |
|
1338 | 1338 | ) { |
1339 | - //$buffer = $Common->getData($hosts[$id]); |
|
1340 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1341 | - $buffer = $Common->getData($value['host']); |
|
1342 | - $all_data = json_decode($buffer,true); |
|
1343 | - if ($buffer != '' && is_array($all_data)) { |
|
1339 | + //$buffer = $Common->getData($hosts[$id]); |
|
1340 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1341 | + $buffer = $Common->getData($value['host']); |
|
1342 | + $all_data = json_decode($buffer,true); |
|
1343 | + if ($buffer != '' && is_array($all_data)) { |
|
1344 | 1344 | $reset = 0; |
1345 | 1345 | foreach ($all_data as $line) { |
1346 | - $data = array(); |
|
1347 | - //$data['id'] = $line['id']; // id not usable |
|
1348 | - $data['id'] = trim($line['flight_id']); |
|
1349 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1350 | - $data['pilot_name'] = $line['pilot_name']; |
|
1351 | - $data['pilot_id'] = $line['pilot_id']; |
|
1352 | - $data['ident'] = trim($line['callsign']); // ident |
|
1353 | - $data['altitude'] = $line['altitude']; // altitude |
|
1354 | - $data['speed'] = $line['gs']; // speed |
|
1355 | - $data['heading'] = $line['heading']; // heading |
|
1356 | - $data['latitude'] = $line['latitude']; // lat |
|
1357 | - $data['longitude'] = $line['longitude']; // long |
|
1358 | - $data['verticalrate'] = ''; // verticale rate |
|
1359 | - $data['squawk'] = ''; // squawk |
|
1360 | - $data['emergency'] = ''; // emergency |
|
1361 | - //$data['datetime'] = $line['lastupdate']; |
|
1362 | - $data['last_update'] = $line['last_update']; |
|
1363 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1364 | - $data['departure_airport_icao'] = $line['departure']; |
|
1365 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1366 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1367 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1368 | - //$data['registration'] = $line['aircraft']; |
|
1369 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1370 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1371 | - $data['id_source'] = $id_source; |
|
1372 | - $data['format_source'] = 'vam'; |
|
1373 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1374 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1375 | - $SI->add($data); |
|
1376 | - unset($data); |
|
1346 | + $data = array(); |
|
1347 | + //$data['id'] = $line['id']; // id not usable |
|
1348 | + $data['id'] = trim($line['flight_id']); |
|
1349 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1350 | + $data['pilot_name'] = $line['pilot_name']; |
|
1351 | + $data['pilot_id'] = $line['pilot_id']; |
|
1352 | + $data['ident'] = trim($line['callsign']); // ident |
|
1353 | + $data['altitude'] = $line['altitude']; // altitude |
|
1354 | + $data['speed'] = $line['gs']; // speed |
|
1355 | + $data['heading'] = $line['heading']; // heading |
|
1356 | + $data['latitude'] = $line['latitude']; // lat |
|
1357 | + $data['longitude'] = $line['longitude']; // long |
|
1358 | + $data['verticalrate'] = ''; // verticale rate |
|
1359 | + $data['squawk'] = ''; // squawk |
|
1360 | + $data['emergency'] = ''; // emergency |
|
1361 | + //$data['datetime'] = $line['lastupdate']; |
|
1362 | + $data['last_update'] = $line['last_update']; |
|
1363 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1364 | + $data['departure_airport_icao'] = $line['departure']; |
|
1365 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1366 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1367 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1368 | + //$data['registration'] = $line['aircraft']; |
|
1369 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1370 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1371 | + $data['id_source'] = $id_source; |
|
1372 | + $data['format_source'] = 'vam'; |
|
1373 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1374 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1375 | + $SI->add($data); |
|
1376 | + unset($data); |
|
1377 | 1377 | } |
1378 | 1378 | if ($globalDebug) echo 'No more data...'."\n"; |
1379 | 1379 | unset($buffer); |
1380 | 1380 | unset($all_data); |
1381 | - } |
|
1382 | - //$last_exec['phpvmacars'] = time(); |
|
1383 | - $last_exec[$id]['last'] = time(); |
|
1381 | + } |
|
1382 | + //$last_exec['phpvmacars'] = time(); |
|
1383 | + $last_exec[$id]['last'] = time(); |
|
1384 | 1384 | } elseif ($value['format'] === 'blitzortung' && |
1385 | - ( |
|
1385 | + ( |
|
1386 | 1386 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1387 | 1387 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1388 | - ) |
|
1388 | + ) |
|
1389 | 1389 | ) { |
1390 | - //$buffer = $Common->getData($hosts[$id]); |
|
1391 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1392 | - $buffer = $Common->getData($value['host']); |
|
1393 | - $all_data = json_decode($buffer,true); |
|
1394 | - if ($buffer != '') { |
|
1390 | + //$buffer = $Common->getData($hosts[$id]); |
|
1391 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1392 | + $buffer = $Common->getData($value['host']); |
|
1393 | + $all_data = json_decode($buffer,true); |
|
1394 | + if ($buffer != '') { |
|
1395 | 1395 | $Source->deleteLocationBySource('blitzortung'); |
1396 | 1396 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1397 | 1397 | $buffer = explode('\n',$buffer); |
1398 | 1398 | foreach ($buffer as $buffer_line) { |
1399 | - $line = json_decode($buffer_line,true); |
|
1400 | - if (isset($line['time'])) { |
|
1399 | + $line = json_decode($buffer_line,true); |
|
1400 | + if (isset($line['time'])) { |
|
1401 | 1401 | $data = array(); |
1402 | 1402 | $data['altitude'] = $line['alt']; // altitude |
1403 | 1403 | $data['latitude'] = $line['lat']; // lat |
@@ -1409,94 +1409,94 @@ discard block |
||
1409 | 1409 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1410 | 1410 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1411 | 1411 | unset($data); |
1412 | - } |
|
1412 | + } |
|
1413 | 1413 | } |
1414 | 1414 | if ($globalDebug) echo 'No more data...'."\n"; |
1415 | 1415 | unset($buffer); |
1416 | - } |
|
1417 | - $last_exec[$id]['last'] = time(); |
|
1416 | + } |
|
1417 | + $last_exec[$id]['last'] = time(); |
|
1418 | 1418 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
1419 | 1419 | } 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') { |
1420 | - //$last_exec[$id]['last'] = time(); |
|
1421 | - //$read = array( $sockets[$id] ); |
|
1422 | - $read = $sockets; |
|
1423 | - $write = NULL; |
|
1424 | - $e = NULL; |
|
1425 | - $n = socket_select($read, $write, $e, $timeout); |
|
1426 | - if ($e != NULL) var_dump($e); |
|
1427 | - if ($n > 0) { |
|
1420 | + //$last_exec[$id]['last'] = time(); |
|
1421 | + //$read = array( $sockets[$id] ); |
|
1422 | + $read = $sockets; |
|
1423 | + $write = NULL; |
|
1424 | + $e = NULL; |
|
1425 | + $n = socket_select($read, $write, $e, $timeout); |
|
1426 | + if ($e != NULL) var_dump($e); |
|
1427 | + if ($n > 0) { |
|
1428 | 1428 | $reset = 0; |
1429 | 1429 | foreach ($read as $nb => $r) { |
1430 | - //$value = $formats[$nb]; |
|
1431 | - $format = $globalSources[$nb]['format']; |
|
1432 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1430 | + //$value = $formats[$nb]; |
|
1431 | + $format = $globalSources[$nb]['format']; |
|
1432 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1433 | 1433 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1434 | - } elseif ($format === 'vrstcp') { |
|
1434 | + } elseif ($format === 'vrstcp') { |
|
1435 | 1435 | $buffer = @socket_read($r, 6000); |
1436 | - } else { |
|
1436 | + } else { |
|
1437 | 1437 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1438 | - } |
|
1439 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1440 | - //echo $buffer."\n"; |
|
1441 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1442 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1443 | - $error = false; |
|
1444 | - //$SI::del(); |
|
1445 | - if ($buffer !== FALSE) { |
|
1438 | + } |
|
1439 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1440 | + //echo $buffer."\n"; |
|
1441 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1442 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1443 | + $error = false; |
|
1444 | + //$SI::del(); |
|
1445 | + if ($buffer !== FALSE) { |
|
1446 | 1446 | if ($format === 'vrstcp') { |
1447 | - $buffer = explode('},{',$buffer); |
|
1447 | + $buffer = explode('},{',$buffer); |
|
1448 | 1448 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1449 | - } |
|
1450 | - // SBS format is CSV format |
|
1451 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1449 | + } |
|
1450 | + // SBS format is CSV format |
|
1451 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1452 | 1452 | $tt[$format] = 0; |
1453 | 1453 | if ($format === 'acarssbs3') { |
1454 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1455 | - $ACARS->add(trim($buffer)); |
|
1456 | - $ACARS->deleteLiveAcarsData(); |
|
1454 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1455 | + $ACARS->add(trim($buffer)); |
|
1456 | + $ACARS->deleteLiveAcarsData(); |
|
1457 | 1457 | } elseif ($format === 'raw') { |
1458 | - // AVR format |
|
1459 | - $data = $SBS->parse($buffer); |
|
1460 | - if (is_array($data)) { |
|
1458 | + // AVR format |
|
1459 | + $data = $SBS->parse($buffer); |
|
1460 | + if (is_array($data)) { |
|
1461 | 1461 | $data['datetime'] = date('Y-m-d H:i:s'); |
1462 | 1462 | $data['format_source'] = 'raw'; |
1463 | 1463 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1464 | 1464 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1465 | 1465 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1466 | 1466 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1467 | - } |
|
1467 | + } |
|
1468 | 1468 | } elseif ($format === 'ais') { |
1469 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1470 | - $data = array(); |
|
1471 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1472 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1473 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1474 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1475 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1476 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1477 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1478 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1479 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1480 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1481 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1482 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1483 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1484 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1485 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1486 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1469 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1470 | + $data = array(); |
|
1471 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1472 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1473 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1474 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1475 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1476 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1477 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1478 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1479 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1480 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1481 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1482 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1483 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1484 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1485 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1486 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1487 | 1487 | |
1488 | - if (isset($ais_data['timestamp'])) { |
|
1488 | + if (isset($ais_data['timestamp'])) { |
|
1489 | 1489 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1490 | - } else { |
|
1490 | + } else { |
|
1491 | 1491 | $data['datetime'] = date('Y-m-d H:i:s'); |
1492 | - } |
|
1493 | - $data['format_source'] = 'aisnmea'; |
|
1494 | - $data['id_source'] = $id_source; |
|
1495 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1496 | - unset($data); |
|
1497 | - } elseif ($format === 'flightgearsp') { |
|
1498 | - //echo $buffer."\n"; |
|
1499 | - if (strlen($buffer) > 5) { |
|
1492 | + } |
|
1493 | + $data['format_source'] = 'aisnmea'; |
|
1494 | + $data['id_source'] = $id_source; |
|
1495 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1496 | + unset($data); |
|
1497 | + } elseif ($format === 'flightgearsp') { |
|
1498 | + //echo $buffer."\n"; |
|
1499 | + if (strlen($buffer) > 5) { |
|
1500 | 1500 | $line = explode(',',$buffer); |
1501 | 1501 | $data = array(); |
1502 | 1502 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1513,38 +1513,38 @@ discard block |
||
1513 | 1513 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1514 | 1514 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1515 | 1515 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1516 | - } |
|
1517 | - } elseif ($format === 'acars') { |
|
1518 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1519 | - $ACARS->add(trim($buffer)); |
|
1520 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1521 | - $ACARS->deleteLiveAcarsData(); |
|
1516 | + } |
|
1517 | + } elseif ($format === 'acars') { |
|
1518 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1519 | + $ACARS->add(trim($buffer)); |
|
1520 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1521 | + $ACARS->deleteLiveAcarsData(); |
|
1522 | 1522 | } elseif ($format === 'flightgearmp') { |
1523 | - if (substr($buffer,0,1) != '#') { |
|
1523 | + if (substr($buffer,0,1) != '#') { |
|
1524 | 1524 | $data = array(); |
1525 | 1525 | //echo $buffer."\n"; |
1526 | 1526 | $line = explode(' ',$buffer); |
1527 | 1527 | if (count($line) === 11) { |
1528 | - $userserver = explode('@',$line[0]); |
|
1529 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1530 | - $data['ident'] = $userserver[0]; |
|
1531 | - $data['registration'] = $userserver[0]; |
|
1532 | - $data['latitude'] = $line[4]; |
|
1533 | - $data['longitude'] = $line[5]; |
|
1534 | - $data['altitude'] = $line[6]; |
|
1535 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1536 | - $aircraft_type = $line[10]; |
|
1537 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1538 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1539 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1540 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1528 | + $userserver = explode('@',$line[0]); |
|
1529 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1530 | + $data['ident'] = $userserver[0]; |
|
1531 | + $data['registration'] = $userserver[0]; |
|
1532 | + $data['latitude'] = $line[4]; |
|
1533 | + $data['longitude'] = $line[5]; |
|
1534 | + $data['altitude'] = $line[6]; |
|
1535 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1536 | + $aircraft_type = $line[10]; |
|
1537 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1538 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1539 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1540 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1541 | + } |
|
1541 | 1542 | } |
1542 | - } |
|
1543 | 1543 | } elseif ($format === 'beast') { |
1544 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1545 | - die; |
|
1544 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1545 | + die; |
|
1546 | 1546 | } elseif ($format === 'vrstcp') { |
1547 | - foreach($buffer as $all_data) { |
|
1547 | + foreach($buffer as $all_data) { |
|
1548 | 1548 | $line = json_decode('{'.$all_data.'}',true); |
1549 | 1549 | $data = array(); |
1550 | 1550 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1564,153 +1564,153 @@ discard block |
||
1564 | 1564 | */ |
1565 | 1565 | $data['datetime'] = date('Y-m-d H:i:s'); |
1566 | 1566 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1567 | - $data['format_source'] = 'vrstcp'; |
|
1567 | + $data['format_source'] = 'vrstcp'; |
|
1568 | 1568 | $data['id_source'] = $id_source; |
1569 | 1569 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1570 | 1570 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1571 | 1571 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1572 | 1572 | unset($data); |
1573 | - } |
|
1573 | + } |
|
1574 | 1574 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
1575 | - $line = explode("\t", $buffer); |
|
1576 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1575 | + $line = explode("\t", $buffer); |
|
1576 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1577 | 1577 | $key = $line[$k]; |
1578 | - $lined[$key] = $line[$k+1]; |
|
1579 | - } |
|
1580 | - if (count($lined) > 3) { |
|
1581 | - $data['hex'] = $lined['hexid']; |
|
1582 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1583 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1584 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1585 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1586 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1587 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1588 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1589 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1590 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1591 | - $data['id_source'] = $id_source; |
|
1592 | - $data['format_source'] = 'tsv'; |
|
1593 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1594 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1578 | + $lined[$key] = $line[$k+1]; |
|
1579 | + } |
|
1580 | + if (count($lined) > 3) { |
|
1581 | + $data['hex'] = $lined['hexid']; |
|
1582 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1583 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1584 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1585 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1586 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1587 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1588 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1589 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1590 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1591 | + $data['id_source'] = $id_source; |
|
1592 | + $data['format_source'] = 'tsv'; |
|
1593 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1594 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1595 | 1595 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1596 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1597 | - unset($lined); |
|
1598 | - unset($data); |
|
1599 | - } else $error = true; |
|
1596 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1597 | + unset($lined); |
|
1598 | + unset($data); |
|
1599 | + } else $error = true; |
|
1600 | 1600 | } elseif ($format === 'aprs' && $use_aprs) { |
1601 | - if ($aprs_connect === 0) { |
|
1601 | + if ($aprs_connect === 0) { |
|
1602 | 1602 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1603 | 1603 | $aprs_connect = 1; |
1604 | - } |
|
1604 | + } |
|
1605 | 1605 | |
1606 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1606 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1607 | 1607 | $aprs_last_tx = time(); |
1608 | 1608 | $data_aprs = "# Keep alive"; |
1609 | 1609 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1610 | - } |
|
1610 | + } |
|
1611 | 1611 | |
1612 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1613 | - //echo 'APRS data : '.$buffer."\n"; |
|
1614 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1615 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1616 | - //echo $buffer."\n"; |
|
1617 | - date_default_timezone_set('UTC'); |
|
1618 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1612 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1613 | + //echo 'APRS data : '.$buffer."\n"; |
|
1614 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1615 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1616 | + //echo $buffer."\n"; |
|
1617 | + date_default_timezone_set('UTC'); |
|
1618 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1619 | 1619 | $line = $APRS->parse($buffer); |
1620 | 1620 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1621 | 1621 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1622 | - $aprs_last_tx = time(); |
|
1623 | - $data = array(); |
|
1624 | - //print_r($line); |
|
1625 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1626 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1627 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1628 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1629 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1630 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1631 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1632 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1633 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1634 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1635 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1636 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1637 | - $data['latitude'] = $line['latitude']; |
|
1638 | - $data['longitude'] = $line['longitude']; |
|
1639 | - //$data['verticalrate'] = $line[16]; |
|
1640 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1641 | - //else $data['speed'] = 0; |
|
1642 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1643 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1644 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1645 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1622 | + $aprs_last_tx = time(); |
|
1623 | + $data = array(); |
|
1624 | + //print_r($line); |
|
1625 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1626 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1627 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1628 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1629 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1630 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1631 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1632 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1633 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1634 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1635 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1636 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1637 | + $data['latitude'] = $line['latitude']; |
|
1638 | + $data['longitude'] = $line['longitude']; |
|
1639 | + //$data['verticalrate'] = $line[16]; |
|
1640 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1641 | + //else $data['speed'] = 0; |
|
1642 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1643 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1644 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1645 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1646 | 1646 | |
1647 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1648 | - //else echo 'No heading...'."\n"; |
|
1649 | - //else $data['heading'] = 0; |
|
1650 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1651 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1652 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1653 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1654 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1655 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1656 | - $data['id_source'] = $id_source; |
|
1657 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1658 | - else $data['format_source'] = 'aprs'; |
|
1659 | - $data['source_name'] = $line['source']; |
|
1660 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1661 | - else $data['source_type'] = 'flarm'; |
|
1662 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1663 | - $currentdate = date('Y-m-d H:i:s'); |
|
1664 | - $aprsdate = strtotime($data['datetime']); |
|
1665 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1666 | - // Accept data if time <= system time + 20s |
|
1667 | - //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'])))) { |
|
1668 | - if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1647 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1648 | + //else echo 'No heading...'."\n"; |
|
1649 | + //else $data['heading'] = 0; |
|
1650 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1651 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1652 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1653 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1654 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1655 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1656 | + $data['id_source'] = $id_source; |
|
1657 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1658 | + else $data['format_source'] = 'aprs'; |
|
1659 | + $data['source_name'] = $line['source']; |
|
1660 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1661 | + else $data['source_type'] = 'flarm'; |
|
1662 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1663 | + $currentdate = date('Y-m-d H:i:s'); |
|
1664 | + $aprsdate = strtotime($data['datetime']); |
|
1665 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1666 | + // Accept data if time <= system time + 20s |
|
1667 | + //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'])))) { |
|
1668 | + if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1669 | 1669 | $send = $SI->add($data); |
1670 | - } elseif ($data['source_type'] === 'ais') { |
|
1670 | + } elseif ($data['source_type'] === 'ais') { |
|
1671 | 1671 | $data['type'] = ''; |
1672 | 1672 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1673 | - } elseif (isset($line['stealth'])) { |
|
1673 | + } elseif (isset($line['stealth'])) { |
|
1674 | 1674 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1675 | 1675 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1676 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1677 | - //$line['symbol'] === 'Balloon' || |
|
1678 | - $line['symbol'] === 'Glider' || |
|
1679 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1680 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1681 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1682 | - $send = $SI->add($data); |
|
1683 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1684 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1685 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
1686 | - $send = $MI->add($data); |
|
1687 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1688 | - $line['symbol'] === 'Car' || |
|
1689 | - $line['symbol'] === 'Ambulance' || |
|
1690 | - $line['symbol'] === 'Van' || |
|
1691 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1692 | - $line['symbol'] === 'Motorcycle' || |
|
1693 | - $line['symbol'] === 'Tractor' || |
|
1694 | - $line['symbol'] === 'Police' || |
|
1695 | - $line['symbol'] === 'Bike' || |
|
1696 | - $line['symbol'] === 'Jogger' || |
|
1697 | - $line['symbol'] === 'Horse' || |
|
1698 | - $line['symbol'] === 'Bus' || |
|
1699 | - $line['symbol'] === 'Jeep' || |
|
1700 | - $line['symbol'] === 'Recreational Vehicle' || |
|
1701 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1702 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
1703 | - $line['symbol'] === 'Firetruck' || |
|
1704 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1705 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1706 | - $line['symbol'] === 'SUV' || |
|
1707 | - $line['symbol'] === 'Snowmobile' || |
|
1708 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
1709 | - //} 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') { |
|
1676 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1677 | + //$line['symbol'] === 'Balloon' || |
|
1678 | + $line['symbol'] === 'Glider' || |
|
1679 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1680 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1681 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1682 | + $send = $SI->add($data); |
|
1683 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1684 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1685 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
1686 | + $send = $MI->add($data); |
|
1687 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1688 | + $line['symbol'] === 'Car' || |
|
1689 | + $line['symbol'] === 'Ambulance' || |
|
1690 | + $line['symbol'] === 'Van' || |
|
1691 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1692 | + $line['symbol'] === 'Motorcycle' || |
|
1693 | + $line['symbol'] === 'Tractor' || |
|
1694 | + $line['symbol'] === 'Police' || |
|
1695 | + $line['symbol'] === 'Bike' || |
|
1696 | + $line['symbol'] === 'Jogger' || |
|
1697 | + $line['symbol'] === 'Horse' || |
|
1698 | + $line['symbol'] === 'Bus' || |
|
1699 | + $line['symbol'] === 'Jeep' || |
|
1700 | + $line['symbol'] === 'Recreational Vehicle' || |
|
1701 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1702 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
1703 | + $line['symbol'] === 'Firetruck' || |
|
1704 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1705 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1706 | + $line['symbol'] === 'SUV' || |
|
1707 | + $line['symbol'] === 'Snowmobile' || |
|
1708 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
1709 | + //} 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') { |
|
1710 | 1710 | // } 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') { |
1711 | 1711 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1712 | 1712 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1713 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1713 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1714 | 1714 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1715 | 1715 | $Source->deleteOldLocationByType('gs'); |
1716 | 1716 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1718,7 +1718,7 @@ discard block |
||
1718 | 1718 | } else { |
1719 | 1719 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1720 | 1720 | } |
1721 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1721 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1722 | 1722 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1723 | 1723 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1724 | 1724 | $Source->deleteOldLocationByType('wx'); |
@@ -1728,7 +1728,7 @@ discard block |
||
1728 | 1728 | } else { |
1729 | 1729 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1730 | 1730 | } |
1731 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1731 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1732 | 1732 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1733 | 1733 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1734 | 1734 | $Source->deleteOldLocationByType('lightning'); |
@@ -1737,11 +1737,11 @@ discard block |
||
1737 | 1737 | } else { |
1738 | 1738 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1739 | 1739 | } |
1740 | - } elseif ($globalDebug) { |
|
1741 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1742 | - print_r($line); |
|
1743 | - } |
|
1744 | - unset($data); |
|
1740 | + } elseif ($globalDebug) { |
|
1741 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1742 | + print_r($line); |
|
1743 | + } |
|
1744 | + unset($data); |
|
1745 | 1745 | } |
1746 | 1746 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1747 | 1747 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1760,12 +1760,12 @@ discard block |
||
1760 | 1760 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1761 | 1761 | $globalSources[$nb]['last_weather_clean'] = time(); |
1762 | 1762 | } |
1763 | - } |
|
1763 | + } |
|
1764 | 1764 | } else { |
1765 | - $line = explode(',', $buffer); |
|
1766 | - if (count($line) > 20) { |
|
1767 | - $data['hex'] = $line[4]; |
|
1768 | - /* |
|
1765 | + $line = explode(',', $buffer); |
|
1766 | + if (count($line) > 20) { |
|
1767 | + $data['hex'] = $line[4]; |
|
1768 | + /* |
|
1769 | 1769 | $data['datetime'] = $line[6].' '.$line[7]; |
1770 | 1770 | date_default_timezone_set($globalTimezone); |
1771 | 1771 | $datetime = new DateTime($data['datetime']); |
@@ -1773,30 +1773,30 @@ discard block |
||
1773 | 1773 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1774 | 1774 | date_default_timezone_set('UTC'); |
1775 | 1775 | */ |
1776 | - // Force datetime to current UTC datetime |
|
1777 | - date_default_timezone_set('UTC'); |
|
1778 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1779 | - $data['ident'] = trim($line[10]); |
|
1780 | - $data['latitude'] = $line[14]; |
|
1781 | - $data['longitude'] = $line[15]; |
|
1782 | - $data['verticalrate'] = $line[16]; |
|
1783 | - $data['emergency'] = $line[20]; |
|
1784 | - $data['speed'] = $line[12]; |
|
1785 | - $data['squawk'] = $line[17]; |
|
1786 | - $data['altitude'] = $line[11]; |
|
1787 | - $data['heading'] = $line[13]; |
|
1788 | - $data['ground'] = $line[21]; |
|
1789 | - $data['emergency'] = $line[19]; |
|
1790 | - $data['format_source'] = 'sbs'; |
|
1776 | + // Force datetime to current UTC datetime |
|
1777 | + date_default_timezone_set('UTC'); |
|
1778 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1779 | + $data['ident'] = trim($line[10]); |
|
1780 | + $data['latitude'] = $line[14]; |
|
1781 | + $data['longitude'] = $line[15]; |
|
1782 | + $data['verticalrate'] = $line[16]; |
|
1783 | + $data['emergency'] = $line[20]; |
|
1784 | + $data['speed'] = $line[12]; |
|
1785 | + $data['squawk'] = $line[17]; |
|
1786 | + $data['altitude'] = $line[11]; |
|
1787 | + $data['heading'] = $line[13]; |
|
1788 | + $data['ground'] = $line[21]; |
|
1789 | + $data['emergency'] = $line[19]; |
|
1790 | + $data['format_source'] = 'sbs'; |
|
1791 | 1791 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1792 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1792 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1793 | 1793 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1794 | - $data['id_source'] = $id_source; |
|
1795 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1796 | - else $error = true; |
|
1797 | - unset($data); |
|
1798 | - } else $error = true; |
|
1799 | - if ($error) { |
|
1794 | + $data['id_source'] = $id_source; |
|
1795 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1796 | + else $error = true; |
|
1797 | + unset($data); |
|
1798 | + } else $error = true; |
|
1799 | + if ($error) { |
|
1800 | 1800 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
1801 | 1801 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1802 | 1802 | } else { |
@@ -1812,13 +1812,13 @@ discard block |
||
1812 | 1812 | connect_all($sourceer); |
1813 | 1813 | $sourceer = array(); |
1814 | 1814 | } |
1815 | - } |
|
1815 | + } |
|
1816 | 1816 | } |
1817 | 1817 | // Sleep for xxx microseconds |
1818 | 1818 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1819 | - } else { |
|
1819 | + } else { |
|
1820 | 1820 | if ($format === 'flightgearmp') { |
1821 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1821 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1822 | 1822 | //@socket_close($r); |
1823 | 1823 | sleep($globalMinFetch); |
1824 | 1824 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1827,9 +1827,9 @@ discard block |
||
1827 | 1827 | break; |
1828 | 1828 | |
1829 | 1829 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1830 | - if (isset($tt[$format])) $tt[$format]++; |
|
1831 | - else $tt[$format] = 0; |
|
1832 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1830 | + if (isset($tt[$format])) $tt[$format]++; |
|
1831 | + else $tt[$format] = 0; |
|
1832 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1833 | 1833 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1834 | 1834 | //@socket_close($r); |
1835 | 1835 | sleep(2); |
@@ -1840,24 +1840,24 @@ discard block |
||
1840 | 1840 | //connect_all($globalSources); |
1841 | 1841 | $tt[$format]=0; |
1842 | 1842 | break; |
1843 | - } |
|
1844 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1843 | + } |
|
1844 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1845 | + } |
|
1845 | 1846 | } |
1846 | - } |
|
1847 | 1847 | } |
1848 | - } else { |
|
1848 | + } else { |
|
1849 | 1849 | $error = socket_strerror(socket_last_error()); |
1850 | 1850 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1851 | 1851 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1852 | 1852 | if (isset($globalDebug)) echo "Restarting...\n"; |
1853 | 1853 | // Restart the script if possible |
1854 | 1854 | if (is_array($sockets)) { |
1855 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1855 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1856 | 1856 | |
1857 | - foreach ($sockets as $sock) { |
|
1857 | + foreach ($sockets as $sock) { |
|
1858 | 1858 | @socket_shutdown($sock,2); |
1859 | 1859 | @socket_close($sock); |
1860 | - } |
|
1860 | + } |
|
1861 | 1861 | |
1862 | 1862 | } |
1863 | 1863 | if ($globalDebug) echo "Waiting..."; |
@@ -1872,15 +1872,15 @@ discard block |
||
1872 | 1872 | if ($globalDebug) echo "Restart all connections..."; |
1873 | 1873 | connect_all($globalSources); |
1874 | 1874 | } |
1875 | - } |
|
1875 | + } |
|
1876 | 1876 | } |
1877 | 1877 | if ($globalDaemon === false) { |
1878 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1879 | - if (isset($SI)) $SI->checkAll(); |
|
1880 | - if (isset($TI)) $TI->checkAll(); |
|
1881 | - if (isset($MI)) $MI->checkAll(); |
|
1878 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1879 | + if (isset($SI)) $SI->checkAll(); |
|
1880 | + if (isset($TI)) $TI->checkAll(); |
|
1881 | + if (isset($MI)) $MI->checkAll(); |
|
1882 | + } |
|
1882 | 1883 | } |
1883 | - } |
|
1884 | 1884 | } |
1885 | 1885 | |
1886 | 1886 | ?> |