@@ -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,127 +195,127 @@ 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 | 314 | sleep(10); |
315 | 315 | $this->connect_all($hosts); |
316 | - } |
|
317 | - } |
|
318 | - } |
|
316 | + } |
|
317 | + } |
|
318 | + } |
|
319 | 319 | } |
320 | 320 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
321 | 321 | |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | //connect_all($globalSources); |
339 | 339 | |
340 | 340 | if (isset($globalProxy) && $globalProxy) { |
341 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
341 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
342 | 342 | } else { |
343 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
343 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | // APRS Configuration |
@@ -349,21 +349,21 @@ discard block |
||
349 | 349 | die; |
350 | 350 | } |
351 | 351 | foreach ($globalSources as $key => $source) { |
352 | - if (!isset($source['format'])) { |
|
353 | - $globalSources[$key]['format'] = 'auto'; |
|
354 | - } |
|
355 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
356 | - unset($globalSources[$key]); |
|
357 | - } |
|
352 | + if (!isset($source['format'])) { |
|
353 | + $globalSources[$key]['format'] = 'auto'; |
|
354 | + } |
|
355 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
356 | + unset($globalSources[$key]); |
|
357 | + } |
|
358 | 358 | } |
359 | 359 | connect_all($globalSources); |
360 | 360 | foreach ($globalSources as $key => $source) { |
361 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
361 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
362 | 362 | $aprs_connect = 0; |
363 | 363 | $use_aprs = true; |
364 | 364 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
365 | 365 | break; |
366 | - } |
|
366 | + } |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | if ($use_aprs) { |
@@ -404,133 +404,133 @@ discard block |
||
404 | 404 | |
405 | 405 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
406 | 406 | while ($i > 0) { |
407 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
407 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
408 | 408 | |
409 | - if (!$globalDaemon) $i = $endtime-time(); |
|
410 | - // Delete old ATC |
|
411 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
409 | + if (!$globalDaemon) $i = $endtime-time(); |
|
410 | + // Delete old ATC |
|
411 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
412 | 412 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
413 | - $ATC->deleteOldATC(); |
|
414 | - } |
|
413 | + $ATC->deleteOldATC(); |
|
414 | + } |
|
415 | 415 | |
416 | - if (count($last_exec) == count($globalSources)) { |
|
416 | + if (count($last_exec) == count($globalSources)) { |
|
417 | 417 | $max = $globalMinFetch; |
418 | 418 | foreach ($last_exec as $last) { |
419 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
419 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
420 | 420 | } |
421 | 421 | if ($max < $globalMinFetch) { |
422 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
423 | - sleep($globalMinFetch-$max+2); |
|
422 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
423 | + sleep($globalMinFetch-$max+2); |
|
424 | + } |
|
424 | 425 | } |
425 | - } |
|
426 | 426 | |
427 | 427 | |
428 | - //foreach ($formats as $id => $value) { |
|
429 | - foreach ($globalSources as $id => $value) { |
|
428 | + //foreach ($formats as $id => $value) { |
|
429 | + foreach ($globalSources as $id => $value) { |
|
430 | 430 | date_default_timezone_set('UTC'); |
431 | 431 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
432 | 432 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
433 | 433 | if ($value['format'] === 'deltadbtxt' && |
434 | - ( |
|
434 | + ( |
|
435 | 435 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
436 | 436 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
437 | - ) |
|
437 | + ) |
|
438 | 438 | ) { |
439 | - //$buffer = $Common->getData($hosts[$id]); |
|
440 | - $buffer = $Common->getData($value['host']); |
|
441 | - if ($buffer != '') $reset = 0; |
|
442 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
443 | - $buffer = explode('\n',$buffer); |
|
444 | - foreach ($buffer as $line) { |
|
445 | - if ($line != '' && count($line) > 7) { |
|
446 | - $line = explode(',', $line); |
|
447 | - $data = array(); |
|
448 | - $data['hex'] = $line[1]; // hex |
|
449 | - $data['ident'] = $line[2]; // ident |
|
450 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
451 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
452 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
453 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
454 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
455 | - $data['verticalrate'] = ''; // vertical rate |
|
456 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
457 | - $data['emergency'] = ''; // emergency |
|
458 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
459 | - $data['format_source'] = 'deltadbtxt'; |
|
460 | - $data['id_source'] = $id_source; |
|
461 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
462 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
463 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
464 | - $SI->add($data); |
|
465 | - unset($data); |
|
466 | - } |
|
467 | - } |
|
468 | - $last_exec[$id]['last'] = time(); |
|
439 | + //$buffer = $Common->getData($hosts[$id]); |
|
440 | + $buffer = $Common->getData($value['host']); |
|
441 | + if ($buffer != '') $reset = 0; |
|
442 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
443 | + $buffer = explode('\n',$buffer); |
|
444 | + foreach ($buffer as $line) { |
|
445 | + if ($line != '' && count($line) > 7) { |
|
446 | + $line = explode(',', $line); |
|
447 | + $data = array(); |
|
448 | + $data['hex'] = $line[1]; // hex |
|
449 | + $data['ident'] = $line[2]; // ident |
|
450 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
451 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
452 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
453 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
454 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
455 | + $data['verticalrate'] = ''; // vertical rate |
|
456 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
457 | + $data['emergency'] = ''; // emergency |
|
458 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
459 | + $data['format_source'] = 'deltadbtxt'; |
|
460 | + $data['id_source'] = $id_source; |
|
461 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
462 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
463 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
464 | + $SI->add($data); |
|
465 | + unset($data); |
|
466 | + } |
|
467 | + } |
|
468 | + $last_exec[$id]['last'] = time(); |
|
469 | 469 | } elseif ($value['format'] === 'aisnmeatxt' && |
470 | - ( |
|
470 | + ( |
|
471 | 471 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
472 | 472 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
473 | - ) |
|
473 | + ) |
|
474 | 474 | ) { |
475 | - date_default_timezone_set('CET'); |
|
476 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
477 | - date_default_timezone_set('UTC'); |
|
478 | - if ($buffer != '') $reset = 0; |
|
479 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
480 | - $buffer = explode('\n',$buffer); |
|
481 | - foreach ($buffer as $line) { |
|
475 | + date_default_timezone_set('CET'); |
|
476 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
477 | + date_default_timezone_set('UTC'); |
|
478 | + if ($buffer != '') $reset = 0; |
|
479 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
480 | + $buffer = explode('\n',$buffer); |
|
481 | + foreach ($buffer as $line) { |
|
482 | 482 | if ($line != '') { |
483 | - //echo "'".$line."'\n"; |
|
484 | - $add = false; |
|
485 | - $ais_data = $AIS->parse_line(trim($line)); |
|
486 | - $data = array(); |
|
487 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
488 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
489 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
490 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
491 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
492 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
493 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
494 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
495 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
496 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
497 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
498 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
499 | - if (isset($ais_data['timestamp'])) { |
|
483 | + //echo "'".$line."'\n"; |
|
484 | + $add = false; |
|
485 | + $ais_data = $AIS->parse_line(trim($line)); |
|
486 | + $data = array(); |
|
487 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
488 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
489 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
490 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
491 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
492 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
493 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
494 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
495 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
496 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
497 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
498 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
499 | + if (isset($ais_data['timestamp'])) { |
|
500 | 500 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
501 | 501 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
502 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
503 | - $add = true; |
|
502 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
503 | + $add = true; |
|
504 | 504 | } |
505 | - } else { |
|
505 | + } else { |
|
506 | 506 | $data['datetime'] = date('Y-m-d H:i:s'); |
507 | 507 | $add = true; |
508 | - } |
|
509 | - $data['format_source'] = 'aisnmeatxt'; |
|
510 | - $data['id_source'] = $id_source; |
|
511 | - //print_r($data); |
|
512 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
513 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
514 | - unset($data); |
|
508 | + } |
|
509 | + $data['format_source'] = 'aisnmeatxt'; |
|
510 | + $data['id_source'] = $id_source; |
|
511 | + //print_r($data); |
|
512 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
513 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
514 | + unset($data); |
|
515 | 515 | } |
516 | - } |
|
517 | - $last_exec[$id]['last'] = time(); |
|
516 | + } |
|
517 | + $last_exec[$id]['last'] = time(); |
|
518 | 518 | } elseif ($value['format'] === 'aisnmeahttp') { |
519 | - $arr = $httpfeeds; |
|
520 | - $w = $e = null; |
|
519 | + $arr = $httpfeeds; |
|
520 | + $w = $e = null; |
|
521 | 521 | |
522 | - if (isset($arr[$id])) { |
|
522 | + if (isset($arr[$id])) { |
|
523 | 523 | $nn = stream_select($arr,$w,$e,$timeout); |
524 | 524 | if ($nn > 0) { |
525 | - foreach ($httpfeeds as $feed) { |
|
525 | + foreach ($httpfeeds as $feed) { |
|
526 | 526 | $buffer = stream_get_line($feed,2000,"\n"); |
527 | 527 | if ($buffer === FALSE) { |
528 | - connect_all($globalSources); |
|
528 | + connect_all($globalSources); |
|
529 | 529 | } |
530 | 530 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
531 | 531 | $buffer = explode('\n',$buffer); |
532 | 532 | foreach ($buffer as $line) { |
533 | - if ($line != '') { |
|
533 | + if ($line != '') { |
|
534 | 534 | $ais_data = $AIS->parse_line(trim($line)); |
535 | 535 | $data = array(); |
536 | 536 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -548,117 +548,117 @@ discard block |
||
548 | 548 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
549 | 549 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
550 | 550 | if (isset($ais_data['timestamp'])) { |
551 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
551 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
552 | 552 | } else { |
553 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
553 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
554 | 554 | } |
555 | 555 | $data['format_source'] = 'aisnmeahttp'; |
556 | 556 | $data['id_source'] = $id_source; |
557 | 557 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
558 | 558 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
559 | 559 | unset($data); |
560 | - } |
|
560 | + } |
|
561 | + } |
|
561 | 562 | } |
562 | - } |
|
563 | 563 | } else { |
564 | - $format = $value['format']; |
|
565 | - if (isset($tt[$format])) $tt[$format]++; |
|
566 | - else $tt[$format] = 0; |
|
567 | - if ($tt[$format] > 30) { |
|
564 | + $format = $value['format']; |
|
565 | + if (isset($tt[$format])) $tt[$format]++; |
|
566 | + else $tt[$format] = 0; |
|
567 | + if ($tt[$format] > 30) { |
|
568 | 568 | if ($globalDebug) echo 'Reconnect...'."\n"; |
569 | 569 | sleep(2); |
570 | 570 | //$sourceeen[] = $value; |
571 | 571 | //connect_all($sourceeen); |
572 | 572 | //$sourceeen = array(); |
573 | 573 | connect_all($globalSources); |
574 | - } |
|
574 | + } |
|
575 | + } |
|
575 | 576 | } |
576 | - } |
|
577 | 577 | } elseif ($value['format'] === 'myshiptracking' && |
578 | - ( |
|
578 | + ( |
|
579 | 579 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
580 | 580 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
581 | - ) |
|
581 | + ) |
|
582 | 582 | ) { |
583 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
584 | - if ($buffer != '') { |
|
583 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
584 | + if ($buffer != '') { |
|
585 | 585 | //echo $buffer; |
586 | 586 | $all_data = json_decode($buffer,true); |
587 | 587 | //print_r($all_data); |
588 | 588 | if (isset($all_data[0]['DATA'])) { |
589 | - foreach ($all_data[0]['DATA'] as $line) { |
|
589 | + foreach ($all_data[0]['DATA'] as $line) { |
|
590 | 590 | if ($line != '') { |
591 | - $data = array(); |
|
592 | - $data['ident'] = $line['NAME']; |
|
593 | - $data['mmsi'] = $line['MMSI']; |
|
594 | - if (strlen($data['mmsi']) > 9) { |
|
591 | + $data = array(); |
|
592 | + $data['ident'] = $line['NAME']; |
|
593 | + $data['mmsi'] = $line['MMSI']; |
|
594 | + if (strlen($data['mmsi']) > 9) { |
|
595 | 595 | $data['mmsi'] = substr($data['mmsi'],-9); |
596 | - } |
|
597 | - $data['speed'] = $line['SOG']; |
|
598 | - $data['heading'] = $line['COG']; |
|
599 | - $data['latitude'] = $line['LAT']; |
|
600 | - $data['longitude'] = $line['LNG']; |
|
601 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
602 | - //$data['type_id'] = $line['TYPE']; |
|
603 | - $data['imo'] = $line['IMO']; |
|
604 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
605 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
606 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
607 | - $data['format_source'] = 'myshiptracking'; |
|
608 | - $data['id_source'] = $id_source; |
|
609 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
610 | - $MI->add($data); |
|
611 | - unset($data); |
|
596 | + } |
|
597 | + $data['speed'] = $line['SOG']; |
|
598 | + $data['heading'] = $line['COG']; |
|
599 | + $data['latitude'] = $line['LAT']; |
|
600 | + $data['longitude'] = $line['LNG']; |
|
601 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
602 | + //$data['type_id'] = $line['TYPE']; |
|
603 | + $data['imo'] = $line['IMO']; |
|
604 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
605 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
606 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
607 | + $data['format_source'] = 'myshiptracking'; |
|
608 | + $data['id_source'] = $id_source; |
|
609 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
610 | + $MI->add($data); |
|
611 | + unset($data); |
|
612 | 612 | } |
613 | - } |
|
613 | + } |
|
614 | + } |
|
614 | 615 | } |
615 | - } |
|
616 | - $last_exec[$id]['last'] = time(); |
|
616 | + $last_exec[$id]['last'] = time(); |
|
617 | 617 | } elseif ($value['format'] === 'boatbeaconapp' && |
618 | - ( |
|
618 | + ( |
|
619 | 619 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
620 | 620 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
621 | - ) |
|
621 | + ) |
|
622 | 622 | ) { |
623 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
624 | - if ($buffer != '') { |
|
623 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
624 | + if ($buffer != '') { |
|
625 | 625 | $all_data = json_decode($buffer,true); |
626 | 626 | if (isset($all_data[0]['mmsi'])) { |
627 | - foreach ($all_data as $line) { |
|
627 | + foreach ($all_data as $line) { |
|
628 | 628 | if ($line != '') { |
629 | - $data = array(); |
|
630 | - $data['ident'] = $line['shipname']; |
|
631 | - $data['callsign'] = $line['callsign']; |
|
632 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
633 | - $data['speed'] = $line['sog']; |
|
634 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
635 | - $data['latitude'] = $line['latitude']; |
|
636 | - $data['longitude'] = $line['longitude']; |
|
637 | - $data['type_id'] = $line['shiptype']; |
|
638 | - $data['arrival_code'] = $line['destination']; |
|
639 | - $data['datetime'] = $line['time']; |
|
640 | - $data['format_source'] = 'boatbeaconapp'; |
|
641 | - $data['id_source'] = $id_source; |
|
642 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
643 | - $MI->add($data); |
|
644 | - unset($data); |
|
629 | + $data = array(); |
|
630 | + $data['ident'] = $line['shipname']; |
|
631 | + $data['callsign'] = $line['callsign']; |
|
632 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
633 | + $data['speed'] = $line['sog']; |
|
634 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
635 | + $data['latitude'] = $line['latitude']; |
|
636 | + $data['longitude'] = $line['longitude']; |
|
637 | + $data['type_id'] = $line['shiptype']; |
|
638 | + $data['arrival_code'] = $line['destination']; |
|
639 | + $data['datetime'] = $line['time']; |
|
640 | + $data['format_source'] = 'boatbeaconapp'; |
|
641 | + $data['id_source'] = $id_source; |
|
642 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
643 | + $MI->add($data); |
|
644 | + unset($data); |
|
645 | + } |
|
645 | 646 | } |
646 | - } |
|
647 | 647 | } |
648 | 648 | |
649 | - } |
|
650 | - $last_exec[$id]['last'] = time(); |
|
649 | + } |
|
650 | + $last_exec[$id]['last'] = time(); |
|
651 | 651 | } elseif ($value['format'] === 'boatnerd' && |
652 | - ( |
|
652 | + ( |
|
653 | 653 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
654 | 654 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
655 | - ) |
|
655 | + ) |
|
656 | 656 | ) { |
657 | - $buffer = $Common->getData($value['host']); |
|
658 | - if ($buffer != '') { |
|
657 | + $buffer = $Common->getData($value['host']); |
|
658 | + if ($buffer != '') { |
|
659 | 659 | $all_data = json_decode($buffer,true); |
660 | 660 | if (isset($all_data['features'][0]['id'])) { |
661 | - foreach ($all_data['features'] as $line) { |
|
661 | + foreach ($all_data['features'] as $line) { |
|
662 | 662 | print_r($line); |
663 | 663 | $data = array(); |
664 | 664 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -678,80 +678,80 @@ discard block |
||
678 | 678 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
679 | 679 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
680 | 680 | unset($data); |
681 | - } |
|
681 | + } |
|
682 | 682 | } |
683 | 683 | |
684 | - } |
|
685 | - $last_exec[$id]['last'] = time(); |
|
684 | + } |
|
685 | + $last_exec[$id]['last'] = time(); |
|
686 | 686 | } elseif ($value['format'] === 'shipplotter' && |
687 | - ( |
|
687 | + ( |
|
688 | 688 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
689 | 689 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
690 | - ) |
|
690 | + ) |
|
691 | 691 | ) { |
692 | - echo 'download...'; |
|
693 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
694 | - echo 'done !'."\n"; |
|
695 | - // FIXME: Need more work |
|
696 | - if ($buffer != '') $reset = 0; |
|
697 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
698 | - $buffer = explode('\n',$buffer); |
|
699 | - foreach ($buffer as $line) { |
|
692 | + echo 'download...'; |
|
693 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
694 | + echo 'done !'."\n"; |
|
695 | + // FIXME: Need more work |
|
696 | + if ($buffer != '') $reset = 0; |
|
697 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
698 | + $buffer = explode('\n',$buffer); |
|
699 | + foreach ($buffer as $line) { |
|
700 | 700 | if ($line != '') { |
701 | - $data = array(); |
|
702 | - echo $line."\n"; |
|
703 | - $data['mmsi'] = (int)substr($line,0,9); |
|
704 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
705 | - $data['status_id'] = substr($line,21,2); |
|
706 | - $data['type_id'] = substr($line,24,3); |
|
707 | - $data['latitude'] = substr($line,29,9); |
|
708 | - $data['longitude'] = substr($line,41,9); |
|
709 | - $data['speed'] = round(substr($line,51,5)); |
|
710 | - //$data['course'] = substr($line,57,5); |
|
711 | - $data['heading'] = round(substr($line,63,3)); |
|
712 | - //$data['draft'] = substr($line,67,4); |
|
713 | - //$data['length'] = substr($line,72,3); |
|
714 | - //$data['beam'] = substr($line,76,2); |
|
715 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
716 | - //$data['callsign'] = trim(substr($line,100,7); |
|
717 | - $data['arrival_code'] = substr($line,108,20); |
|
718 | - //$data['etaDate'] = substr($line,129,5); |
|
719 | - //$data['etaTime'] = substr($line,135,5); |
|
720 | - $data['format_source'] = 'shipplotter'; |
|
721 | - $data['id_source'] = $id_source; |
|
722 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
723 | - //print_r($data); |
|
724 | - echo 'Add...'."\n"; |
|
725 | - $MI->add($data); |
|
726 | - unset($data); |
|
701 | + $data = array(); |
|
702 | + echo $line."\n"; |
|
703 | + $data['mmsi'] = (int)substr($line,0,9); |
|
704 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
705 | + $data['status_id'] = substr($line,21,2); |
|
706 | + $data['type_id'] = substr($line,24,3); |
|
707 | + $data['latitude'] = substr($line,29,9); |
|
708 | + $data['longitude'] = substr($line,41,9); |
|
709 | + $data['speed'] = round(substr($line,51,5)); |
|
710 | + //$data['course'] = substr($line,57,5); |
|
711 | + $data['heading'] = round(substr($line,63,3)); |
|
712 | + //$data['draft'] = substr($line,67,4); |
|
713 | + //$data['length'] = substr($line,72,3); |
|
714 | + //$data['beam'] = substr($line,76,2); |
|
715 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
716 | + //$data['callsign'] = trim(substr($line,100,7); |
|
717 | + $data['arrival_code'] = substr($line,108,20); |
|
718 | + //$data['etaDate'] = substr($line,129,5); |
|
719 | + //$data['etaTime'] = substr($line,135,5); |
|
720 | + $data['format_source'] = 'shipplotter'; |
|
721 | + $data['id_source'] = $id_source; |
|
722 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
723 | + //print_r($data); |
|
724 | + echo 'Add...'."\n"; |
|
725 | + $MI->add($data); |
|
726 | + unset($data); |
|
727 | 727 | } |
728 | - } |
|
729 | - $last_exec[$id]['last'] = time(); |
|
728 | + } |
|
729 | + $last_exec[$id]['last'] = time(); |
|
730 | 730 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
731 | 731 | } elseif ( |
732 | - ( |
|
732 | + ( |
|
733 | 733 | $value['format'] === 'whazzup' && |
734 | 734 | ( |
735 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
736 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
735 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
736 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
737 | 737 | ) |
738 | - ) || ( |
|
738 | + ) || ( |
|
739 | 739 | $value['format'] === 'vatsimtxt' && |
740 | 740 | ( |
741 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
742 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
741 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
742 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
743 | + ) |
|
743 | 744 | ) |
744 | - ) |
|
745 | 745 | ) { |
746 | - //$buffer = $Common->getData($hosts[$id]); |
|
747 | - $buffer = $Common->getData($value['host']); |
|
748 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
749 | - $buffer = explode('\n',$buffer); |
|
750 | - $reset = 0; |
|
751 | - foreach ($buffer as $line) { |
|
752 | - if ($line != '') { |
|
753 | - $line = explode(':', $line); |
|
754 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
746 | + //$buffer = $Common->getData($hosts[$id]); |
|
747 | + $buffer = $Common->getData($value['host']); |
|
748 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
749 | + $buffer = explode('\n',$buffer); |
|
750 | + $reset = 0; |
|
751 | + foreach ($buffer as $line) { |
|
752 | + if ($line != '') { |
|
753 | + $line = explode(':', $line); |
|
754 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
755 | 755 | $data = array(); |
756 | 756 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
757 | 757 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -764,37 +764,37 @@ discard block |
||
764 | 764 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
765 | 765 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
766 | 766 | $data['latitude'] = $line[5]; // lat |
767 | - $data['longitude'] = $line[6]; // long |
|
768 | - $data['verticalrate'] = ''; // vertical rate |
|
769 | - $data['squawk'] = ''; // squawk |
|
770 | - $data['emergency'] = ''; // emergency |
|
771 | - $data['waypoints'] = $line[30]; |
|
767 | + $data['longitude'] = $line[6]; // long |
|
768 | + $data['verticalrate'] = ''; // vertical rate |
|
769 | + $data['squawk'] = ''; // squawk |
|
770 | + $data['emergency'] = ''; // emergency |
|
771 | + $data['waypoints'] = $line[30]; |
|
772 | 772 | $data['datetime'] = date('Y-m-d H:i:s'); |
773 | 773 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
774 | 774 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
775 | - $data['departure_airport_icao'] = $line[11]; |
|
776 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
777 | - $data['arrival_airport_icao'] = $line[13]; |
|
775 | + $data['departure_airport_icao'] = $line[11]; |
|
776 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
777 | + $data['arrival_airport_icao'] = $line[13]; |
|
778 | 778 | $data['frequency'] = $line[4]; |
779 | 779 | $data['type'] = $line[18]; |
780 | 780 | $data['range'] = $line[19]; |
781 | 781 | if (isset($line[35])) $data['info'] = $line[35]; |
782 | - $data['id_source'] = $id_source; |
|
783 | - //$data['arrival_airport_time'] = ; |
|
784 | - if ($line[9] != '') { |
|
785 | - $aircraft_data = explode('/',$line[9]); |
|
786 | - if (isset($aircraft_data[1])) { |
|
787 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
788 | - } |
|
789 | - } |
|
790 | - /* |
|
782 | + $data['id_source'] = $id_source; |
|
783 | + //$data['arrival_airport_time'] = ; |
|
784 | + if ($line[9] != '') { |
|
785 | + $aircraft_data = explode('/',$line[9]); |
|
786 | + if (isset($aircraft_data[1])) { |
|
787 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
788 | + } |
|
789 | + } |
|
790 | + /* |
|
791 | 791 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
792 | 792 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
793 | 793 | */ |
794 | - $data['format_source'] = $value['format']; |
|
794 | + $data['format_source'] = $value['format']; |
|
795 | 795 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
796 | 796 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
797 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
797 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
798 | 798 | elseif ($line[3] === 'ATC') { |
799 | 799 | //print_r($data); |
800 | 800 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -815,21 +815,21 @@ discard block |
||
815 | 815 | 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']); |
816 | 816 | } |
817 | 817 | } |
818 | - unset($data); |
|
819 | - } |
|
820 | - } |
|
821 | - } |
|
822 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
823 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
824 | - $last_exec[$id]['last'] = time(); |
|
825 | - } elseif ($value['format'] === 'airwhere' && |
|
826 | - ( |
|
827 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
828 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
829 | - ) |
|
830 | - ) { |
|
831 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
832 | - if ($buffer != '') { |
|
818 | + unset($data); |
|
819 | + } |
|
820 | + } |
|
821 | + } |
|
822 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
823 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
824 | + $last_exec[$id]['last'] = time(); |
|
825 | + } elseif ($value['format'] === 'airwhere' && |
|
826 | + ( |
|
827 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
828 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
829 | + ) |
|
830 | + ) { |
|
831 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
832 | + if ($buffer != '') { |
|
833 | 833 | $all_data = simplexml_load_string($buffer); |
834 | 834 | foreach($all_data->children() as $childdata) { |
835 | 835 | $data = array(); |
@@ -851,10 +851,10 @@ discard block |
||
851 | 851 | $SI->add($data); |
852 | 852 | unset($data); |
853 | 853 | } |
854 | - } |
|
855 | - $Source->deleteOldLocationByType('gs'); |
|
856 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
857 | - if ($buffer != '') { |
|
854 | + } |
|
855 | + $Source->deleteOldLocationByType('gs'); |
|
856 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
857 | + if ($buffer != '') { |
|
858 | 858 | $all_data = simplexml_load_string($buffer); |
859 | 859 | foreach($all_data->children() as $childdata) { |
860 | 860 | $data = array(); |
@@ -872,8 +872,8 @@ discard block |
||
872 | 872 | } |
873 | 873 | unset($data); |
874 | 874 | } |
875 | - } |
|
876 | - $last_exec[$id]['last'] = time(); |
|
875 | + } |
|
876 | + $last_exec[$id]['last'] = time(); |
|
877 | 877 | /* |
878 | 878 | } if ($value['format'] === 'aircraftlistjson') { |
879 | 879 | print_r($globalSources); |
@@ -881,17 +881,17 @@ discard block |
||
881 | 881 | echo $globalMinFetch; |
882 | 882 | */ |
883 | 883 | } elseif ($value['format'] === 'aircraftlistjson' && |
884 | - ( |
|
884 | + ( |
|
885 | 885 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
886 | 886 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
887 | - ) |
|
887 | + ) |
|
888 | 888 | ) { |
889 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
890 | - if ($buffer != '') { |
|
891 | - $all_data = json_decode($buffer,true); |
|
889 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
890 | + if ($buffer != '') { |
|
891 | + $all_data = json_decode($buffer,true); |
|
892 | 892 | if (isset($all_data['acList'])) { |
893 | - $reset = 0; |
|
894 | - foreach ($all_data['acList'] as $line) { |
|
893 | + $reset = 0; |
|
894 | + foreach ($all_data['acList'] as $line) { |
|
895 | 895 | $data = array(); |
896 | 896 | $data['hex'] = $line['Icao']; // hex |
897 | 897 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -914,10 +914,10 @@ discard block |
||
914 | 914 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
915 | 915 | if (isset($data['latitude'])) $SI->add($data); |
916 | 916 | unset($data); |
917 | - } |
|
917 | + } |
|
918 | 918 | } elseif (is_array($all_data)) { |
919 | - $reset = 0; |
|
920 | - foreach ($all_data as $line) { |
|
919 | + $reset = 0; |
|
920 | + foreach ($all_data as $line) { |
|
921 | 921 | $data = array(); |
922 | 922 | $data['hex'] = $line['hex']; // hex |
923 | 923 | $data['ident'] = $line['flight']; // ident |
@@ -937,257 +937,257 @@ discard block |
||
937 | 937 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
938 | 938 | $SI->add($data); |
939 | 939 | unset($data); |
940 | - } |
|
940 | + } |
|
941 | 941 | } |
942 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
943 | - //$last_exec['aircraftlistjson'] = time(); |
|
944 | - $last_exec[$id]['last'] = time(); |
|
945 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
946 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
947 | - ( |
|
948 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
949 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
950 | - ) |
|
951 | - ) { |
|
952 | - $buffer = $Common->getData($value['host']); |
|
953 | - $all_data = json_decode($buffer,true); |
|
954 | - if (isset($all_data['planes'])) { |
|
942 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
943 | + //$last_exec['aircraftlistjson'] = time(); |
|
944 | + $last_exec[$id]['last'] = time(); |
|
945 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
946 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
947 | + ( |
|
948 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
949 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
950 | + ) |
|
951 | + ) { |
|
952 | + $buffer = $Common->getData($value['host']); |
|
953 | + $all_data = json_decode($buffer,true); |
|
954 | + if (isset($all_data['planes'])) { |
|
955 | 955 | $reset = 0; |
956 | 956 | foreach ($all_data['planes'] as $key => $line) { |
957 | - $data = array(); |
|
958 | - $data['hex'] = $key; // hex |
|
959 | - $data['ident'] = $line[3]; // ident |
|
960 | - $data['altitude'] = $line[6]; // altitude |
|
961 | - $data['speed'] = $line[8]; // speed |
|
962 | - $data['heading'] = $line[7]; // heading |
|
963 | - $data['latitude'] = $line[4]; // lat |
|
964 | - $data['longitude'] = $line[5]; // long |
|
965 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
966 | - $data['squawk'] = $line[10]; // squawk |
|
967 | - $data['emergency'] = ''; // emergency |
|
968 | - $data['registration'] = $line[2]; |
|
969 | - $data['aircraft_icao'] = $line[0]; |
|
970 | - $deparr = explode('-',$line[1]); |
|
971 | - if (count($deparr) === 2) { |
|
957 | + $data = array(); |
|
958 | + $data['hex'] = $key; // hex |
|
959 | + $data['ident'] = $line[3]; // ident |
|
960 | + $data['altitude'] = $line[6]; // altitude |
|
961 | + $data['speed'] = $line[8]; // speed |
|
962 | + $data['heading'] = $line[7]; // heading |
|
963 | + $data['latitude'] = $line[4]; // lat |
|
964 | + $data['longitude'] = $line[5]; // long |
|
965 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
966 | + $data['squawk'] = $line[10]; // squawk |
|
967 | + $data['emergency'] = ''; // emergency |
|
968 | + $data['registration'] = $line[2]; |
|
969 | + $data['aircraft_icao'] = $line[0]; |
|
970 | + $deparr = explode('-',$line[1]); |
|
971 | + if (count($deparr) === 2) { |
|
972 | 972 | $data['departure_airport_icao'] = $deparr[0]; |
973 | 973 | $data['arrival_airport_icao'] = $deparr[1]; |
974 | - } |
|
975 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
976 | - $data['format_source'] = 'planeupdatefaa'; |
|
977 | - $data['id_source'] = $id_source; |
|
978 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
979 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
980 | - $SI->add($data); |
|
981 | - unset($data); |
|
974 | + } |
|
975 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
976 | + $data['format_source'] = 'planeupdatefaa'; |
|
977 | + $data['id_source'] = $id_source; |
|
978 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
979 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
980 | + $SI->add($data); |
|
981 | + unset($data); |
|
982 | 982 | } |
983 | - } |
|
984 | - //$last_exec['planeupdatefaa'] = time(); |
|
985 | - $last_exec[$id]['last'] = time(); |
|
983 | + } |
|
984 | + //$last_exec['planeupdatefaa'] = time(); |
|
985 | + $last_exec[$id]['last'] = time(); |
|
986 | 986 | } elseif ($value['format'] === 'opensky' && |
987 | - ( |
|
987 | + ( |
|
988 | 988 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
989 | 989 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
990 | - ) |
|
990 | + ) |
|
991 | 991 | ) { |
992 | - $buffer = $Common->getData($value['host']); |
|
993 | - $all_data = json_decode($buffer,true); |
|
994 | - if (isset($all_data['states'])) { |
|
992 | + $buffer = $Common->getData($value['host']); |
|
993 | + $all_data = json_decode($buffer,true); |
|
994 | + if (isset($all_data['states'])) { |
|
995 | 995 | $reset = 0; |
996 | 996 | foreach ($all_data['states'] as $key => $line) { |
997 | - $data = array(); |
|
998 | - $data['hex'] = $line[0]; // hex |
|
999 | - $data['ident'] = trim($line[1]); // ident |
|
1000 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1001 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
1002 | - $data['heading'] = round($line[10]); // heading |
|
1003 | - $data['latitude'] = $line[6]; // lat |
|
1004 | - $data['longitude'] = $line[5]; // long |
|
1005 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
1006 | - //$data['squawk'] = $line[10]; // squawk |
|
1007 | - //$data['emergency'] = ''; // emergency |
|
1008 | - //$data['registration'] = $line[2]; |
|
1009 | - //$data['aircraft_icao'] = $line[0]; |
|
1010 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1011 | - $data['format_source'] = 'opensky'; |
|
1012 | - $data['id_source'] = $id_source; |
|
1013 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1014 | - $SI->add($data); |
|
1015 | - unset($data); |
|
997 | + $data = array(); |
|
998 | + $data['hex'] = $line[0]; // hex |
|
999 | + $data['ident'] = trim($line[1]); // ident |
|
1000 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1001 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
1002 | + $data['heading'] = round($line[10]); // heading |
|
1003 | + $data['latitude'] = $line[6]; // lat |
|
1004 | + $data['longitude'] = $line[5]; // long |
|
1005 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
1006 | + //$data['squawk'] = $line[10]; // squawk |
|
1007 | + //$data['emergency'] = ''; // emergency |
|
1008 | + //$data['registration'] = $line[2]; |
|
1009 | + //$data['aircraft_icao'] = $line[0]; |
|
1010 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1011 | + $data['format_source'] = 'opensky'; |
|
1012 | + $data['id_source'] = $id_source; |
|
1013 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1014 | + $SI->add($data); |
|
1015 | + unset($data); |
|
1016 | 1016 | } |
1017 | - } |
|
1018 | - //$last_exec['planeupdatefaa'] = time(); |
|
1019 | - $last_exec[$id]['last'] = time(); |
|
1017 | + } |
|
1018 | + //$last_exec['planeupdatefaa'] = time(); |
|
1019 | + $last_exec[$id]['last'] = time(); |
|
1020 | 1020 | } elseif ($value['format'] === 'aircraftjson' && |
1021 | - ( |
|
1021 | + ( |
|
1022 | 1022 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1023 | 1023 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1024 | - ) |
|
1024 | + ) |
|
1025 | 1025 | ) { |
1026 | - $buffer = $Common->getData($value['host']); |
|
1027 | - $all_data = json_decode($buffer,true); |
|
1028 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1026 | + $buffer = $Common->getData($value['host']); |
|
1027 | + $all_data = json_decode($buffer,true); |
|
1028 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1029 | 1029 | $reset = 0; |
1030 | 1030 | foreach ($all_data['aircraft'] as $key => $line) { |
1031 | - $data = array(); |
|
1032 | - // add support for ground vehicule with ~ in front of hex |
|
1033 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1034 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1035 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1036 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1037 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1038 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1039 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1040 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1041 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1042 | - //$data['emergency'] = ''; // emergency |
|
1043 | - //$data['registration'] = $line[2]; |
|
1044 | - //$data['aircraft_icao'] = $line[0]; |
|
1045 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1046 | - $data['format_source'] = 'aircraftjson'; |
|
1047 | - $data['id_source'] = $id_source; |
|
1048 | - if (isset($value['name']) && $value['name'] != '') { |
|
1049 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1050 | - else $data['source_name'] = $value['name']; |
|
1051 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1052 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1053 | - $SI->add($data); |
|
1054 | - unset($data); |
|
1031 | + $data = array(); |
|
1032 | + // add support for ground vehicule with ~ in front of hex |
|
1033 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1034 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1035 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1036 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1037 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1038 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1039 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1040 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1041 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1042 | + //$data['emergency'] = ''; // emergency |
|
1043 | + //$data['registration'] = $line[2]; |
|
1044 | + //$data['aircraft_icao'] = $line[0]; |
|
1045 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1046 | + $data['format_source'] = 'aircraftjson'; |
|
1047 | + $data['id_source'] = $id_source; |
|
1048 | + if (isset($value['name']) && $value['name'] != '') { |
|
1049 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1050 | + else $data['source_name'] = $value['name']; |
|
1051 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1052 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1053 | + $SI->add($data); |
|
1054 | + unset($data); |
|
1055 | 1055 | } |
1056 | - } |
|
1057 | - //$last_exec['planeupdatefaa'] = time(); |
|
1058 | - $last_exec[$id]['last'] = time(); |
|
1056 | + } |
|
1057 | + //$last_exec['planeupdatefaa'] = time(); |
|
1058 | + $last_exec[$id]['last'] = time(); |
|
1059 | 1059 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1060 | 1060 | } elseif ($value['format'] === 'fr24json' && |
1061 | - ( |
|
1061 | + ( |
|
1062 | 1062 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1063 | 1063 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1064 | - ) |
|
1064 | + ) |
|
1065 | 1065 | ) { |
1066 | - //$buffer = $Common->getData($hosts[$id]); |
|
1067 | - $buffer = $Common->getData($value['host']); |
|
1068 | - $all_data = json_decode($buffer,true); |
|
1069 | - if (!empty($all_data)) $reset = 0; |
|
1070 | - foreach ($all_data as $key => $line) { |
|
1066 | + //$buffer = $Common->getData($hosts[$id]); |
|
1067 | + $buffer = $Common->getData($value['host']); |
|
1068 | + $all_data = json_decode($buffer,true); |
|
1069 | + if (!empty($all_data)) $reset = 0; |
|
1070 | + foreach ($all_data as $key => $line) { |
|
1071 | 1071 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1072 | - $data = array(); |
|
1073 | - $data['hex'] = $line[0]; |
|
1074 | - $data['ident'] = $line[16]; //$line[13] |
|
1075 | - $data['altitude'] = $line[4]; // altitude |
|
1076 | - $data['speed'] = $line[5]; // speed |
|
1077 | - $data['heading'] = $line[3]; // heading |
|
1078 | - $data['latitude'] = $line[1]; // lat |
|
1079 | - $data['longitude'] = $line[2]; // long |
|
1080 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1081 | - $data['squawk'] = $line[6]; // squawk |
|
1082 | - $data['aircraft_icao'] = $line[8]; |
|
1083 | - $data['registration'] = $line[9]; |
|
1084 | - $data['departure_airport_iata'] = $line[11]; |
|
1085 | - $data['arrival_airport_iata'] = $line[12]; |
|
1086 | - $data['emergency'] = ''; // emergency |
|
1087 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1088 | - $data['format_source'] = 'fr24json'; |
|
1089 | - $data['id_source'] = $id_source; |
|
1090 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1091 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1092 | - $SI->add($data); |
|
1093 | - unset($data); |
|
1072 | + $data = array(); |
|
1073 | + $data['hex'] = $line[0]; |
|
1074 | + $data['ident'] = $line[16]; //$line[13] |
|
1075 | + $data['altitude'] = $line[4]; // altitude |
|
1076 | + $data['speed'] = $line[5]; // speed |
|
1077 | + $data['heading'] = $line[3]; // heading |
|
1078 | + $data['latitude'] = $line[1]; // lat |
|
1079 | + $data['longitude'] = $line[2]; // long |
|
1080 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1081 | + $data['squawk'] = $line[6]; // squawk |
|
1082 | + $data['aircraft_icao'] = $line[8]; |
|
1083 | + $data['registration'] = $line[9]; |
|
1084 | + $data['departure_airport_iata'] = $line[11]; |
|
1085 | + $data['arrival_airport_iata'] = $line[12]; |
|
1086 | + $data['emergency'] = ''; // emergency |
|
1087 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1088 | + $data['format_source'] = 'fr24json'; |
|
1089 | + $data['id_source'] = $id_source; |
|
1090 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1091 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1092 | + $SI->add($data); |
|
1093 | + unset($data); |
|
1094 | + } |
|
1094 | 1095 | } |
1095 | - } |
|
1096 | - //$last_exec['fr24json'] = time(); |
|
1097 | - $last_exec[$id]['last'] = time(); |
|
1096 | + //$last_exec['fr24json'] = time(); |
|
1097 | + $last_exec[$id]['last'] = time(); |
|
1098 | 1098 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1099 | 1099 | } elseif ($value['format'] === 'radarvirtueljson' && |
1100 | - ( |
|
1100 | + ( |
|
1101 | 1101 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1102 | 1102 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1103 | - ) |
|
1103 | + ) |
|
1104 | 1104 | ) { |
1105 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1106 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1107 | - //echo $buffer; |
|
1108 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1109 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1110 | - $all_data = json_decode($buffer,true); |
|
1111 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1105 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1106 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1107 | + //echo $buffer; |
|
1108 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1109 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1110 | + $all_data = json_decode($buffer,true); |
|
1111 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1112 | 1112 | die(json_last_error_msg()); |
1113 | - } |
|
1114 | - if (isset($all_data['mrkrs'])) { |
|
1113 | + } |
|
1114 | + if (isset($all_data['mrkrs'])) { |
|
1115 | 1115 | $reset = 0; |
1116 | 1116 | foreach ($all_data['mrkrs'] as $key => $line) { |
1117 | - if (isset($line['inf'])) { |
|
1117 | + if (isset($line['inf'])) { |
|
1118 | 1118 | $data = array(); |
1119 | 1119 | $data['hex'] = $line['inf']['ia']; |
1120 | 1120 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1121 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1122 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1123 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1124 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1125 | - $data['longitude'] = $line['pt'][1]; // long |
|
1126 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1127 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1128 | - //$data['aircraft_icao'] = $line[8]; |
|
1129 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1121 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1122 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1123 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1124 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1125 | + $data['longitude'] = $line['pt'][1]; // long |
|
1126 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1127 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1128 | + //$data['aircraft_icao'] = $line[8]; |
|
1129 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1130 | 1130 | //$data['departure_airport_iata'] = $line[11]; |
1131 | 1131 | //$data['arrival_airport_iata'] = $line[12]; |
1132 | - //$data['emergency'] = ''; // emergency |
|
1132 | + //$data['emergency'] = ''; // emergency |
|
1133 | 1133 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1134 | - $data['format_source'] = 'radarvirtueljson'; |
|
1135 | - $data['id_source'] = $id_source; |
|
1134 | + $data['format_source'] = 'radarvirtueljson'; |
|
1135 | + $data['id_source'] = $id_source; |
|
1136 | 1136 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1137 | 1137 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1138 | 1138 | $SI->add($data); |
1139 | 1139 | unset($data); |
1140 | - } |
|
1140 | + } |
|
1141 | + } |
|
1141 | 1142 | } |
1142 | - } |
|
1143 | - //$last_exec['radarvirtueljson'] = time(); |
|
1144 | - $last_exec[$id]['last'] = time(); |
|
1143 | + //$last_exec['radarvirtueljson'] = time(); |
|
1144 | + $last_exec[$id]['last'] = time(); |
|
1145 | 1145 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1146 | 1146 | } elseif ($value['format'] === 'pirepsjson' && |
1147 | - ( |
|
1147 | + ( |
|
1148 | 1148 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1149 | 1149 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1150 | - ) |
|
1150 | + ) |
|
1151 | 1151 | ) { |
1152 | - //$buffer = $Common->getData($hosts[$id]); |
|
1153 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1154 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1152 | + //$buffer = $Common->getData($hosts[$id]); |
|
1153 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1154 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1155 | 1155 | |
1156 | - if (isset($all_data['pireps'])) { |
|
1156 | + if (isset($all_data['pireps'])) { |
|
1157 | 1157 | $reset = 0; |
1158 | - foreach ($all_data['pireps'] as $line) { |
|
1159 | - $data = array(); |
|
1160 | - $data['id'] = $line['id']; |
|
1161 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1162 | - $data['ident'] = $line['callsign']; // ident |
|
1163 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1164 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1165 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1166 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1167 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1168 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1169 | - $data['latitude'] = $line['lat']; // lat |
|
1170 | - $data['longitude'] = $line['lon']; // long |
|
1171 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1172 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1173 | - //$data['emergency'] = ''; // emergency |
|
1174 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1175 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1176 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1177 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1178 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1179 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1180 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1181 | - else $data['info'] = ''; |
|
1182 | - $data['format_source'] = 'pireps'; |
|
1183 | - $data['id_source'] = $id_source; |
|
1184 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1185 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1186 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1187 | - if ($line['icon'] === 'plane') { |
|
1158 | + foreach ($all_data['pireps'] as $line) { |
|
1159 | + $data = array(); |
|
1160 | + $data['id'] = $line['id']; |
|
1161 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1162 | + $data['ident'] = $line['callsign']; // ident |
|
1163 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1164 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1165 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1166 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1167 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1168 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1169 | + $data['latitude'] = $line['lat']; // lat |
|
1170 | + $data['longitude'] = $line['lon']; // long |
|
1171 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1172 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1173 | + //$data['emergency'] = ''; // emergency |
|
1174 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1175 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1176 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1177 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1178 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1179 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1180 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1181 | + else $data['info'] = ''; |
|
1182 | + $data['format_source'] = 'pireps'; |
|
1183 | + $data['id_source'] = $id_source; |
|
1184 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1185 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1186 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1187 | + if ($line['icon'] === 'plane') { |
|
1188 | 1188 | $SI->add($data); |
1189 | - // print_r($data); |
|
1190 | - } elseif ($line['icon'] === 'ct') { |
|
1189 | + // print_r($data); |
|
1190 | + } elseif ($line['icon'] === 'ct') { |
|
1191 | 1191 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1192 | 1192 | $data['info'] = str_replace('&sect;','',$data['info']); |
1193 | 1193 | $typec = substr($data['ident'],-3); |
@@ -1202,209 +1202,209 @@ discard block |
||
1202 | 1202 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1203 | 1203 | else $data['type'] = 'Observer'; |
1204 | 1204 | 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']); |
1205 | - } |
|
1206 | - unset($data); |
|
1205 | + } |
|
1206 | + unset($data); |
|
1207 | + } |
|
1207 | 1208 | } |
1208 | - } |
|
1209 | - //$last_exec['pirepsjson'] = time(); |
|
1210 | - $last_exec[$id]['last'] = time(); |
|
1209 | + //$last_exec['pirepsjson'] = time(); |
|
1210 | + $last_exec[$id]['last'] = time(); |
|
1211 | 1211 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1212 | 1212 | } elseif ($value['format'] === 'phpvmacars' && |
1213 | - ( |
|
1213 | + ( |
|
1214 | 1214 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1215 | 1215 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1216 | - ) |
|
1216 | + ) |
|
1217 | 1217 | ) { |
1218 | - //$buffer = $Common->getData($hosts[$id]); |
|
1219 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1220 | - $buffer = $Common->getData($value['host']); |
|
1221 | - $all_data = json_decode($buffer,true); |
|
1222 | - if ($buffer != '' && is_array($all_data)) { |
|
1218 | + //$buffer = $Common->getData($hosts[$id]); |
|
1219 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1220 | + $buffer = $Common->getData($value['host']); |
|
1221 | + $all_data = json_decode($buffer,true); |
|
1222 | + if ($buffer != '' && is_array($all_data)) { |
|
1223 | 1223 | $reset = 0; |
1224 | 1224 | foreach ($all_data as $line) { |
1225 | - $data = array(); |
|
1226 | - //$data['id'] = $line['id']; // id not usable |
|
1227 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1228 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1229 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1230 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1231 | - $data['ident'] = $line['flightnum']; // ident |
|
1232 | - $data['altitude'] = $line['alt']; // altitude |
|
1233 | - $data['speed'] = $line['gs']; // speed |
|
1234 | - $data['heading'] = $line['heading']; // heading |
|
1235 | - $data['latitude'] = $line['lat']; // lat |
|
1236 | - $data['longitude'] = $line['lng']; // long |
|
1237 | - $data['verticalrate'] = ''; // verticale rate |
|
1238 | - $data['squawk'] = ''; // squawk |
|
1239 | - $data['emergency'] = ''; // emergency |
|
1240 | - //$data['datetime'] = $line['lastupdate']; |
|
1241 | - //$data['last_update'] = $line['lastupdate']; |
|
1242 | - if (isset($value['timezone'])) { |
|
1243 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1244 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1245 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1246 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1247 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1248 | - $data['departure_airport_time'] = $line['deptime']; |
|
1249 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1250 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1251 | - if (isset($line['registration'])) { |
|
1252 | - $data['registration'] = $line['registration']; |
|
1253 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1254 | - } else $data['registration'] = $line['aircraft']; |
|
1255 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1256 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1257 | - if (isset($line['aircraftname'])) { |
|
1225 | + $data = array(); |
|
1226 | + //$data['id'] = $line['id']; // id not usable |
|
1227 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1228 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1229 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1230 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1231 | + $data['ident'] = $line['flightnum']; // ident |
|
1232 | + $data['altitude'] = $line['alt']; // altitude |
|
1233 | + $data['speed'] = $line['gs']; // speed |
|
1234 | + $data['heading'] = $line['heading']; // heading |
|
1235 | + $data['latitude'] = $line['lat']; // lat |
|
1236 | + $data['longitude'] = $line['lng']; // long |
|
1237 | + $data['verticalrate'] = ''; // verticale rate |
|
1238 | + $data['squawk'] = ''; // squawk |
|
1239 | + $data['emergency'] = ''; // emergency |
|
1240 | + //$data['datetime'] = $line['lastupdate']; |
|
1241 | + //$data['last_update'] = $line['lastupdate']; |
|
1242 | + if (isset($value['timezone'])) { |
|
1243 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1244 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1245 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1246 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1247 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1248 | + $data['departure_airport_time'] = $line['deptime']; |
|
1249 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1250 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1251 | + if (isset($line['registration'])) { |
|
1252 | + $data['registration'] = $line['registration']; |
|
1253 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1254 | + } else $data['registration'] = $line['aircraft']; |
|
1255 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1256 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1257 | + if (isset($line['aircraftname'])) { |
|
1258 | 1258 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1259 | 1259 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1260 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1261 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1262 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1263 | - else { |
|
1264 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1265 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1266 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1267 | - } |
|
1268 | - } |
|
1269 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1270 | - $data['id_source'] = $id_source; |
|
1271 | - $data['format_source'] = 'phpvmacars'; |
|
1272 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1273 | - $SI->add($data); |
|
1274 | - unset($data); |
|
1260 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1261 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1262 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1263 | + else { |
|
1264 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1265 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1266 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1267 | + } |
|
1268 | + } |
|
1269 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1270 | + $data['id_source'] = $id_source; |
|
1271 | + $data['format_source'] = 'phpvmacars'; |
|
1272 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1273 | + $SI->add($data); |
|
1274 | + unset($data); |
|
1275 | 1275 | } |
1276 | 1276 | if ($globalDebug) echo 'No more data...'."\n"; |
1277 | 1277 | unset($buffer); |
1278 | 1278 | unset($all_data); |
1279 | - } |
|
1280 | - //$last_exec['phpvmacars'] = time(); |
|
1281 | - $last_exec[$id]['last'] = time(); |
|
1279 | + } |
|
1280 | + //$last_exec['phpvmacars'] = time(); |
|
1281 | + $last_exec[$id]['last'] = time(); |
|
1282 | 1282 | } elseif ($value['format'] === 'vaos' && |
1283 | - ( |
|
1283 | + ( |
|
1284 | 1284 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1285 | 1285 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1286 | - ) |
|
1286 | + ) |
|
1287 | 1287 | ) { |
1288 | - //$buffer = $Common->getData($hosts[$id]); |
|
1289 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1290 | - $buffer = $Common->getData($value['host']); |
|
1291 | - $all_data = json_decode($buffer,true); |
|
1292 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1288 | + //$buffer = $Common->getData($hosts[$id]); |
|
1289 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1290 | + $buffer = $Common->getData($value['host']); |
|
1291 | + $all_data = json_decode($buffer,true); |
|
1292 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1293 | 1293 | $reset = 0; |
1294 | 1294 | foreach ($all_data['ACARSData'] as $line) { |
1295 | - //print_r($line); |
|
1296 | - $data = array(); |
|
1297 | - //$data['id'] = $line['id']; // id not usable |
|
1298 | - $data['id'] = $line['id']; |
|
1299 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1300 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1301 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1302 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1303 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1304 | - $data['altitude'] = $line['altitude']; // altitude |
|
1305 | - $data['speed'] = $line['groundspeed']; // speed |
|
1306 | - $data['heading'] = $line['heading']; // heading |
|
1307 | - $data['latitude'] = $line['lat']; // lat |
|
1308 | - $data['longitude'] = $line['lon']; // long |
|
1309 | - //$data['verticalrate'] = ''; // verticale rate |
|
1310 | - //$data['squawk'] = ''; // squawk |
|
1311 | - //$data['emergency'] = ''; // emergency |
|
1312 | - if (isset($value['timezone'])) { |
|
1313 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1314 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1315 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1316 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1295 | + //print_r($line); |
|
1296 | + $data = array(); |
|
1297 | + //$data['id'] = $line['id']; // id not usable |
|
1298 | + $data['id'] = $line['id']; |
|
1299 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1300 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1301 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1302 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1303 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1304 | + $data['altitude'] = $line['altitude']; // altitude |
|
1305 | + $data['speed'] = $line['groundspeed']; // speed |
|
1306 | + $data['heading'] = $line['heading']; // heading |
|
1307 | + $data['latitude'] = $line['lat']; // lat |
|
1308 | + $data['longitude'] = $line['lon']; // long |
|
1309 | + //$data['verticalrate'] = ''; // verticale rate |
|
1310 | + //$data['squawk'] = ''; // squawk |
|
1311 | + //$data['emergency'] = ''; // emergency |
|
1312 | + if (isset($value['timezone'])) { |
|
1313 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1314 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1315 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1316 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1317 | 1317 | |
1318 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1319 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1320 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1321 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1322 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1318 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1319 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1320 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1321 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1322 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1323 | 1323 | |
1324 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1325 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1326 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1324 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1325 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1326 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1327 | 1327 | |
1328 | - $data['id_source'] = $id_source; |
|
1329 | - $data['format_source'] = 'vaos'; |
|
1330 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1331 | - $SI->add($data); |
|
1332 | - unset($data); |
|
1328 | + $data['id_source'] = $id_source; |
|
1329 | + $data['format_source'] = 'vaos'; |
|
1330 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1331 | + $SI->add($data); |
|
1332 | + unset($data); |
|
1333 | 1333 | } |
1334 | 1334 | if ($globalDebug) echo 'No more data...'."\n"; |
1335 | 1335 | unset($buffer); |
1336 | 1336 | unset($all_data); |
1337 | - } |
|
1338 | - //$last_exec['phpvmacars'] = time(); |
|
1339 | - $last_exec[$id]['last'] = time(); |
|
1337 | + } |
|
1338 | + //$last_exec['phpvmacars'] = time(); |
|
1339 | + $last_exec[$id]['last'] = time(); |
|
1340 | 1340 | } elseif ($value['format'] === 'vam' && |
1341 | - ( |
|
1341 | + ( |
|
1342 | 1342 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1343 | 1343 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1344 | - ) |
|
1344 | + ) |
|
1345 | 1345 | ) { |
1346 | - //$buffer = $Common->getData($hosts[$id]); |
|
1347 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1348 | - $buffer = $Common->getData($value['host']); |
|
1349 | - $all_data = json_decode($buffer,true); |
|
1350 | - if ($buffer != '' && is_array($all_data)) { |
|
1346 | + //$buffer = $Common->getData($hosts[$id]); |
|
1347 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1348 | + $buffer = $Common->getData($value['host']); |
|
1349 | + $all_data = json_decode($buffer,true); |
|
1350 | + if ($buffer != '' && is_array($all_data)) { |
|
1351 | 1351 | $reset = 0; |
1352 | 1352 | foreach ($all_data as $line) { |
1353 | - $data = array(); |
|
1354 | - //$data['id'] = $line['id']; // id not usable |
|
1355 | - $data['id'] = trim($line['flight_id']); |
|
1356 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1357 | - $data['pilot_name'] = $line['pilot_name']; |
|
1358 | - $data['pilot_id'] = $line['pilot_id']; |
|
1359 | - $data['ident'] = trim($line['callsign']); // ident |
|
1360 | - $data['altitude'] = $line['altitude']; // altitude |
|
1361 | - $data['speed'] = $line['gs']; // speed |
|
1362 | - $data['heading'] = $line['heading']; // heading |
|
1363 | - $data['latitude'] = $line['latitude']; // lat |
|
1364 | - $data['longitude'] = $line['longitude']; // long |
|
1365 | - $data['verticalrate'] = ''; // verticale rate |
|
1366 | - $data['squawk'] = ''; // squawk |
|
1367 | - $data['emergency'] = ''; // emergency |
|
1368 | - //$data['datetime'] = $line['lastupdate']; |
|
1369 | - $data['last_update'] = $line['last_update']; |
|
1370 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1371 | - $data['departure_airport_icao'] = $line['departure']; |
|
1372 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1373 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1374 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1375 | - //$data['registration'] = $line['aircraft']; |
|
1376 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1377 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1378 | - $data['id_source'] = $id_source; |
|
1379 | - $data['format_source'] = 'vam'; |
|
1380 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1381 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1382 | - $SI->add($data); |
|
1383 | - unset($data); |
|
1353 | + $data = array(); |
|
1354 | + //$data['id'] = $line['id']; // id not usable |
|
1355 | + $data['id'] = trim($line['flight_id']); |
|
1356 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1357 | + $data['pilot_name'] = $line['pilot_name']; |
|
1358 | + $data['pilot_id'] = $line['pilot_id']; |
|
1359 | + $data['ident'] = trim($line['callsign']); // ident |
|
1360 | + $data['altitude'] = $line['altitude']; // altitude |
|
1361 | + $data['speed'] = $line['gs']; // speed |
|
1362 | + $data['heading'] = $line['heading']; // heading |
|
1363 | + $data['latitude'] = $line['latitude']; // lat |
|
1364 | + $data['longitude'] = $line['longitude']; // long |
|
1365 | + $data['verticalrate'] = ''; // verticale rate |
|
1366 | + $data['squawk'] = ''; // squawk |
|
1367 | + $data['emergency'] = ''; // emergency |
|
1368 | + //$data['datetime'] = $line['lastupdate']; |
|
1369 | + $data['last_update'] = $line['last_update']; |
|
1370 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1371 | + $data['departure_airport_icao'] = $line['departure']; |
|
1372 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1373 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1374 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1375 | + //$data['registration'] = $line['aircraft']; |
|
1376 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1377 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1378 | + $data['id_source'] = $id_source; |
|
1379 | + $data['format_source'] = 'vam'; |
|
1380 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1381 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1382 | + $SI->add($data); |
|
1383 | + unset($data); |
|
1384 | 1384 | } |
1385 | 1385 | if ($globalDebug) echo 'No more data...'."\n"; |
1386 | 1386 | unset($buffer); |
1387 | 1387 | unset($all_data); |
1388 | - } |
|
1389 | - //$last_exec['phpvmacars'] = time(); |
|
1390 | - $last_exec[$id]['last'] = time(); |
|
1388 | + } |
|
1389 | + //$last_exec['phpvmacars'] = time(); |
|
1390 | + $last_exec[$id]['last'] = time(); |
|
1391 | 1391 | } elseif ($value['format'] === 'blitzortung' && |
1392 | - ( |
|
1392 | + ( |
|
1393 | 1393 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1394 | 1394 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1395 | - ) |
|
1395 | + ) |
|
1396 | 1396 | ) { |
1397 | - //$buffer = $Common->getData($hosts[$id]); |
|
1398 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1399 | - $buffer = $Common->getData($value['host']); |
|
1400 | - $all_data = json_decode($buffer,true); |
|
1401 | - if ($buffer != '') { |
|
1397 | + //$buffer = $Common->getData($hosts[$id]); |
|
1398 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1399 | + $buffer = $Common->getData($value['host']); |
|
1400 | + $all_data = json_decode($buffer,true); |
|
1401 | + if ($buffer != '') { |
|
1402 | 1402 | $Source->deleteLocationBySource('blitzortung'); |
1403 | 1403 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1404 | 1404 | $buffer = explode('\n',$buffer); |
1405 | 1405 | foreach ($buffer as $buffer_line) { |
1406 | - $line = json_decode($buffer_line,true); |
|
1407 | - if (isset($line['time'])) { |
|
1406 | + $line = json_decode($buffer_line,true); |
|
1407 | + if (isset($line['time'])) { |
|
1408 | 1408 | $data = array(); |
1409 | 1409 | $data['altitude'] = $line['alt']; // altitude |
1410 | 1410 | $data['latitude'] = $line['lat']; // lat |
@@ -1416,94 +1416,94 @@ discard block |
||
1416 | 1416 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1417 | 1417 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1418 | 1418 | unset($data); |
1419 | - } |
|
1419 | + } |
|
1420 | 1420 | } |
1421 | 1421 | if ($globalDebug) echo 'No more data...'."\n"; |
1422 | 1422 | unset($buffer); |
1423 | - } |
|
1424 | - $last_exec[$id]['last'] = time(); |
|
1423 | + } |
|
1424 | + $last_exec[$id]['last'] = time(); |
|
1425 | 1425 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
1426 | 1426 | } 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') { |
1427 | - //$last_exec[$id]['last'] = time(); |
|
1428 | - //$read = array( $sockets[$id] ); |
|
1429 | - $read = $sockets; |
|
1430 | - $write = NULL; |
|
1431 | - $e = NULL; |
|
1432 | - $n = socket_select($read, $write, $e, $timeout); |
|
1433 | - if ($e != NULL) var_dump($e); |
|
1434 | - if ($n > 0) { |
|
1427 | + //$last_exec[$id]['last'] = time(); |
|
1428 | + //$read = array( $sockets[$id] ); |
|
1429 | + $read = $sockets; |
|
1430 | + $write = NULL; |
|
1431 | + $e = NULL; |
|
1432 | + $n = socket_select($read, $write, $e, $timeout); |
|
1433 | + if ($e != NULL) var_dump($e); |
|
1434 | + if ($n > 0) { |
|
1435 | 1435 | $reset = 0; |
1436 | 1436 | foreach ($read as $nb => $r) { |
1437 | - //$value = $formats[$nb]; |
|
1438 | - $format = $globalSources[$nb]['format']; |
|
1439 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1437 | + //$value = $formats[$nb]; |
|
1438 | + $format = $globalSources[$nb]['format']; |
|
1439 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1440 | 1440 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1441 | - } elseif ($format === 'vrstcp') { |
|
1441 | + } elseif ($format === 'vrstcp') { |
|
1442 | 1442 | $buffer = @socket_read($r, 6000); |
1443 | - } else { |
|
1443 | + } else { |
|
1444 | 1444 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1445 | - } |
|
1446 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1447 | - //echo $buffer."\n"; |
|
1448 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1449 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1450 | - $error = false; |
|
1451 | - //$SI::del(); |
|
1452 | - if ($buffer !== FALSE) { |
|
1445 | + } |
|
1446 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1447 | + //echo $buffer."\n"; |
|
1448 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1449 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1450 | + $error = false; |
|
1451 | + //$SI::del(); |
|
1452 | + if ($buffer !== FALSE) { |
|
1453 | 1453 | if ($format === 'vrstcp') { |
1454 | - $buffer = explode('},{',$buffer); |
|
1454 | + $buffer = explode('},{',$buffer); |
|
1455 | 1455 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1456 | - } |
|
1457 | - // SBS format is CSV format |
|
1458 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1456 | + } |
|
1457 | + // SBS format is CSV format |
|
1458 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1459 | 1459 | $tt[$format] = 0; |
1460 | 1460 | if ($format === 'acarssbs3') { |
1461 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1462 | - $ACARS->add(trim($buffer)); |
|
1463 | - $ACARS->deleteLiveAcarsData(); |
|
1461 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1462 | + $ACARS->add(trim($buffer)); |
|
1463 | + $ACARS->deleteLiveAcarsData(); |
|
1464 | 1464 | } elseif ($format === 'raw') { |
1465 | - // AVR format |
|
1466 | - $data = $SBS->parse($buffer); |
|
1467 | - if (is_array($data)) { |
|
1465 | + // AVR format |
|
1466 | + $data = $SBS->parse($buffer); |
|
1467 | + if (is_array($data)) { |
|
1468 | 1468 | $data['datetime'] = date('Y-m-d H:i:s'); |
1469 | 1469 | $data['format_source'] = 'raw'; |
1470 | 1470 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1471 | 1471 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1472 | 1472 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1473 | 1473 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1474 | - } |
|
1474 | + } |
|
1475 | 1475 | } elseif ($format === 'ais') { |
1476 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1477 | - $data = array(); |
|
1478 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1479 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1480 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1481 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1482 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1483 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1484 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1485 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1486 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1487 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1488 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1489 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1490 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1491 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1492 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1493 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1476 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1477 | + $data = array(); |
|
1478 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1479 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1480 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1481 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1482 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1483 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1484 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1485 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1486 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1487 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1488 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1489 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1490 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1491 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1492 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1493 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1494 | 1494 | |
1495 | - if (isset($ais_data['timestamp'])) { |
|
1495 | + if (isset($ais_data['timestamp'])) { |
|
1496 | 1496 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1497 | - } else { |
|
1497 | + } else { |
|
1498 | 1498 | $data['datetime'] = date('Y-m-d H:i:s'); |
1499 | - } |
|
1500 | - $data['format_source'] = 'aisnmea'; |
|
1501 | - $data['id_source'] = $id_source; |
|
1502 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1503 | - unset($data); |
|
1504 | - } elseif ($format === 'flightgearsp') { |
|
1505 | - //echo $buffer."\n"; |
|
1506 | - if (strlen($buffer) > 5) { |
|
1499 | + } |
|
1500 | + $data['format_source'] = 'aisnmea'; |
|
1501 | + $data['id_source'] = $id_source; |
|
1502 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1503 | + unset($data); |
|
1504 | + } elseif ($format === 'flightgearsp') { |
|
1505 | + //echo $buffer."\n"; |
|
1506 | + if (strlen($buffer) > 5) { |
|
1507 | 1507 | $line = explode(',',$buffer); |
1508 | 1508 | $data = array(); |
1509 | 1509 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1520,38 +1520,38 @@ discard block |
||
1520 | 1520 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1521 | 1521 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1522 | 1522 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1523 | - } |
|
1524 | - } elseif ($format === 'acars') { |
|
1525 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1526 | - $ACARS->add(trim($buffer)); |
|
1527 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1528 | - $ACARS->deleteLiveAcarsData(); |
|
1523 | + } |
|
1524 | + } elseif ($format === 'acars') { |
|
1525 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1526 | + $ACARS->add(trim($buffer)); |
|
1527 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1528 | + $ACARS->deleteLiveAcarsData(); |
|
1529 | 1529 | } elseif ($format === 'flightgearmp') { |
1530 | - if (substr($buffer,0,1) != '#') { |
|
1530 | + if (substr($buffer,0,1) != '#') { |
|
1531 | 1531 | $data = array(); |
1532 | 1532 | //echo $buffer."\n"; |
1533 | 1533 | $line = explode(' ',$buffer); |
1534 | 1534 | if (count($line) === 11) { |
1535 | - $userserver = explode('@',$line[0]); |
|
1536 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1537 | - $data['ident'] = $userserver[0]; |
|
1538 | - $data['registration'] = $userserver[0]; |
|
1539 | - $data['latitude'] = $line[4]; |
|
1540 | - $data['longitude'] = $line[5]; |
|
1541 | - $data['altitude'] = $line[6]; |
|
1542 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1543 | - $aircraft_type = $line[10]; |
|
1544 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1545 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1546 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1547 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1535 | + $userserver = explode('@',$line[0]); |
|
1536 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1537 | + $data['ident'] = $userserver[0]; |
|
1538 | + $data['registration'] = $userserver[0]; |
|
1539 | + $data['latitude'] = $line[4]; |
|
1540 | + $data['longitude'] = $line[5]; |
|
1541 | + $data['altitude'] = $line[6]; |
|
1542 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1543 | + $aircraft_type = $line[10]; |
|
1544 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1545 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1546 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1547 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1548 | + } |
|
1548 | 1549 | } |
1549 | - } |
|
1550 | 1550 | } elseif ($format === 'beast') { |
1551 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1552 | - die; |
|
1551 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1552 | + die; |
|
1553 | 1553 | } elseif ($format === 'vrstcp') { |
1554 | - foreach($buffer as $all_data) { |
|
1554 | + foreach($buffer as $all_data) { |
|
1555 | 1555 | $line = json_decode('{'.$all_data.'}',true); |
1556 | 1556 | $data = array(); |
1557 | 1557 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1571,153 +1571,153 @@ discard block |
||
1571 | 1571 | */ |
1572 | 1572 | $data['datetime'] = date('Y-m-d H:i:s'); |
1573 | 1573 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1574 | - $data['format_source'] = 'vrstcp'; |
|
1574 | + $data['format_source'] = 'vrstcp'; |
|
1575 | 1575 | $data['id_source'] = $id_source; |
1576 | 1576 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1577 | 1577 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1578 | 1578 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1579 | 1579 | unset($data); |
1580 | - } |
|
1580 | + } |
|
1581 | 1581 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
1582 | - $line = explode("\t", $buffer); |
|
1583 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1582 | + $line = explode("\t", $buffer); |
|
1583 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1584 | 1584 | $key = $line[$k]; |
1585 | - $lined[$key] = $line[$k+1]; |
|
1586 | - } |
|
1587 | - if (count($lined) > 3) { |
|
1588 | - $data['hex'] = $lined['hexid']; |
|
1589 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1590 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1591 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1592 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1593 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1594 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1595 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1596 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1597 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1598 | - $data['id_source'] = $id_source; |
|
1599 | - $data['format_source'] = 'tsv'; |
|
1600 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1601 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1585 | + $lined[$key] = $line[$k+1]; |
|
1586 | + } |
|
1587 | + if (count($lined) > 3) { |
|
1588 | + $data['hex'] = $lined['hexid']; |
|
1589 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1590 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1591 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1592 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1593 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1594 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1595 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1596 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1597 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1598 | + $data['id_source'] = $id_source; |
|
1599 | + $data['format_source'] = 'tsv'; |
|
1600 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1601 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1602 | 1602 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1603 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1604 | - unset($lined); |
|
1605 | - unset($data); |
|
1606 | - } else $error = true; |
|
1603 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1604 | + unset($lined); |
|
1605 | + unset($data); |
|
1606 | + } else $error = true; |
|
1607 | 1607 | } elseif ($format === 'aprs' && $use_aprs) { |
1608 | - if ($aprs_connect === 0) { |
|
1608 | + if ($aprs_connect === 0) { |
|
1609 | 1609 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1610 | 1610 | $aprs_connect = 1; |
1611 | - } |
|
1611 | + } |
|
1612 | 1612 | |
1613 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1613 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1614 | 1614 | $aprs_last_tx = time(); |
1615 | 1615 | $data_aprs = "# Keep alive"; |
1616 | 1616 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1617 | - } |
|
1617 | + } |
|
1618 | 1618 | |
1619 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1620 | - //echo 'APRS data : '.$buffer."\n"; |
|
1621 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1622 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1623 | - //echo $buffer."\n"; |
|
1624 | - date_default_timezone_set('UTC'); |
|
1625 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1619 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1620 | + //echo 'APRS data : '.$buffer."\n"; |
|
1621 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1622 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1623 | + //echo $buffer."\n"; |
|
1624 | + date_default_timezone_set('UTC'); |
|
1625 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1626 | 1626 | $line = $APRS->parse($buffer); |
1627 | 1627 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1628 | 1628 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1629 | - $aprs_last_tx = time(); |
|
1630 | - $data = array(); |
|
1631 | - //print_r($line); |
|
1632 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1633 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1634 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1635 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1636 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1637 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1638 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1639 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1640 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1641 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1642 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1643 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1644 | - $data['latitude'] = $line['latitude']; |
|
1645 | - $data['longitude'] = $line['longitude']; |
|
1646 | - //$data['verticalrate'] = $line[16]; |
|
1647 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1648 | - //else $data['speed'] = 0; |
|
1649 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1650 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1651 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1652 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1629 | + $aprs_last_tx = time(); |
|
1630 | + $data = array(); |
|
1631 | + //print_r($line); |
|
1632 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1633 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1634 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1635 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1636 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1637 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1638 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1639 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1640 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1641 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1642 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1643 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1644 | + $data['latitude'] = $line['latitude']; |
|
1645 | + $data['longitude'] = $line['longitude']; |
|
1646 | + //$data['verticalrate'] = $line[16]; |
|
1647 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1648 | + //else $data['speed'] = 0; |
|
1649 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1650 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1651 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1652 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1653 | 1653 | |
1654 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1655 | - //else echo 'No heading...'."\n"; |
|
1656 | - //else $data['heading'] = 0; |
|
1657 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1658 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1659 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1660 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1661 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1662 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1663 | - $data['id_source'] = $id_source; |
|
1664 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1665 | - else $data['format_source'] = 'aprs'; |
|
1666 | - $data['source_name'] = $line['source']; |
|
1667 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1668 | - else $data['source_type'] = 'flarm'; |
|
1669 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1670 | - $currentdate = date('Y-m-d H:i:s'); |
|
1671 | - $aprsdate = strtotime($data['datetime']); |
|
1672 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1673 | - // Accept data if time <= system time + 20s |
|
1674 | - //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'])))) { |
|
1675 | - 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'])))) { |
|
1654 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1655 | + //else echo 'No heading...'."\n"; |
|
1656 | + //else $data['heading'] = 0; |
|
1657 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1658 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1659 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1660 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1661 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1662 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1663 | + $data['id_source'] = $id_source; |
|
1664 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1665 | + else $data['format_source'] = 'aprs'; |
|
1666 | + $data['source_name'] = $line['source']; |
|
1667 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1668 | + else $data['source_type'] = 'flarm'; |
|
1669 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1670 | + $currentdate = date('Y-m-d H:i:s'); |
|
1671 | + $aprsdate = strtotime($data['datetime']); |
|
1672 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1673 | + // Accept data if time <= system time + 20s |
|
1674 | + //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'])))) { |
|
1675 | + 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'])))) { |
|
1676 | 1676 | $send = $SI->add($data); |
1677 | - } elseif ($data['source_type'] === 'ais') { |
|
1677 | + } elseif ($data['source_type'] === 'ais') { |
|
1678 | 1678 | $data['type'] = ''; |
1679 | 1679 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1680 | - } elseif (isset($line['stealth'])) { |
|
1680 | + } elseif (isset($line['stealth'])) { |
|
1681 | 1681 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1682 | 1682 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1683 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1684 | - //$line['symbol'] === 'Balloon' || |
|
1685 | - $line['symbol'] === 'Glider' || |
|
1686 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1687 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1688 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1689 | - $send = $SI->add($data); |
|
1690 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1691 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1692 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
1693 | - $send = $MI->add($data); |
|
1694 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1695 | - $line['symbol'] === 'Car' || |
|
1696 | - $line['symbol'] === 'Ambulance' || |
|
1697 | - $line['symbol'] === 'Van' || |
|
1698 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1699 | - $line['symbol'] === 'Motorcycle' || |
|
1700 | - $line['symbol'] === 'Tractor' || |
|
1701 | - $line['symbol'] === 'Police' || |
|
1702 | - $line['symbol'] === 'Bike' || |
|
1703 | - $line['symbol'] === 'Jogger' || |
|
1704 | - $line['symbol'] === 'Horse' || |
|
1705 | - $line['symbol'] === 'Bus' || |
|
1706 | - $line['symbol'] === 'Jeep' || |
|
1707 | - $line['symbol'] === 'Recreational Vehicle' || |
|
1708 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1709 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
1710 | - $line['symbol'] === 'Firetruck' || |
|
1711 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1712 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1713 | - $line['symbol'] === 'SUV' || |
|
1714 | - $line['symbol'] === 'Snowmobile' || |
|
1715 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
1716 | - //} 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') { |
|
1683 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1684 | + //$line['symbol'] === 'Balloon' || |
|
1685 | + $line['symbol'] === 'Glider' || |
|
1686 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1687 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1688 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1689 | + $send = $SI->add($data); |
|
1690 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1691 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1692 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
1693 | + $send = $MI->add($data); |
|
1694 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1695 | + $line['symbol'] === 'Car' || |
|
1696 | + $line['symbol'] === 'Ambulance' || |
|
1697 | + $line['symbol'] === 'Van' || |
|
1698 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1699 | + $line['symbol'] === 'Motorcycle' || |
|
1700 | + $line['symbol'] === 'Tractor' || |
|
1701 | + $line['symbol'] === 'Police' || |
|
1702 | + $line['symbol'] === 'Bike' || |
|
1703 | + $line['symbol'] === 'Jogger' || |
|
1704 | + $line['symbol'] === 'Horse' || |
|
1705 | + $line['symbol'] === 'Bus' || |
|
1706 | + $line['symbol'] === 'Jeep' || |
|
1707 | + $line['symbol'] === 'Recreational Vehicle' || |
|
1708 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1709 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
1710 | + $line['symbol'] === 'Firetruck' || |
|
1711 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1712 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1713 | + $line['symbol'] === 'SUV' || |
|
1714 | + $line['symbol'] === 'Snowmobile' || |
|
1715 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
1716 | + //} 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') { |
|
1717 | 1717 | // } 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') { |
1718 | 1718 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1719 | 1719 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1720 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1720 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1721 | 1721 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1722 | 1722 | $Source->deleteOldLocationByType('gs'); |
1723 | 1723 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | } else { |
1726 | 1726 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1727 | 1727 | } |
1728 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1728 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1729 | 1729 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1730 | 1730 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1731 | 1731 | $Source->deleteOldLocationByType('wx'); |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | } else { |
1736 | 1736 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1737 | 1737 | } |
1738 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1738 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1739 | 1739 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1740 | 1740 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1741 | 1741 | $Source->deleteOldLocationByType('lightning'); |
@@ -1744,11 +1744,11 @@ discard block |
||
1744 | 1744 | } else { |
1745 | 1745 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1746 | 1746 | } |
1747 | - } elseif ($globalDebug) { |
|
1748 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1749 | - print_r($line); |
|
1750 | - } |
|
1751 | - unset($data); |
|
1747 | + } elseif ($globalDebug) { |
|
1748 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1749 | + print_r($line); |
|
1750 | + } |
|
1751 | + unset($data); |
|
1752 | 1752 | } |
1753 | 1753 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1754 | 1754 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1767,12 +1767,12 @@ discard block |
||
1767 | 1767 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1768 | 1768 | $globalSources[$nb]['last_weather_clean'] = time(); |
1769 | 1769 | } |
1770 | - } |
|
1770 | + } |
|
1771 | 1771 | } else { |
1772 | - $line = explode(',', $buffer); |
|
1773 | - if (count($line) > 20) { |
|
1774 | - $data['hex'] = $line[4]; |
|
1775 | - /* |
|
1772 | + $line = explode(',', $buffer); |
|
1773 | + if (count($line) > 20) { |
|
1774 | + $data['hex'] = $line[4]; |
|
1775 | + /* |
|
1776 | 1776 | $data['datetime'] = $line[6].' '.$line[7]; |
1777 | 1777 | date_default_timezone_set($globalTimezone); |
1778 | 1778 | $datetime = new DateTime($data['datetime']); |
@@ -1780,30 +1780,30 @@ discard block |
||
1780 | 1780 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1781 | 1781 | date_default_timezone_set('UTC'); |
1782 | 1782 | */ |
1783 | - // Force datetime to current UTC datetime |
|
1784 | - date_default_timezone_set('UTC'); |
|
1785 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1786 | - $data['ident'] = trim($line[10]); |
|
1787 | - $data['latitude'] = $line[14]; |
|
1788 | - $data['longitude'] = $line[15]; |
|
1789 | - $data['verticalrate'] = $line[16]; |
|
1790 | - $data['emergency'] = $line[20]; |
|
1791 | - $data['speed'] = $line[12]; |
|
1792 | - $data['squawk'] = $line[17]; |
|
1793 | - $data['altitude'] = $line[11]; |
|
1794 | - $data['heading'] = $line[13]; |
|
1795 | - $data['ground'] = $line[21]; |
|
1796 | - $data['emergency'] = $line[19]; |
|
1797 | - $data['format_source'] = 'sbs'; |
|
1783 | + // Force datetime to current UTC datetime |
|
1784 | + date_default_timezone_set('UTC'); |
|
1785 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1786 | + $data['ident'] = trim($line[10]); |
|
1787 | + $data['latitude'] = $line[14]; |
|
1788 | + $data['longitude'] = $line[15]; |
|
1789 | + $data['verticalrate'] = $line[16]; |
|
1790 | + $data['emergency'] = $line[20]; |
|
1791 | + $data['speed'] = $line[12]; |
|
1792 | + $data['squawk'] = $line[17]; |
|
1793 | + $data['altitude'] = $line[11]; |
|
1794 | + $data['heading'] = $line[13]; |
|
1795 | + $data['ground'] = $line[21]; |
|
1796 | + $data['emergency'] = $line[19]; |
|
1797 | + $data['format_source'] = 'sbs'; |
|
1798 | 1798 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1799 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1799 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1800 | 1800 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1801 | - $data['id_source'] = $id_source; |
|
1802 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1803 | - else $error = true; |
|
1804 | - unset($data); |
|
1805 | - } else $error = true; |
|
1806 | - if ($error) { |
|
1801 | + $data['id_source'] = $id_source; |
|
1802 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1803 | + else $error = true; |
|
1804 | + unset($data); |
|
1805 | + } else $error = true; |
|
1806 | + if ($error) { |
|
1807 | 1807 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
1808 | 1808 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1809 | 1809 | } else { |
@@ -1819,13 +1819,13 @@ discard block |
||
1819 | 1819 | connect_all($sourceer); |
1820 | 1820 | $sourceer = array(); |
1821 | 1821 | } |
1822 | - } |
|
1822 | + } |
|
1823 | 1823 | } |
1824 | 1824 | // Sleep for xxx microseconds |
1825 | 1825 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1826 | - } else { |
|
1826 | + } else { |
|
1827 | 1827 | if ($format === 'flightgearmp') { |
1828 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1828 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1829 | 1829 | //@socket_close($r); |
1830 | 1830 | sleep($globalMinFetch); |
1831 | 1831 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1834,9 +1834,9 @@ discard block |
||
1834 | 1834 | break; |
1835 | 1835 | |
1836 | 1836 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1837 | - if (isset($tt[$format])) $tt[$format]++; |
|
1838 | - else $tt[$format] = 0; |
|
1839 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1837 | + if (isset($tt[$format])) $tt[$format]++; |
|
1838 | + else $tt[$format] = 0; |
|
1839 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1840 | 1840 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1841 | 1841 | //@socket_close($r); |
1842 | 1842 | sleep(2); |
@@ -1847,24 +1847,24 @@ discard block |
||
1847 | 1847 | //connect_all($globalSources); |
1848 | 1848 | $tt[$format]=0; |
1849 | 1849 | break; |
1850 | - } |
|
1851 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1850 | + } |
|
1851 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1852 | + } |
|
1852 | 1853 | } |
1853 | - } |
|
1854 | 1854 | } |
1855 | - } else { |
|
1855 | + } else { |
|
1856 | 1856 | $error = socket_strerror(socket_last_error()); |
1857 | 1857 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1858 | 1858 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1859 | 1859 | if (isset($globalDebug)) echo "Restarting...\n"; |
1860 | 1860 | // Restart the script if possible |
1861 | 1861 | if (is_array($sockets)) { |
1862 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1862 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1863 | 1863 | |
1864 | - foreach ($sockets as $sock) { |
|
1864 | + foreach ($sockets as $sock) { |
|
1865 | 1865 | @socket_shutdown($sock,2); |
1866 | 1866 | @socket_close($sock); |
1867 | - } |
|
1867 | + } |
|
1868 | 1868 | |
1869 | 1869 | } |
1870 | 1870 | if ($globalDebug) echo "Waiting..."; |
@@ -1879,15 +1879,15 @@ discard block |
||
1879 | 1879 | if ($globalDebug) echo "Restart all connections..."; |
1880 | 1880 | connect_all($globalSources); |
1881 | 1881 | } |
1882 | - } |
|
1882 | + } |
|
1883 | 1883 | } |
1884 | 1884 | if ($globalDaemon === false) { |
1885 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1886 | - if (isset($SI)) $SI->checkAll(); |
|
1887 | - if (isset($TI)) $TI->checkAll(); |
|
1888 | - if (isset($MI)) $MI->checkAll(); |
|
1885 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1886 | + if (isset($SI)) $SI->checkAll(); |
|
1887 | + if (isset($TI)) $TI->checkAll(); |
|
1888 | + if (isset($MI)) $MI->checkAll(); |
|
1889 | + } |
|
1889 | 1890 | } |
1890 | - } |
|
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | ?> |
@@ -14,13 +14,17 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
17 | +if (isset($globalTracker) && $globalTracker) { |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | +} |
|
18 | 20 | if (isset($globalMarine) && $globalMarine) { |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
21 | 23 | } |
22 | 24 | |
23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
24 | 28 | |
25 | 29 | // Check if schema is at latest version |
26 | 30 | $Connection = new Connection(); |
@@ -59,66 +63,107 @@ discard block |
||
59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 64 | if (isset($options['s'])) { |
61 | 65 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
64 | -} elseif (isset($options['source'])) { |
|
66 | + if (isset($options['format'])) { |
|
67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
68 | + } else { |
|
69 | + $globalSources[] = array('host' => $options['s']); |
|
70 | + } |
|
71 | + } elseif (isset($options['source'])) { |
|
65 | 72 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
68 | -} |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['source']); |
|
77 | + } |
|
78 | + } |
|
69 | 79 | if (isset($options['aprsserverhost'])) { |
70 | 80 | $globalServerAPRS = TRUE; |
71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
72 | 82 | } |
73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
83 | +if (isset($options['aprsserverport'])) { |
|
84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
85 | +} |
|
86 | +if (isset($options['aprsserverssid'])) { |
|
87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
88 | +} |
|
89 | +if (isset($options['aprsserverpass'])) { |
|
90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
91 | +} |
|
92 | +if (isset($options['noaprsserver'])) { |
|
93 | + $globalServerAPRS = FALSE; |
|
94 | +} |
|
77 | 95 | if (isset($options['enable-aircraft'])) { |
78 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
96 | + if ($globalDebug) { |
|
97 | + echo 'Enable Aircraft mode'."\n"; |
|
98 | + } |
|
79 | 99 | $globalAircraft = TRUE; |
80 | 100 | } |
81 | 101 | if (isset($options['disable-aircraft'])) { |
82 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
102 | + if ($globalDebug) { |
|
103 | + echo 'Disable Aircraft mode'."\n"; |
|
104 | + } |
|
83 | 105 | $globalAircraft = FALSE; |
84 | 106 | } |
85 | 107 | if (isset($options['enable-tracker'])) { |
86 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
108 | + if ($globalDebug) { |
|
109 | + echo 'Enable Tracker mode'."\n"; |
|
110 | + } |
|
87 | 111 | $globalTracker = TRUE; |
88 | 112 | } |
89 | 113 | if (isset($options['disable-tracker'])) { |
90 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
114 | + if ($globalDebug) { |
|
115 | + echo 'Disable Tracker mode'."\n"; |
|
116 | + } |
|
91 | 117 | $globalTracker = FALSE; |
92 | 118 | } |
93 | 119 | if (isset($options['enable-marine'])) { |
94 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
120 | + if ($globalDebug) { |
|
121 | + echo 'Enable Marine mode'."\n"; |
|
122 | + } |
|
95 | 123 | $globalMarine = TRUE; |
96 | 124 | } |
97 | 125 | if (isset($options['disable-marine'])) { |
98 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
126 | + if ($globalDebug) { |
|
127 | + echo 'Disable Marine mode'."\n"; |
|
128 | + } |
|
99 | 129 | $globalMarine = FALSE; |
100 | 130 | } |
101 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
102 | -if (isset($options['server'])) $globalServer = TRUE; |
|
103 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
104 | -else $id_source = 1; |
|
131 | +if (isset($options['nodaemon'])) { |
|
132 | + $globalDaemon = FALSE; |
|
133 | +} |
|
134 | +if (isset($options['server'])) { |
|
135 | + $globalServer = TRUE; |
|
136 | +} |
|
137 | +if (isset($options['idsource'])) { |
|
138 | + $id_source = $options['idsource']; |
|
139 | +} else { |
|
140 | + $id_source = 1; |
|
141 | +} |
|
105 | 142 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
143 | + if ($globalDebug) { |
|
144 | + echo "Using Server Mode\n"; |
|
145 | + } |
|
107 | 146 | $SI=new SpotterServer(); |
108 | 147 | /* |
109 | 148 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 149 | $SI = new adsb2aprs(); |
111 | 150 | $SI->connect(); |
112 | 151 | */ |
113 | -} else $SI=new SpotterImport($Connection->db); |
|
152 | +} else { |
|
153 | + $SI=new SpotterImport($Connection->db); |
|
154 | +} |
|
114 | 155 | |
115 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
156 | +if (isset($globalTracker) && $globalTracker) { |
|
157 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
158 | +} |
|
116 | 159 | if (isset($globalMarine) && $globalMarine) { |
117 | 160 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
118 | 161 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
119 | 162 | } |
120 | 163 | |
121 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
164 | +if (isset($globalTracker) && $globalTracker) { |
|
165 | + $TI = new TrackerImport($Connection->db); |
|
166 | +} |
|
122 | 167 | if (isset($globalMarine) && $globalMarine) { |
123 | 168 | $AIS = new AIS(); |
124 | 169 | $MI = new MarineImport($Connection->db); |
@@ -143,7 +188,9 @@ discard block |
||
143 | 188 | } |
144 | 189 | |
145 | 190 | // let's try and connect |
146 | -if ($globalDebug) echo "Connecting...\n"; |
|
191 | +if ($globalDebug) { |
|
192 | + echo "Connecting...\n"; |
|
193 | +} |
|
147 | 194 | $use_aprs = false; |
148 | 195 | $aprs_full = false; |
149 | 196 | $reset = 0; |
@@ -152,7 +199,9 @@ discard block |
||
152 | 199 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
153 | 200 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
154 | 201 | $reset++; |
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'Connect to all...'."\n"; |
|
204 | + } |
|
156 | 205 | foreach ($hosts as $id => $value) { |
157 | 206 | $host = $value['host']; |
158 | 207 | $globalSources[$id]['last_exec'] = 0; |
@@ -162,27 +211,37 @@ discard block |
||
162 | 211 | //$formats[$id] = 'deltadbtxt'; |
163 | 212 | $globalSources[$id]['format'] = 'deltadbtxt'; |
164 | 213 | //$last_exec['deltadbtxt'] = 0; |
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
216 | + } |
|
166 | 217 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
167 | 218 | //$formats[$id] = 'vatsimtxt'; |
168 | 219 | $globalSources[$id]['format'] = 'vatsimtxt'; |
169 | 220 | //$last_exec['vatsimtxt'] = 0; |
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
221 | + if ($globalDebug) { |
|
222 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
223 | + } |
|
171 | 224 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
172 | 225 | //$formats[$id] = 'aircraftlistjson'; |
173 | 226 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
174 | 227 | //$last_exec['aircraftlistjson'] = 0; |
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
228 | + if ($globalDebug) { |
|
229 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
230 | + } |
|
176 | 231 | } else if (preg_match('/aircraft.json$/i',$host)) { |
177 | 232 | //$formats[$id] = 'aircraftjson'; |
178 | 233 | $globalSources[$id]['format'] = 'aircraftjson'; |
179 | 234 | //$last_exec['aircraftlistjson'] = 0; |
180 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
237 | + } |
|
181 | 238 | } else if (preg_match('/opensky/i',$host)) { |
182 | 239 | //$formats[$id] = 'aircraftlistjson'; |
183 | 240 | $globalSources[$id]['format'] = 'opensky'; |
184 | 241 | //$last_exec['aircraftlistjson'] = 0; |
185 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "Connect to opensky source (".$host.")...\n"; |
|
244 | + } |
|
186 | 245 | /* |
187 | 246 | // Disabled for now, site change source format |
188 | 247 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -199,7 +258,9 @@ discard block |
||
199 | 258 | //$formats[$id] = 'planeupdatefaa'; |
200 | 259 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
201 | 260 | //$last_exec['planeupdatefaa'] = 0; |
202 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
261 | + if ($globalDebug) { |
|
262 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
263 | + } |
|
203 | 264 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
204 | 265 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
205 | 266 | exit(0); |
@@ -208,37 +269,53 @@ discard block |
||
208 | 269 | //$formats[$id] = 'phpvmacars'; |
209 | 270 | $globalSources[$id]['format'] = 'phpvmacars'; |
210 | 271 | //$last_exec['phpvmacars'] = 0; |
211 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
272 | + if ($globalDebug) { |
|
273 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
274 | + } |
|
212 | 275 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
213 | 276 | //$formats[$id] = 'phpvmacars'; |
214 | 277 | $globalSources[$id]['format'] = 'vaos'; |
215 | 278 | //$last_exec['phpvmacars'] = 0; |
216 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
279 | + if ($globalDebug) { |
|
280 | + echo "Connect to vaos source (".$host.")...\n"; |
|
281 | + } |
|
217 | 282 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
218 | 283 | //$formats[$id] = 'phpvmacars'; |
219 | 284 | $globalSources[$id]['format'] = 'vam'; |
220 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
285 | + if ($globalDebug) { |
|
286 | + echo "Connect to Vam source (".$host.")...\n"; |
|
287 | + } |
|
221 | 288 | } else if (preg_match('/whazzup/i',$host)) { |
222 | 289 | //$formats[$id] = 'whazzup'; |
223 | 290 | $globalSources[$id]['format'] = 'whazzup'; |
224 | 291 | //$last_exec['whazzup'] = 0; |
225 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
292 | + if ($globalDebug) { |
|
293 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
294 | + } |
|
226 | 295 | } else if (preg_match('/blitzortung/i',$host)) { |
227 | 296 | $globalSources[$id]['format'] = 'blitzortung'; |
228 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
297 | + if ($globalDebug) { |
|
298 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
299 | + } |
|
229 | 300 | } else if (preg_match('/airwhere/i',$host)) { |
230 | 301 | $globalSources[$id]['format'] = 'airwhere'; |
231 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
302 | + if ($globalDebug) { |
|
303 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
304 | + } |
|
232 | 305 | } else if (preg_match('/recentpireps/i',$host)) { |
233 | 306 | //$formats[$id] = 'pirepsjson'; |
234 | 307 | $globalSources[$id]['format'] = 'pirepsjson'; |
235 | 308 | //$last_exec['pirepsjson'] = 0; |
236 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
311 | + } |
|
237 | 312 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
238 | 313 | //$formats[$id] = 'fr24json'; |
239 | 314 | $globalSources[$id]['format'] = 'fr24json'; |
240 | 315 | //$last_exec['fr24json'] = 0; |
241 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
316 | + if ($globalDebug) { |
|
317 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
318 | + } |
|
242 | 319 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
243 | 320 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
244 | 321 | exit(0); |
@@ -247,7 +324,9 @@ discard block |
||
247 | 324 | //$formats[$id] = 'fr24json'; |
248 | 325 | $globalSources[$id]['format'] = 'myshiptracking'; |
249 | 326 | //$last_exec['fr24json'] = 0; |
250 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
327 | + if ($globalDebug) { |
|
328 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
329 | + } |
|
251 | 330 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
252 | 331 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
253 | 332 | exit(0); |
@@ -256,16 +335,24 @@ discard block |
||
256 | 335 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
257 | 336 | //$formats[$id] = 'tsv'; |
258 | 337 | $globalSources[$id]['format'] = 'tsv'; |
259 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
338 | + if ($globalDebug) { |
|
339 | + echo "Connect to tsv source (".$host.")...\n"; |
|
340 | + } |
|
260 | 341 | } |
261 | 342 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
262 | 343 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
263 | 344 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
264 | 345 | if ($idf !== false) { |
265 | 346 | $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"; |
|
347 | + if ($globalDebug) { |
|
348 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
349 | + } |
|
350 | + } elseif ($globalDebug) { |
|
351 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
352 | + } |
|
353 | + } elseif ($globalDebug) { |
|
354 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
355 | + } |
|
269 | 356 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
270 | 357 | $hostport = explode(':',$host); |
271 | 358 | if (isset($hostport[1])) { |
@@ -305,19 +392,27 @@ discard block |
||
305 | 392 | //$formats[$id] = 'beast'; |
306 | 393 | $globalSources[$id]['format'] = 'beast'; |
307 | 394 | //} else $formats[$id] = 'sbs'; |
308 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
395 | + } else { |
|
396 | + $globalSources[$id]['format'] = 'sbs'; |
|
397 | + } |
|
309 | 398 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
310 | 399 | } |
311 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
400 | + if ($globalDebug) { |
|
401 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
402 | + } |
|
312 | 403 | } else { |
313 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
404 | + if ($globalDebug) { |
|
405 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
406 | + } |
|
314 | 407 | sleep(10); |
315 | 408 | $this->connect_all($hosts); |
316 | 409 | } |
317 | 410 | } |
318 | 411 | } |
319 | 412 | } |
320 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
413 | +if (!isset($globalMinFetch)) { |
|
414 | + $globalMinFetch = 15; |
|
415 | +} |
|
321 | 416 | |
322 | 417 | // Initialize all |
323 | 418 | $status = array(); |
@@ -326,13 +421,19 @@ discard block |
||
326 | 421 | $formats = array(); |
327 | 422 | $last_exec = array(); |
328 | 423 | $time = time(); |
329 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
330 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
331 | -else $timeout = 20; |
|
424 | +if (isset($globalSourcesTimeout)) { |
|
425 | + $timeout = $globalSourcesTimeOut; |
|
426 | +} else if (isset($globalSBS1TimeOut)) { |
|
427 | + $timeout = $globalSBS1TimeOut; |
|
428 | +} else { |
|
429 | + $timeout = 20; |
|
430 | +} |
|
332 | 431 | $errno = ''; |
333 | 432 | $errstr=''; |
334 | 433 | |
335 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
434 | +if (!isset($globalDaemon)) { |
|
435 | + $globalDaemon = TRUE; |
|
436 | +} |
|
336 | 437 | /* Initiate connections to all the hosts simultaneously */ |
337 | 438 | //connect_all($hosts); |
338 | 439 | //connect_all($globalSources); |
@@ -361,7 +462,9 @@ discard block |
||
361 | 462 | if (isset($source['format']) && $source['format'] == 'aprs') { |
362 | 463 | $aprs_connect = 0; |
363 | 464 | $use_aprs = true; |
364 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
465 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
466 | + $aprs_full = true; |
|
467 | + } |
|
365 | 468 | break; |
366 | 469 | } |
367 | 470 | } |
@@ -372,25 +475,46 @@ discard block |
||
372 | 475 | $aprs_connect = 0; |
373 | 476 | $aprs_keep = 120; |
374 | 477 | $aprs_last_tx = time(); |
375 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
376 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
377 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
378 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
379 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
380 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
381 | - if ($aprs_full) $aprs_filter = ''; |
|
382 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
383 | - else $aprs_pass = '-1'; |
|
478 | + if (isset($globalAPRSversion)) { |
|
479 | + $aprs_version = $globalAPRSversion; |
|
480 | + } else { |
|
481 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
482 | + } |
|
483 | + if (isset($globalAPRSssid)) { |
|
484 | + $aprs_ssid = $globalAPRSssid; |
|
485 | + } else { |
|
486 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
487 | + } |
|
488 | + if (isset($globalAPRSfilter)) { |
|
489 | + $aprs_filter = $globalAPRSfilter; |
|
490 | + } else { |
|
491 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
492 | + } |
|
493 | + if ($aprs_full) { |
|
494 | + $aprs_filter = ''; |
|
495 | + } |
|
496 | + if (isset($globalAPRSpass)) { |
|
497 | + $aprs_pass = $globalAPRSpass; |
|
498 | + } else { |
|
499 | + $aprs_pass = '-1'; |
|
500 | + } |
|
384 | 501 | |
385 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
386 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
387 | -} |
|
502 | + if ($aprs_filter != '') { |
|
503 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
504 | + } else { |
|
505 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
506 | + } |
|
507 | + } |
|
388 | 508 | |
389 | 509 | // connected - lets do some work |
390 | 510 | //if ($globalDebug) echo "Connected!\n"; |
391 | 511 | sleep(1); |
392 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
393 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
512 | +if ($globalDebug) { |
|
513 | + echo "SCAN MODE \n\n"; |
|
514 | +} |
|
515 | +if (!isset($globalCronEnd)) { |
|
516 | + $globalCronEnd = 60; |
|
517 | +} |
|
394 | 518 | $endtime = time()+$globalCronEnd; |
395 | 519 | $i = 1; |
396 | 520 | $tt = array(); |
@@ -404,22 +528,32 @@ discard block |
||
404 | 528 | |
405 | 529 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
406 | 530 | while ($i > 0) { |
407 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
531 | + if (function_exists('pcntl_fork')) { |
|
532 | + pcntl_signal_dispatch(); |
|
533 | + } |
|
408 | 534 | |
409 | - if (!$globalDaemon) $i = $endtime-time(); |
|
535 | + if (!$globalDaemon) { |
|
536 | + $i = $endtime-time(); |
|
537 | + } |
|
410 | 538 | // Delete old ATC |
411 | 539 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
412 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
540 | + if ($globalDebug) { |
|
541 | + echo 'Delete old ATC...'."\n"; |
|
542 | + } |
|
413 | 543 | $ATC->deleteOldATC(); |
414 | 544 | } |
415 | 545 | |
416 | 546 | if (count($last_exec) == count($globalSources)) { |
417 | 547 | $max = $globalMinFetch; |
418 | 548 | foreach ($last_exec as $last) { |
419 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
549 | + if ((time() - $last['last']) < $max) { |
|
550 | + $max = time() - $last['last']; |
|
551 | + } |
|
420 | 552 | } |
421 | 553 | if ($max < $globalMinFetch) { |
422 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
554 | + if ($globalDebug) { |
|
555 | + echo 'Sleeping...'."\n"; |
|
556 | + } |
|
423 | 557 | sleep($globalMinFetch-$max+2); |
424 | 558 | } |
425 | 559 | } |
@@ -429,7 +563,9 @@ discard block |
||
429 | 563 | foreach ($globalSources as $id => $value) { |
430 | 564 | date_default_timezone_set('UTC'); |
431 | 565 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
432 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
566 | + if (!isset($last_exec[$id]['last'])) { |
|
567 | + $last_exec[$id]['last'] = 0; |
|
568 | + } |
|
433 | 569 | if ($value['format'] === 'deltadbtxt' && |
434 | 570 | ( |
435 | 571 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -438,7 +574,9 @@ discard block |
||
438 | 574 | ) { |
439 | 575 | //$buffer = $Common->getData($hosts[$id]); |
440 | 576 | $buffer = $Common->getData($value['host']); |
441 | - if ($buffer != '') $reset = 0; |
|
577 | + if ($buffer != '') { |
|
578 | + $reset = 0; |
|
579 | + } |
|
442 | 580 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
443 | 581 | $buffer = explode('\n',$buffer); |
444 | 582 | foreach ($buffer as $line) { |
@@ -447,20 +585,41 @@ discard block |
||
447 | 585 | $data = array(); |
448 | 586 | $data['hex'] = $line[1]; // hex |
449 | 587 | $data['ident'] = $line[2]; // ident |
450 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
451 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
452 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
453 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
454 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
588 | + if (isset($line[3])) { |
|
589 | + $data['altitude'] = $line[3]; |
|
590 | + } |
|
591 | + // altitude |
|
592 | + if (isset($line[4])) { |
|
593 | + $data['speed'] = $line[4]; |
|
594 | + } |
|
595 | + // speed |
|
596 | + if (isset($line[5])) { |
|
597 | + $data['heading'] = $line[5]; |
|
598 | + } |
|
599 | + // heading |
|
600 | + if (isset($line[6])) { |
|
601 | + $data['latitude'] = $line[6]; |
|
602 | + } |
|
603 | + // lat |
|
604 | + if (isset($line[7])) { |
|
605 | + $data['longitude'] = $line[7]; |
|
606 | + } |
|
607 | + // long |
|
455 | 608 | $data['verticalrate'] = ''; // vertical rate |
456 | 609 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
457 | 610 | $data['emergency'] = ''; // emergency |
458 | 611 | $data['datetime'] = date('Y-m-d H:i:s'); |
459 | 612 | $data['format_source'] = 'deltadbtxt'; |
460 | 613 | $data['id_source'] = $id_source; |
461 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
462 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
463 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
614 | + if (isset($value['name']) && $value['name'] != '') { |
|
615 | + $data['source_name'] = $value['name']; |
|
616 | + } |
|
617 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
618 | + $data['noarchive'] = true; |
|
619 | + } |
|
620 | + if (isset($value['sourcestats'])) { |
|
621 | + $data['sourcestats'] = $value['sourcestats']; |
|
622 | + } |
|
464 | 623 | $SI->add($data); |
465 | 624 | unset($data); |
466 | 625 | } |
@@ -475,7 +634,9 @@ discard block |
||
475 | 634 | date_default_timezone_set('CET'); |
476 | 635 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
477 | 636 | date_default_timezone_set('UTC'); |
478 | - if ($buffer != '') $reset = 0; |
|
637 | + if ($buffer != '') { |
|
638 | + $reset = 0; |
|
639 | + } |
|
479 | 640 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
480 | 641 | $buffer = explode('\n',$buffer); |
481 | 642 | foreach ($buffer as $line) { |
@@ -484,18 +645,42 @@ discard block |
||
484 | 645 | $add = false; |
485 | 646 | $ais_data = $AIS->parse_line(trim($line)); |
486 | 647 | $data = array(); |
487 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
488 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
489 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
490 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
491 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
492 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
493 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
494 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
495 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
496 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
497 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
498 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
648 | + if (isset($ais_data['ident'])) { |
|
649 | + $data['ident'] = $ais_data['ident']; |
|
650 | + } |
|
651 | + if (isset($ais_data['mmsi'])) { |
|
652 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
653 | + } |
|
654 | + if (isset($ais_data['speed'])) { |
|
655 | + $data['speed'] = $ais_data['speed']; |
|
656 | + } |
|
657 | + if (isset($ais_data['heading'])) { |
|
658 | + $data['heading'] = $ais_data['heading']; |
|
659 | + } |
|
660 | + if (isset($ais_data['latitude'])) { |
|
661 | + $data['latitude'] = $ais_data['latitude']; |
|
662 | + } |
|
663 | + if (isset($ais_data['longitude'])) { |
|
664 | + $data['longitude'] = $ais_data['longitude']; |
|
665 | + } |
|
666 | + if (isset($ais_data['status'])) { |
|
667 | + $data['status'] = $ais_data['status']; |
|
668 | + } |
|
669 | + if (isset($ais_data['statusid'])) { |
|
670 | + $data['status_id'] = $ais_data['statusid']; |
|
671 | + } |
|
672 | + if (isset($ais_data['type'])) { |
|
673 | + $data['type'] = $ais_data['type']; |
|
674 | + } |
|
675 | + if (isset($ais_data['typeid'])) { |
|
676 | + $data['type_id'] = $ais_data['typeid']; |
|
677 | + } |
|
678 | + if (isset($ais_data['imo'])) { |
|
679 | + $data['imo'] = $ais_data['imo']; |
|
680 | + } |
|
681 | + if (isset($ais_data['callsign'])) { |
|
682 | + $data['callsign'] = $ais_data['callsign']; |
|
683 | + } |
|
499 | 684 | if (isset($ais_data['timestamp'])) { |
500 | 685 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
501 | 686 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -509,8 +694,12 @@ discard block |
||
509 | 694 | $data['format_source'] = 'aisnmeatxt'; |
510 | 695 | $data['id_source'] = $id_source; |
511 | 696 | //print_r($data); |
512 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
513 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
697 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
698 | + $data['noarchive'] = true; |
|
699 | + } |
|
700 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
701 | + $MI->add($data); |
|
702 | + } |
|
514 | 703 | unset($data); |
515 | 704 | } |
516 | 705 | } |
@@ -533,20 +722,48 @@ discard block |
||
533 | 722 | if ($line != '') { |
534 | 723 | $ais_data = $AIS->parse_line(trim($line)); |
535 | 724 | $data = array(); |
536 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
537 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
538 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
539 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
540 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
541 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
542 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
543 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
544 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
545 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
546 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
547 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
548 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
549 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
725 | + if (isset($ais_data['ident'])) { |
|
726 | + $data['ident'] = $ais_data['ident']; |
|
727 | + } |
|
728 | + if (isset($ais_data['mmsi'])) { |
|
729 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
730 | + } |
|
731 | + if (isset($ais_data['speed'])) { |
|
732 | + $data['speed'] = $ais_data['speed']; |
|
733 | + } |
|
734 | + if (isset($ais_data['heading'])) { |
|
735 | + $data['heading'] = $ais_data['heading']; |
|
736 | + } |
|
737 | + if (isset($ais_data['latitude'])) { |
|
738 | + $data['latitude'] = $ais_data['latitude']; |
|
739 | + } |
|
740 | + if (isset($ais_data['longitude'])) { |
|
741 | + $data['longitude'] = $ais_data['longitude']; |
|
742 | + } |
|
743 | + if (isset($ais_data['status'])) { |
|
744 | + $data['status'] = $ais_data['status']; |
|
745 | + } |
|
746 | + if (isset($ais_data['statusid'])) { |
|
747 | + $data['status_id'] = $ais_data['statusid']; |
|
748 | + } |
|
749 | + if (isset($ais_data['type'])) { |
|
750 | + $data['type'] = $ais_data['type']; |
|
751 | + } |
|
752 | + if (isset($ais_data['typeid'])) { |
|
753 | + $data['type_id'] = $ais_data['typeid']; |
|
754 | + } |
|
755 | + if (isset($ais_data['imo'])) { |
|
756 | + $data['imo'] = $ais_data['imo']; |
|
757 | + } |
|
758 | + if (isset($ais_data['callsign'])) { |
|
759 | + $data['callsign'] = $ais_data['callsign']; |
|
760 | + } |
|
761 | + if (isset($ais_data['destination'])) { |
|
762 | + $data['arrival_code'] = $ais_data['destination']; |
|
763 | + } |
|
764 | + if (isset($ais_data['eta_ts'])) { |
|
765 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
766 | + } |
|
550 | 767 | if (isset($ais_data['timestamp'])) { |
551 | 768 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
552 | 769 | } else { |
@@ -554,18 +771,27 @@ discard block |
||
554 | 771 | } |
555 | 772 | $data['format_source'] = 'aisnmeahttp'; |
556 | 773 | $data['id_source'] = $id_source; |
557 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
558 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
774 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
775 | + $data['noarchive'] = true; |
|
776 | + } |
|
777 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
778 | + $MI->add($data); |
|
779 | + } |
|
559 | 780 | unset($data); |
560 | 781 | } |
561 | 782 | } |
562 | 783 | } |
563 | 784 | } else { |
564 | 785 | $format = $value['format']; |
565 | - if (isset($tt[$format])) $tt[$format]++; |
|
566 | - else $tt[$format] = 0; |
|
786 | + if (isset($tt[$format])) { |
|
787 | + $tt[$format]++; |
|
788 | + } else { |
|
789 | + $tt[$format] = 0; |
|
790 | + } |
|
567 | 791 | if ($tt[$format] > 30) { |
568 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
792 | + if ($globalDebug) { |
|
793 | + echo 'Reconnect...'."\n"; |
|
794 | + } |
|
569 | 795 | sleep(2); |
570 | 796 | //$sourceeen[] = $value; |
571 | 797 | //connect_all($sourceeen); |
@@ -601,12 +827,18 @@ discard block |
||
601 | 827 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
602 | 828 | //$data['type_id'] = $line['TYPE']; |
603 | 829 | $data['imo'] = $line['IMO']; |
604 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
605 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
830 | + if ($line['DEST'] != '') { |
|
831 | + $data['arrival_code'] = $line['DEST']; |
|
832 | + } |
|
833 | + if ($line['ARV'] != '') { |
|
834 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
835 | + } |
|
606 | 836 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
607 | 837 | $data['format_source'] = 'myshiptracking'; |
608 | 838 | $data['id_source'] = $id_source; |
609 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
839 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
840 | + $data['noarchive'] = true; |
|
841 | + } |
|
610 | 842 | $MI->add($data); |
611 | 843 | unset($data); |
612 | 844 | } |
@@ -631,7 +863,9 @@ discard block |
||
631 | 863 | $data['callsign'] = $line['callsign']; |
632 | 864 | $data['mmsi'] = substr($line['mmsi'],-9); |
633 | 865 | $data['speed'] = $line['sog']; |
634 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
866 | + if ($line['heading'] != '511') { |
|
867 | + $data['heading'] = $line['heading']; |
|
868 | + } |
|
635 | 869 | $data['latitude'] = $line['latitude']; |
636 | 870 | $data['longitude'] = $line['longitude']; |
637 | 871 | $data['type_id'] = $line['shiptype']; |
@@ -639,7 +873,9 @@ discard block |
||
639 | 873 | $data['datetime'] = $line['time']; |
640 | 874 | $data['format_source'] = 'boatbeaconapp'; |
641 | 875 | $data['id_source'] = $id_source; |
642 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
876 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
877 | + $data['noarchive'] = true; |
|
878 | + } |
|
643 | 879 | $MI->add($data); |
644 | 880 | unset($data); |
645 | 881 | } |
@@ -661,22 +897,44 @@ discard block |
||
661 | 897 | foreach ($all_data['features'] as $line) { |
662 | 898 | print_r($line); |
663 | 899 | $data = array(); |
664 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
665 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
666 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
667 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
668 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
669 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
900 | + if (isset($line['properties']['name'])) { |
|
901 | + $data['ident'] = $line['properties']['name']; |
|
902 | + } |
|
903 | + if (isset($line['properties']['callsign'])) { |
|
904 | + $data['callsign'] = $line['properties']['callsign']; |
|
905 | + } |
|
906 | + if (isset($line['properties']['mmsi'])) { |
|
907 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
908 | + } |
|
909 | + if (isset($line['properties']['imo'])) { |
|
910 | + $data['imo'] = $line['properties']['imo']; |
|
911 | + } |
|
912 | + if (isset($line['properties']['speed'])) { |
|
913 | + $data['speed'] = $line['properties']['speed']; |
|
914 | + } |
|
915 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
916 | + $data['heading'] = $line['properties']['heading']; |
|
917 | + } |
|
670 | 918 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
671 | 919 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
672 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
673 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
674 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
920 | + if (isset($line['properties']['vesselType'])) { |
|
921 | + $data['type'] = $line['properties']['vesselType']; |
|
922 | + } |
|
923 | + if (isset($line['properties']['destination'])) { |
|
924 | + $data['arrival_code'] = $line['properties']['destination']; |
|
925 | + } |
|
926 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
927 | + $data['arrival_date'] = $line['properties']['eta']; |
|
928 | + } |
|
675 | 929 | $data['format_source'] = 'boatnerd'; |
676 | 930 | $data['id_source'] = $id_source; |
677 | 931 | $data['datetime'] = date('Y-m-d H:i:s'); |
678 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
679 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
932 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
933 | + $data['noarchive'] = true; |
|
934 | + } |
|
935 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
936 | + $MI->add($data); |
|
937 | + } |
|
680 | 938 | unset($data); |
681 | 939 | } |
682 | 940 | } |
@@ -693,7 +951,9 @@ discard block |
||
693 | 951 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
694 | 952 | echo 'done !'."\n"; |
695 | 953 | // FIXME: Need more work |
696 | - if ($buffer != '') $reset = 0; |
|
954 | + if ($buffer != '') { |
|
955 | + $reset = 0; |
|
956 | + } |
|
697 | 957 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
698 | 958 | $buffer = explode('\n',$buffer); |
699 | 959 | foreach ($buffer as $line) { |
@@ -719,7 +979,9 @@ discard block |
||
719 | 979 | //$data['etaTime'] = substr($line,135,5); |
720 | 980 | $data['format_source'] = 'shipplotter'; |
721 | 981 | $data['id_source'] = $id_source; |
722 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
982 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
983 | + $data['noarchive'] = true; |
|
984 | + } |
|
723 | 985 | //print_r($data); |
724 | 986 | echo 'Add...'."\n"; |
725 | 987 | $MI->add($data); |
@@ -753,16 +1015,28 @@ discard block |
||
753 | 1015 | $line = explode(':', $line); |
754 | 1016 | if (count($line) > 30 && $line[0] != 'callsign') { |
755 | 1017 | $data = array(); |
756 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
757 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1018 | + if (isset($line[37]) && $line[37] != '') { |
|
1019 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
1020 | + } else { |
|
1021 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1022 | + } |
|
758 | 1023 | $data['pilot_id'] = $line[1]; |
759 | 1024 | $data['pilot_name'] = $line[2]; |
760 | 1025 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
761 | 1026 | $data['ident'] = $line[0]; // ident |
762 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
1027 | + if ($line[7] != '' && $line[7] != 0) { |
|
1028 | + $data['altitude'] = $line[7]; |
|
1029 | + } |
|
1030 | + // altitude |
|
763 | 1031 | $data['speed'] = $line[8]; // speed |
764 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
765 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
1032 | + if (isset($line[45])) { |
|
1033 | + $data['heading'] = $line[45]; |
|
1034 | + } |
|
1035 | + // heading |
|
1036 | + elseif (isset($line[38])) { |
|
1037 | + $data['heading'] = $line[38]; |
|
1038 | + } |
|
1039 | + // heading |
|
766 | 1040 | $data['latitude'] = $line[5]; // lat |
767 | 1041 | $data['longitude'] = $line[6]; // long |
768 | 1042 | $data['verticalrate'] = ''; // vertical rate |
@@ -778,7 +1052,9 @@ discard block |
||
778 | 1052 | $data['frequency'] = $line[4]; |
779 | 1053 | $data['type'] = $line[18]; |
780 | 1054 | $data['range'] = $line[19]; |
781 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
1055 | + if (isset($line[35])) { |
|
1056 | + $data['info'] = $line[35]; |
|
1057 | + } |
|
782 | 1058 | $data['id_source'] = $id_source; |
783 | 1059 | //$data['arrival_airport_time'] = ; |
784 | 1060 | if ($line[9] != '') { |
@@ -792,27 +1068,47 @@ discard block |
||
792 | 1068 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
793 | 1069 | */ |
794 | 1070 | $data['format_source'] = $value['format']; |
795 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
796 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
797 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
798 | - elseif ($line[3] === 'ATC') { |
|
1071 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1072 | + $data['noarchive'] = true; |
|
1073 | + } |
|
1074 | + if (isset($value['name']) && $value['name'] != '') { |
|
1075 | + $data['source_name'] = $value['name']; |
|
1076 | + } |
|
1077 | + if ($line[3] === 'PILOT') { |
|
1078 | + $SI->add($data); |
|
1079 | + } elseif ($line[3] === 'ATC') { |
|
799 | 1080 | //print_r($data); |
800 | 1081 | $data['info'] = str_replace('^§','<br />',$data['info']); |
801 | 1082 | $data['info'] = str_replace('&sect;','',$data['info']); |
802 | 1083 | $typec = substr($data['ident'],-3); |
803 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
804 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
805 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
806 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
807 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
808 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
809 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
810 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
811 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
812 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1084 | + if ($typec === 'APP') { |
|
1085 | + $data['type'] = 'Approach'; |
|
1086 | + } elseif ($typec === 'TWR') { |
|
1087 | + $data['type'] = 'Tower'; |
|
1088 | + } elseif ($typec === 'OBS') { |
|
1089 | + $data['type'] = 'Observer'; |
|
1090 | + } elseif ($typec === 'GND') { |
|
1091 | + $data['type'] = 'Ground'; |
|
1092 | + } elseif ($typec === 'DEL') { |
|
1093 | + $data['type'] = 'Delivery'; |
|
1094 | + } elseif ($typec === 'DEP') { |
|
1095 | + $data['type'] = 'Departure'; |
|
1096 | + } elseif ($typec === 'FSS') { |
|
1097 | + $data['type'] = 'Flight Service Station'; |
|
1098 | + } elseif ($typec === 'CTR') { |
|
1099 | + $data['type'] = 'Control Radar or Centre'; |
|
1100 | + } elseif ($data['type'] === '') { |
|
1101 | + $data['type'] = 'Observer'; |
|
1102 | + } |
|
1103 | + if (!isset($data['source_name'])) { |
|
1104 | + $data['source_name'] = ''; |
|
1105 | + } |
|
813 | 1106 | if (isset($ATC)) { |
814 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($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']); |
|
815 | - 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']); |
|
1107 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1108 | + echo $ATC->update($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']); |
|
1109 | + } else { |
|
1110 | + 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']); |
|
1111 | + } |
|
816 | 1112 | } |
817 | 1113 | } |
818 | 1114 | unset($data); |
@@ -839,14 +1135,20 @@ discard block |
||
839 | 1135 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
840 | 1136 | $data['latitude'] = (float)$line['pktLatitude']; |
841 | 1137 | $data['longitude'] = (float)$line['pktLongitude']; |
842 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
843 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1138 | + if ((float)$line['pktTrack'] != 0) { |
|
1139 | + $data['heading'] = (float)$line['pktTrack']; |
|
1140 | + } |
|
1141 | + if ((int)$line['pktSpeed'] != 0) { |
|
1142 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1143 | + } |
|
844 | 1144 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
845 | 1145 | $data['altitude_relative'] = 'AMSL'; |
846 | 1146 | $data['pilot_id'] = (int)$line['pktPilotID']; |
847 | 1147 | $data['aircraft_icao'] = 'PARAGLIDER'; |
848 | 1148 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
849 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1149 | + if (isset($pilot_data[4])) { |
|
1150 | + $data['pilot_name'] = $pilot_data[4]; |
|
1151 | + } |
|
850 | 1152 | $data['format_source'] = $value['format']; |
851 | 1153 | $SI->add($data); |
852 | 1154 | unset($data); |
@@ -894,25 +1196,59 @@ discard block |
||
894 | 1196 | foreach ($all_data['acList'] as $line) { |
895 | 1197 | $data = array(); |
896 | 1198 | $data['hex'] = $line['Icao']; // hex |
897 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
898 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
899 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
900 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
901 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
902 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1199 | + if (isset($line['Call'])) { |
|
1200 | + $data['ident'] = $line['Call']; |
|
1201 | + } |
|
1202 | + // ident |
|
1203 | + if (isset($line['Alt'])) { |
|
1204 | + $data['altitude'] = $line['Alt']; |
|
1205 | + } |
|
1206 | + // altitude |
|
1207 | + if (isset($line['Spd'])) { |
|
1208 | + $data['speed'] = $line['Spd']; |
|
1209 | + } |
|
1210 | + // speed |
|
1211 | + if (isset($line['Trak'])) { |
|
1212 | + $data['heading'] = $line['Trak']; |
|
1213 | + } |
|
1214 | + // heading |
|
1215 | + if (isset($line['Lat'])) { |
|
1216 | + $data['latitude'] = $line['Lat']; |
|
1217 | + } |
|
1218 | + // lat |
|
1219 | + if (isset($line['Long'])) { |
|
1220 | + $data['longitude'] = $line['Long']; |
|
1221 | + } |
|
1222 | + // long |
|
903 | 1223 | //$data['verticalrate'] = $line['']; // verticale rate |
904 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1224 | + if (isset($line['Sqk'])) { |
|
1225 | + $data['squawk'] = $line['Sqk']; |
|
1226 | + } |
|
1227 | + // squawk |
|
905 | 1228 | $data['emergency'] = ''; // emergency |
906 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
907 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
908 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1229 | + if (isset($line['Reg'])) { |
|
1230 | + $data['registration'] = $line['Reg']; |
|
1231 | + } |
|
1232 | + if (isset($line['PosTime'])) { |
|
1233 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1234 | + } else { |
|
1235 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1236 | + } |
|
909 | 1237 | //$data['datetime'] = date('Y-m-d H:i:s'); |
910 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1238 | + if (isset($line['Type'])) { |
|
1239 | + $data['aircraft_icao'] = $line['Type']; |
|
1240 | + } |
|
911 | 1241 | $data['format_source'] = 'aircraftlistjson'; |
912 | 1242 | $data['id_source'] = $id_source; |
913 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
914 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
915 | - if (isset($data['latitude'])) $SI->add($data); |
|
1243 | + if (isset($value['name']) && $value['name'] != '') { |
|
1244 | + $data['source_name'] = $value['name']; |
|
1245 | + } |
|
1246 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1247 | + $data['noarchive'] = true; |
|
1248 | + } |
|
1249 | + if (isset($data['latitude'])) { |
|
1250 | + $SI->add($data); |
|
1251 | + } |
|
916 | 1252 | unset($data); |
917 | 1253 | } |
918 | 1254 | } elseif (is_array($all_data)) { |
@@ -929,17 +1265,26 @@ discard block |
||
929 | 1265 | $data['verticalrate'] = $line['vrt']; // verticale rate |
930 | 1266 | $data['squawk'] = $line['squawk']; // squawk |
931 | 1267 | $data['emergency'] = ''; // emergency |
932 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
933 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1268 | + if (isset($line['PosTime'])) { |
|
1269 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1270 | + } else { |
|
1271 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1272 | + } |
|
934 | 1273 | $data['format_source'] = 'aircraftlistjson'; |
935 | 1274 | $data['id_source'] = $id_source; |
936 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
937 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1275 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1276 | + $data['noarchive'] = true; |
|
1277 | + } |
|
1278 | + if (isset($value['name']) && $value['name'] != '') { |
|
1279 | + $data['source_name'] = $value['name']; |
|
1280 | + } |
|
938 | 1281 | $SI->add($data); |
939 | 1282 | unset($data); |
940 | 1283 | } |
941 | 1284 | } |
942 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1285 | + } elseif ($globalDebug) { |
|
1286 | + echo 'No data'."\n"; |
|
1287 | + } |
|
943 | 1288 | //$last_exec['aircraftlistjson'] = time(); |
944 | 1289 | $last_exec[$id]['last'] = time(); |
945 | 1290 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -975,8 +1320,12 @@ discard block |
||
975 | 1320 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
976 | 1321 | $data['format_source'] = 'planeupdatefaa'; |
977 | 1322 | $data['id_source'] = $id_source; |
978 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
979 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1323 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1324 | + $data['noarchive'] = true; |
|
1325 | + } |
|
1326 | + if (isset($value['name']) && $value['name'] != '') { |
|
1327 | + $data['source_name'] = $value['name']; |
|
1328 | + } |
|
980 | 1329 | $SI->add($data); |
981 | 1330 | unset($data); |
982 | 1331 | } |
@@ -1010,7 +1359,9 @@ discard block |
||
1010 | 1359 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
1011 | 1360 | $data['format_source'] = 'opensky'; |
1012 | 1361 | $data['id_source'] = $id_source; |
1013 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1362 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1363 | + $data['noarchive'] = true; |
|
1364 | + } |
|
1014 | 1365 | $SI->add($data); |
1015 | 1366 | unset($data); |
1016 | 1367 | } |
@@ -1030,15 +1381,42 @@ discard block |
||
1030 | 1381 | foreach ($all_data['aircraft'] as $key => $line) { |
1031 | 1382 | $data = array(); |
1032 | 1383 | // add support for ground vehicule with ~ in front of hex |
1033 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1034 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1035 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1036 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1037 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1038 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1039 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1040 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1041 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1384 | + if (isset($line['hex'])) { |
|
1385 | + $data['hex'] = $line['hex']; |
|
1386 | + } |
|
1387 | + // hex |
|
1388 | + if (isset($line['flight'])) { |
|
1389 | + $data['ident'] = trim($line['flight']); |
|
1390 | + } |
|
1391 | + // ident |
|
1392 | + if (isset($line['altitude'])) { |
|
1393 | + $data['altitude'] = $line['altitude']; |
|
1394 | + } |
|
1395 | + // altitude |
|
1396 | + if (isset($line['speed'])) { |
|
1397 | + $data['speed'] = $line['speed']; |
|
1398 | + } |
|
1399 | + // speed |
|
1400 | + if (isset($line['track'])) { |
|
1401 | + $data['heading'] = $line['track']; |
|
1402 | + } |
|
1403 | + // heading |
|
1404 | + if (isset($line['lat'])) { |
|
1405 | + $data['latitude'] = $line['lat']; |
|
1406 | + } |
|
1407 | + // lat |
|
1408 | + if (isset($line['lon'])) { |
|
1409 | + $data['longitude'] = $line['lon']; |
|
1410 | + } |
|
1411 | + // long |
|
1412 | + if (isset($line['vert_rate'])) { |
|
1413 | + $data['verticalrate'] = $line['vert_rate']; |
|
1414 | + } |
|
1415 | + // verticale rate |
|
1416 | + if (isset($line['squawk'])) { |
|
1417 | + $data['squawk'] = $line['squawk']; |
|
1418 | + } |
|
1419 | + // squawk |
|
1042 | 1420 | //$data['emergency'] = ''; // emergency |
1043 | 1421 | //$data['registration'] = $line[2]; |
1044 | 1422 | //$data['aircraft_icao'] = $line[0]; |
@@ -1046,10 +1424,17 @@ discard block |
||
1046 | 1424 | $data['format_source'] = 'aircraftjson'; |
1047 | 1425 | $data['id_source'] = $id_source; |
1048 | 1426 | if (isset($value['name']) && $value['name'] != '') { |
1049 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1050 | - else $data['source_name'] = $value['name']; |
|
1051 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1052 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1427 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1428 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
1429 | + } else { |
|
1430 | + $data['source_name'] = $value['name']; |
|
1431 | + } |
|
1432 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1433 | + $data['source_name'] = 'MLAT'; |
|
1434 | + } |
|
1435 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1436 | + $data['noarchive'] = true; |
|
1437 | + } |
|
1053 | 1438 | $SI->add($data); |
1054 | 1439 | unset($data); |
1055 | 1440 | } |
@@ -1066,7 +1451,9 @@ discard block |
||
1066 | 1451 | //$buffer = $Common->getData($hosts[$id]); |
1067 | 1452 | $buffer = $Common->getData($value['host']); |
1068 | 1453 | $all_data = json_decode($buffer,true); |
1069 | - if (!empty($all_data)) $reset = 0; |
|
1454 | + if (!empty($all_data)) { |
|
1455 | + $reset = 0; |
|
1456 | + } |
|
1070 | 1457 | foreach ($all_data as $key => $line) { |
1071 | 1458 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1072 | 1459 | $data = array(); |
@@ -1087,8 +1474,12 @@ discard block |
||
1087 | 1474 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1088 | 1475 | $data['format_source'] = 'fr24json'; |
1089 | 1476 | $data['id_source'] = $id_source; |
1090 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1091 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1477 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1478 | + $data['noarchive'] = true; |
|
1479 | + } |
|
1480 | + if (isset($value['name']) && $value['name'] != '') { |
|
1481 | + $data['source_name'] = $value['name']; |
|
1482 | + } |
|
1092 | 1483 | $SI->add($data); |
1093 | 1484 | unset($data); |
1094 | 1485 | } |
@@ -1117,24 +1508,42 @@ discard block |
||
1117 | 1508 | if (isset($line['inf'])) { |
1118 | 1509 | $data = array(); |
1119 | 1510 | $data['hex'] = $line['inf']['ia']; |
1120 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1511 | + if (isset($line['inf']['cs'])) { |
|
1512 | + $data['ident'] = $line['inf']['cs']; |
|
1513 | + } |
|
1514 | + //$line[13] |
|
1121 | 1515 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1122 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1123 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1516 | + if (isset($line['inf']['gs'])) { |
|
1517 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1518 | + } |
|
1519 | + // speed |
|
1520 | + if (isset($line['inf']['tr'])) { |
|
1521 | + $data['heading'] = $line['inf']['tr']; |
|
1522 | + } |
|
1523 | + // heading |
|
1124 | 1524 | $data['latitude'] = $line['pt'][0]; // lat |
1125 | 1525 | $data['longitude'] = $line['pt'][1]; // long |
1126 | 1526 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1127 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1527 | + if (isset($line['inf']['sq'])) { |
|
1528 | + $data['squawk'] = $line['inf']['sq']; |
|
1529 | + } |
|
1530 | + // squawk |
|
1128 | 1531 | //$data['aircraft_icao'] = $line[8]; |
1129 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1532 | + if (isset($line['inf']['rc'])) { |
|
1533 | + $data['registration'] = $line['inf']['rc']; |
|
1534 | + } |
|
1130 | 1535 | //$data['departure_airport_iata'] = $line[11]; |
1131 | 1536 | //$data['arrival_airport_iata'] = $line[12]; |
1132 | 1537 | //$data['emergency'] = ''; // emergency |
1133 | 1538 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1134 | 1539 | $data['format_source'] = 'radarvirtueljson'; |
1135 | 1540 | $data['id_source'] = $id_source; |
1136 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1137 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1541 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1542 | + $data['noarchive'] = true; |
|
1543 | + } |
|
1544 | + if (isset($value['name']) && $value['name'] != '') { |
|
1545 | + $data['source_name'] = $value['name']; |
|
1546 | + } |
|
1138 | 1547 | $SI->add($data); |
1139 | 1548 | unset($data); |
1140 | 1549 | } |
@@ -1160,30 +1569,65 @@ discard block |
||
1160 | 1569 | $data['id'] = $line['id']; |
1161 | 1570 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1162 | 1571 | $data['ident'] = $line['callsign']; // ident |
1163 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1164 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1165 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1166 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1167 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1168 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1572 | + if (isset($line['pilotid'])) { |
|
1573 | + $data['pilot_id'] = $line['pilotid']; |
|
1574 | + } |
|
1575 | + // pilot id |
|
1576 | + if (isset($line['name'])) { |
|
1577 | + $data['pilot_name'] = $line['name']; |
|
1578 | + } |
|
1579 | + // pilot name |
|
1580 | + if (isset($line['alt'])) { |
|
1581 | + $data['altitude'] = $line['alt']; |
|
1582 | + } |
|
1583 | + // altitude |
|
1584 | + if (isset($line['gs'])) { |
|
1585 | + $data['speed'] = $line['gs']; |
|
1586 | + } |
|
1587 | + // speed |
|
1588 | + if (isset($line['heading'])) { |
|
1589 | + $data['heading'] = $line['heading']; |
|
1590 | + } |
|
1591 | + // heading |
|
1592 | + if (isset($line['route'])) { |
|
1593 | + $data['waypoints'] = $line['route']; |
|
1594 | + } |
|
1595 | + // route |
|
1169 | 1596 | $data['latitude'] = $line['lat']; // lat |
1170 | 1597 | $data['longitude'] = $line['lon']; // long |
1171 | 1598 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1172 | 1599 | //$data['squawk'] = $line['squawk']; // squawk |
1173 | 1600 | //$data['emergency'] = ''; // emergency |
1174 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1175 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1176 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1601 | + if (isset($line['depicao'])) { |
|
1602 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1603 | + } |
|
1604 | + if (isset($line['deptime'])) { |
|
1605 | + $data['departure_airport_time'] = $line['deptime']; |
|
1606 | + } |
|
1607 | + if (isset($line['arricao'])) { |
|
1608 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1609 | + } |
|
1177 | 1610 | //$data['arrival_airport_time'] = $line['arrtime']; |
1178 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1179 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1180 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1181 | - else $data['info'] = ''; |
|
1611 | + if (isset($line['aircraft'])) { |
|
1612 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1613 | + } |
|
1614 | + if (isset($line['transponder'])) { |
|
1615 | + $data['squawk'] = $line['transponder']; |
|
1616 | + } |
|
1617 | + if (isset($line['atis'])) { |
|
1618 | + $data['info'] = $line['atis']; |
|
1619 | + } else { |
|
1620 | + $data['info'] = ''; |
|
1621 | + } |
|
1182 | 1622 | $data['format_source'] = 'pireps'; |
1183 | 1623 | $data['id_source'] = $id_source; |
1184 | 1624 | $data['datetime'] = date('Y-m-d H:i:s'); |
1185 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1186 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1625 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1626 | + $data['noarchive'] = true; |
|
1627 | + } |
|
1628 | + if (isset($value['name']) && $value['name'] != '') { |
|
1629 | + $data['source_name'] = $value['name']; |
|
1630 | + } |
|
1187 | 1631 | if ($line['icon'] === 'plane') { |
1188 | 1632 | $SI->add($data); |
1189 | 1633 | // print_r($data); |
@@ -1192,16 +1636,28 @@ discard block |
||
1192 | 1636 | $data['info'] = str_replace('&sect;','',$data['info']); |
1193 | 1637 | $typec = substr($data['ident'],-3); |
1194 | 1638 | $data['type'] = ''; |
1195 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1196 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
1197 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
1198 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
1199 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
1200 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
1201 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1202 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1203 | - else $data['type'] = 'Observer'; |
|
1204 | - 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']); |
|
1639 | + if ($typec === 'APP') { |
|
1640 | + $data['type'] = 'Approach'; |
|
1641 | + } elseif ($typec === 'TWR') { |
|
1642 | + $data['type'] = 'Tower'; |
|
1643 | + } elseif ($typec === 'OBS') { |
|
1644 | + $data['type'] = 'Observer'; |
|
1645 | + } elseif ($typec === 'GND') { |
|
1646 | + $data['type'] = 'Ground'; |
|
1647 | + } elseif ($typec === 'DEL') { |
|
1648 | + $data['type'] = 'Delivery'; |
|
1649 | + } elseif ($typec === 'DEP') { |
|
1650 | + $data['type'] = 'Departure'; |
|
1651 | + } elseif ($typec === 'FSS') { |
|
1652 | + $data['type'] = 'Flight Service Station'; |
|
1653 | + } elseif ($typec === 'CTR') { |
|
1654 | + $data['type'] = 'Control Radar or Centre'; |
|
1655 | + } else { |
|
1656 | + $data['type'] = 'Observer'; |
|
1657 | + } |
|
1658 | + if (isset($ATC)) { |
|
1659 | + 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']); |
|
1660 | + } |
|
1205 | 1661 | } |
1206 | 1662 | unset($data); |
1207 | 1663 | } |
@@ -1216,7 +1672,9 @@ discard block |
||
1216 | 1672 | ) |
1217 | 1673 | ) { |
1218 | 1674 | //$buffer = $Common->getData($hosts[$id]); |
1219 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1675 | + if ($globalDebug) { |
|
1676 | + echo 'Get Data...'."\n"; |
|
1677 | + } |
|
1220 | 1678 | $buffer = $Common->getData($value['host']); |
1221 | 1679 | $all_data = json_decode($buffer,true); |
1222 | 1680 | if ($buffer != '' && is_array($all_data)) { |
@@ -1224,10 +1682,16 @@ discard block |
||
1224 | 1682 | foreach ($all_data as $line) { |
1225 | 1683 | $data = array(); |
1226 | 1684 | //$data['id'] = $line['id']; // id not usable |
1227 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1685 | + if (isset($line['pilotid'])) { |
|
1686 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1687 | + } |
|
1228 | 1688 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1229 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1230 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1689 | + if (isset($line['pilotname'])) { |
|
1690 | + $data['pilot_name'] = $line['pilotname']; |
|
1691 | + } |
|
1692 | + if (isset($line['pilotid'])) { |
|
1693 | + $data['pilot_id'] = $line['pilotid']; |
|
1694 | + } |
|
1231 | 1695 | $data['ident'] = $line['flightnum']; // ident |
1232 | 1696 | $data['altitude'] = $line['alt']; // altitude |
1233 | 1697 | $data['speed'] = $line['gs']; // speed |
@@ -1243,7 +1707,9 @@ discard block |
||
1243 | 1707 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1244 | 1708 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1245 | 1709 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1246 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1710 | + } else { |
|
1711 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1712 | + } |
|
1247 | 1713 | $data['departure_airport_icao'] = $line['depicao']; |
1248 | 1714 | $data['departure_airport_time'] = $line['deptime']; |
1249 | 1715 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1251,29 +1717,47 @@ discard block |
||
1251 | 1717 | if (isset($line['registration'])) { |
1252 | 1718 | $data['registration'] = $line['registration']; |
1253 | 1719 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
1254 | - } else $data['registration'] = $line['aircraft']; |
|
1255 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1256 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1720 | + } else { |
|
1721 | + $data['registration'] = $line['aircraft']; |
|
1722 | + } |
|
1723 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1724 | + $data['noarchive'] = true; |
|
1725 | + } |
|
1726 | + if (isset($line['route'])) { |
|
1727 | + $data['waypoints'] = $line['route']; |
|
1728 | + } |
|
1729 | + // route |
|
1257 | 1730 | if (isset($line['aircraftname'])) { |
1258 | 1731 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1259 | 1732 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1260 | 1733 | $aircraft_data = explode('-',$line['aircraftname']); |
1261 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1262 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1263 | - else { |
|
1734 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1735 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1736 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1737 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1738 | + } else { |
|
1264 | 1739 | $aircraft_data = explode(' ',$line['aircraftname']); |
1265 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1266 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1740 | + if (isset($aircraft_data[1])) { |
|
1741 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1742 | + } else { |
|
1743 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1744 | + } |
|
1267 | 1745 | } |
1268 | 1746 | } |
1269 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1747 | + if (isset($line['route'])) { |
|
1748 | + $data['waypoints'] = $line['route']; |
|
1749 | + } |
|
1270 | 1750 | $data['id_source'] = $id_source; |
1271 | 1751 | $data['format_source'] = 'phpvmacars'; |
1272 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1752 | + if (isset($value['name']) && $value['name'] != '') { |
|
1753 | + $data['source_name'] = $value['name']; |
|
1754 | + } |
|
1273 | 1755 | $SI->add($data); |
1274 | 1756 | unset($data); |
1275 | 1757 | } |
1276 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1758 | + if ($globalDebug) { |
|
1759 | + echo 'No more data...'."\n"; |
|
1760 | + } |
|
1277 | 1761 | unset($buffer); |
1278 | 1762 | unset($all_data); |
1279 | 1763 | } |
@@ -1286,7 +1770,9 @@ discard block |
||
1286 | 1770 | ) |
1287 | 1771 | ) { |
1288 | 1772 | //$buffer = $Common->getData($hosts[$id]); |
1289 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1773 | + if ($globalDebug) { |
|
1774 | + echo 'Get Data...'."\n"; |
|
1775 | + } |
|
1290 | 1776 | $buffer = $Common->getData($value['host']); |
1291 | 1777 | $all_data = json_decode($buffer,true); |
1292 | 1778 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1297,10 +1783,16 @@ discard block |
||
1297 | 1783 | //$data['id'] = $line['id']; // id not usable |
1298 | 1784 | $data['id'] = $line['id']; |
1299 | 1785 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1300 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1301 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1786 | + if (isset($line['user']['username'])) { |
|
1787 | + $data['pilot_name'] = $line['user']['username']; |
|
1788 | + } |
|
1789 | + if (isset($line['user_id'])) { |
|
1790 | + $data['pilot_id'] = $line['user_id']; |
|
1791 | + } |
|
1302 | 1792 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
1303 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1793 | + if (is_numeric($data['ident'])) { |
|
1794 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1795 | + } |
|
1304 | 1796 | $data['altitude'] = $line['altitude']; // altitude |
1305 | 1797 | $data['speed'] = $line['groundspeed']; // speed |
1306 | 1798 | $data['heading'] = $line['heading']; // heading |
@@ -1313,7 +1805,9 @@ discard block |
||
1313 | 1805 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
1314 | 1806 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1315 | 1807 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1316 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1808 | + } else { |
|
1809 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1810 | + } |
|
1317 | 1811 | |
1318 | 1812 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
1319 | 1813 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1321,17 +1815,26 @@ discard block |
||
1321 | 1815 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
1322 | 1816 | $data['registration'] = $line['bid']['aircraft']['registration']; |
1323 | 1817 | |
1324 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1325 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1818 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1819 | + $data['noarchive'] = true; |
|
1820 | + } |
|
1821 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
1822 | + $data['waypoints'] = $line['bid']['route']; |
|
1823 | + } |
|
1824 | + // route |
|
1326 | 1825 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
1327 | 1826 | |
1328 | 1827 | $data['id_source'] = $id_source; |
1329 | 1828 | $data['format_source'] = 'vaos'; |
1330 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1829 | + if (isset($value['name']) && $value['name'] != '') { |
|
1830 | + $data['source_name'] = $value['name']; |
|
1831 | + } |
|
1331 | 1832 | $SI->add($data); |
1332 | 1833 | unset($data); |
1333 | 1834 | } |
1334 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1835 | + if ($globalDebug) { |
|
1836 | + echo 'No more data...'."\n"; |
|
1837 | + } |
|
1335 | 1838 | unset($buffer); |
1336 | 1839 | unset($all_data); |
1337 | 1840 | } |
@@ -1344,7 +1847,9 @@ discard block |
||
1344 | 1847 | ) |
1345 | 1848 | ) { |
1346 | 1849 | //$buffer = $Common->getData($hosts[$id]); |
1347 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1850 | + if ($globalDebug) { |
|
1851 | + echo 'Get Data...'."\n"; |
|
1852 | + } |
|
1348 | 1853 | $buffer = $Common->getData($value['host']); |
1349 | 1854 | $all_data = json_decode($buffer,true); |
1350 | 1855 | if ($buffer != '' && is_array($all_data)) { |
@@ -1373,16 +1878,25 @@ discard block |
||
1373 | 1878 | $data['arrival_airport_icao'] = $line['arrival']; |
1374 | 1879 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1375 | 1880 | //$data['registration'] = $line['aircraft']; |
1376 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1881 | + if (isset($line['route'])) { |
|
1882 | + $data['waypoints'] = $line['route']; |
|
1883 | + } |
|
1884 | + // route |
|
1377 | 1885 | $data['aircraft_icao'] = $line['plane_type']; |
1378 | 1886 | $data['id_source'] = $id_source; |
1379 | 1887 | $data['format_source'] = 'vam'; |
1380 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1381 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1888 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1889 | + $data['noarchive'] = true; |
|
1890 | + } |
|
1891 | + if (isset($value['name']) && $value['name'] != '') { |
|
1892 | + $data['source_name'] = $value['name']; |
|
1893 | + } |
|
1382 | 1894 | $SI->add($data); |
1383 | 1895 | unset($data); |
1384 | 1896 | } |
1385 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1897 | + if ($globalDebug) { |
|
1898 | + echo 'No more data...'."\n"; |
|
1899 | + } |
|
1386 | 1900 | unset($buffer); |
1387 | 1901 | unset($all_data); |
1388 | 1902 | } |
@@ -1395,7 +1909,9 @@ discard block |
||
1395 | 1909 | ) |
1396 | 1910 | ) { |
1397 | 1911 | //$buffer = $Common->getData($hosts[$id]); |
1398 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1912 | + if ($globalDebug) { |
|
1913 | + echo 'Get Data...'."\n"; |
|
1914 | + } |
|
1399 | 1915 | $buffer = $Common->getData($value['host']); |
1400 | 1916 | $all_data = json_decode($buffer,true); |
1401 | 1917 | if ($buffer != '') { |
@@ -1413,12 +1929,16 @@ discard block |
||
1413 | 1929 | $data['id_source'] = $id_source; |
1414 | 1930 | $data['format_source'] = 'blitzortung'; |
1415 | 1931 | $SI->add($data); |
1416 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1932 | + if ($globalDebug) { |
|
1933 | + echo '☈ Lightning added'."\n"; |
|
1934 | + } |
|
1417 | 1935 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1418 | 1936 | unset($data); |
1419 | 1937 | } |
1420 | 1938 | } |
1421 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1939 | + if ($globalDebug) { |
|
1940 | + echo 'No more data...'."\n"; |
|
1941 | + } |
|
1422 | 1942 | unset($buffer); |
1423 | 1943 | } |
1424 | 1944 | $last_exec[$id]['last'] = time(); |
@@ -1430,7 +1950,9 @@ discard block |
||
1430 | 1950 | $write = NULL; |
1431 | 1951 | $e = NULL; |
1432 | 1952 | $n = socket_select($read, $write, $e, $timeout); |
1433 | - if ($e != NULL) var_dump($e); |
|
1953 | + if ($e != NULL) { |
|
1954 | + var_dump($e); |
|
1955 | + } |
|
1434 | 1956 | if ($n > 0) { |
1435 | 1957 | $reset = 0; |
1436 | 1958 | foreach ($read as $nb => $r) { |
@@ -1452,13 +1974,17 @@ discard block |
||
1452 | 1974 | if ($buffer !== FALSE) { |
1453 | 1975 | if ($format === 'vrstcp') { |
1454 | 1976 | $buffer = explode('},{',$buffer); |
1455 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1977 | + } else { |
|
1978 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1979 | + } |
|
1456 | 1980 | } |
1457 | 1981 | // SBS format is CSV format |
1458 | 1982 | if ($buffer !== FALSE && $buffer !== '') { |
1459 | 1983 | $tt[$format] = 0; |
1460 | 1984 | if ($format === 'acarssbs3') { |
1461 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1985 | + if ($globalDebug) { |
|
1986 | + echo 'ACARS : '.$buffer."\n"; |
|
1987 | + } |
|
1462 | 1988 | $ACARS->add(trim($buffer)); |
1463 | 1989 | $ACARS->deleteLiveAcarsData(); |
1464 | 1990 | } elseif ($format === 'raw') { |
@@ -1467,30 +1993,70 @@ discard block |
||
1467 | 1993 | if (is_array($data)) { |
1468 | 1994 | $data['datetime'] = date('Y-m-d H:i:s'); |
1469 | 1995 | $data['format_source'] = 'raw'; |
1470 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1471 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1472 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1473 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1996 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1997 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1998 | + } |
|
1999 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2000 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2001 | + } |
|
2002 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2003 | + $data['noarchive'] = true; |
|
2004 | + } |
|
2005 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2006 | + $SI->add($data); |
|
2007 | + } |
|
1474 | 2008 | } |
1475 | 2009 | } elseif ($format === 'ais') { |
1476 | 2010 | $ais_data = $AIS->parse_line(trim($buffer)); |
1477 | 2011 | $data = array(); |
1478 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1479 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1480 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1481 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1482 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1483 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1484 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1485 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1486 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1487 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1488 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1489 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1490 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1491 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1492 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1493 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2012 | + if (isset($ais_data['ident'])) { |
|
2013 | + $data['ident'] = $ais_data['ident']; |
|
2014 | + } |
|
2015 | + if (isset($ais_data['mmsi'])) { |
|
2016 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
2017 | + } |
|
2018 | + if (isset($ais_data['speed'])) { |
|
2019 | + $data['speed'] = $ais_data['speed']; |
|
2020 | + } |
|
2021 | + if (isset($ais_data['heading'])) { |
|
2022 | + $data['heading'] = $ais_data['heading']; |
|
2023 | + } |
|
2024 | + if (isset($ais_data['latitude'])) { |
|
2025 | + $data['latitude'] = $ais_data['latitude']; |
|
2026 | + } |
|
2027 | + if (isset($ais_data['longitude'])) { |
|
2028 | + $data['longitude'] = $ais_data['longitude']; |
|
2029 | + } |
|
2030 | + if (isset($ais_data['status'])) { |
|
2031 | + $data['status'] = $ais_data['status']; |
|
2032 | + } |
|
2033 | + if (isset($ais_data['statusid'])) { |
|
2034 | + $data['status_id'] = $ais_data['statusid']; |
|
2035 | + } |
|
2036 | + if (isset($ais_data['type'])) { |
|
2037 | + $data['type'] = $ais_data['type']; |
|
2038 | + } |
|
2039 | + if (isset($ais_data['imo'])) { |
|
2040 | + $data['imo'] = $ais_data['imo']; |
|
2041 | + } |
|
2042 | + if (isset($ais_data['callsign'])) { |
|
2043 | + $data['callsign'] = $ais_data['callsign']; |
|
2044 | + } |
|
2045 | + if (isset($ais_data['destination'])) { |
|
2046 | + $data['arrival_code'] = $ais_data['destination']; |
|
2047 | + } |
|
2048 | + if (isset($ais_data['eta_ts'])) { |
|
2049 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
2050 | + } |
|
2051 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2052 | + $data['noarchive'] = true; |
|
2053 | + } |
|
2054 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2055 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2056 | + } |
|
2057 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2058 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2059 | + } |
|
1494 | 2060 | |
1495 | 2061 | if (isset($ais_data['timestamp'])) { |
1496 | 2062 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1499,7 +2065,9 @@ discard block |
||
1499 | 2065 | } |
1500 | 2066 | $data['format_source'] = 'aisnmea'; |
1501 | 2067 | $data['id_source'] = $id_source; |
1502 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
2068 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
2069 | + $MI->add($data); |
|
2070 | + } |
|
1503 | 2071 | unset($data); |
1504 | 2072 | } elseif ($format === 'flightgearsp') { |
1505 | 2073 | //echo $buffer."\n"; |
@@ -1517,12 +2085,18 @@ discard block |
||
1517 | 2085 | $data['speed'] = round($line[5]*1.94384); |
1518 | 2086 | $data['datetime'] = date('Y-m-d H:i:s'); |
1519 | 2087 | $data['format_source'] = 'flightgearsp'; |
1520 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1521 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2088 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2089 | + $data['noarchive'] = true; |
|
2090 | + } |
|
2091 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2092 | + $SI->add($data); |
|
2093 | + } |
|
1522 | 2094 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1523 | 2095 | } |
1524 | 2096 | } elseif ($format === 'acars') { |
1525 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2097 | + if ($globalDebug) { |
|
2098 | + echo 'ACARS : '.$buffer."\n"; |
|
2099 | + } |
|
1526 | 2100 | $ACARS->add(trim($buffer)); |
1527 | 2101 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1528 | 2102 | $ACARS->deleteLiveAcarsData(); |
@@ -1543,8 +2117,12 @@ discard block |
||
1543 | 2117 | $aircraft_type = $line[10]; |
1544 | 2118 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1545 | 2119 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1546 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1547 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2120 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2121 | + $data['noarchive'] = true; |
|
2122 | + } |
|
2123 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2124 | + $SI->add($data); |
|
2125 | + } |
|
1548 | 2126 | } |
1549 | 2127 | } |
1550 | 2128 | } elseif ($format === 'beast') { |
@@ -1554,28 +2132,62 @@ discard block |
||
1554 | 2132 | foreach($buffer as $all_data) { |
1555 | 2133 | $line = json_decode('{'.$all_data.'}',true); |
1556 | 2134 | $data = array(); |
1557 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1558 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1559 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1560 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1561 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1562 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1563 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
2135 | + if (isset($line['Icao'])) { |
|
2136 | + $data['hex'] = $line['Icao']; |
|
2137 | + } |
|
2138 | + // hex |
|
2139 | + if (isset($line['Call'])) { |
|
2140 | + $data['ident'] = $line['Call']; |
|
2141 | + } |
|
2142 | + // ident |
|
2143 | + if (isset($line['Alt'])) { |
|
2144 | + $data['altitude'] = $line['Alt']; |
|
2145 | + } |
|
2146 | + // altitude |
|
2147 | + if (isset($line['Spd'])) { |
|
2148 | + $data['speed'] = $line['Spd']; |
|
2149 | + } |
|
2150 | + // speed |
|
2151 | + if (isset($line['Trak'])) { |
|
2152 | + $data['heading'] = $line['Trak']; |
|
2153 | + } |
|
2154 | + // heading |
|
2155 | + if (isset($line['Lat'])) { |
|
2156 | + $data['latitude'] = $line['Lat']; |
|
2157 | + } |
|
2158 | + // lat |
|
2159 | + if (isset($line['Long'])) { |
|
2160 | + $data['longitude'] = $line['Long']; |
|
2161 | + } |
|
2162 | + // long |
|
1564 | 2163 | //$data['verticalrate'] = $line['']; // verticale rate |
1565 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
2164 | + if (isset($line['Sqk'])) { |
|
2165 | + $data['squawk'] = $line['Sqk']; |
|
2166 | + } |
|
2167 | + // squawk |
|
1566 | 2168 | $data['emergency'] = ''; // emergency |
1567 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
2169 | + if (isset($line['Reg'])) { |
|
2170 | + $data['registration'] = $line['Reg']; |
|
2171 | + } |
|
1568 | 2172 | /* |
1569 | 2173 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1570 | 2174 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1571 | 2175 | */ |
1572 | 2176 | $data['datetime'] = date('Y-m-d H:i:s'); |
1573 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
2177 | + if (isset($line['Type'])) { |
|
2178 | + $data['aircraft_icao'] = $line['Type']; |
|
2179 | + } |
|
1574 | 2180 | $data['format_source'] = 'vrstcp'; |
1575 | 2181 | $data['id_source'] = $id_source; |
1576 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1577 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1578 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
2182 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2183 | + $data['noarchive'] = true; |
|
2184 | + } |
|
2185 | + if (isset($value['name']) && $value['name'] != '') { |
|
2186 | + $data['source_name'] = $value['name']; |
|
2187 | + } |
|
2188 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
2189 | + $SI->add($data); |
|
2190 | + } |
|
1579 | 2191 | unset($data); |
1580 | 2192 | } |
1581 | 2193 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1588,22 +2200,46 @@ discard block |
||
1588 | 2200 | $data['hex'] = $lined['hexid']; |
1589 | 2201 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1590 | 2202 | $data['datetime'] = date('Y-m-d H:i:s');; |
1591 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1592 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1593 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1594 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1595 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1596 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1597 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
2203 | + if (isset($lined['ident'])) { |
|
2204 | + $data['ident'] = $lined['ident']; |
|
2205 | + } |
|
2206 | + if (isset($lined['lat'])) { |
|
2207 | + $data['latitude'] = $lined['lat']; |
|
2208 | + } |
|
2209 | + if (isset($lined['lon'])) { |
|
2210 | + $data['longitude'] = $lined['lon']; |
|
2211 | + } |
|
2212 | + if (isset($lined['speed'])) { |
|
2213 | + $data['speed'] = $lined['speed']; |
|
2214 | + } |
|
2215 | + if (isset($lined['squawk'])) { |
|
2216 | + $data['squawk'] = $lined['squawk']; |
|
2217 | + } |
|
2218 | + if (isset($lined['alt'])) { |
|
2219 | + $data['altitude'] = $lined['alt']; |
|
2220 | + } |
|
2221 | + if (isset($lined['heading'])) { |
|
2222 | + $data['heading'] = $lined['heading']; |
|
2223 | + } |
|
1598 | 2224 | $data['id_source'] = $id_source; |
1599 | 2225 | $data['format_source'] = 'tsv'; |
1600 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1601 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1602 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1603 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2226 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2227 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2228 | + } |
|
2229 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2230 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2231 | + } |
|
2232 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2233 | + $data['noarchive'] = true; |
|
2234 | + } |
|
2235 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2236 | + $SI->add($data); |
|
2237 | + } |
|
1604 | 2238 | unset($lined); |
1605 | 2239 | unset($data); |
1606 | - } else $error = true; |
|
2240 | + } else { |
|
2241 | + $error = true; |
|
2242 | + } |
|
1607 | 2243 | } elseif ($format === 'aprs' && $use_aprs) { |
1608 | 2244 | if ($aprs_connect === 0) { |
1609 | 2245 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1629,63 +2265,121 @@ discard block |
||
1629 | 2265 | $aprs_last_tx = time(); |
1630 | 2266 | $data = array(); |
1631 | 2267 | //print_r($line); |
1632 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1633 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1634 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1635 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1636 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1637 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1638 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1639 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1640 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1641 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2268 | + if (isset($line['address'])) { |
|
2269 | + $data['hex'] = $line['address']; |
|
2270 | + } |
|
2271 | + if (isset($line['mmsi'])) { |
|
2272 | + $data['mmsi'] = $line['mmsi']; |
|
2273 | + } |
|
2274 | + if (isset($line['imo'])) { |
|
2275 | + $data['imo'] = $line['imo']; |
|
2276 | + } |
|
2277 | + if (isset($line['squawk'])) { |
|
2278 | + $data['squawk'] = $line['squawk']; |
|
2279 | + } |
|
2280 | + if (isset($line['arrival_code'])) { |
|
2281 | + $data['arrival_code'] = $line['arrival_code']; |
|
2282 | + } |
|
2283 | + if (isset($line['arrival_date'])) { |
|
2284 | + $data['arrival_date'] = $line['arrival_date']; |
|
2285 | + } |
|
2286 | + if (isset($line['typeid'])) { |
|
2287 | + $data['type_id'] = $line['typeid']; |
|
2288 | + } |
|
2289 | + if (isset($line['statusid'])) { |
|
2290 | + $data['status_id'] = $line['statusid']; |
|
2291 | + } |
|
2292 | + if (isset($line['timestamp'])) { |
|
2293 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2294 | + } else { |
|
2295 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2296 | + } |
|
1642 | 2297 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1643 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2298 | + if (isset($line['ident'])) { |
|
2299 | + $data['ident'] = $line['ident']; |
|
2300 | + } |
|
1644 | 2301 | $data['latitude'] = $line['latitude']; |
1645 | 2302 | $data['longitude'] = $line['longitude']; |
1646 | 2303 | //$data['verticalrate'] = $line[16]; |
1647 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2304 | + if (isset($line['speed'])) { |
|
2305 | + $data['speed'] = $line['speed']; |
|
2306 | + } |
|
1648 | 2307 | //else $data['speed'] = 0; |
1649 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1650 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1651 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2308 | + if (isset($line['altitude'])) { |
|
2309 | + $data['altitude'] = $line['altitude']; |
|
2310 | + } |
|
2311 | + if (isset($line['comment'])) { |
|
2312 | + $data['comment'] = $line['comment']; |
|
2313 | + } |
|
2314 | + if (isset($line['symbol'])) { |
|
2315 | + $data['type'] = $line['symbol']; |
|
2316 | + } |
|
1652 | 2317 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1653 | 2318 | |
1654 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2319 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2320 | + $data['heading'] = $line['heading']; |
|
2321 | + } |
|
1655 | 2322 | //else echo 'No heading...'."\n"; |
1656 | 2323 | //else $data['heading'] = 0; |
1657 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2324 | + if (isset($line['stealth'])) { |
|
2325 | + $data['aircraft_type'] = $line['stealth']; |
|
2326 | + } |
|
1658 | 2327 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1659 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1660 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1661 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1662 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2328 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2329 | + $data['noarchive'] = true; |
|
2330 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2331 | + $data['noarchive'] = false; |
|
2332 | + } |
|
2333 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2334 | + $data['noarchive'] = true; |
|
2335 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2336 | + $data['noarchive'] = false; |
|
2337 | + } |
|
1663 | 2338 | $data['id_source'] = $id_source; |
1664 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1665 | - else $data['format_source'] = 'aprs'; |
|
2339 | + if (isset($line['format_source'])) { |
|
2340 | + $data['format_source'] = $line['format_source']; |
|
2341 | + } else { |
|
2342 | + $data['format_source'] = 'aprs'; |
|
2343 | + } |
|
1666 | 2344 | $data['source_name'] = $line['source']; |
1667 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1668 | - else $data['source_type'] = 'flarm'; |
|
1669 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2345 | + if (isset($line['source_type'])) { |
|
2346 | + $data['source_type'] = $line['source_type']; |
|
2347 | + } else { |
|
2348 | + $data['source_type'] = 'flarm'; |
|
2349 | + } |
|
2350 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2351 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2352 | + } |
|
1670 | 2353 | $currentdate = date('Y-m-d H:i:s'); |
1671 | 2354 | $aprsdate = strtotime($data['datetime']); |
1672 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2355 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2356 | + $data['altitude_relative'] = 'AMSL'; |
|
2357 | + } |
|
1673 | 2358 | // Accept data if time <= system time + 20s |
1674 | 2359 | //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'])))) { |
1675 | 2360 | 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'])))) { |
1676 | 2361 | $send = $SI->add($data); |
1677 | 2362 | } elseif ($data['source_type'] === 'ais') { |
1678 | 2363 | $data['type'] = ''; |
1679 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2364 | + if (isset($globalMarine) && $globalMarine) { |
|
2365 | + $send = $MI->add($data); |
|
2366 | + } |
|
1680 | 2367 | } elseif (isset($line['stealth'])) { |
1681 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1682 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2368 | + if ($line['stealth'] != 0) { |
|
2369 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
2370 | + } else { |
|
2371 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2372 | + } |
|
1683 | 2373 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1684 | 2374 | //$line['symbol'] === 'Balloon' || |
1685 | 2375 | $line['symbol'] === 'Glider' || |
1686 | 2376 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
1687 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1688 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2377 | + if ($line['symbol'] === 'Ballon') { |
|
2378 | + $data['aircraft_icao'] = 'BALL'; |
|
2379 | + } |
|
2380 | + if ($line['symbol'] === 'Glider') { |
|
2381 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2382 | + } |
|
1689 | 2383 | $send = $SI->add($data); |
1690 | 2384 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1691 | 2385 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1716,9 +2410,13 @@ discard block |
||
1716 | 2410 | //} 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') { |
1717 | 2411 | // } 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') { |
1718 | 2412 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1719 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2413 | + if (isset($globalTracker) && $globalTracker) { |
|
2414 | + $send = $TI->add($data); |
|
2415 | + } |
|
1720 | 2416 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1721 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2417 | + if (!isset($data['altitude'])) { |
|
2418 | + $data['altitude'] = 0; |
|
2419 | + } |
|
1722 | 2420 | $Source->deleteOldLocationByType('gs'); |
1723 | 2421 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1724 | 2422 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1727,7 +2425,9 @@ discard block |
||
1727 | 2425 | } |
1728 | 2426 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
1729 | 2427 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1730 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2428 | + if ($globalDebug) { |
|
2429 | + echo '# Weather Station added'."\n"; |
|
2430 | + } |
|
1731 | 2431 | $Source->deleteOldLocationByType('wx'); |
1732 | 2432 | $weather_data = json_encode($line); |
1733 | 2433 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1737,7 +2437,9 @@ discard block |
||
1737 | 2437 | } |
1738 | 2438 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
1739 | 2439 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1740 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2440 | + if ($globalDebug) { |
|
2441 | + echo '☈ Lightning added'."\n"; |
|
2442 | + } |
|
1741 | 2443 | $Source->deleteOldLocationByType('lightning'); |
1742 | 2444 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1743 | 2445 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1749,8 +2451,7 @@ discard block |
||
1749 | 2451 | print_r($line); |
1750 | 2452 | } |
1751 | 2453 | unset($data); |
1752 | - } |
|
1753 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2454 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1754 | 2455 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1755 | 2456 | } |
1756 | 2457 | /* |
@@ -1759,7 +2460,9 @@ discard block |
||
1759 | 2460 | } |
1760 | 2461 | */ |
1761 | 2462 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1762 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2463 | + elseif ($line === true && $globalDebug) { |
|
2464 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2465 | + } |
|
1763 | 2466 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
1764 | 2467 | $Source->deleteOldLocationByType('lightning'); |
1765 | 2468 | $Source->deleteOldLocationByType('wx'); |
@@ -1795,26 +2498,45 @@ discard block |
||
1795 | 2498 | $data['ground'] = $line[21]; |
1796 | 2499 | $data['emergency'] = $line[19]; |
1797 | 2500 | $data['format_source'] = 'sbs'; |
1798 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1799 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1800 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2501 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2502 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2503 | + } |
|
2504 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2505 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2506 | + } |
|
2507 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2508 | + $data['noarchive'] = true; |
|
2509 | + } |
|
1801 | 2510 | $data['id_source'] = $id_source; |
1802 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1803 | - else $error = true; |
|
2511 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2512 | + $send = $SI->add($data); |
|
2513 | + } else { |
|
2514 | + $error = true; |
|
2515 | + } |
|
1804 | 2516 | unset($data); |
1805 | - } else $error = true; |
|
2517 | + } else { |
|
2518 | + $error = true; |
|
2519 | + } |
|
1806 | 2520 | if ($error) { |
1807 | 2521 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
1808 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2522 | + if ($globalDebug) { |
|
2523 | + echo "Not a message. Ignoring... \n"; |
|
2524 | + } |
|
1809 | 2525 | } else { |
1810 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2526 | + if ($globalDebug) { |
|
2527 | + echo "Wrong line format. Ignoring... \n"; |
|
2528 | + } |
|
1811 | 2529 | if ($globalDebug) { |
1812 | 2530 | echo $buffer; |
1813 | 2531 | //print_r($line); |
1814 | 2532 | } |
1815 | 2533 | //socket_close($r); |
1816 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1817 | - if ($format === 'aprs') $aprs_connect = 0; |
|
2534 | + if ($globalDebug) { |
|
2535 | + echo "Reconnect after an error...\n"; |
|
2536 | + } |
|
2537 | + if ($format === 'aprs') { |
|
2538 | + $aprs_connect = 0; |
|
2539 | + } |
|
1818 | 2540 | $sourceer[$nb] = $globalSources[$nb]; |
1819 | 2541 | connect_all($sourceer); |
1820 | 2542 | $sourceer = array(); |
@@ -1822,10 +2544,14 @@ discard block |
||
1822 | 2544 | } |
1823 | 2545 | } |
1824 | 2546 | // Sleep for xxx microseconds |
1825 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2547 | + if (isset($globalSBSSleep)) { |
|
2548 | + usleep($globalSBSSleep); |
|
2549 | + } |
|
1826 | 2550 | } else { |
1827 | 2551 | if ($format === 'flightgearmp') { |
1828 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2552 | + if ($globalDebug) { |
|
2553 | + echo "Reconnect FlightGear MP..."; |
|
2554 | + } |
|
1829 | 2555 | //@socket_close($r); |
1830 | 2556 | sleep($globalMinFetch); |
1831 | 2557 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1834,10 +2560,15 @@ discard block |
||
1834 | 2560 | break; |
1835 | 2561 | |
1836 | 2562 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1837 | - if (isset($tt[$format])) $tt[$format]++; |
|
1838 | - else $tt[$format] = 0; |
|
2563 | + if (isset($tt[$format])) { |
|
2564 | + $tt[$format]++; |
|
2565 | + } else { |
|
2566 | + $tt[$format] = 0; |
|
2567 | + } |
|
1839 | 2568 | if ($tt[$format] > 30 || $buffer === FALSE) { |
1840 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2569 | + if ($globalDebug) { |
|
2570 | + echo "ERROR : Reconnect ".$format."..."; |
|
2571 | + } |
|
1841 | 2572 | //@socket_close($r); |
1842 | 2573 | sleep(2); |
1843 | 2574 | $aprs_connect = 0; |
@@ -1855,11 +2586,17 @@ discard block |
||
1855 | 2586 | } else { |
1856 | 2587 | $error = socket_strerror(socket_last_error()); |
1857 | 2588 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1858 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1859 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2589 | + if ($globalDebug) { |
|
2590 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2591 | + } |
|
2592 | + if (isset($globalDebug)) { |
|
2593 | + echo "Restarting...\n"; |
|
2594 | + } |
|
1860 | 2595 | // Restart the script if possible |
1861 | 2596 | if (is_array($sockets)) { |
1862 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2597 | + if ($globalDebug) { |
|
2598 | + echo "Shutdown all sockets..."; |
|
2599 | + } |
|
1863 | 2600 | |
1864 | 2601 | foreach ($sockets as $sock) { |
1865 | 2602 | @socket_shutdown($sock,2); |
@@ -1867,25 +2604,45 @@ discard block |
||
1867 | 2604 | } |
1868 | 2605 | |
1869 | 2606 | } |
1870 | - if ($globalDebug) echo "Waiting..."; |
|
2607 | + if ($globalDebug) { |
|
2608 | + echo "Waiting..."; |
|
2609 | + } |
|
1871 | 2610 | sleep(2); |
1872 | 2611 | $time = time(); |
1873 | 2612 | //connect_all($hosts); |
1874 | 2613 | $aprs_connect = 0; |
1875 | - if ($reset%5 === 0) sleep(20); |
|
1876 | - if ($reset%10 === 0) sleep(100); |
|
1877 | - if ($reset%20 === 0) sleep(200); |
|
1878 | - if ($reset > 100) exit('Too many attempts...'); |
|
1879 | - if ($globalDebug) echo "Restart all connections..."; |
|
2614 | + if ($reset%5 === 0) { |
|
2615 | + sleep(20); |
|
2616 | + } |
|
2617 | + if ($reset%10 === 0) { |
|
2618 | + sleep(100); |
|
2619 | + } |
|
2620 | + if ($reset%20 === 0) { |
|
2621 | + sleep(200); |
|
2622 | + } |
|
2623 | + if ($reset > 100) { |
|
2624 | + exit('Too many attempts...'); |
|
2625 | + } |
|
2626 | + if ($globalDebug) { |
|
2627 | + echo "Restart all connections..."; |
|
2628 | + } |
|
1880 | 2629 | connect_all($globalSources); |
1881 | 2630 | } |
1882 | 2631 | } |
1883 | 2632 | } |
1884 | 2633 | if ($globalDaemon === false) { |
1885 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1886 | - if (isset($SI)) $SI->checkAll(); |
|
1887 | - if (isset($TI)) $TI->checkAll(); |
|
1888 | - if (isset($MI)) $MI->checkAll(); |
|
2634 | + if ($globalDebug) { |
|
2635 | + echo 'Check all...'."\n"; |
|
2636 | + } |
|
2637 | + if (isset($SI)) { |
|
2638 | + $SI->checkAll(); |
|
2639 | + } |
|
2640 | + if (isset($TI)) { |
|
2641 | + $TI->checkAll(); |
|
2642 | + } |
|
2643 | + if (isset($MI)) { |
|
2644 | + $MI->checkAll(); |
|
2645 | + } |
|
1889 | 2646 | } |
1890 | 2647 | } |
1891 | 2648 | } |