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