@@ -15,65 +15,65 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) { |
18 | - require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | 19 | } |
20 | 20 | if (isset($globalMarine) && $globalMarine) { |
21 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
22 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
22 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | if (!isset($globalDebug)) $globalDebug = FALSE; |
26 | 26 | |
27 | 27 | if ($globalInstalled === FALSE) { |
28 | - echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
|
29 | - sleep(5); |
|
30 | - die(); |
|
28 | + echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
|
29 | + sleep(5); |
|
30 | + die(); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | // Check if schema is at latest version |
35 | 35 | $Connection = new Connection(); |
36 | 36 | if ($Connection->connectionExists() === false) { |
37 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
38 | - exit(); |
|
37 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
38 | + exit(); |
|
39 | 39 | } |
40 | 40 | if ($Connection->latest() === false) { |
41 | - echo "You MUST update to latest schema. Use your web browser to run install/index.php"; |
|
42 | - exit(); |
|
41 | + echo "You MUST update to latest schema. Use your web browser to run install/index.php"; |
|
42 | + exit(); |
|
43 | 43 | } |
44 | 44 | if (PHP_SAPI != 'cli') { |
45 | - echo "This script MUST be called from console, not a web browser."; |
|
45 | + echo "This script MUST be called from console, not a web browser."; |
|
46 | 46 | // exit(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | // This is to be compatible with old version of settings.php |
50 | 50 | if (!isset($globalSources)) { |
51 | - if (isset($globalSBS1Hosts)) { |
|
52 | - //$hosts = $globalSBS1Hosts; |
|
53 | - foreach ($globalSBS1Hosts as $host) { |
|
54 | - $globalSources[] = array('host' => $host); |
|
55 | - } |
|
56 | - } else { |
|
57 | - if (!isset($globalSBS1Host)) { |
|
58 | - echo '$globalSources MUST be defined !'; |
|
59 | - die; |
|
51 | + if (isset($globalSBS1Hosts)) { |
|
52 | + //$hosts = $globalSBS1Hosts; |
|
53 | + foreach ($globalSBS1Hosts as $host) { |
|
54 | + $globalSources[] = array('host' => $host); |
|
55 | + } |
|
56 | + } else { |
|
57 | + if (!isset($globalSBS1Host)) { |
|
58 | + echo '$globalSources MUST be defined !'; |
|
59 | + die; |
|
60 | 60 | } |
61 | 61 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
62 | 62 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
63 | - } |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
67 | 67 | //if (isset($options['s'])) $hosts = array($options['s']); |
68 | 68 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
69 | 69 | if (isset($options['s'])) { |
70 | - $globalSources = array(); |
|
71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
72 | - else $globalSources[] = array('host' => $options['s']); |
|
70 | + $globalSources = array(); |
|
71 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
72 | + else $globalSources[] = array('host' => $options['s']); |
|
73 | 73 | } elseif (isset($options['source'])) { |
74 | - $globalSources = array(); |
|
75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
76 | - else $globalSources[] = array('host' => $options['source']); |
|
74 | + $globalSources = array(); |
|
75 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
76 | + else $globalSources[] = array('host' => $options['source']); |
|
77 | 77 | } |
78 | 78 | if (isset($options['aprsserverhost'])) { |
79 | 79 | $globalServerAPRS = TRUE; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
113 | 113 | else $id_source = 1; |
114 | 114 | if (isset($globalServer) && $globalServer) { |
115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
116 | - $SI=new SpotterServer(); |
|
115 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
116 | + $SI=new SpotterServer(); |
|
117 | 117 | /* |
118 | 118 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
119 | 119 | $SI = new adsb2aprs(); |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | |
124 | 124 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
125 | 125 | if (isset($globalMarine) && $globalMarine) { |
126 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
127 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
126 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
127 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
131 | 131 | if (isset($globalMarine) && $globalMarine) { |
132 | - $AIS = new AIS(); |
|
133 | - $MI = new MarineImport($Connection->db); |
|
132 | + $AIS = new AIS(); |
|
133 | + $MI = new MarineImport($Connection->db); |
|
134 | 134 | } |
135 | 135 | //$APRS=new APRS($Connection->db); |
136 | 136 | $SBS=new SBS(); |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | //$servertz = system('date +%Z'); |
144 | 144 | // signal handler - playing nice with sockets and dump1090 |
145 | 145 | if (function_exists('pcntl_fork')) { |
146 | - pcntl_signal(SIGINT, function() { |
|
147 | - global $sockets; |
|
148 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
149 | - die("Bye!\n"); |
|
150 | - }); |
|
151 | - pcntl_signal_dispatch(); |
|
146 | + pcntl_signal(SIGINT, function() { |
|
147 | + global $sockets; |
|
148 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
149 | + die("Bye!\n"); |
|
150 | + }); |
|
151 | + pcntl_signal_dispatch(); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // let's try and connect |
@@ -158,46 +158,46 @@ discard block |
||
158 | 158 | $reset = 0; |
159 | 159 | |
160 | 160 | function connect_all($hosts) { |
161 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
162 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
163 | - $reset++; |
|
164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
165 | - foreach ($hosts as $id => $value) { |
|
161 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
162 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
163 | + $reset++; |
|
164 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
165 | + foreach ($hosts as $id => $value) { |
|
166 | 166 | $host = $value['host']; |
167 | 167 | $globalSources[$id]['last_exec'] = 0; |
168 | 168 | // Here we check type of source(s) |
169 | 169 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
170 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
171 | - //$formats[$id] = 'deltadbtxt'; |
|
172 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
173 | - //$last_exec['deltadbtxt'] = 0; |
|
174 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
175 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
176 | - //$formats[$id] = 'vatsimtxt'; |
|
177 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
178 | - //$last_exec['vatsimtxt'] = 0; |
|
179 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
180 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
181 | - //$formats[$id] = 'aircraftlistjson'; |
|
182 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
183 | - //$last_exec['aircraftlistjson'] = 0; |
|
184 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
185 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
186 | - //$formats[$id] = 'aircraftjson'; |
|
187 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
188 | - //$last_exec['aircraftlistjson'] = 0; |
|
189 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
190 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
191 | - //$formats[$id] = 'planefinderclient'; |
|
192 | - $globalSources[$id]['format'] = 'planefinderclient'; |
|
193 | - //$last_exec['aircraftlistjson'] = 0; |
|
194 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
195 | - } else if (preg_match('/opensky/i',$host)) { |
|
196 | - //$formats[$id] = 'aircraftlistjson'; |
|
197 | - $globalSources[$id]['format'] = 'opensky'; |
|
198 | - //$last_exec['aircraftlistjson'] = 0; |
|
199 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
200 | - /* |
|
170 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
171 | + //$formats[$id] = 'deltadbtxt'; |
|
172 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
173 | + //$last_exec['deltadbtxt'] = 0; |
|
174 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
175 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
176 | + //$formats[$id] = 'vatsimtxt'; |
|
177 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
178 | + //$last_exec['vatsimtxt'] = 0; |
|
179 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
180 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
181 | + //$formats[$id] = 'aircraftlistjson'; |
|
182 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
183 | + //$last_exec['aircraftlistjson'] = 0; |
|
184 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
185 | + } else if (preg_match('/aircraft.json$/i',$host)) { |
|
186 | + //$formats[$id] = 'aircraftjson'; |
|
187 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
188 | + //$last_exec['aircraftlistjson'] = 0; |
|
189 | + if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
190 | + } else if (preg_match('/aircraft$/i',$host)) { |
|
191 | + //$formats[$id] = 'planefinderclient'; |
|
192 | + $globalSources[$id]['format'] = 'planefinderclient'; |
|
193 | + //$last_exec['aircraftlistjson'] = 0; |
|
194 | + if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
195 | + } else if (preg_match('/opensky/i',$host)) { |
|
196 | + //$formats[$id] = 'aircraftlistjson'; |
|
197 | + $globalSources[$id]['format'] = 'opensky'; |
|
198 | + //$last_exec['aircraftlistjson'] = 0; |
|
199 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
200 | + /* |
|
201 | 201 | // Disabled for now, site change source format |
202 | 202 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
203 | 203 | //$formats[$id] = 'radarvirtueljson'; |
@@ -209,128 +209,128 @@ discard block |
||
209 | 209 | exit(0); |
210 | 210 | } |
211 | 211 | */ |
212 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
213 | - //$formats[$id] = 'planeupdatefaa'; |
|
214 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
215 | - //$last_exec['planeupdatefaa'] = 0; |
|
216 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
217 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
218 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
219 | - exit(0); |
|
220 | - } |
|
221 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
222 | - //$formats[$id] = 'phpvmacars'; |
|
223 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
224 | - //$last_exec['phpvmacars'] = 0; |
|
225 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
226 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
227 | - //$formats[$id] = 'phpvmacars'; |
|
228 | - $globalSources[$id]['format'] = 'vaos'; |
|
229 | - //$last_exec['phpvmacars'] = 0; |
|
230 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
231 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
232 | - //$formats[$id] = 'phpvmacars'; |
|
233 | - $globalSources[$id]['format'] = 'vam'; |
|
234 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
235 | - } else if (preg_match('/whazzup/i',$host)) { |
|
236 | - //$formats[$id] = 'whazzup'; |
|
237 | - $globalSources[$id]['format'] = 'whazzup'; |
|
238 | - //$last_exec['whazzup'] = 0; |
|
239 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
240 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
241 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
242 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
243 | - } else if (preg_match('/airwhere/i',$host)) { |
|
244 | - $globalSources[$id]['format'] = 'airwhere'; |
|
245 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
246 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
247 | - //$formats[$id] = 'pirepsjson'; |
|
248 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
249 | - //$last_exec['pirepsjson'] = 0; |
|
250 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
251 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
252 | - //$formats[$id] = 'fr24json'; |
|
253 | - $globalSources[$id]['format'] = 'fr24json'; |
|
254 | - //$last_exec['fr24json'] = 0; |
|
255 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
256 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
257 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
258 | - exit(0); |
|
259 | - } |
|
260 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
261 | - //$formats[$id] = 'fr24json'; |
|
262 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
263 | - //$last_exec['fr24json'] = 0; |
|
264 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
265 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
266 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
267 | - exit(0); |
|
268 | - } |
|
269 | - //} else if (preg_match('/10001/',$host)) { |
|
270 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
271 | - //$formats[$id] = 'tsv'; |
|
272 | - $globalSources[$id]['format'] = 'tsv'; |
|
273 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
274 | - } |
|
275 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
276 | - if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
277 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
278 | - if ($idf !== false) { |
|
279 | - $httpfeeds[$id] = $idf; |
|
280 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
281 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
282 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
283 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
284 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
285 | - $hostport = explode(':',$host); |
|
286 | - if (isset($hostport[1])) { |
|
212 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
213 | + //$formats[$id] = 'planeupdatefaa'; |
|
214 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
215 | + //$last_exec['planeupdatefaa'] = 0; |
|
216 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
217 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
218 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
219 | + exit(0); |
|
220 | + } |
|
221 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
222 | + //$formats[$id] = 'phpvmacars'; |
|
223 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
224 | + //$last_exec['phpvmacars'] = 0; |
|
225 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
226 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
227 | + //$formats[$id] = 'phpvmacars'; |
|
228 | + $globalSources[$id]['format'] = 'vaos'; |
|
229 | + //$last_exec['phpvmacars'] = 0; |
|
230 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
231 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
232 | + //$formats[$id] = 'phpvmacars'; |
|
233 | + $globalSources[$id]['format'] = 'vam'; |
|
234 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
235 | + } else if (preg_match('/whazzup/i',$host)) { |
|
236 | + //$formats[$id] = 'whazzup'; |
|
237 | + $globalSources[$id]['format'] = 'whazzup'; |
|
238 | + //$last_exec['whazzup'] = 0; |
|
239 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
240 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
241 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
242 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
243 | + } else if (preg_match('/airwhere/i',$host)) { |
|
244 | + $globalSources[$id]['format'] = 'airwhere'; |
|
245 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
246 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
247 | + //$formats[$id] = 'pirepsjson'; |
|
248 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
249 | + //$last_exec['pirepsjson'] = 0; |
|
250 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
251 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
252 | + //$formats[$id] = 'fr24json'; |
|
253 | + $globalSources[$id]['format'] = 'fr24json'; |
|
254 | + //$last_exec['fr24json'] = 0; |
|
255 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
256 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
257 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
258 | + exit(0); |
|
259 | + } |
|
260 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
261 | + //$formats[$id] = 'fr24json'; |
|
262 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
263 | + //$last_exec['fr24json'] = 0; |
|
264 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
265 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
266 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
267 | + exit(0); |
|
268 | + } |
|
269 | + //} else if (preg_match('/10001/',$host)) { |
|
270 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
271 | + //$formats[$id] = 'tsv'; |
|
272 | + $globalSources[$id]['format'] = 'tsv'; |
|
273 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
274 | + } |
|
275 | + } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
276 | + if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
277 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
278 | + if ($idf !== false) { |
|
279 | + $httpfeeds[$id] = $idf; |
|
280 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
281 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
282 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
283 | + elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
284 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
285 | + $hostport = explode(':',$host); |
|
286 | + if (isset($hostport[1])) { |
|
287 | 287 | $port = $hostport[1]; |
288 | 288 | $hostn = $hostport[0]; |
289 | - } else { |
|
289 | + } else { |
|
290 | 290 | $port = $globalSources[$id]['port']; |
291 | 291 | $hostn = $globalSources[$id]['host']; |
292 | - } |
|
293 | - $Common = new Common(); |
|
294 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
295 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
296 | - } else { |
|
297 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
298 | - } |
|
299 | - if ($s) { |
|
300 | - $sockets[$id] = $s; |
|
301 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
302 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
292 | + } |
|
293 | + $Common = new Common(); |
|
294 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
295 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
296 | + } else { |
|
297 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
298 | + } |
|
299 | + if ($s) { |
|
300 | + $sockets[$id] = $s; |
|
301 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
302 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
303 | 303 | //$formats[$id] = 'aprs'; |
304 | 304 | $globalSources[$id]['format'] = 'aprs'; |
305 | 305 | //$aprs_connect = 0; |
306 | 306 | //$use_aprs = true; |
307 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
307 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
308 | 308 | $globalSources[$id]['format'] = 'vrstcp'; |
309 | - } elseif ($port == '10001') { |
|
310 | - //$formats[$id] = 'tsv'; |
|
311 | - $globalSources[$id]['format'] = 'tsv'; |
|
312 | - } elseif ($port == '30002') { |
|
313 | - //$formats[$id] = 'raw'; |
|
314 | - $globalSources[$id]['format'] = 'raw'; |
|
315 | - } elseif ($port == '5001') { |
|
316 | - //$formats[$id] = 'raw'; |
|
317 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
318 | - } elseif ($port == '30005') { |
|
309 | + } elseif ($port == '10001') { |
|
310 | + //$formats[$id] = 'tsv'; |
|
311 | + $globalSources[$id]['format'] = 'tsv'; |
|
312 | + } elseif ($port == '30002') { |
|
313 | + //$formats[$id] = 'raw'; |
|
314 | + $globalSources[$id]['format'] = 'raw'; |
|
315 | + } elseif ($port == '5001') { |
|
316 | + //$formats[$id] = 'raw'; |
|
317 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
318 | + } elseif ($port == '30005') { |
|
319 | 319 | // Not yet supported |
320 | - //$formats[$id] = 'beast'; |
|
321 | - $globalSources[$id]['format'] = 'beast'; |
|
322 | - //} else $formats[$id] = 'sbs'; |
|
323 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
324 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
320 | + //$formats[$id] = 'beast'; |
|
321 | + $globalSources[$id]['format'] = 'beast'; |
|
322 | + //} else $formats[$id] = 'sbs'; |
|
323 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
324 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
325 | 325 | } |
326 | 326 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
327 | - } else { |
|
327 | + } else { |
|
328 | 328 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
329 | 329 | sleep(10); |
330 | 330 | connect_all($hosts); |
331 | - } |
|
332 | - } |
|
333 | - } |
|
331 | + } |
|
332 | + } |
|
333 | + } |
|
334 | 334 | } |
335 | 335 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
336 | 336 | |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | //connect_all($globalSources); |
354 | 354 | |
355 | 355 | if (isset($globalProxy) && $globalProxy) { |
356 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
356 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
357 | 357 | } else { |
358 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
358 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | // APRS Configuration |
@@ -364,21 +364,21 @@ discard block |
||
364 | 364 | die; |
365 | 365 | } |
366 | 366 | foreach ($globalSources as $key => $source) { |
367 | - if (!isset($source['format'])) { |
|
368 | - $globalSources[$key]['format'] = 'auto'; |
|
369 | - } |
|
370 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
371 | - unset($globalSources[$key]); |
|
372 | - } |
|
367 | + if (!isset($source['format'])) { |
|
368 | + $globalSources[$key]['format'] = 'auto'; |
|
369 | + } |
|
370 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
371 | + unset($globalSources[$key]); |
|
372 | + } |
|
373 | 373 | } |
374 | 374 | connect_all($globalSources); |
375 | 375 | foreach ($globalSources as $key => $source) { |
376 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
376 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
377 | 377 | $aprs_connect = 0; |
378 | 378 | $use_aprs = true; |
379 | 379 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
380 | 380 | break; |
381 | - } |
|
381 | + } |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | if ($use_aprs) { |
@@ -419,168 +419,168 @@ discard block |
||
419 | 419 | |
420 | 420 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
421 | 421 | while ($i > 0) { |
422 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
422 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
423 | 423 | |
424 | - if (!$globalDaemon) $i = $endtime-time(); |
|
425 | - // Delete old ATC |
|
426 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
424 | + if (!$globalDaemon) $i = $endtime-time(); |
|
425 | + // Delete old ATC |
|
426 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
427 | 427 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
428 | - $ATC->deleteOldATC(); |
|
429 | - } |
|
428 | + $ATC->deleteOldATC(); |
|
429 | + } |
|
430 | 430 | |
431 | - if (count($last_exec) == count($globalSources)) { |
|
431 | + if (count($last_exec) == count($globalSources)) { |
|
432 | 432 | $max = $globalMinFetch; |
433 | 433 | foreach ($last_exec as $last) { |
434 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
434 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
435 | 435 | } |
436 | 436 | if ($max < $globalMinFetch) { |
437 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
438 | - sleep($globalMinFetch-$max+2); |
|
437 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
438 | + sleep($globalMinFetch-$max+2); |
|
439 | + } |
|
439 | 440 | } |
440 | - } |
|
441 | 441 | |
442 | 442 | |
443 | - //foreach ($formats as $id => $value) { |
|
444 | - foreach ($globalSources as $id => $value) { |
|
443 | + //foreach ($formats as $id => $value) { |
|
444 | + foreach ($globalSources as $id => $value) { |
|
445 | 445 | date_default_timezone_set('UTC'); |
446 | 446 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
447 | 447 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
448 | 448 | if ($value['format'] === 'deltadbtxt' && |
449 | - ( |
|
449 | + ( |
|
450 | 450 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
451 | 451 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
452 | - ) |
|
452 | + ) |
|
453 | 453 | ) { |
454 | - //$buffer = $Common->getData($hosts[$id]); |
|
455 | - $buffer = $Common->getData($value['host']); |
|
456 | - if ($buffer != '') $reset = 0; |
|
457 | - $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
458 | - $buffer = explode('\n', $buffer); |
|
459 | - foreach ($buffer as $line) { |
|
460 | - if ($line != '' && count($line) > 7) { |
|
461 | - $line = explode(',', $line); |
|
462 | - $data = array(); |
|
463 | - $data['hex'] = $line[1]; // hex |
|
464 | - $data['ident'] = $line[2]; // ident |
|
465 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
466 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
467 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
468 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
469 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
470 | - $data['verticalrate'] = ''; // vertical rate |
|
471 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
472 | - $data['emergency'] = ''; // emergency |
|
473 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
474 | - $data['format_source'] = 'deltadbtxt'; |
|
475 | - $data['id_source'] = $id_source; |
|
476 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
477 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
478 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
479 | - $SI->add($data); |
|
480 | - unset($data); |
|
481 | - } |
|
482 | - } |
|
483 | - $last_exec[$id]['last'] = time(); |
|
484 | - } elseif ($value['format'] === 'radarcapejson' && |
|
485 | - ( |
|
486 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
487 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
488 | - ) |
|
489 | - ) { |
|
490 | - //$buffer = $Common->getData($hosts[$id]); |
|
491 | - $buffer = $Common->getData($value['host']); |
|
492 | - if ($buffer != '') { |
|
493 | - $all_data = json_decode($buffer,true); |
|
494 | - foreach ($all_data as $line) { |
|
495 | - $data = array(); |
|
496 | - $data['datetime'] = date('Y-m-d H:i:s',$line['tim']); |
|
497 | - $data['hex'] = $line['hex']; // hex |
|
498 | - $data['ident'] = $line['fli']; // ident |
|
499 | - $data['altitude'] = $line['alt']; // altitude |
|
500 | - $data['speed'] = $line['spd']; // speed |
|
501 | - $data['heading'] = $line['trk']; // heading |
|
502 | - $data['latitude'] = $line['lat']; // lat |
|
503 | - $data['longitude'] = $line['lon']; // long |
|
504 | - $data['verticalrate'] = $line['vrt']; // vertical rate |
|
505 | - $data['squawk'] = $line['squ']; // squawk |
|
506 | - $data['ground'] = $line['gda']; // ground |
|
507 | - //$data['emergency'] = ''; // emergency |
|
508 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
509 | - $data['format_source'] = 'radarcapejson'; |
|
510 | - $data['id_source'] = $id_source; |
|
511 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
512 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
513 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
514 | - $SI->add($data); |
|
515 | - unset($data); |
|
516 | - } |
|
517 | - } |
|
518 | - $last_exec[$id]['last'] = time(); |
|
454 | + //$buffer = $Common->getData($hosts[$id]); |
|
455 | + $buffer = $Common->getData($value['host']); |
|
456 | + if ($buffer != '') $reset = 0; |
|
457 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
458 | + $buffer = explode('\n', $buffer); |
|
459 | + foreach ($buffer as $line) { |
|
460 | + if ($line != '' && count($line) > 7) { |
|
461 | + $line = explode(',', $line); |
|
462 | + $data = array(); |
|
463 | + $data['hex'] = $line[1]; // hex |
|
464 | + $data['ident'] = $line[2]; // ident |
|
465 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
466 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
467 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
468 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
469 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
470 | + $data['verticalrate'] = ''; // vertical rate |
|
471 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
472 | + $data['emergency'] = ''; // emergency |
|
473 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
474 | + $data['format_source'] = 'deltadbtxt'; |
|
475 | + $data['id_source'] = $id_source; |
|
476 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
477 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
478 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
479 | + $SI->add($data); |
|
480 | + unset($data); |
|
481 | + } |
|
482 | + } |
|
483 | + $last_exec[$id]['last'] = time(); |
|
484 | + } elseif ($value['format'] === 'radarcapejson' && |
|
485 | + ( |
|
486 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
487 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
488 | + ) |
|
489 | + ) { |
|
490 | + //$buffer = $Common->getData($hosts[$id]); |
|
491 | + $buffer = $Common->getData($value['host']); |
|
492 | + if ($buffer != '') { |
|
493 | + $all_data = json_decode($buffer,true); |
|
494 | + foreach ($all_data as $line) { |
|
495 | + $data = array(); |
|
496 | + $data['datetime'] = date('Y-m-d H:i:s',$line['tim']); |
|
497 | + $data['hex'] = $line['hex']; // hex |
|
498 | + $data['ident'] = $line['fli']; // ident |
|
499 | + $data['altitude'] = $line['alt']; // altitude |
|
500 | + $data['speed'] = $line['spd']; // speed |
|
501 | + $data['heading'] = $line['trk']; // heading |
|
502 | + $data['latitude'] = $line['lat']; // lat |
|
503 | + $data['longitude'] = $line['lon']; // long |
|
504 | + $data['verticalrate'] = $line['vrt']; // vertical rate |
|
505 | + $data['squawk'] = $line['squ']; // squawk |
|
506 | + $data['ground'] = $line['gda']; // ground |
|
507 | + //$data['emergency'] = ''; // emergency |
|
508 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
509 | + $data['format_source'] = 'radarcapejson'; |
|
510 | + $data['id_source'] = $id_source; |
|
511 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
512 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
513 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
514 | + $SI->add($data); |
|
515 | + unset($data); |
|
516 | + } |
|
517 | + } |
|
518 | + $last_exec[$id]['last'] = time(); |
|
519 | 519 | } elseif ($value['format'] === 'aisnmeatxt' && |
520 | - ( |
|
520 | + ( |
|
521 | 521 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
522 | 522 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
523 | - ) |
|
523 | + ) |
|
524 | 524 | ) { |
525 | - date_default_timezone_set('CET'); |
|
526 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
527 | - date_default_timezone_set('UTC'); |
|
528 | - if ($buffer != '') $reset = 0; |
|
529 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
530 | - $buffer = explode('\n',$buffer); |
|
531 | - foreach ($buffer as $line) { |
|
525 | + date_default_timezone_set('CET'); |
|
526 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
527 | + date_default_timezone_set('UTC'); |
|
528 | + if ($buffer != '') $reset = 0; |
|
529 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
530 | + $buffer = explode('\n',$buffer); |
|
531 | + foreach ($buffer as $line) { |
|
532 | 532 | if ($line != '') { |
533 | - //echo "'".$line."'\n"; |
|
534 | - $add = false; |
|
535 | - $ais_data = $AIS->parse_line(trim($line)); |
|
536 | - $data = array(); |
|
537 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
538 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
539 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
540 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
541 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
542 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
543 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
544 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
545 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
546 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
547 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
548 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
549 | - if (isset($ais_data['timestamp'])) { |
|
533 | + //echo "'".$line."'\n"; |
|
534 | + $add = false; |
|
535 | + $ais_data = $AIS->parse_line(trim($line)); |
|
536 | + $data = array(); |
|
537 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
538 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
539 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
540 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
541 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
542 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
543 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
544 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
545 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
546 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
547 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
548 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
549 | + if (isset($ais_data['timestamp'])) { |
|
550 | 550 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
551 | 551 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
552 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
553 | - $add = true; |
|
552 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
553 | + $add = true; |
|
554 | 554 | } |
555 | - } else { |
|
555 | + } else { |
|
556 | 556 | $data['datetime'] = date('Y-m-d H:i:s'); |
557 | 557 | $add = true; |
558 | - } |
|
559 | - $data['format_source'] = 'aisnmeatxt'; |
|
560 | - $data['id_source'] = $id_source; |
|
561 | - //print_r($data); |
|
562 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
563 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
564 | - unset($data); |
|
558 | + } |
|
559 | + $data['format_source'] = 'aisnmeatxt'; |
|
560 | + $data['id_source'] = $id_source; |
|
561 | + //print_r($data); |
|
562 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
563 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
564 | + unset($data); |
|
565 | 565 | } |
566 | - } |
|
567 | - $last_exec[$id]['last'] = time(); |
|
566 | + } |
|
567 | + $last_exec[$id]['last'] = time(); |
|
568 | 568 | } elseif ($value['format'] === 'aisnmeahttp') { |
569 | - $arr = $httpfeeds; |
|
570 | - $w = $e = null; |
|
569 | + $arr = $httpfeeds; |
|
570 | + $w = $e = null; |
|
571 | 571 | |
572 | - if (isset($arr[$id])) { |
|
572 | + if (isset($arr[$id])) { |
|
573 | 573 | $nn = stream_select($arr,$w,$e,$timeout); |
574 | 574 | if ($nn > 0) { |
575 | - foreach ($httpfeeds as $feed) { |
|
575 | + foreach ($httpfeeds as $feed) { |
|
576 | 576 | $buffer = stream_get_line($feed,2000,"\n"); |
577 | 577 | if ($buffer === FALSE) { |
578 | - connect_all($globalSources); |
|
578 | + connect_all($globalSources); |
|
579 | 579 | } |
580 | 580 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
581 | 581 | $buffer = explode('\n',$buffer); |
582 | 582 | foreach ($buffer as $line) { |
583 | - if ($line != '') { |
|
583 | + if ($line != '') { |
|
584 | 584 | $ais_data = $AIS->parse_line(trim($line)); |
585 | 585 | $data = array(); |
586 | 586 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -598,117 +598,117 @@ discard block |
||
598 | 598 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
599 | 599 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
600 | 600 | if (isset($ais_data['timestamp'])) { |
601 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
601 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
602 | 602 | } else { |
603 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
603 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
604 | 604 | } |
605 | 605 | $data['format_source'] = 'aisnmeahttp'; |
606 | 606 | $data['id_source'] = $id_source; |
607 | 607 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
608 | 608 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
609 | 609 | unset($data); |
610 | - } |
|
610 | + } |
|
611 | + } |
|
611 | 612 | } |
612 | - } |
|
613 | 613 | } else { |
614 | - $format = $value['format']; |
|
615 | - if (isset($tt[$format])) $tt[$format]++; |
|
616 | - else $tt[$format] = 0; |
|
617 | - if ($tt[$format] > 30) { |
|
614 | + $format = $value['format']; |
|
615 | + if (isset($tt[$format])) $tt[$format]++; |
|
616 | + else $tt[$format] = 0; |
|
617 | + if ($tt[$format] > 30) { |
|
618 | 618 | if ($globalDebug) echo 'Reconnect...'."\n"; |
619 | 619 | sleep(2); |
620 | 620 | //$sourceeen[] = $value; |
621 | 621 | //connect_all($sourceeen); |
622 | 622 | //$sourceeen = array(); |
623 | 623 | connect_all($globalSources); |
624 | - } |
|
624 | + } |
|
625 | + } |
|
625 | 626 | } |
626 | - } |
|
627 | 627 | } elseif ($value['format'] === 'myshiptracking' && |
628 | - ( |
|
628 | + ( |
|
629 | 629 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
630 | 630 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
631 | - ) |
|
631 | + ) |
|
632 | 632 | ) { |
633 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
634 | - if ($buffer != '') { |
|
633 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
634 | + if ($buffer != '') { |
|
635 | 635 | //echo $buffer; |
636 | 636 | $all_data = json_decode($buffer,true); |
637 | 637 | //print_r($all_data); |
638 | 638 | if (isset($all_data[0]['DATA'])) { |
639 | - foreach ($all_data[0]['DATA'] as $line) { |
|
639 | + foreach ($all_data[0]['DATA'] as $line) { |
|
640 | 640 | if ($line != '') { |
641 | - $data = array(); |
|
642 | - $data['ident'] = $line['NAME']; |
|
643 | - $data['mmsi'] = $line['MMSI']; |
|
644 | - if (strlen($data['mmsi']) > 9) { |
|
641 | + $data = array(); |
|
642 | + $data['ident'] = $line['NAME']; |
|
643 | + $data['mmsi'] = $line['MMSI']; |
|
644 | + if (strlen($data['mmsi']) > 9) { |
|
645 | 645 | $data['mmsi'] = substr($data['mmsi'],-9); |
646 | - } |
|
647 | - $data['speed'] = $line['SOG']; |
|
648 | - $data['heading'] = $line['COG']; |
|
649 | - $data['latitude'] = $line['LAT']; |
|
650 | - $data['longitude'] = $line['LNG']; |
|
651 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
652 | - //$data['type_id'] = $line['TYPE']; |
|
653 | - $data['imo'] = $line['IMO']; |
|
654 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
655 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
656 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
657 | - $data['format_source'] = 'myshiptracking'; |
|
658 | - $data['id_source'] = $id_source; |
|
659 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
660 | - $MI->add($data); |
|
661 | - unset($data); |
|
646 | + } |
|
647 | + $data['speed'] = $line['SOG']; |
|
648 | + $data['heading'] = $line['COG']; |
|
649 | + $data['latitude'] = $line['LAT']; |
|
650 | + $data['longitude'] = $line['LNG']; |
|
651 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
652 | + //$data['type_id'] = $line['TYPE']; |
|
653 | + $data['imo'] = $line['IMO']; |
|
654 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
655 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
656 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
657 | + $data['format_source'] = 'myshiptracking'; |
|
658 | + $data['id_source'] = $id_source; |
|
659 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
660 | + $MI->add($data); |
|
661 | + unset($data); |
|
662 | + } |
|
662 | 663 | } |
663 | - } |
|
664 | 664 | } |
665 | - } |
|
666 | - $last_exec[$id]['last'] = time(); |
|
665 | + } |
|
666 | + $last_exec[$id]['last'] = time(); |
|
667 | 667 | } elseif ($value['format'] === 'boatbeaconapp' && |
668 | - ( |
|
668 | + ( |
|
669 | 669 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
670 | 670 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
671 | - ) |
|
671 | + ) |
|
672 | 672 | ) { |
673 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
674 | - if ($buffer != '') { |
|
673 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
674 | + if ($buffer != '') { |
|
675 | 675 | $all_data = json_decode($buffer,true); |
676 | 676 | if (isset($all_data[0]['mmsi'])) { |
677 | - foreach ($all_data as $line) { |
|
677 | + foreach ($all_data as $line) { |
|
678 | 678 | if ($line != '') { |
679 | - $data = array(); |
|
680 | - $data['ident'] = $line['shipname']; |
|
681 | - $data['callsign'] = $line['callsign']; |
|
682 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
683 | - $data['speed'] = $line['sog']; |
|
684 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
685 | - $data['latitude'] = $line['latitude']; |
|
686 | - $data['longitude'] = $line['longitude']; |
|
687 | - $data['type_id'] = $line['shiptype']; |
|
688 | - $data['arrival_code'] = $line['destination']; |
|
689 | - $data['datetime'] = $line['time']; |
|
690 | - $data['format_source'] = 'boatbeaconapp'; |
|
691 | - $data['id_source'] = $id_source; |
|
692 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
693 | - $MI->add($data); |
|
694 | - unset($data); |
|
679 | + $data = array(); |
|
680 | + $data['ident'] = $line['shipname']; |
|
681 | + $data['callsign'] = $line['callsign']; |
|
682 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
683 | + $data['speed'] = $line['sog']; |
|
684 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
685 | + $data['latitude'] = $line['latitude']; |
|
686 | + $data['longitude'] = $line['longitude']; |
|
687 | + $data['type_id'] = $line['shiptype']; |
|
688 | + $data['arrival_code'] = $line['destination']; |
|
689 | + $data['datetime'] = $line['time']; |
|
690 | + $data['format_source'] = 'boatbeaconapp'; |
|
691 | + $data['id_source'] = $id_source; |
|
692 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
693 | + $MI->add($data); |
|
694 | + unset($data); |
|
695 | + } |
|
695 | 696 | } |
696 | - } |
|
697 | 697 | } |
698 | 698 | |
699 | - } |
|
700 | - $last_exec[$id]['last'] = time(); |
|
699 | + } |
|
700 | + $last_exec[$id]['last'] = time(); |
|
701 | 701 | } elseif ($value['format'] === 'boatnerd' && |
702 | - ( |
|
702 | + ( |
|
703 | 703 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
704 | 704 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
705 | - ) |
|
705 | + ) |
|
706 | 706 | ) { |
707 | - $buffer = $Common->getData($value['host']); |
|
708 | - if ($buffer != '') { |
|
707 | + $buffer = $Common->getData($value['host']); |
|
708 | + if ($buffer != '') { |
|
709 | 709 | $all_data = json_decode($buffer,true); |
710 | 710 | if (isset($all_data['features'][0]['id'])) { |
711 | - foreach ($all_data['features'] as $line) { |
|
711 | + foreach ($all_data['features'] as $line) { |
|
712 | 712 | print_r($line); |
713 | 713 | $data = array(); |
714 | 714 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -728,76 +728,76 @@ discard block |
||
728 | 728 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
729 | 729 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
730 | 730 | unset($data); |
731 | - } |
|
731 | + } |
|
732 | 732 | } |
733 | 733 | |
734 | - } |
|
735 | - $last_exec[$id]['last'] = time(); |
|
734 | + } |
|
735 | + $last_exec[$id]['last'] = time(); |
|
736 | 736 | } elseif ($value['format'] === 'shipplotter' && |
737 | - ( |
|
737 | + ( |
|
738 | 738 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
739 | 739 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
740 | - ) |
|
740 | + ) |
|
741 | 741 | ) { |
742 | - if ($globalDebug) echo 'download...'; |
|
743 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
744 | - if ($globalDebug) echo 'done !'."\n"; |
|
745 | - // FIXME: Need more work |
|
746 | - if ($buffer != '') $reset = 0; |
|
747 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
748 | - $buffer = explode('\n',$buffer); |
|
749 | - foreach ($buffer as $line) { |
|
742 | + if ($globalDebug) echo 'download...'; |
|
743 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
744 | + if ($globalDebug) echo 'done !'."\n"; |
|
745 | + // FIXME: Need more work |
|
746 | + if ($buffer != '') $reset = 0; |
|
747 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
748 | + $buffer = explode('\n',$buffer); |
|
749 | + foreach ($buffer as $line) { |
|
750 | 750 | if ($line != '') { |
751 | - $data = array(); |
|
752 | - //echo $line."\n"; |
|
753 | - $data['mmsi'] = (int)substr($line,0,9); |
|
754 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
755 | - $data['status_id'] = substr($line,21,2); |
|
756 | - $data['type_id'] = substr($line,24,3); |
|
757 | - $data['latitude'] = substr($line,29,9); |
|
758 | - $data['longitude'] = substr($line,41,9); |
|
759 | - $data['speed'] = round(substr($line,51,5)); |
|
760 | - //$data['course'] = substr($line,57,5); |
|
761 | - $data['heading'] = round(substr($line,63,3)); |
|
762 | - //$data['draft'] = substr($line,67,4); |
|
763 | - //$data['length'] = substr($line,72,3); |
|
764 | - //$data['beam'] = substr($line,76,2); |
|
765 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
766 | - //$data['callsign'] = trim(substr($line,100,7); |
|
767 | - $data['arrival_code'] = substr($line,108,20); |
|
768 | - //$data['etaDate'] = substr($line,129,5); |
|
769 | - //$data['etaTime'] = substr($line,135,5); |
|
770 | - $data['format_source'] = 'shipplotter'; |
|
771 | - $data['id_source'] = $id_source; |
|
772 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
773 | - //print_r($data); |
|
774 | - //echo 'Add...'."\n"; |
|
775 | - $MI->add($data); |
|
776 | - unset($data); |
|
751 | + $data = array(); |
|
752 | + //echo $line."\n"; |
|
753 | + $data['mmsi'] = (int)substr($line,0,9); |
|
754 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
755 | + $data['status_id'] = substr($line,21,2); |
|
756 | + $data['type_id'] = substr($line,24,3); |
|
757 | + $data['latitude'] = substr($line,29,9); |
|
758 | + $data['longitude'] = substr($line,41,9); |
|
759 | + $data['speed'] = round(substr($line,51,5)); |
|
760 | + //$data['course'] = substr($line,57,5); |
|
761 | + $data['heading'] = round(substr($line,63,3)); |
|
762 | + //$data['draft'] = substr($line,67,4); |
|
763 | + //$data['length'] = substr($line,72,3); |
|
764 | + //$data['beam'] = substr($line,76,2); |
|
765 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
766 | + //$data['callsign'] = trim(substr($line,100,7); |
|
767 | + $data['arrival_code'] = substr($line,108,20); |
|
768 | + //$data['etaDate'] = substr($line,129,5); |
|
769 | + //$data['etaTime'] = substr($line,135,5); |
|
770 | + $data['format_source'] = 'shipplotter'; |
|
771 | + $data['id_source'] = $id_source; |
|
772 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
773 | + //print_r($data); |
|
774 | + //echo 'Add...'."\n"; |
|
775 | + $MI->add($data); |
|
776 | + unset($data); |
|
777 | 777 | } |
778 | - } |
|
779 | - $last_exec[$id]['last'] = time(); |
|
778 | + } |
|
779 | + $last_exec[$id]['last'] = time(); |
|
780 | 780 | } elseif ($value['format'] === 'sailaway' && |
781 | - ( |
|
781 | + ( |
|
782 | 782 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
783 | 783 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
784 | - ) |
|
784 | + ) |
|
785 | 785 | ) { |
786 | - if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
786 | + if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
787 | 787 | $authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true); |
788 | 788 | //echo $authsailaway; |
789 | 789 | preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie); |
790 | 790 | if (isset($setcookie[1][0])) { |
791 | - $sailaway_authcookie = $setcookie[1][0]; |
|
791 | + $sailaway_authcookie = $setcookie[1][0]; |
|
792 | + } |
|
792 | 793 | } |
793 | - } |
|
794 | 794 | |
795 | - if ($globalDebug) echo '! Download... '; |
|
796 | - for ($i =0; $i <= 1; $i++) { |
|
795 | + if ($globalDebug) echo '! Download... '; |
|
796 | + for ($i =0; $i <= 1; $i++) { |
|
797 | 797 | if ($globalDebug) echo 'Racetype: '.$i.' '; |
798 | 798 | $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
799 | - if ($globalDebug) echo 'done'."\n"; |
|
800 | - if ($buffer != '') { |
|
799 | + if ($globalDebug) echo 'done'."\n"; |
|
800 | + if ($buffer != '') { |
|
801 | 801 | $all_data = json_decode($buffer,true); |
802 | 802 | if (isset($all_data['missions'])) { |
803 | 803 | foreach ($all_data['missions'] as $mission) { |
@@ -816,19 +816,19 @@ discard block |
||
816 | 816 | //print_r($race_data); |
817 | 817 | unset($racebuffer); |
818 | 818 | if (isset($race_data['mission'])) { |
819 | - $datar = array(); |
|
820 | - $datar['id'] = $mission['misnr']; |
|
821 | - $datar['desc'] = $race_data['mission']['misdescr']; |
|
822 | - $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
823 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
824 | - $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
825 | - $markers = array(); |
|
826 | - foreach ($race_data['mission']['course'] as $course) { |
|
819 | + $datar = array(); |
|
820 | + $datar['id'] = $mission['misnr']; |
|
821 | + $datar['desc'] = $race_data['mission']['misdescr']; |
|
822 | + $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
823 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
824 | + $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
825 | + $markers = array(); |
|
826 | + foreach ($race_data['mission']['course'] as $course) { |
|
827 | 827 | $markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']); |
828 | - } |
|
829 | - $datar['markers'] = json_encode($markers); |
|
830 | - //print_r($datar); |
|
831 | - $MI->race_add($datar); |
|
828 | + } |
|
829 | + $datar['markers'] = json_encode($markers); |
|
830 | + //print_r($datar); |
|
831 | + $MI->race_add($datar); |
|
832 | 832 | } |
833 | 833 | } |
834 | 834 | if ($bufferm != '') { |
@@ -892,34 +892,34 @@ discard block |
||
892 | 892 | } |
893 | 893 | } |
894 | 894 | } |
895 | - } |
|
896 | - } |
|
897 | - $last_exec[$id]['last'] = time(); |
|
895 | + } |
|
896 | + } |
|
897 | + $last_exec[$id]['last'] = time(); |
|
898 | 898 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
899 | 899 | } elseif ( |
900 | - ( |
|
900 | + ( |
|
901 | 901 | $value['format'] === 'whazzup' && |
902 | 902 | ( |
903 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
904 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
903 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
904 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
905 | 905 | ) |
906 | - ) || ( |
|
906 | + ) || ( |
|
907 | 907 | $value['format'] === 'vatsimtxt' && |
908 | 908 | ( |
909 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
910 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
909 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
910 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
911 | + ) |
|
911 | 912 | ) |
912 | - ) |
|
913 | 913 | ) { |
914 | - //$buffer = $Common->getData($hosts[$id]); |
|
915 | - $buffer = $Common->getData($value['host']); |
|
916 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
917 | - $buffer = explode('\n',$buffer); |
|
918 | - $reset = 0; |
|
919 | - foreach ($buffer as $line) { |
|
920 | - if ($line != '') { |
|
921 | - $line = explode(':', $line); |
|
922 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
914 | + //$buffer = $Common->getData($hosts[$id]); |
|
915 | + $buffer = $Common->getData($value['host']); |
|
916 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
917 | + $buffer = explode('\n',$buffer); |
|
918 | + $reset = 0; |
|
919 | + foreach ($buffer as $line) { |
|
920 | + if ($line != '') { |
|
921 | + $line = explode(':', $line); |
|
922 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
923 | 923 | $data = array(); |
924 | 924 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
925 | 925 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -932,37 +932,37 @@ discard block |
||
932 | 932 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
933 | 933 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
934 | 934 | $data['latitude'] = $line[5]; // lat |
935 | - $data['longitude'] = $line[6]; // long |
|
936 | - $data['verticalrate'] = ''; // vertical rate |
|
937 | - $data['squawk'] = ''; // squawk |
|
938 | - $data['emergency'] = ''; // emergency |
|
939 | - $data['waypoints'] = $line[30]; |
|
935 | + $data['longitude'] = $line[6]; // long |
|
936 | + $data['verticalrate'] = ''; // vertical rate |
|
937 | + $data['squawk'] = ''; // squawk |
|
938 | + $data['emergency'] = ''; // emergency |
|
939 | + $data['waypoints'] = $line[30]; |
|
940 | 940 | $data['datetime'] = date('Y-m-d H:i:s'); |
941 | 941 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
942 | 942 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
943 | - $data['departure_airport_icao'] = $line[11]; |
|
944 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
945 | - $data['arrival_airport_icao'] = $line[13]; |
|
943 | + $data['departure_airport_icao'] = $line[11]; |
|
944 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
945 | + $data['arrival_airport_icao'] = $line[13]; |
|
946 | 946 | $data['frequency'] = $line[4]; |
947 | 947 | $data['type'] = $line[18]; |
948 | 948 | $data['range'] = $line[19]; |
949 | 949 | if (isset($line[35])) $data['info'] = $line[35]; |
950 | - $data['id_source'] = $id_source; |
|
951 | - //$data['arrival_airport_time'] = ; |
|
952 | - if ($line[9] != '') { |
|
953 | - $aircraft_data = explode('/',$line[9]); |
|
954 | - if (isset($aircraft_data[1])) { |
|
955 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
956 | - } |
|
957 | - } |
|
958 | - /* |
|
950 | + $data['id_source'] = $id_source; |
|
951 | + //$data['arrival_airport_time'] = ; |
|
952 | + if ($line[9] != '') { |
|
953 | + $aircraft_data = explode('/',$line[9]); |
|
954 | + if (isset($aircraft_data[1])) { |
|
955 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
956 | + } |
|
957 | + } |
|
958 | + /* |
|
959 | 959 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
960 | 960 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
961 | 961 | */ |
962 | - $data['format_source'] = $value['format']; |
|
962 | + $data['format_source'] = $value['format']; |
|
963 | 963 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
964 | 964 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
965 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
965 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
966 | 966 | elseif ($line[3] === 'ATC') { |
967 | 967 | //print_r($data); |
968 | 968 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -983,21 +983,21 @@ discard block |
||
983 | 983 | 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']); |
984 | 984 | } |
985 | 985 | } |
986 | - unset($data); |
|
987 | - } |
|
988 | - } |
|
989 | - } |
|
990 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
991 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
992 | - $last_exec[$id]['last'] = time(); |
|
993 | - } elseif ($value['format'] === 'airwhere' && |
|
994 | - ( |
|
995 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
996 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
997 | - ) |
|
998 | - ) { |
|
999 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
1000 | - if ($buffer != '') { |
|
986 | + unset($data); |
|
987 | + } |
|
988 | + } |
|
989 | + } |
|
990 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
991 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
992 | + $last_exec[$id]['last'] = time(); |
|
993 | + } elseif ($value['format'] === 'airwhere' && |
|
994 | + ( |
|
995 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
996 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
997 | + ) |
|
998 | + ) { |
|
999 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
1000 | + if ($buffer != '') { |
|
1001 | 1001 | $all_data = simplexml_load_string($buffer); |
1002 | 1002 | foreach($all_data->children() as $childdata) { |
1003 | 1003 | $data = array(); |
@@ -1019,10 +1019,10 @@ discard block |
||
1019 | 1019 | $SI->add($data); |
1020 | 1020 | unset($data); |
1021 | 1021 | } |
1022 | - } |
|
1023 | - $Source->deleteOldLocationByType('gs'); |
|
1024 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
1025 | - if ($buffer != '') { |
|
1022 | + } |
|
1023 | + $Source->deleteOldLocationByType('gs'); |
|
1024 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
1025 | + if ($buffer != '') { |
|
1026 | 1026 | $all_data = simplexml_load_string($buffer); |
1027 | 1027 | foreach($all_data->children() as $childdata) { |
1028 | 1028 | $data = array(); |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | } |
1041 | 1041 | unset($data); |
1042 | 1042 | } |
1043 | - } |
|
1044 | - $last_exec[$id]['last'] = time(); |
|
1043 | + } |
|
1044 | + $last_exec[$id]['last'] = time(); |
|
1045 | 1045 | /* |
1046 | 1046 | } if ($value['format'] === 'aircraftlistjson') { |
1047 | 1047 | print_r($globalSources); |
@@ -1049,17 +1049,17 @@ discard block |
||
1049 | 1049 | echo $globalMinFetch; |
1050 | 1050 | */ |
1051 | 1051 | } elseif ($value['format'] === 'aircraftlistjson' && |
1052 | - ( |
|
1052 | + ( |
|
1053 | 1053 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1054 | 1054 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1055 | - ) |
|
1055 | + ) |
|
1056 | 1056 | ) { |
1057 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
1058 | - if ($buffer != '') { |
|
1059 | - $all_data = json_decode($buffer,true); |
|
1057 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
1058 | + if ($buffer != '') { |
|
1059 | + $all_data = json_decode($buffer,true); |
|
1060 | 1060 | if (isset($all_data['acList'])) { |
1061 | - $reset = 0; |
|
1062 | - foreach ($all_data['acList'] as $line) { |
|
1061 | + $reset = 0; |
|
1062 | + foreach ($all_data['acList'] as $line) { |
|
1063 | 1063 | $data = array(); |
1064 | 1064 | $data['hex'] = $line['Icao']; // hex |
1065 | 1065 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1082,10 +1082,10 @@ discard block |
||
1082 | 1082 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1083 | 1083 | if (isset($data['latitude'])) $SI->add($data); |
1084 | 1084 | unset($data); |
1085 | - } |
|
1085 | + } |
|
1086 | 1086 | } elseif (is_array($all_data)) { |
1087 | - $reset = 0; |
|
1088 | - foreach ($all_data as $line) { |
|
1087 | + $reset = 0; |
|
1088 | + foreach ($all_data as $line) { |
|
1089 | 1089 | $data = array(); |
1090 | 1090 | $data['hex'] = $line['hex']; // hex |
1091 | 1091 | $data['ident'] = $line['flight']; // ident |
@@ -1105,291 +1105,291 @@ discard block |
||
1105 | 1105 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1106 | 1106 | $SI->add($data); |
1107 | 1107 | unset($data); |
1108 | - } |
|
1108 | + } |
|
1109 | 1109 | } |
1110 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1111 | - //$last_exec['aircraftlistjson'] = time(); |
|
1112 | - $last_exec[$id]['last'] = time(); |
|
1113 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
1114 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
1115 | - ( |
|
1116 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1117 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1118 | - ) |
|
1119 | - ) { |
|
1120 | - $buffer = $Common->getData($value['host']); |
|
1121 | - $all_data = json_decode($buffer,true); |
|
1122 | - if (isset($all_data['planes'])) { |
|
1110 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
1111 | + //$last_exec['aircraftlistjson'] = time(); |
|
1112 | + $last_exec[$id]['last'] = time(); |
|
1113 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
1114 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
1115 | + ( |
|
1116 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1117 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1118 | + ) |
|
1119 | + ) { |
|
1120 | + $buffer = $Common->getData($value['host']); |
|
1121 | + $all_data = json_decode($buffer,true); |
|
1122 | + if (isset($all_data['planes'])) { |
|
1123 | 1123 | $reset = 0; |
1124 | 1124 | foreach ($all_data['planes'] as $key => $line) { |
1125 | - $data = array(); |
|
1126 | - $data['hex'] = $key; // hex |
|
1127 | - $data['ident'] = $line[3]; // ident |
|
1128 | - $data['altitude'] = $line[6]; // altitude |
|
1129 | - $data['speed'] = $line[8]; // speed |
|
1130 | - $data['heading'] = $line[7]; // heading |
|
1131 | - $data['latitude'] = $line[4]; // lat |
|
1132 | - $data['longitude'] = $line[5]; // long |
|
1133 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
1134 | - $data['squawk'] = $line[10]; // squawk |
|
1135 | - $data['emergency'] = ''; // emergency |
|
1136 | - $data['registration'] = $line[2]; |
|
1137 | - $data['aircraft_icao'] = $line[0]; |
|
1138 | - $deparr = explode('-',$line[1]); |
|
1139 | - if (count($deparr) === 2) { |
|
1125 | + $data = array(); |
|
1126 | + $data['hex'] = $key; // hex |
|
1127 | + $data['ident'] = $line[3]; // ident |
|
1128 | + $data['altitude'] = $line[6]; // altitude |
|
1129 | + $data['speed'] = $line[8]; // speed |
|
1130 | + $data['heading'] = $line[7]; // heading |
|
1131 | + $data['latitude'] = $line[4]; // lat |
|
1132 | + $data['longitude'] = $line[5]; // long |
|
1133 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
1134 | + $data['squawk'] = $line[10]; // squawk |
|
1135 | + $data['emergency'] = ''; // emergency |
|
1136 | + $data['registration'] = $line[2]; |
|
1137 | + $data['aircraft_icao'] = $line[0]; |
|
1138 | + $deparr = explode('-',$line[1]); |
|
1139 | + if (count($deparr) === 2) { |
|
1140 | 1140 | $data['departure_airport_icao'] = $deparr[0]; |
1141 | 1141 | $data['arrival_airport_icao'] = $deparr[1]; |
1142 | - } |
|
1143 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
1144 | - $data['format_source'] = 'planeupdatefaa'; |
|
1145 | - $data['id_source'] = $id_source; |
|
1146 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1147 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1148 | - $SI->add($data); |
|
1149 | - unset($data); |
|
1142 | + } |
|
1143 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
1144 | + $data['format_source'] = 'planeupdatefaa'; |
|
1145 | + $data['id_source'] = $id_source; |
|
1146 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1147 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1148 | + $SI->add($data); |
|
1149 | + unset($data); |
|
1150 | + } |
|
1150 | 1151 | } |
1151 | - } |
|
1152 | - //$last_exec['planeupdatefaa'] = time(); |
|
1153 | - $last_exec[$id]['last'] = time(); |
|
1152 | + //$last_exec['planeupdatefaa'] = time(); |
|
1153 | + $last_exec[$id]['last'] = time(); |
|
1154 | 1154 | } elseif ($value['format'] === 'opensky' && |
1155 | - ( |
|
1155 | + ( |
|
1156 | 1156 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1157 | 1157 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1158 | - ) |
|
1158 | + ) |
|
1159 | 1159 | ) { |
1160 | - $buffer = $Common->getData($value['host']); |
|
1161 | - $all_data = json_decode($buffer,true); |
|
1162 | - if (isset($all_data['states'])) { |
|
1160 | + $buffer = $Common->getData($value['host']); |
|
1161 | + $all_data = json_decode($buffer,true); |
|
1162 | + if (isset($all_data['states'])) { |
|
1163 | 1163 | $reset = 0; |
1164 | 1164 | foreach ($all_data['states'] as $key => $line) { |
1165 | - $data = array(); |
|
1166 | - $data['hex'] = $line[0]; // hex |
|
1167 | - $data['ident'] = trim($line[1]); // ident |
|
1168 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1169 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
1170 | - $data['heading'] = round($line[10]); // heading |
|
1171 | - $data['latitude'] = $line[6]; // lat |
|
1172 | - $data['longitude'] = $line[5]; // long |
|
1173 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
1174 | - //$data['squawk'] = $line[10]; // squawk |
|
1175 | - //$data['emergency'] = ''; // emergency |
|
1176 | - //$data['registration'] = $line[2]; |
|
1177 | - //$data['aircraft_icao'] = $line[0]; |
|
1178 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1179 | - $data['format_source'] = 'opensky'; |
|
1180 | - $data['id_source'] = $id_source; |
|
1181 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1182 | - $SI->add($data); |
|
1183 | - unset($data); |
|
1165 | + $data = array(); |
|
1166 | + $data['hex'] = $line[0]; // hex |
|
1167 | + $data['ident'] = trim($line[1]); // ident |
|
1168 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1169 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
1170 | + $data['heading'] = round($line[10]); // heading |
|
1171 | + $data['latitude'] = $line[6]; // lat |
|
1172 | + $data['longitude'] = $line[5]; // long |
|
1173 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
1174 | + //$data['squawk'] = $line[10]; // squawk |
|
1175 | + //$data['emergency'] = ''; // emergency |
|
1176 | + //$data['registration'] = $line[2]; |
|
1177 | + //$data['aircraft_icao'] = $line[0]; |
|
1178 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1179 | + $data['format_source'] = 'opensky'; |
|
1180 | + $data['id_source'] = $id_source; |
|
1181 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1182 | + $SI->add($data); |
|
1183 | + unset($data); |
|
1184 | 1184 | } |
1185 | - } |
|
1186 | - //$last_exec['planeupdatefaa'] = time(); |
|
1187 | - $last_exec[$id]['last'] = time(); |
|
1185 | + } |
|
1186 | + //$last_exec['planeupdatefaa'] = time(); |
|
1187 | + $last_exec[$id]['last'] = time(); |
|
1188 | 1188 | } elseif ($value['format'] === 'aircraftjson' && |
1189 | - ( |
|
1189 | + ( |
|
1190 | 1190 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1191 | 1191 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1192 | - ) |
|
1192 | + ) |
|
1193 | 1193 | ) { |
1194 | - $buffer = $Common->getData($value['host']); |
|
1195 | - $all_data = json_decode($buffer,true); |
|
1196 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1194 | + $buffer = $Common->getData($value['host']); |
|
1195 | + $all_data = json_decode($buffer,true); |
|
1196 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1197 | 1197 | $reset = 0; |
1198 | 1198 | foreach ($all_data['aircraft'] as $key => $line) { |
1199 | - $data = array(); |
|
1200 | - // add support for ground vehicule with ~ in front of hex |
|
1201 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1202 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1203 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1204 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1205 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1206 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1207 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1208 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1209 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1210 | - //$data['emergency'] = ''; // emergency |
|
1211 | - //$data['registration'] = $line[2]; |
|
1212 | - //$data['aircraft_icao'] = $line[0]; |
|
1213 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1214 | - $data['format_source'] = 'aircraftjson'; |
|
1215 | - $data['id_source'] = $id_source; |
|
1216 | - if (isset($value['name']) && $value['name'] != '') { |
|
1217 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1218 | - else $data['source_name'] = $value['name']; |
|
1219 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1220 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1221 | - $SI->add($data); |
|
1222 | - unset($data); |
|
1199 | + $data = array(); |
|
1200 | + // add support for ground vehicule with ~ in front of hex |
|
1201 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1202 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1203 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1204 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1205 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1206 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1207 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1208 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1209 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1210 | + //$data['emergency'] = ''; // emergency |
|
1211 | + //$data['registration'] = $line[2]; |
|
1212 | + //$data['aircraft_icao'] = $line[0]; |
|
1213 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1214 | + $data['format_source'] = 'aircraftjson'; |
|
1215 | + $data['id_source'] = $id_source; |
|
1216 | + if (isset($value['name']) && $value['name'] != '') { |
|
1217 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1218 | + else $data['source_name'] = $value['name']; |
|
1219 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1220 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1221 | + $SI->add($data); |
|
1222 | + unset($data); |
|
1223 | + } |
|
1223 | 1224 | } |
1224 | - } |
|
1225 | - //$last_exec['planeupdatefaa'] = time(); |
|
1226 | - $last_exec[$id]['last'] = time(); |
|
1225 | + //$last_exec['planeupdatefaa'] = time(); |
|
1226 | + $last_exec[$id]['last'] = time(); |
|
1227 | 1227 | } elseif ($value['format'] === 'planefinderclient' && |
1228 | - ( |
|
1228 | + ( |
|
1229 | 1229 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1230 | 1230 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1231 | - ) |
|
1231 | + ) |
|
1232 | 1232 | ) { |
1233 | - $buffer = $Common->getData($value['host']); |
|
1234 | - $all_data = json_decode($buffer,true); |
|
1235 | - if (isset($all_data['aircraft'])) { |
|
1233 | + $buffer = $Common->getData($value['host']); |
|
1234 | + $all_data = json_decode($buffer,true); |
|
1235 | + if (isset($all_data['aircraft'])) { |
|
1236 | 1236 | $reset = 0; |
1237 | 1237 | foreach ($all_data['aircraft'] as $key => $line) { |
1238 | - $data = array(); |
|
1239 | - $data['hex'] = $key; // hex |
|
1240 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1241 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1242 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1243 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1244 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1245 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1246 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1247 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1248 | - //$data['emergency'] = ''; // emergency |
|
1249 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1250 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1251 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1252 | - $data['format_source'] = 'planefinderclient'; |
|
1253 | - $data['id_source'] = $id_source; |
|
1254 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1255 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1256 | - $SI->add($data); |
|
1257 | - unset($data); |
|
1238 | + $data = array(); |
|
1239 | + $data['hex'] = $key; // hex |
|
1240 | + if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1241 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1242 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1243 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1244 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1245 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1246 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1247 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1248 | + //$data['emergency'] = ''; // emergency |
|
1249 | + if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1250 | + if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1251 | + $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1252 | + $data['format_source'] = 'planefinderclient'; |
|
1253 | + $data['id_source'] = $id_source; |
|
1254 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1255 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1256 | + $SI->add($data); |
|
1257 | + unset($data); |
|
1258 | 1258 | } |
1259 | - } |
|
1260 | - $last_exec[$id]['last'] = time(); |
|
1259 | + } |
|
1260 | + $last_exec[$id]['last'] = time(); |
|
1261 | 1261 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1262 | 1262 | } elseif ($value['format'] === 'fr24json' && |
1263 | - ( |
|
1263 | + ( |
|
1264 | 1264 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1265 | 1265 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1266 | - ) |
|
1266 | + ) |
|
1267 | 1267 | ) { |
1268 | - //$buffer = $Common->getData($hosts[$id]); |
|
1269 | - $buffer = $Common->getData($value['host']); |
|
1270 | - $all_data = json_decode($buffer,true); |
|
1271 | - if (!empty($all_data)) $reset = 0; |
|
1272 | - foreach ($all_data as $key => $line) { |
|
1268 | + //$buffer = $Common->getData($hosts[$id]); |
|
1269 | + $buffer = $Common->getData($value['host']); |
|
1270 | + $all_data = json_decode($buffer,true); |
|
1271 | + if (!empty($all_data)) $reset = 0; |
|
1272 | + foreach ($all_data as $key => $line) { |
|
1273 | 1273 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1274 | - $data = array(); |
|
1275 | - $data['hex'] = $line[0]; |
|
1276 | - $data['ident'] = $line[16]; //$line[13] |
|
1277 | - $data['altitude'] = $line[4]; // altitude |
|
1278 | - $data['speed'] = $line[5]; // speed |
|
1279 | - $data['heading'] = $line[3]; // heading |
|
1280 | - $data['latitude'] = $line[1]; // lat |
|
1281 | - $data['longitude'] = $line[2]; // long |
|
1282 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1283 | - $data['squawk'] = $line[6]; // squawk |
|
1284 | - $data['aircraft_icao'] = $line[8]; |
|
1285 | - $data['registration'] = $line[9]; |
|
1286 | - $data['departure_airport_iata'] = $line[11]; |
|
1287 | - $data['arrival_airport_iata'] = $line[12]; |
|
1288 | - $data['emergency'] = ''; // emergency |
|
1289 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1290 | - $data['format_source'] = 'fr24json'; |
|
1291 | - $data['id_source'] = $id_source; |
|
1292 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1293 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1294 | - $SI->add($data); |
|
1295 | - unset($data); |
|
1274 | + $data = array(); |
|
1275 | + $data['hex'] = $line[0]; |
|
1276 | + $data['ident'] = $line[16]; //$line[13] |
|
1277 | + $data['altitude'] = $line[4]; // altitude |
|
1278 | + $data['speed'] = $line[5]; // speed |
|
1279 | + $data['heading'] = $line[3]; // heading |
|
1280 | + $data['latitude'] = $line[1]; // lat |
|
1281 | + $data['longitude'] = $line[2]; // long |
|
1282 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1283 | + $data['squawk'] = $line[6]; // squawk |
|
1284 | + $data['aircraft_icao'] = $line[8]; |
|
1285 | + $data['registration'] = $line[9]; |
|
1286 | + $data['departure_airport_iata'] = $line[11]; |
|
1287 | + $data['arrival_airport_iata'] = $line[12]; |
|
1288 | + $data['emergency'] = ''; // emergency |
|
1289 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1290 | + $data['format_source'] = 'fr24json'; |
|
1291 | + $data['id_source'] = $id_source; |
|
1292 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1293 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1294 | + $SI->add($data); |
|
1295 | + unset($data); |
|
1296 | 1296 | } |
1297 | - } |
|
1298 | - //$last_exec['fr24json'] = time(); |
|
1299 | - $last_exec[$id]['last'] = time(); |
|
1297 | + } |
|
1298 | + //$last_exec['fr24json'] = time(); |
|
1299 | + $last_exec[$id]['last'] = time(); |
|
1300 | 1300 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1301 | 1301 | } elseif ($value['format'] === 'radarvirtueljson' && |
1302 | - ( |
|
1302 | + ( |
|
1303 | 1303 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1304 | 1304 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1305 | - ) |
|
1305 | + ) |
|
1306 | 1306 | ) { |
1307 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1308 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1309 | - //echo $buffer; |
|
1310 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1311 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1312 | - $all_data = json_decode($buffer,true); |
|
1313 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1307 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1308 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1309 | + //echo $buffer; |
|
1310 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1311 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1312 | + $all_data = json_decode($buffer,true); |
|
1313 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1314 | 1314 | die(json_last_error_msg()); |
1315 | - } |
|
1316 | - if (isset($all_data['mrkrs'])) { |
|
1315 | + } |
|
1316 | + if (isset($all_data['mrkrs'])) { |
|
1317 | 1317 | $reset = 0; |
1318 | 1318 | foreach ($all_data['mrkrs'] as $key => $line) { |
1319 | - if (isset($line['inf'])) { |
|
1319 | + if (isset($line['inf'])) { |
|
1320 | 1320 | $data = array(); |
1321 | 1321 | $data['hex'] = $line['inf']['ia']; |
1322 | 1322 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1323 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1324 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1325 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1326 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1327 | - $data['longitude'] = $line['pt'][1]; // long |
|
1328 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1329 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1330 | - //$data['aircraft_icao'] = $line[8]; |
|
1331 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1323 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1324 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1325 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1326 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1327 | + $data['longitude'] = $line['pt'][1]; // long |
|
1328 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1329 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1330 | + //$data['aircraft_icao'] = $line[8]; |
|
1331 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1332 | 1332 | //$data['departure_airport_iata'] = $line[11]; |
1333 | 1333 | //$data['arrival_airport_iata'] = $line[12]; |
1334 | - //$data['emergency'] = ''; // emergency |
|
1334 | + //$data['emergency'] = ''; // emergency |
|
1335 | 1335 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1336 | - $data['format_source'] = 'radarvirtueljson'; |
|
1337 | - $data['id_source'] = $id_source; |
|
1336 | + $data['format_source'] = 'radarvirtueljson'; |
|
1337 | + $data['id_source'] = $id_source; |
|
1338 | 1338 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1339 | 1339 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1340 | 1340 | $SI->add($data); |
1341 | 1341 | unset($data); |
1342 | - } |
|
1342 | + } |
|
1343 | 1343 | } |
1344 | - } |
|
1345 | - //$last_exec['radarvirtueljson'] = time(); |
|
1346 | - $last_exec[$id]['last'] = time(); |
|
1344 | + } |
|
1345 | + //$last_exec['radarvirtueljson'] = time(); |
|
1346 | + $last_exec[$id]['last'] = time(); |
|
1347 | 1347 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1348 | 1348 | } elseif ($value['format'] === 'pirepsjson' && |
1349 | - ( |
|
1349 | + ( |
|
1350 | 1350 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1351 | 1351 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1352 | - ) |
|
1352 | + ) |
|
1353 | 1353 | ) { |
1354 | - //$buffer = $Common->getData($hosts[$id]); |
|
1355 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1356 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1354 | + //$buffer = $Common->getData($hosts[$id]); |
|
1355 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1356 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1357 | 1357 | |
1358 | - if (isset($all_data['pireps'])) { |
|
1358 | + if (isset($all_data['pireps'])) { |
|
1359 | 1359 | $reset = 0; |
1360 | - foreach ($all_data['pireps'] as $line) { |
|
1361 | - $data = array(); |
|
1362 | - $data['id'] = $line['id']; |
|
1363 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1364 | - $data['ident'] = $line['callsign']; // ident |
|
1365 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1366 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1367 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1368 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1369 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1370 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1371 | - $data['latitude'] = $line['lat']; // lat |
|
1372 | - $data['longitude'] = $line['lon']; // long |
|
1373 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1374 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1375 | - //$data['emergency'] = ''; // emergency |
|
1376 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1377 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1378 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1379 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1380 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1381 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1382 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1383 | - else $data['info'] = ''; |
|
1384 | - $data['format_source'] = 'pireps'; |
|
1385 | - $data['id_source'] = $id_source; |
|
1386 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1387 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1388 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1389 | - if ($line['icon'] === 'plane') { |
|
1360 | + foreach ($all_data['pireps'] as $line) { |
|
1361 | + $data = array(); |
|
1362 | + $data['id'] = $line['id']; |
|
1363 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1364 | + $data['ident'] = $line['callsign']; // ident |
|
1365 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1366 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1367 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1368 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1369 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1370 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1371 | + $data['latitude'] = $line['lat']; // lat |
|
1372 | + $data['longitude'] = $line['lon']; // long |
|
1373 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1374 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1375 | + //$data['emergency'] = ''; // emergency |
|
1376 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1377 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1378 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1379 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1380 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1381 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1382 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1383 | + else $data['info'] = ''; |
|
1384 | + $data['format_source'] = 'pireps'; |
|
1385 | + $data['id_source'] = $id_source; |
|
1386 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1387 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1388 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1389 | + if ($line['icon'] === 'plane') { |
|
1390 | 1390 | $SI->add($data); |
1391 | - // print_r($data); |
|
1392 | - } elseif ($line['icon'] === 'ct') { |
|
1391 | + // print_r($data); |
|
1392 | + } elseif ($line['icon'] === 'ct') { |
|
1393 | 1393 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1394 | 1394 | $data['info'] = str_replace('&sect;','',$data['info']); |
1395 | 1395 | $typec = substr($data['ident'],-3); |
@@ -1404,209 +1404,209 @@ discard block |
||
1404 | 1404 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1405 | 1405 | else $data['type'] = 'Observer'; |
1406 | 1406 | 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']); |
1407 | - } |
|
1408 | - unset($data); |
|
1407 | + } |
|
1408 | + unset($data); |
|
1409 | 1409 | } |
1410 | - } |
|
1411 | - //$last_exec['pirepsjson'] = time(); |
|
1412 | - $last_exec[$id]['last'] = time(); |
|
1410 | + } |
|
1411 | + //$last_exec['pirepsjson'] = time(); |
|
1412 | + $last_exec[$id]['last'] = time(); |
|
1413 | 1413 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1414 | 1414 | } elseif ($value['format'] === 'phpvmacars' && |
1415 | - ( |
|
1415 | + ( |
|
1416 | 1416 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1417 | 1417 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1418 | - ) |
|
1418 | + ) |
|
1419 | 1419 | ) { |
1420 | - //$buffer = $Common->getData($hosts[$id]); |
|
1421 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1422 | - $buffer = $Common->getData($value['host']); |
|
1423 | - $all_data = json_decode($buffer,true); |
|
1424 | - if ($buffer != '' && is_array($all_data)) { |
|
1420 | + //$buffer = $Common->getData($hosts[$id]); |
|
1421 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1422 | + $buffer = $Common->getData($value['host']); |
|
1423 | + $all_data = json_decode($buffer,true); |
|
1424 | + if ($buffer != '' && is_array($all_data)) { |
|
1425 | 1425 | $reset = 0; |
1426 | 1426 | foreach ($all_data as $line) { |
1427 | - $data = array(); |
|
1428 | - //$data['id'] = $line['id']; // id not usable |
|
1429 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1430 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1431 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1432 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1433 | - $data['ident'] = $line['flightnum']; // ident |
|
1434 | - $data['altitude'] = $line['alt']; // altitude |
|
1435 | - $data['speed'] = $line['gs']; // speed |
|
1436 | - $data['heading'] = $line['heading']; // heading |
|
1437 | - $data['latitude'] = $line['lat']; // lat |
|
1438 | - $data['longitude'] = $line['lng']; // long |
|
1439 | - $data['verticalrate'] = ''; // verticale rate |
|
1440 | - $data['squawk'] = ''; // squawk |
|
1441 | - $data['emergency'] = ''; // emergency |
|
1442 | - //$data['datetime'] = $line['lastupdate']; |
|
1443 | - //$data['last_update'] = $line['lastupdate']; |
|
1444 | - if (isset($value['timezone'])) { |
|
1445 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1446 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1447 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1448 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1449 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1450 | - $data['departure_airport_time'] = $line['deptime']; |
|
1451 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1452 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1453 | - if (isset($line['registration'])) { |
|
1454 | - $data['registration'] = $line['registration']; |
|
1455 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1456 | - } else $data['registration'] = $line['aircraft']; |
|
1457 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1458 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1459 | - if (isset($line['aircraftname'])) { |
|
1427 | + $data = array(); |
|
1428 | + //$data['id'] = $line['id']; // id not usable |
|
1429 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1430 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1431 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1432 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1433 | + $data['ident'] = $line['flightnum']; // ident |
|
1434 | + $data['altitude'] = $line['alt']; // altitude |
|
1435 | + $data['speed'] = $line['gs']; // speed |
|
1436 | + $data['heading'] = $line['heading']; // heading |
|
1437 | + $data['latitude'] = $line['lat']; // lat |
|
1438 | + $data['longitude'] = $line['lng']; // long |
|
1439 | + $data['verticalrate'] = ''; // verticale rate |
|
1440 | + $data['squawk'] = ''; // squawk |
|
1441 | + $data['emergency'] = ''; // emergency |
|
1442 | + //$data['datetime'] = $line['lastupdate']; |
|
1443 | + //$data['last_update'] = $line['lastupdate']; |
|
1444 | + if (isset($value['timezone'])) { |
|
1445 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1446 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1447 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1448 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1449 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1450 | + $data['departure_airport_time'] = $line['deptime']; |
|
1451 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1452 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1453 | + if (isset($line['registration'])) { |
|
1454 | + $data['registration'] = $line['registration']; |
|
1455 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1456 | + } else $data['registration'] = $line['aircraft']; |
|
1457 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1458 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1459 | + if (isset($line['aircraftname'])) { |
|
1460 | 1460 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1461 | 1461 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1462 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1463 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1464 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1465 | - else { |
|
1466 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1467 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1468 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1469 | - } |
|
1470 | - } |
|
1471 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1472 | - $data['id_source'] = $id_source; |
|
1473 | - $data['format_source'] = 'phpvmacars'; |
|
1474 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1475 | - $SI->add($data); |
|
1476 | - unset($data); |
|
1462 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1463 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1464 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1465 | + else { |
|
1466 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1467 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1468 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1469 | + } |
|
1470 | + } |
|
1471 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1472 | + $data['id_source'] = $id_source; |
|
1473 | + $data['format_source'] = 'phpvmacars'; |
|
1474 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1475 | + $SI->add($data); |
|
1476 | + unset($data); |
|
1477 | 1477 | } |
1478 | 1478 | if ($globalDebug) echo 'No more data...'."\n"; |
1479 | 1479 | unset($buffer); |
1480 | 1480 | unset($all_data); |
1481 | - } |
|
1482 | - //$last_exec['phpvmacars'] = time(); |
|
1483 | - $last_exec[$id]['last'] = time(); |
|
1481 | + } |
|
1482 | + //$last_exec['phpvmacars'] = time(); |
|
1483 | + $last_exec[$id]['last'] = time(); |
|
1484 | 1484 | } elseif ($value['format'] === 'vaos' && |
1485 | - ( |
|
1485 | + ( |
|
1486 | 1486 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1487 | 1487 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1488 | - ) |
|
1488 | + ) |
|
1489 | 1489 | ) { |
1490 | - //$buffer = $Common->getData($hosts[$id]); |
|
1491 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1492 | - $buffer = $Common->getData($value['host']); |
|
1493 | - $all_data = json_decode($buffer,true); |
|
1494 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1490 | + //$buffer = $Common->getData($hosts[$id]); |
|
1491 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1492 | + $buffer = $Common->getData($value['host']); |
|
1493 | + $all_data = json_decode($buffer,true); |
|
1494 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1495 | 1495 | $reset = 0; |
1496 | 1496 | foreach ($all_data['ACARSData'] as $line) { |
1497 | - //print_r($line); |
|
1498 | - $data = array(); |
|
1499 | - //$data['id'] = $line['id']; // id not usable |
|
1500 | - $data['id'] = $line['id']; |
|
1501 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1502 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1503 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1504 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1505 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1506 | - $data['altitude'] = $line['altitude']; // altitude |
|
1507 | - $data['speed'] = $line['groundspeed']; // speed |
|
1508 | - $data['heading'] = $line['heading']; // heading |
|
1509 | - $data['latitude'] = $line['lat']; // lat |
|
1510 | - $data['longitude'] = $line['lon']; // long |
|
1511 | - //$data['verticalrate'] = ''; // verticale rate |
|
1512 | - //$data['squawk'] = ''; // squawk |
|
1513 | - //$data['emergency'] = ''; // emergency |
|
1514 | - if (isset($value['timezone'])) { |
|
1515 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1516 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1517 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1518 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1497 | + //print_r($line); |
|
1498 | + $data = array(); |
|
1499 | + //$data['id'] = $line['id']; // id not usable |
|
1500 | + $data['id'] = $line['id']; |
|
1501 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1502 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1503 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1504 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1505 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1506 | + $data['altitude'] = $line['altitude']; // altitude |
|
1507 | + $data['speed'] = $line['groundspeed']; // speed |
|
1508 | + $data['heading'] = $line['heading']; // heading |
|
1509 | + $data['latitude'] = $line['lat']; // lat |
|
1510 | + $data['longitude'] = $line['lon']; // long |
|
1511 | + //$data['verticalrate'] = ''; // verticale rate |
|
1512 | + //$data['squawk'] = ''; // squawk |
|
1513 | + //$data['emergency'] = ''; // emergency |
|
1514 | + if (isset($value['timezone'])) { |
|
1515 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1516 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1517 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1518 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1519 | 1519 | |
1520 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1521 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1522 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1523 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1524 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1520 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1521 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1522 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1523 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1524 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1525 | 1525 | |
1526 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1527 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1528 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1526 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1527 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1528 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1529 | 1529 | |
1530 | - $data['id_source'] = $id_source; |
|
1531 | - $data['format_source'] = 'vaos'; |
|
1532 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1533 | - $SI->add($data); |
|
1534 | - unset($data); |
|
1530 | + $data['id_source'] = $id_source; |
|
1531 | + $data['format_source'] = 'vaos'; |
|
1532 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1533 | + $SI->add($data); |
|
1534 | + unset($data); |
|
1535 | 1535 | } |
1536 | 1536 | if ($globalDebug) echo 'No more data...'."\n"; |
1537 | 1537 | unset($buffer); |
1538 | 1538 | unset($all_data); |
1539 | - } |
|
1540 | - //$last_exec['phpvmacars'] = time(); |
|
1541 | - $last_exec[$id]['last'] = time(); |
|
1539 | + } |
|
1540 | + //$last_exec['phpvmacars'] = time(); |
|
1541 | + $last_exec[$id]['last'] = time(); |
|
1542 | 1542 | } elseif ($value['format'] === 'vam' && |
1543 | - ( |
|
1543 | + ( |
|
1544 | 1544 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1545 | 1545 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1546 | - ) |
|
1546 | + ) |
|
1547 | 1547 | ) { |
1548 | - //$buffer = $Common->getData($hosts[$id]); |
|
1549 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1550 | - $buffer = $Common->getData($value['host']); |
|
1551 | - $all_data = json_decode($buffer,true); |
|
1552 | - if ($buffer != '' && is_array($all_data)) { |
|
1548 | + //$buffer = $Common->getData($hosts[$id]); |
|
1549 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1550 | + $buffer = $Common->getData($value['host']); |
|
1551 | + $all_data = json_decode($buffer,true); |
|
1552 | + if ($buffer != '' && is_array($all_data)) { |
|
1553 | 1553 | $reset = 0; |
1554 | 1554 | foreach ($all_data as $line) { |
1555 | - $data = array(); |
|
1556 | - //$data['id'] = $line['id']; // id not usable |
|
1557 | - $data['id'] = trim($line['flight_id']); |
|
1558 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1559 | - $data['pilot_name'] = $line['pilot_name']; |
|
1560 | - $data['pilot_id'] = $line['pilot_id']; |
|
1561 | - $data['ident'] = trim($line['callsign']); // ident |
|
1562 | - $data['altitude'] = $line['altitude']; // altitude |
|
1563 | - $data['speed'] = $line['gs']; // speed |
|
1564 | - $data['heading'] = $line['heading']; // heading |
|
1565 | - $data['latitude'] = $line['latitude']; // lat |
|
1566 | - $data['longitude'] = $line['longitude']; // long |
|
1567 | - $data['verticalrate'] = ''; // verticale rate |
|
1568 | - $data['squawk'] = ''; // squawk |
|
1569 | - $data['emergency'] = ''; // emergency |
|
1570 | - //$data['datetime'] = $line['lastupdate']; |
|
1571 | - $data['last_update'] = $line['last_update']; |
|
1572 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1573 | - $data['departure_airport_icao'] = $line['departure']; |
|
1574 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1575 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1576 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1577 | - //$data['registration'] = $line['aircraft']; |
|
1578 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1579 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1580 | - $data['id_source'] = $id_source; |
|
1581 | - $data['format_source'] = 'vam'; |
|
1582 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1583 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1584 | - $SI->add($data); |
|
1585 | - unset($data); |
|
1555 | + $data = array(); |
|
1556 | + //$data['id'] = $line['id']; // id not usable |
|
1557 | + $data['id'] = trim($line['flight_id']); |
|
1558 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1559 | + $data['pilot_name'] = $line['pilot_name']; |
|
1560 | + $data['pilot_id'] = $line['pilot_id']; |
|
1561 | + $data['ident'] = trim($line['callsign']); // ident |
|
1562 | + $data['altitude'] = $line['altitude']; // altitude |
|
1563 | + $data['speed'] = $line['gs']; // speed |
|
1564 | + $data['heading'] = $line['heading']; // heading |
|
1565 | + $data['latitude'] = $line['latitude']; // lat |
|
1566 | + $data['longitude'] = $line['longitude']; // long |
|
1567 | + $data['verticalrate'] = ''; // verticale rate |
|
1568 | + $data['squawk'] = ''; // squawk |
|
1569 | + $data['emergency'] = ''; // emergency |
|
1570 | + //$data['datetime'] = $line['lastupdate']; |
|
1571 | + $data['last_update'] = $line['last_update']; |
|
1572 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1573 | + $data['departure_airport_icao'] = $line['departure']; |
|
1574 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1575 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1576 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1577 | + //$data['registration'] = $line['aircraft']; |
|
1578 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1579 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1580 | + $data['id_source'] = $id_source; |
|
1581 | + $data['format_source'] = 'vam'; |
|
1582 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1583 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1584 | + $SI->add($data); |
|
1585 | + unset($data); |
|
1586 | 1586 | } |
1587 | 1587 | if ($globalDebug) echo 'No more data...'."\n"; |
1588 | 1588 | unset($buffer); |
1589 | 1589 | unset($all_data); |
1590 | - } |
|
1591 | - //$last_exec['phpvmacars'] = time(); |
|
1592 | - $last_exec[$id]['last'] = time(); |
|
1590 | + } |
|
1591 | + //$last_exec['phpvmacars'] = time(); |
|
1592 | + $last_exec[$id]['last'] = time(); |
|
1593 | 1593 | } elseif ($value['format'] === 'blitzortung' && |
1594 | - ( |
|
1594 | + ( |
|
1595 | 1595 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1596 | 1596 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1597 | - ) |
|
1597 | + ) |
|
1598 | 1598 | ) { |
1599 | - //$buffer = $Common->getData($hosts[$id]); |
|
1600 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1601 | - $buffer = $Common->getData($value['host']); |
|
1602 | - $all_data = json_decode($buffer,true); |
|
1603 | - if ($buffer != '') { |
|
1599 | + //$buffer = $Common->getData($hosts[$id]); |
|
1600 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1601 | + $buffer = $Common->getData($value['host']); |
|
1602 | + $all_data = json_decode($buffer,true); |
|
1603 | + if ($buffer != '') { |
|
1604 | 1604 | $Source->deleteLocationBySource('blitzortung'); |
1605 | 1605 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1606 | 1606 | $buffer = explode('\n',$buffer); |
1607 | 1607 | foreach ($buffer as $buffer_line) { |
1608 | - $line = json_decode($buffer_line,true); |
|
1609 | - if (isset($line['time'])) { |
|
1608 | + $line = json_decode($buffer_line,true); |
|
1609 | + if (isset($line['time'])) { |
|
1610 | 1610 | $data = array(); |
1611 | 1611 | $data['altitude'] = $line['alt']; // altitude |
1612 | 1612 | $data['latitude'] = $line['lat']; // lat |
@@ -1618,92 +1618,92 @@ discard block |
||
1618 | 1618 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1619 | 1619 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1620 | 1620 | unset($data); |
1621 | - } |
|
1621 | + } |
|
1622 | 1622 | } |
1623 | 1623 | if ($globalDebug) echo 'No more data...'."\n"; |
1624 | 1624 | unset($buffer); |
1625 | - } |
|
1626 | - $last_exec[$id]['last'] = time(); |
|
1625 | + } |
|
1626 | + $last_exec[$id]['last'] = time(); |
|
1627 | 1627 | } elseif ($value['format'] === 'acarsjson') { |
1628 | - $arr = $httpfeeds; |
|
1629 | - $w = $e = null; |
|
1630 | - if (isset($arr[$id])) { |
|
1631 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
1632 | - if ($nn > 0) { |
|
1633 | - foreach ($httpfeeds as $feed) { |
|
1634 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
1635 | - if ($buffer === FALSE) { |
|
1636 | - connect_all($globalSources); |
|
1637 | - } |
|
1638 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1639 | - $buffer = explode('\n',$buffer); |
|
1640 | - foreach ($buffer as $line) { |
|
1641 | - if ($line != '') { |
|
1642 | - $line = json_decode($line, true); |
|
1643 | - if (!empty($line)) { |
|
1644 | - $ACARS->add($line['text'], array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => $line['text'])); |
|
1645 | - $ACARS->deleteLiveAcarsData(); |
|
1646 | - } |
|
1647 | - } |
|
1648 | - } |
|
1649 | - } |
|
1650 | - } else { |
|
1651 | - $format = $value['format']; |
|
1652 | - if (isset($tt[$format])) $tt[$format]++; |
|
1653 | - else $tt[$format] = 0; |
|
1654 | - if ($tt[$format] > 30) { |
|
1655 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
1656 | - sleep(2); |
|
1657 | - //$sourceeen[] = $value; |
|
1658 | - //connect_all($sourceeen); |
|
1659 | - //$sourceeen = array(); |
|
1660 | - connect_all($globalSources); |
|
1661 | - } |
|
1662 | - } |
|
1663 | - } |
|
1628 | + $arr = $httpfeeds; |
|
1629 | + $w = $e = null; |
|
1630 | + if (isset($arr[$id])) { |
|
1631 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
1632 | + if ($nn > 0) { |
|
1633 | + foreach ($httpfeeds as $feed) { |
|
1634 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
1635 | + if ($buffer === FALSE) { |
|
1636 | + connect_all($globalSources); |
|
1637 | + } |
|
1638 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1639 | + $buffer = explode('\n',$buffer); |
|
1640 | + foreach ($buffer as $line) { |
|
1641 | + if ($line != '') { |
|
1642 | + $line = json_decode($line, true); |
|
1643 | + if (!empty($line)) { |
|
1644 | + $ACARS->add($line['text'], array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => $line['text'])); |
|
1645 | + $ACARS->deleteLiveAcarsData(); |
|
1646 | + } |
|
1647 | + } |
|
1648 | + } |
|
1649 | + } |
|
1650 | + } else { |
|
1651 | + $format = $value['format']; |
|
1652 | + if (isset($tt[$format])) $tt[$format]++; |
|
1653 | + else $tt[$format] = 0; |
|
1654 | + if ($tt[$format] > 30) { |
|
1655 | + if ($globalDebug) echo 'Reconnect...'."\n"; |
|
1656 | + sleep(2); |
|
1657 | + //$sourceeen[] = $value; |
|
1658 | + //connect_all($sourceeen); |
|
1659 | + //$sourceeen = array(); |
|
1660 | + connect_all($globalSources); |
|
1661 | + } |
|
1662 | + } |
|
1663 | + } |
|
1664 | 1664 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
1665 | 1665 | } 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') { |
1666 | - //$last_exec[$id]['last'] = time(); |
|
1667 | - //$read = array( $sockets[$id] ); |
|
1668 | - $read = $sockets; |
|
1669 | - $write = NULL; |
|
1670 | - $e = NULL; |
|
1671 | - $n = socket_select($read, $write, $e, $timeout); |
|
1672 | - if ($e != NULL) var_dump($e); |
|
1673 | - if ($n > 0) { |
|
1666 | + //$last_exec[$id]['last'] = time(); |
|
1667 | + //$read = array( $sockets[$id] ); |
|
1668 | + $read = $sockets; |
|
1669 | + $write = NULL; |
|
1670 | + $e = NULL; |
|
1671 | + $n = socket_select($read, $write, $e, $timeout); |
|
1672 | + if ($e != NULL) var_dump($e); |
|
1673 | + if ($n > 0) { |
|
1674 | 1674 | $reset = 0; |
1675 | 1675 | foreach ($read as $nb => $r) { |
1676 | - //$value = $formats[$nb]; |
|
1677 | - $format = $globalSources[$nb]['format']; |
|
1678 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1676 | + //$value = $formats[$nb]; |
|
1677 | + $format = $globalSources[$nb]['format']; |
|
1678 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1679 | 1679 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1680 | - } elseif ($format === 'vrstcp') { |
|
1680 | + } elseif ($format === 'vrstcp') { |
|
1681 | 1681 | $buffer = @socket_read($r, 6000); |
1682 | - } else { |
|
1682 | + } else { |
|
1683 | 1683 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1684 | - } |
|
1685 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1686 | - //echo $buffer."\n"; |
|
1687 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1688 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1689 | - $error = false; |
|
1690 | - //$SI::del(); |
|
1691 | - if ($buffer !== FALSE) { |
|
1684 | + } |
|
1685 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1686 | + //echo $buffer."\n"; |
|
1687 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1688 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1689 | + $error = false; |
|
1690 | + //$SI::del(); |
|
1691 | + if ($buffer !== FALSE) { |
|
1692 | 1692 | if ($format === 'vrstcp') { |
1693 | - $buffer = explode('},{',$buffer); |
|
1693 | + $buffer = explode('},{',$buffer); |
|
1694 | 1694 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1695 | - } |
|
1696 | - // SBS format is CSV format |
|
1697 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1695 | + } |
|
1696 | + // SBS format is CSV format |
|
1697 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1698 | 1698 | $tt[$format] = 0; |
1699 | 1699 | if ($format === 'acarssbs3') { |
1700 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1701 | - $ACARS->add(trim($buffer)); |
|
1702 | - $ACARS->deleteLiveAcarsData(); |
|
1700 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1701 | + $ACARS->add(trim($buffer)); |
|
1702 | + $ACARS->deleteLiveAcarsData(); |
|
1703 | 1703 | } elseif ($format === 'raw') { |
1704 | - // AVR format |
|
1705 | - $data = $SBS->parse($buffer); |
|
1706 | - if (is_array($data)) { |
|
1704 | + // AVR format |
|
1705 | + $data = $SBS->parse($buffer); |
|
1706 | + if (is_array($data)) { |
|
1707 | 1707 | //if (!empty($data)) print_r($data); |
1708 | 1708 | $data['datetime'] = date('Y-m-d H:i:s'); |
1709 | 1709 | $data['format_source'] = 'raw'; |
@@ -1713,39 +1713,39 @@ discard block |
||
1713 | 1713 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1714 | 1714 | $SI->add($data); |
1715 | 1715 | unset($data); |
1716 | - } |
|
1716 | + } |
|
1717 | 1717 | } elseif ($format === 'ais') { |
1718 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1719 | - $data = array(); |
|
1720 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1721 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1722 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1723 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1724 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1725 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1726 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1727 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1728 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1729 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1730 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1731 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1732 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1733 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1734 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1735 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1718 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1719 | + $data = array(); |
|
1720 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1721 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1722 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1723 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1724 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1725 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1726 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1727 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1728 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1729 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1730 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1731 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1732 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1733 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1734 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1735 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1736 | 1736 | |
1737 | - if (isset($ais_data['timestamp'])) { |
|
1737 | + if (isset($ais_data['timestamp'])) { |
|
1738 | 1738 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1739 | - } else { |
|
1739 | + } else { |
|
1740 | 1740 | $data['datetime'] = date('Y-m-d H:i:s'); |
1741 | - } |
|
1742 | - $data['format_source'] = 'aisnmea'; |
|
1743 | - $data['id_source'] = $id_source; |
|
1744 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1745 | - unset($data); |
|
1746 | - } elseif ($format === 'flightgearsp') { |
|
1747 | - //echo $buffer."\n"; |
|
1748 | - if (strlen($buffer) > 5) { |
|
1741 | + } |
|
1742 | + $data['format_source'] = 'aisnmea'; |
|
1743 | + $data['id_source'] = $id_source; |
|
1744 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1745 | + unset($data); |
|
1746 | + } elseif ($format === 'flightgearsp') { |
|
1747 | + //echo $buffer."\n"; |
|
1748 | + if (strlen($buffer) > 5) { |
|
1749 | 1749 | $line = explode(',',$buffer); |
1750 | 1750 | $data = array(); |
1751 | 1751 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1762,38 +1762,38 @@ discard block |
||
1762 | 1762 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1763 | 1763 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1764 | 1764 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1765 | - } |
|
1766 | - } elseif ($format === 'acars') { |
|
1767 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1768 | - $ACARS->add(trim($buffer)); |
|
1769 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1770 | - $ACARS->deleteLiveAcarsData(); |
|
1765 | + } |
|
1766 | + } elseif ($format === 'acars') { |
|
1767 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1768 | + $ACARS->add(trim($buffer)); |
|
1769 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1770 | + $ACARS->deleteLiveAcarsData(); |
|
1771 | 1771 | } elseif ($format === 'flightgearmp') { |
1772 | - if (substr($buffer,0,1) != '#') { |
|
1772 | + if (substr($buffer,0,1) != '#') { |
|
1773 | 1773 | $data = array(); |
1774 | 1774 | //echo $buffer."\n"; |
1775 | 1775 | $line = explode(' ',$buffer); |
1776 | 1776 | if (count($line) === 11) { |
1777 | - $userserver = explode('@',$line[0]); |
|
1778 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1779 | - $data['ident'] = $userserver[0]; |
|
1780 | - $data['registration'] = $userserver[0]; |
|
1781 | - $data['latitude'] = $line[4]; |
|
1782 | - $data['longitude'] = $line[5]; |
|
1783 | - $data['altitude'] = $line[6]; |
|
1784 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1785 | - $aircraft_type = $line[10]; |
|
1786 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1787 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1788 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1789 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1777 | + $userserver = explode('@',$line[0]); |
|
1778 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1779 | + $data['ident'] = $userserver[0]; |
|
1780 | + $data['registration'] = $userserver[0]; |
|
1781 | + $data['latitude'] = $line[4]; |
|
1782 | + $data['longitude'] = $line[5]; |
|
1783 | + $data['altitude'] = $line[6]; |
|
1784 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1785 | + $aircraft_type = $line[10]; |
|
1786 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1787 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1788 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1789 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1790 | + } |
|
1790 | 1791 | } |
1791 | - } |
|
1792 | 1792 | } elseif ($format === 'beast') { |
1793 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1794 | - die; |
|
1793 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1794 | + die; |
|
1795 | 1795 | } elseif ($format === 'vrstcp') { |
1796 | - foreach($buffer as $all_data) { |
|
1796 | + foreach($buffer as $all_data) { |
|
1797 | 1797 | $line = json_decode('{'.$all_data.'}',true); |
1798 | 1798 | $data = array(); |
1799 | 1799 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1813,158 +1813,158 @@ discard block |
||
1813 | 1813 | */ |
1814 | 1814 | $data['datetime'] = date('Y-m-d H:i:s'); |
1815 | 1815 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1816 | - $data['format_source'] = 'vrstcp'; |
|
1816 | + $data['format_source'] = 'vrstcp'; |
|
1817 | 1817 | $data['id_source'] = $id_source; |
1818 | 1818 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1819 | 1819 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1820 | 1820 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1821 | 1821 | unset($data); |
1822 | - } |
|
1822 | + } |
|
1823 | 1823 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
1824 | - $line = explode("\t", $buffer); |
|
1825 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1824 | + $line = explode("\t", $buffer); |
|
1825 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1826 | 1826 | $key = $line[$k]; |
1827 | - $lined[$key] = $line[$k+1]; |
|
1828 | - } |
|
1829 | - if (count($lined) > 3) { |
|
1830 | - $data['hex'] = $lined['hexid']; |
|
1831 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1832 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1833 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1834 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1835 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1836 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1837 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1838 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1839 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1840 | - $data['id_source'] = $id_source; |
|
1841 | - $data['format_source'] = 'tsv'; |
|
1842 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1843 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1827 | + $lined[$key] = $line[$k+1]; |
|
1828 | + } |
|
1829 | + if (count($lined) > 3) { |
|
1830 | + $data['hex'] = $lined['hexid']; |
|
1831 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1832 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1833 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1834 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1835 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1836 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1837 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1838 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1839 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1840 | + $data['id_source'] = $id_source; |
|
1841 | + $data['format_source'] = 'tsv'; |
|
1842 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1843 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1844 | 1844 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1845 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1846 | - unset($lined); |
|
1847 | - unset($data); |
|
1848 | - } else $error = true; |
|
1845 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1846 | + unset($lined); |
|
1847 | + unset($data); |
|
1848 | + } else $error = true; |
|
1849 | 1849 | } elseif ($format === 'aprs' && $use_aprs) { |
1850 | - if ($aprs_connect === 0) { |
|
1850 | + if ($aprs_connect === 0) { |
|
1851 | 1851 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1852 | 1852 | $aprs_connect = 1; |
1853 | - } |
|
1853 | + } |
|
1854 | 1854 | |
1855 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1855 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1856 | 1856 | $aprs_last_tx = time(); |
1857 | 1857 | $data_aprs = "# Keep alive"; |
1858 | 1858 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1859 | - } |
|
1859 | + } |
|
1860 | 1860 | |
1861 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1862 | - //echo 'APRS data : '.$buffer."\n"; |
|
1863 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1864 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1865 | - //echo $buffer."\n"; |
|
1866 | - date_default_timezone_set('UTC'); |
|
1867 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1861 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1862 | + //echo 'APRS data : '.$buffer."\n"; |
|
1863 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1864 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1865 | + //echo $buffer."\n"; |
|
1866 | + date_default_timezone_set('UTC'); |
|
1867 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1868 | 1868 | $line = $APRS->parse($buffer); |
1869 | 1869 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1870 | 1870 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1871 | - $aprs_last_tx = time(); |
|
1872 | - $data = array(); |
|
1873 | - //print_r($line); |
|
1874 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1875 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1876 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1877 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1878 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1879 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1880 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1881 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1882 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1883 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1884 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1885 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1886 | - $data['latitude'] = $line['latitude']; |
|
1887 | - $data['longitude'] = $line['longitude']; |
|
1888 | - //$data['verticalrate'] = $line[16]; |
|
1889 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1890 | - //else $data['speed'] = 0; |
|
1891 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1892 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1893 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1894 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1871 | + $aprs_last_tx = time(); |
|
1872 | + $data = array(); |
|
1873 | + //print_r($line); |
|
1874 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1875 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1876 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1877 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1878 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1879 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1880 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1881 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1882 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1883 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1884 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1885 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1886 | + $data['latitude'] = $line['latitude']; |
|
1887 | + $data['longitude'] = $line['longitude']; |
|
1888 | + //$data['verticalrate'] = $line[16]; |
|
1889 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1890 | + //else $data['speed'] = 0; |
|
1891 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1892 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1893 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1894 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1895 | 1895 | |
1896 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1897 | - //else echo 'No heading...'."\n"; |
|
1898 | - //else $data['heading'] = 0; |
|
1899 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1900 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1901 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1902 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1903 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1904 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1905 | - $data['id_source'] = $id_source; |
|
1906 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1907 | - else $data['format_source'] = 'aprs'; |
|
1908 | - $data['source_name'] = $line['source']; |
|
1909 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1910 | - else $data['source_type'] = 'flarm'; |
|
1911 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1912 | - $currentdate = date('Y-m-d H:i:s'); |
|
1913 | - $aprsdate = strtotime($data['datetime']); |
|
1914 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1915 | - // Accept data if time <= system time + 20s |
|
1916 | - //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'])))) { |
|
1917 | - if ( |
|
1896 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1897 | + //else echo 'No heading...'."\n"; |
|
1898 | + //else $data['heading'] = 0; |
|
1899 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1900 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1901 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1902 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1903 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1904 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1905 | + $data['id_source'] = $id_source; |
|
1906 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1907 | + else $data['format_source'] = 'aprs'; |
|
1908 | + $data['source_name'] = $line['source']; |
|
1909 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1910 | + else $data['source_type'] = 'flarm'; |
|
1911 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1912 | + $currentdate = date('Y-m-d H:i:s'); |
|
1913 | + $aprsdate = strtotime($data['datetime']); |
|
1914 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1915 | + // Accept data if time <= system time + 20s |
|
1916 | + //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'])))) { |
|
1917 | + if ( |
|
1918 | 1918 | ($data['source_type'] === 'modes') || |
1919 | 1919 | isset($line['stealth']) && |
1920 | 1920 | (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && |
1921 | 1921 | ($line['stealth'] === 0 || $line['stealth'] == '') && |
1922 | 1922 | (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1923 | 1923 | $send = $SI->add($data); |
1924 | - } elseif ($data['source_type'] === 'ais') { |
|
1924 | + } elseif ($data['source_type'] === 'ais') { |
|
1925 | 1925 | $data['type'] = ''; |
1926 | 1926 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1927 | - } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
1927 | + } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
1928 | 1928 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1929 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1930 | - //$line['symbol'] === 'Balloon' || |
|
1931 | - $line['symbol'] === 'Glider' || |
|
1932 | - $line['symbol'] === 'No. Plane' || |
|
1933 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1934 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1935 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1936 | - $send = $SI->add($data); |
|
1937 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1938 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1939 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
1940 | - $send = $MI->add($data); |
|
1941 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1942 | - $line['symbol'] === 'Car' || |
|
1943 | - $line['symbol'] === 'Ambulance' || |
|
1944 | - $line['symbol'] === 'Van' || |
|
1945 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1946 | - $line['symbol'] === 'Motorcycle' || |
|
1947 | - $line['symbol'] === 'Tractor' || |
|
1948 | - $line['symbol'] === 'Police' || |
|
1949 | - $line['symbol'] === 'Bike' || |
|
1950 | - $line['symbol'] === 'Jogger' || |
|
1951 | - $line['symbol'] === 'Horse' || |
|
1952 | - $line['symbol'] === 'Bus' || |
|
1953 | - $line['symbol'] === 'Jeep' || |
|
1954 | - $line['symbol'] === 'Recreational Vehicle' || |
|
1955 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1956 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
1957 | - $line['symbol'] === 'Firetruck' || |
|
1958 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1959 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1960 | - $line['symbol'] === 'SUV' || |
|
1961 | - $line['symbol'] === 'Snowmobile' || |
|
1962 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
1963 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1929 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1930 | + //$line['symbol'] === 'Balloon' || |
|
1931 | + $line['symbol'] === 'Glider' || |
|
1932 | + $line['symbol'] === 'No. Plane' || |
|
1933 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1934 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1935 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1936 | + $send = $SI->add($data); |
|
1937 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1938 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1939 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
1940 | + $send = $MI->add($data); |
|
1941 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1942 | + $line['symbol'] === 'Car' || |
|
1943 | + $line['symbol'] === 'Ambulance' || |
|
1944 | + $line['symbol'] === 'Van' || |
|
1945 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1946 | + $line['symbol'] === 'Motorcycle' || |
|
1947 | + $line['symbol'] === 'Tractor' || |
|
1948 | + $line['symbol'] === 'Police' || |
|
1949 | + $line['symbol'] === 'Bike' || |
|
1950 | + $line['symbol'] === 'Jogger' || |
|
1951 | + $line['symbol'] === 'Horse' || |
|
1952 | + $line['symbol'] === 'Bus' || |
|
1953 | + $line['symbol'] === 'Jeep' || |
|
1954 | + $line['symbol'] === 'Recreational Vehicle' || |
|
1955 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1956 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
1957 | + $line['symbol'] === 'Firetruck' || |
|
1958 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1959 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1960 | + $line['symbol'] === 'SUV' || |
|
1961 | + $line['symbol'] === 'Snowmobile' || |
|
1962 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
1963 | + //} 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') { |
|
1964 | 1964 | // } 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') { |
1965 | 1965 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1966 | 1966 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1967 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1967 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1968 | 1968 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1969 | 1969 | $Source->deleteOldLocationByType('gs'); |
1970 | 1970 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1972,7 +1972,7 @@ discard block |
||
1972 | 1972 | } else { |
1973 | 1973 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1974 | 1974 | } |
1975 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1975 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1976 | 1976 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1977 | 1977 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1978 | 1978 | $Source->deleteOldLocationByType('wx'); |
@@ -1982,7 +1982,7 @@ discard block |
||
1982 | 1982 | } else { |
1983 | 1983 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1984 | 1984 | } |
1985 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1985 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1986 | 1986 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1987 | 1987 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1988 | 1988 | $Source->deleteOldLocationByType('lightning'); |
@@ -1991,11 +1991,11 @@ discard block |
||
1991 | 1991 | } else { |
1992 | 1992 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1993 | 1993 | } |
1994 | - } elseif ($globalDebug) { |
|
1995 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1996 | - print_r($line); |
|
1997 | - } |
|
1998 | - unset($data); |
|
1994 | + } elseif ($globalDebug) { |
|
1995 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1996 | + print_r($line); |
|
1997 | + } |
|
1998 | + unset($data); |
|
1999 | 1999 | } |
2000 | 2000 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
2001 | 2001 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -2014,13 +2014,13 @@ discard block |
||
2014 | 2014 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
2015 | 2015 | $globalSources[$nb]['last_weather_clean'] = time(); |
2016 | 2016 | } |
2017 | - } |
|
2017 | + } |
|
2018 | 2018 | } else { |
2019 | - $line = explode(',', $buffer); |
|
2020 | - //print_r($line); |
|
2021 | - if (count($line) > 20) { |
|
2022 | - $data['hex'] = $line[4]; |
|
2023 | - /* |
|
2019 | + $line = explode(',', $buffer); |
|
2020 | + //print_r($line); |
|
2021 | + if (count($line) > 20) { |
|
2022 | + $data['hex'] = $line[4]; |
|
2023 | + /* |
|
2024 | 2024 | $data['datetime'] = $line[6].' '.$line[7]; |
2025 | 2025 | date_default_timezone_set($globalTimezone); |
2026 | 2026 | $datetime = new DateTime($data['datetime']); |
@@ -2028,31 +2028,31 @@ discard block |
||
2028 | 2028 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
2029 | 2029 | date_default_timezone_set('UTC'); |
2030 | 2030 | */ |
2031 | - // Force datetime to current UTC datetime |
|
2032 | - date_default_timezone_set('UTC'); |
|
2033 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
2034 | - $data['ident'] = trim($line[10]); |
|
2035 | - $data['latitude'] = $line[14]; |
|
2036 | - $data['longitude'] = $line[15]; |
|
2037 | - $data['verticalrate'] = $line[16]; |
|
2038 | - $data['emergency'] = $line[20]; |
|
2039 | - $data['speed'] = $line[12]; |
|
2040 | - $data['squawk'] = $line[17]; |
|
2041 | - $data['altitude'] = $line[11]; |
|
2042 | - $data['heading'] = $line[13]; |
|
2043 | - $data['ground'] = $line[21]; |
|
2044 | - $data['emergency'] = $line[19]; |
|
2045 | - $data['format_source'] = 'sbs'; |
|
2031 | + // Force datetime to current UTC datetime |
|
2032 | + date_default_timezone_set('UTC'); |
|
2033 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2034 | + $data['ident'] = trim($line[10]); |
|
2035 | + $data['latitude'] = $line[14]; |
|
2036 | + $data['longitude'] = $line[15]; |
|
2037 | + $data['verticalrate'] = $line[16]; |
|
2038 | + $data['emergency'] = $line[20]; |
|
2039 | + $data['speed'] = $line[12]; |
|
2040 | + $data['squawk'] = $line[17]; |
|
2041 | + $data['altitude'] = $line[11]; |
|
2042 | + $data['heading'] = $line[13]; |
|
2043 | + $data['ground'] = $line[21]; |
|
2044 | + $data['emergency'] = $line[19]; |
|
2045 | + $data['format_source'] = 'sbs'; |
|
2046 | 2046 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
2047 | 2047 | elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
2048 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2048 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2049 | 2049 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
2050 | - $data['id_source'] = $id_source; |
|
2051 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2052 | - else $error = true; |
|
2053 | - unset($data); |
|
2054 | - } else $error = true; |
|
2055 | - if ($error) { |
|
2050 | + $data['id_source'] = $id_source; |
|
2051 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2052 | + else $error = true; |
|
2053 | + unset($data); |
|
2054 | + } else $error = true; |
|
2055 | + if ($error) { |
|
2056 | 2056 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
2057 | 2057 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
2058 | 2058 | } else { |
@@ -2068,13 +2068,13 @@ discard block |
||
2068 | 2068 | connect_all($sourceer); |
2069 | 2069 | $sourceer = array(); |
2070 | 2070 | } |
2071 | - } |
|
2071 | + } |
|
2072 | 2072 | } |
2073 | 2073 | // Sleep for xxx microseconds |
2074 | 2074 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
2075 | - } else { |
|
2075 | + } else { |
|
2076 | 2076 | if ($format === 'flightgearmp') { |
2077 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2077 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2078 | 2078 | //@socket_close($r); |
2079 | 2079 | sleep($globalMinFetch); |
2080 | 2080 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2083,9 +2083,9 @@ discard block |
||
2083 | 2083 | break; |
2084 | 2084 | |
2085 | 2085 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
2086 | - if (isset($tt[$format])) $tt[$format]++; |
|
2087 | - else $tt[$format] = 0; |
|
2088 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
2086 | + if (isset($tt[$format])) $tt[$format]++; |
|
2087 | + else $tt[$format] = 0; |
|
2088 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
2089 | 2089 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
2090 | 2090 | //@socket_close($r); |
2091 | 2091 | sleep(2); |
@@ -2096,24 +2096,24 @@ discard block |
||
2096 | 2096 | //connect_all($globalSources); |
2097 | 2097 | $tt[$format]=0; |
2098 | 2098 | break; |
2099 | - } |
|
2100 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
2099 | + } |
|
2100 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
2101 | + } |
|
2101 | 2102 | } |
2102 | - } |
|
2103 | 2103 | } |
2104 | - } else { |
|
2104 | + } else { |
|
2105 | 2105 | $error = socket_strerror(socket_last_error()); |
2106 | 2106 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
2107 | 2107 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
2108 | 2108 | if (isset($globalDebug)) echo "Restarting...\n"; |
2109 | 2109 | // Restart the script if possible |
2110 | 2110 | if (is_array($sockets)) { |
2111 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2111 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
2112 | 2112 | |
2113 | - foreach ($sockets as $sock) { |
|
2113 | + foreach ($sockets as $sock) { |
|
2114 | 2114 | @socket_shutdown($sock,2); |
2115 | 2115 | @socket_close($sock); |
2116 | - } |
|
2116 | + } |
|
2117 | 2117 | |
2118 | 2118 | } |
2119 | 2119 | if ($globalDebug) echo "Waiting..."; |
@@ -2128,15 +2128,15 @@ discard block |
||
2128 | 2128 | if ($globalDebug) echo "Restart all connections..."; |
2129 | 2129 | connect_all($globalSources); |
2130 | 2130 | } |
2131 | - } |
|
2131 | + } |
|
2132 | 2132 | } |
2133 | 2133 | if ($globalDaemon === false) { |
2134 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
2135 | - if (isset($SI)) $SI->checkAll(); |
|
2136 | - if (isset($TI)) $TI->checkAll(); |
|
2137 | - if (isset($MI)) $MI->checkAll(); |
|
2134 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
2135 | + if (isset($SI)) $SI->checkAll(); |
|
2136 | + if (isset($TI)) $TI->checkAll(); |
|
2137 | + if (isset($MI)) $MI->checkAll(); |
|
2138 | + } |
|
2138 | 2139 | } |
2139 | - } |
|
2140 | 2140 | } |
2141 | 2141 | |
2142 | 2142 | ?> |
@@ -59,20 +59,20 @@ discard block |
||
59 | 59 | die; |
60 | 60 | } |
61 | 61 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
62 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
62 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
|
66 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); |
|
67 | 67 | //if (isset($options['s'])) $hosts = array($options['s']); |
68 | 68 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
69 | 69 | if (isset($options['s'])) { |
70 | 70 | $globalSources = array(); |
71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
71 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
72 | 72 | else $globalSources[] = array('host' => $options['s']); |
73 | 73 | } elseif (isset($options['source'])) { |
74 | 74 | $globalSources = array(); |
75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
75 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
76 | 76 | else $globalSources[] = array('host' => $options['source']); |
77 | 77 | } |
78 | 78 | if (isset($options['aprsserverhost'])) { |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | else $id_source = 1; |
114 | 114 | if (isset($globalServer) && $globalServer) { |
115 | 115 | if ($globalDebug) echo "Using Server Mode\n"; |
116 | - $SI=new SpotterServer(); |
|
116 | + $SI = new SpotterServer(); |
|
117 | 117 | /* |
118 | 118 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
119 | 119 | $SI = new adsb2aprs(); |
120 | 120 | $SI->connect(); |
121 | 121 | */ |
122 | -} else $SI=new SpotterImport($Connection->db); |
|
122 | +} else $SI = new SpotterImport($Connection->db); |
|
123 | 123 | |
124 | 124 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
125 | 125 | if (isset($globalMarine) && $globalMarine) { |
@@ -133,17 +133,17 @@ discard block |
||
133 | 133 | $MI = new MarineImport($Connection->db); |
134 | 134 | } |
135 | 135 | //$APRS=new APRS($Connection->db); |
136 | -$SBS=new SBS(); |
|
136 | +$SBS = new SBS(); |
|
137 | 137 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
138 | - $ACARS=new ACARS($Connection->db,true); |
|
139 | - $Source=new Source($Connection->db); |
|
138 | + $ACARS = new ACARS($Connection->db, true); |
|
139 | + $Source = new Source($Connection->db); |
|
140 | 140 | } |
141 | -$Common=new Common(); |
|
141 | +$Common = new Common(); |
|
142 | 142 | date_default_timezone_set('UTC'); |
143 | 143 | //$servertz = system('date +%Z'); |
144 | 144 | // signal handler - playing nice with sockets and dump1090 |
145 | 145 | if (function_exists('pcntl_fork')) { |
146 | - pcntl_signal(SIGINT, function() { |
|
146 | + pcntl_signal(SIGINT, function() { |
|
147 | 147 | global $sockets; |
148 | 148 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
149 | 149 | die("Bye!\n"); |
@@ -159,40 +159,40 @@ discard block |
||
159 | 159 | |
160 | 160 | function connect_all($hosts) { |
161 | 161 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
162 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
162 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
163 | 163 | $reset++; |
164 | 164 | if ($globalDebug) echo 'Connect to all...'."\n"; |
165 | 165 | foreach ($hosts as $id => $value) { |
166 | 166 | $host = $value['host']; |
167 | 167 | $globalSources[$id]['last_exec'] = 0; |
168 | 168 | // Here we check type of source(s) |
169 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
170 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
169 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
170 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
171 | 171 | //$formats[$id] = 'deltadbtxt'; |
172 | 172 | $globalSources[$id]['format'] = 'deltadbtxt'; |
173 | 173 | //$last_exec['deltadbtxt'] = 0; |
174 | 174 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
175 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
175 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
176 | 176 | //$formats[$id] = 'vatsimtxt'; |
177 | 177 | $globalSources[$id]['format'] = 'vatsimtxt'; |
178 | 178 | //$last_exec['vatsimtxt'] = 0; |
179 | 179 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
180 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
180 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
181 | 181 | //$formats[$id] = 'aircraftlistjson'; |
182 | 182 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
183 | 183 | //$last_exec['aircraftlistjson'] = 0; |
184 | 184 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
185 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
185 | + } else if (preg_match('/aircraft.json$/i', $host)) { |
|
186 | 186 | //$formats[$id] = 'aircraftjson'; |
187 | 187 | $globalSources[$id]['format'] = 'aircraftjson'; |
188 | 188 | //$last_exec['aircraftlistjson'] = 0; |
189 | 189 | if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
190 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
190 | + } else if (preg_match('/aircraft$/i', $host)) { |
|
191 | 191 | //$formats[$id] = 'planefinderclient'; |
192 | 192 | $globalSources[$id]['format'] = 'planefinderclient'; |
193 | 193 | //$last_exec['aircraftlistjson'] = 0; |
194 | 194 | if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
195 | - } else if (preg_match('/opensky/i',$host)) { |
|
195 | + } else if (preg_match('/opensky/i', $host)) { |
|
196 | 196 | //$formats[$id] = 'aircraftlistjson'; |
197 | 197 | $globalSources[$id]['format'] = 'opensky'; |
198 | 198 | //$last_exec['aircraftlistjson'] = 0; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | exit(0); |
210 | 210 | } |
211 | 211 | */ |
212 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
212 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
213 | 213 | //$formats[$id] = 'planeupdatefaa'; |
214 | 214 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
215 | 215 | //$last_exec['planeupdatefaa'] = 0; |
@@ -218,37 +218,37 @@ discard block |
||
218 | 218 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
219 | 219 | exit(0); |
220 | 220 | } |
221 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
221 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
222 | 222 | //$formats[$id] = 'phpvmacars'; |
223 | 223 | $globalSources[$id]['format'] = 'phpvmacars'; |
224 | 224 | //$last_exec['phpvmacars'] = 0; |
225 | 225 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
226 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
226 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { |
|
227 | 227 | //$formats[$id] = 'phpvmacars'; |
228 | 228 | $globalSources[$id]['format'] = 'vaos'; |
229 | 229 | //$last_exec['phpvmacars'] = 0; |
230 | 230 | if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
231 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
231 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
232 | 232 | //$formats[$id] = 'phpvmacars'; |
233 | 233 | $globalSources[$id]['format'] = 'vam'; |
234 | 234 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
235 | - } else if (preg_match('/whazzup/i',$host)) { |
|
235 | + } else if (preg_match('/whazzup/i', $host)) { |
|
236 | 236 | //$formats[$id] = 'whazzup'; |
237 | 237 | $globalSources[$id]['format'] = 'whazzup'; |
238 | 238 | //$last_exec['whazzup'] = 0; |
239 | 239 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
240 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
240 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
241 | 241 | $globalSources[$id]['format'] = 'blitzortung'; |
242 | 242 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
243 | - } else if (preg_match('/airwhere/i',$host)) { |
|
243 | + } else if (preg_match('/airwhere/i', $host)) { |
|
244 | 244 | $globalSources[$id]['format'] = 'airwhere'; |
245 | 245 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
246 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
246 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
247 | 247 | //$formats[$id] = 'pirepsjson'; |
248 | 248 | $globalSources[$id]['format'] = 'pirepsjson'; |
249 | 249 | //$last_exec['pirepsjson'] = 0; |
250 | 250 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
251 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
251 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
252 | 252 | //$formats[$id] = 'fr24json'; |
253 | 253 | $globalSources[$id]['format'] = 'fr24json'; |
254 | 254 | //$last_exec['fr24json'] = 0; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
258 | 258 | exit(0); |
259 | 259 | } |
260 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
260 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
261 | 261 | //$formats[$id] = 'fr24json'; |
262 | 262 | $globalSources[$id]['format'] = 'myshiptracking'; |
263 | 263 | //$last_exec['fr24json'] = 0; |
@@ -267,22 +267,22 @@ discard block |
||
267 | 267 | exit(0); |
268 | 268 | } |
269 | 269 | //} else if (preg_match('/10001/',$host)) { |
270 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
270 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
271 | 271 | //$formats[$id] = 'tsv'; |
272 | 272 | $globalSources[$id]['format'] = 'tsv'; |
273 | 273 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
274 | 274 | } |
275 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
275 | + } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
276 | 276 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
277 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
277 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
278 | 278 | if ($idf !== false) { |
279 | 279 | $httpfeeds[$id] = $idf; |
280 | 280 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
281 | 281 | } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
282 | 282 | } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
283 | 283 | elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
284 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
285 | - $hostport = explode(':',$host); |
|
284 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
285 | + $hostport = explode(':', $host); |
|
286 | 286 | if (isset($hostport[1])) { |
287 | 287 | $port = $hostport[1]; |
288 | 288 | $hostn = $hostport[0]; |
@@ -292,19 +292,19 @@ discard block |
||
292 | 292 | } |
293 | 293 | $Common = new Common(); |
294 | 294 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
295 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
295 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
296 | 296 | } else { |
297 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
297 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
298 | 298 | } |
299 | 299 | if ($s) { |
300 | 300 | $sockets[$id] = $s; |
301 | 301 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
302 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
302 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
303 | 303 | //$formats[$id] = 'aprs'; |
304 | 304 | $globalSources[$id]['format'] = 'aprs'; |
305 | 305 | //$aprs_connect = 0; |
306 | 306 | //$use_aprs = true; |
307 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
307 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
308 | 308 | $globalSources[$id]['format'] = 'vrstcp'; |
309 | 309 | } elseif ($port == '10001') { |
310 | 310 | //$formats[$id] = 'tsv'; |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
346 | 346 | else $timeout = 20; |
347 | 347 | $errno = ''; |
348 | -$errstr=''; |
|
348 | +$errstr = ''; |
|
349 | 349 | |
350 | 350 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
351 | 351 | /* Initiate connections to all the hosts simultaneously */ |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | //connect_all($globalSources); |
354 | 354 | |
355 | 355 | if (isset($globalProxy) && $globalProxy) { |
356 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
356 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
357 | 357 | } else { |
358 | 358 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
359 | 359 | } |
@@ -383,16 +383,16 @@ discard block |
||
383 | 383 | |
384 | 384 | if ($use_aprs) { |
385 | 385 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
386 | - $APRS=new APRS(); |
|
386 | + $APRS = new APRS(); |
|
387 | 387 | $aprs_connect = 0; |
388 | 388 | $aprs_keep = 120; |
389 | 389 | $aprs_last_tx = time(); |
390 | 390 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
391 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
391 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
392 | 392 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
393 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
393 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
394 | 394 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
395 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
395 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
396 | 396 | if ($aprs_full) $aprs_filter = ''; |
397 | 397 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
398 | 398 | else $aprs_pass = '-1'; |
@@ -406,12 +406,12 @@ discard block |
||
406 | 406 | sleep(1); |
407 | 407 | if ($globalDebug) echo "SCAN MODE \n\n"; |
408 | 408 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
409 | -$endtime = time()+$globalCronEnd; |
|
409 | +$endtime = time() + $globalCronEnd; |
|
410 | 410 | $i = 1; |
411 | 411 | $tt = array(); |
412 | 412 | // Delete all ATC |
413 | 413 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
414 | - $ATC=new ATC($Connection->db); |
|
414 | + $ATC = new ATC($Connection->db); |
|
415 | 415 | } |
416 | 416 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
417 | 417 | $ATC->deleteAll(); |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | while ($i > 0) { |
422 | 422 | if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
423 | 423 | |
424 | - if (!$globalDaemon) $i = $endtime-time(); |
|
424 | + if (!$globalDaemon) $i = $endtime - time(); |
|
425 | 425 | // Delete old ATC |
426 | 426 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
427 | 427 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | } |
436 | 436 | if ($max < $globalMinFetch) { |
437 | 437 | if ($globalDebug) echo 'Sleeping...'."\n"; |
438 | - sleep($globalMinFetch-$max+2); |
|
438 | + sleep($globalMinFetch - $max + 2); |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
@@ -490,10 +490,10 @@ discard block |
||
490 | 490 | //$buffer = $Common->getData($hosts[$id]); |
491 | 491 | $buffer = $Common->getData($value['host']); |
492 | 492 | if ($buffer != '') { |
493 | - $all_data = json_decode($buffer,true); |
|
493 | + $all_data = json_decode($buffer, true); |
|
494 | 494 | foreach ($all_data as $line) { |
495 | 495 | $data = array(); |
496 | - $data['datetime'] = date('Y-m-d H:i:s',$line['tim']); |
|
496 | + $data['datetime'] = date('Y-m-d H:i:s', $line['tim']); |
|
497 | 497 | $data['hex'] = $line['hex']; // hex |
498 | 498 | $data['ident'] = $line['fli']; // ident |
499 | 499 | $data['altitude'] = $line['alt']; // altitude |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | ) |
524 | 524 | ) { |
525 | 525 | date_default_timezone_set('CET'); |
526 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
526 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
527 | 527 | date_default_timezone_set('UTC'); |
528 | 528 | if ($buffer != '') $reset = 0; |
529 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
530 | - $buffer = explode('\n',$buffer); |
|
529 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
530 | + $buffer = explode('\n', $buffer); |
|
531 | 531 | foreach ($buffer as $line) { |
532 | 532 | if ($line != '') { |
533 | 533 | //echo "'".$line."'\n"; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | $ais_data = $AIS->parse_line(trim($line)); |
536 | 536 | $data = array(); |
537 | 537 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
538 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
538 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
539 | 539 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
540 | 540 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
541 | 541 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
548 | 548 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
549 | 549 | if (isset($ais_data['timestamp'])) { |
550 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
550 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
551 | 551 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
552 | 552 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
553 | 553 | $add = true; |
@@ -570,21 +570,21 @@ discard block |
||
570 | 570 | $w = $e = null; |
571 | 571 | |
572 | 572 | if (isset($arr[$id])) { |
573 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
573 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
574 | 574 | if ($nn > 0) { |
575 | 575 | foreach ($httpfeeds as $feed) { |
576 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
576 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
577 | 577 | if ($buffer === FALSE) { |
578 | 578 | connect_all($globalSources); |
579 | 579 | } |
580 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
581 | - $buffer = explode('\n',$buffer); |
|
580 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
581 | + $buffer = explode('\n', $buffer); |
|
582 | 582 | foreach ($buffer as $line) { |
583 | 583 | if ($line != '') { |
584 | 584 | $ais_data = $AIS->parse_line(trim($line)); |
585 | 585 | $data = array(); |
586 | 586 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
587 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
587 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
588 | 588 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
589 | 589 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
590 | 590 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -596,9 +596,9 @@ discard block |
||
596 | 596 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
597 | 597 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
598 | 598 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
599 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
599 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
600 | 600 | if (isset($ais_data['timestamp'])) { |
601 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
601 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
602 | 602 | } else { |
603 | 603 | $data['datetime'] = date('Y-m-d H:i:s'); |
604 | 604 | } |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
631 | 631 | ) |
632 | 632 | ) { |
633 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
633 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
634 | 634 | if ($buffer != '') { |
635 | 635 | //echo $buffer; |
636 | - $all_data = json_decode($buffer,true); |
|
636 | + $all_data = json_decode($buffer, true); |
|
637 | 637 | //print_r($all_data); |
638 | 638 | if (isset($all_data[0]['DATA'])) { |
639 | 639 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | $data['ident'] = $line['NAME']; |
643 | 643 | $data['mmsi'] = $line['MMSI']; |
644 | 644 | if (strlen($data['mmsi']) > 9) { |
645 | - $data['mmsi'] = substr($data['mmsi'],-9); |
|
645 | + $data['mmsi'] = substr($data['mmsi'], -9); |
|
646 | 646 | } |
647 | 647 | $data['speed'] = $line['SOG']; |
648 | 648 | $data['heading'] = $line['COG']; |
@@ -652,8 +652,8 @@ discard block |
||
652 | 652 | //$data['type_id'] = $line['TYPE']; |
653 | 653 | $data['imo'] = $line['IMO']; |
654 | 654 | if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
655 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
656 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
655 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV'])); |
|
656 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
657 | 657 | $data['format_source'] = 'myshiptracking'; |
658 | 658 | $data['id_source'] = $id_source; |
659 | 659 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -670,16 +670,16 @@ discard block |
||
670 | 670 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
671 | 671 | ) |
672 | 672 | ) { |
673 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
673 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
674 | 674 | if ($buffer != '') { |
675 | - $all_data = json_decode($buffer,true); |
|
675 | + $all_data = json_decode($buffer, true); |
|
676 | 676 | if (isset($all_data[0]['mmsi'])) { |
677 | 677 | foreach ($all_data as $line) { |
678 | 678 | if ($line != '') { |
679 | 679 | $data = array(); |
680 | 680 | $data['ident'] = $line['shipname']; |
681 | 681 | $data['callsign'] = $line['callsign']; |
682 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
682 | + $data['mmsi'] = substr($line['mmsi'], -9); |
|
683 | 683 | $data['speed'] = $line['sog']; |
684 | 684 | if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
685 | 685 | $data['latitude'] = $line['latitude']; |
@@ -706,14 +706,14 @@ discard block |
||
706 | 706 | ) { |
707 | 707 | $buffer = $Common->getData($value['host']); |
708 | 708 | if ($buffer != '') { |
709 | - $all_data = json_decode($buffer,true); |
|
709 | + $all_data = json_decode($buffer, true); |
|
710 | 710 | if (isset($all_data['features'][0]['id'])) { |
711 | 711 | foreach ($all_data['features'] as $line) { |
712 | 712 | print_r($line); |
713 | 713 | $data = array(); |
714 | 714 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
715 | 715 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
716 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
716 | + if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9); |
|
717 | 717 | if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
718 | 718 | if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
719 | 719 | if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
@@ -740,31 +740,31 @@ discard block |
||
740 | 740 | ) |
741 | 741 | ) { |
742 | 742 | if ($globalDebug) echo 'download...'; |
743 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
743 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
744 | 744 | if ($globalDebug) echo 'done !'."\n"; |
745 | 745 | // FIXME: Need more work |
746 | 746 | if ($buffer != '') $reset = 0; |
747 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
748 | - $buffer = explode('\n',$buffer); |
|
747 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
748 | + $buffer = explode('\n', $buffer); |
|
749 | 749 | foreach ($buffer as $line) { |
750 | 750 | if ($line != '') { |
751 | 751 | $data = array(); |
752 | 752 | //echo $line."\n"; |
753 | - $data['mmsi'] = (int)substr($line,0,9); |
|
754 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
755 | - $data['status_id'] = substr($line,21,2); |
|
756 | - $data['type_id'] = substr($line,24,3); |
|
757 | - $data['latitude'] = substr($line,29,9); |
|
758 | - $data['longitude'] = substr($line,41,9); |
|
759 | - $data['speed'] = round(substr($line,51,5)); |
|
753 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
754 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
755 | + $data['status_id'] = substr($line, 21, 2); |
|
756 | + $data['type_id'] = substr($line, 24, 3); |
|
757 | + $data['latitude'] = substr($line, 29, 9); |
|
758 | + $data['longitude'] = substr($line, 41, 9); |
|
759 | + $data['speed'] = round(substr($line, 51, 5)); |
|
760 | 760 | //$data['course'] = substr($line,57,5); |
761 | - $data['heading'] = round(substr($line,63,3)); |
|
761 | + $data['heading'] = round(substr($line, 63, 3)); |
|
762 | 762 | //$data['draft'] = substr($line,67,4); |
763 | 763 | //$data['length'] = substr($line,72,3); |
764 | 764 | //$data['beam'] = substr($line,76,2); |
765 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
765 | + $data['ident'] = trim(utf8_encode(substr($line, 78, 20))); |
|
766 | 766 | //$data['callsign'] = trim(substr($line,100,7); |
767 | - $data['arrival_code'] = substr($line,108,20); |
|
767 | + $data['arrival_code'] = substr($line, 108, 20); |
|
768 | 768 | //$data['etaDate'] = substr($line,129,5); |
769 | 769 | //$data['etaTime'] = substr($line,135,5); |
770 | 770 | $data['format_source'] = 'shipplotter'; |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | ) |
785 | 785 | ) { |
786 | 786 | if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
787 | - $authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true); |
|
787 | + $authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true); |
|
788 | 788 | //echo $authsailaway; |
789 | 789 | preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie); |
790 | 790 | if (isset($setcookie[1][0])) { |
@@ -793,18 +793,18 @@ discard block |
||
793 | 793 | } |
794 | 794 | |
795 | 795 | if ($globalDebug) echo '! Download... '; |
796 | - for ($i =0; $i <= 1; $i++) { |
|
796 | + for ($i = 0; $i <= 1; $i++) { |
|
797 | 797 | if ($globalDebug) echo 'Racetype: '.$i.' '; |
798 | 798 | $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
799 | 799 | if ($globalDebug) echo 'done'."\n"; |
800 | 800 | if ($buffer != '') { |
801 | - $all_data = json_decode($buffer,true); |
|
801 | + $all_data = json_decode($buffer, true); |
|
802 | 802 | if (isset($all_data['missions'])) { |
803 | 803 | foreach ($all_data['missions'] as $mission) { |
804 | 804 | $mission_user = $mission['usrname']; |
805 | - $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
|
806 | - if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
|
807 | - if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
805 | + $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle'])); |
|
806 | + if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) { |
|
807 | + if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie); |
|
808 | 808 | else $racebuffer = ''; |
809 | 809 | $bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
810 | 810 | } else { |
@@ -812,19 +812,19 @@ discard block |
||
812 | 812 | $racebuffer = ''; |
813 | 813 | } |
814 | 814 | if ($racebuffer != '') { |
815 | - $race_data = json_decode($racebuffer,true); |
|
815 | + $race_data = json_decode($racebuffer, true); |
|
816 | 816 | //print_r($race_data); |
817 | 817 | unset($racebuffer); |
818 | 818 | if (isset($race_data['mission'])) { |
819 | 819 | $datar = array(); |
820 | 820 | $datar['id'] = $mission['misnr']; |
821 | 821 | $datar['desc'] = $race_data['mission']['misdescr']; |
822 | - $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
823 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
822 | + $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname']))); |
|
823 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle']))); |
|
824 | 824 | $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
825 | 825 | $markers = array(); |
826 | 826 | foreach ($race_data['mission']['course'] as $course) { |
827 | - $markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']); |
|
827 | + $markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']); |
|
828 | 828 | } |
829 | 829 | $datar['markers'] = json_encode($markers); |
830 | 830 | //print_r($datar); |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | } |
833 | 833 | } |
834 | 834 | if ($bufferm != '') { |
835 | - $mission_data = json_decode($bufferm,true); |
|
835 | + $mission_data = json_decode($bufferm, true); |
|
836 | 836 | unset($bufferm); |
837 | 837 | if (isset($mission_data['leaderboard'][0]['results'])) { |
838 | 838 | foreach ($mission_data['leaderboard'][0]['results'] as $sail) { |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | //$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr']; |
846 | 846 | $data['id'] = $sail['misnr'].'-'.$sail['usrnr']; |
847 | 847 | $data['datetime'] = date('Y-m-d H:i:s'); |
848 | - $data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart'])); |
|
848 | + $data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart'])); |
|
849 | 849 | $data['last_update'] = date('Y-m-d H:i:s'); |
850 | 850 | $data['status'] = $sail['status']; |
851 | 851 | $data['type'] = $sail['btptype']; |
@@ -856,16 +856,16 @@ discard block |
||
856 | 856 | $data['longitude'] = $pos['longitude']; |
857 | 857 | } |
858 | 858 | if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') { |
859 | - $resultdescr = explode(',',$sail['resultdescr']); |
|
859 | + $resultdescr = explode(',', $sail['resultdescr']); |
|
860 | 860 | if (count($resultdescr) > 2) { |
861 | - $data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2); |
|
862 | - $data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1])); |
|
861 | + $data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2); |
|
862 | + $data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1])); |
|
863 | 863 | if (isset($resultdescr[3])) { |
864 | - $data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3); |
|
864 | + $data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3); |
|
865 | 865 | } |
866 | 866 | } |
867 | 867 | } |
868 | - $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); |
|
868 | + $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); |
|
869 | 869 | $data['captain_id'] = $sail['usrnr']; |
870 | 870 | $data['captain_name'] = $sail['usrname']; |
871 | 871 | $data['race_id'] = $sail['misnr']; |
@@ -913,8 +913,8 @@ discard block |
||
913 | 913 | ) { |
914 | 914 | //$buffer = $Common->getData($hosts[$id]); |
915 | 915 | $buffer = $Common->getData($value['host']); |
916 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
917 | - $buffer = explode('\n',$buffer); |
|
916 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
917 | + $buffer = explode('\n', $buffer); |
|
918 | 918 | $reset = 0; |
919 | 919 | foreach ($buffer as $line) { |
920 | 920 | if ($line != '') { |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
926 | 926 | $data['pilot_id'] = $line[1]; |
927 | 927 | $data['pilot_name'] = $line[2]; |
928 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
928 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
929 | 929 | $data['ident'] = $line[0]; // ident |
930 | 930 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
931 | 931 | $data['speed'] = $line[8]; // speed |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
942 | 942 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
943 | 943 | $data['departure_airport_icao'] = $line[11]; |
944 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
944 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
945 | 945 | $data['arrival_airport_icao'] = $line[13]; |
946 | 946 | $data['frequency'] = $line[4]; |
947 | 947 | $data['type'] = $line[18]; |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | $data['id_source'] = $id_source; |
951 | 951 | //$data['arrival_airport_time'] = ; |
952 | 952 | if ($line[9] != '') { |
953 | - $aircraft_data = explode('/',$line[9]); |
|
953 | + $aircraft_data = explode('/', $line[9]); |
|
954 | 954 | if (isset($aircraft_data[1])) { |
955 | 955 | $data['aircraft_icao'] = $aircraft_data[1]; |
956 | 956 | } |
@@ -965,9 +965,9 @@ discard block |
||
965 | 965 | if ($line[3] === 'PILOT') $SI->add($data); |
966 | 966 | elseif ($line[3] === 'ATC') { |
967 | 967 | //print_r($data); |
968 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
969 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
970 | - $typec = substr($data['ident'],-3); |
|
968 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
969 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
970 | + $typec = substr($data['ident'], -3); |
|
971 | 971 | if ($typec === 'APP') $data['type'] = 'Approach'; |
972 | 972 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
973 | 973 | elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
@@ -979,8 +979,8 @@ discard block |
||
979 | 979 | elseif ($data['type'] === '') $data['type'] = 'Observer'; |
980 | 980 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
981 | 981 | if (isset($ATC)) { |
982 | - 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']); |
|
983 | - 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']); |
|
982 | + 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']); |
|
983 | + 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']); |
|
984 | 984 | } |
985 | 985 | } |
986 | 986 | unset($data); |
@@ -996,24 +996,24 @@ discard block |
||
996 | 996 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
997 | 997 | ) |
998 | 998 | ) { |
999 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
999 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
1000 | 1000 | if ($buffer != '') { |
1001 | 1001 | $all_data = simplexml_load_string($buffer); |
1002 | - foreach($all_data->children() as $childdata) { |
|
1002 | + foreach ($all_data->children() as $childdata) { |
|
1003 | 1003 | $data = array(); |
1004 | 1004 | $line = $childdata; |
1005 | 1005 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
1006 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
1007 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
1008 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
1009 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
1010 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
1011 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1012 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
1006 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
1007 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
1008 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
1009 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
1010 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
1011 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
1012 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
1013 | 1013 | $data['altitude_relative'] = 'AMSL'; |
1014 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
1014 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
1015 | 1015 | $data['aircraft_icao'] = 'PARAGLIDER'; |
1016 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
1016 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
1017 | 1017 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
1018 | 1018 | $data['format_source'] = $value['format']; |
1019 | 1019 | $SI->add($data); |
@@ -1021,22 +1021,22 @@ discard block |
||
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | $Source->deleteOldLocationByType('gs'); |
1024 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
1024 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
1025 | 1025 | if ($buffer != '') { |
1026 | 1026 | $all_data = simplexml_load_string($buffer); |
1027 | - foreach($all_data->children() as $childdata) { |
|
1027 | + foreach ($all_data->children() as $childdata) { |
|
1028 | 1028 | $data = array(); |
1029 | 1029 | $line = $childdata; |
1030 | - $data['id'] = (int)$line['gsID']; |
|
1031 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
1032 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
1033 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
1030 | + $data['id'] = (int) $line['gsID']; |
|
1031 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
1032 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
1033 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
1034 | 1034 | $data['altitude_relative'] = 'AMSL'; |
1035 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
1035 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
1036 | 1036 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
1037 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
1037 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
1038 | 1038 | } else { |
1039 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
1039 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
1040 | 1040 | } |
1041 | 1041 | unset($data); |
1042 | 1042 | } |
@@ -1054,9 +1054,9 @@ discard block |
||
1054 | 1054 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1055 | 1055 | ) |
1056 | 1056 | ) { |
1057 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
1057 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
1058 | 1058 | if ($buffer != '') { |
1059 | - $all_data = json_decode($buffer,true); |
|
1059 | + $all_data = json_decode($buffer, true); |
|
1060 | 1060 | if (isset($all_data['acList'])) { |
1061 | 1061 | $reset = 0; |
1062 | 1062 | foreach ($all_data['acList'] as $line) { |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
1073 | 1073 | $data['emergency'] = ''; // emergency |
1074 | 1074 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
1075 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1075 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
1076 | 1076 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1077 | 1077 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1078 | 1078 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | $data['verticalrate'] = $line['vrt']; // verticale rate |
1098 | 1098 | $data['squawk'] = $line['squawk']; // squawk |
1099 | 1099 | $data['emergency'] = ''; // emergency |
1100 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1100 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
1101 | 1101 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1102 | 1102 | $data['format_source'] = 'aircraftlistjson'; |
1103 | 1103 | $data['id_source'] = $id_source; |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | ) |
1119 | 1119 | ) { |
1120 | 1120 | $buffer = $Common->getData($value['host']); |
1121 | - $all_data = json_decode($buffer,true); |
|
1121 | + $all_data = json_decode($buffer, true); |
|
1122 | 1122 | if (isset($all_data['planes'])) { |
1123 | 1123 | $reset = 0; |
1124 | 1124 | foreach ($all_data['planes'] as $key => $line) { |
@@ -1135,12 +1135,12 @@ discard block |
||
1135 | 1135 | $data['emergency'] = ''; // emergency |
1136 | 1136 | $data['registration'] = $line[2]; |
1137 | 1137 | $data['aircraft_icao'] = $line[0]; |
1138 | - $deparr = explode('-',$line[1]); |
|
1138 | + $deparr = explode('-', $line[1]); |
|
1139 | 1139 | if (count($deparr) === 2) { |
1140 | 1140 | $data['departure_airport_icao'] = $deparr[0]; |
1141 | 1141 | $data['arrival_airport_icao'] = $deparr[1]; |
1142 | 1142 | } |
1143 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
1143 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
1144 | 1144 | $data['format_source'] = 'planeupdatefaa'; |
1145 | 1145 | $data['id_source'] = $id_source; |
1146 | 1146 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | ) |
1159 | 1159 | ) { |
1160 | 1160 | $buffer = $Common->getData($value['host']); |
1161 | - $all_data = json_decode($buffer,true); |
|
1161 | + $all_data = json_decode($buffer, true); |
|
1162 | 1162 | if (isset($all_data['states'])) { |
1163 | 1163 | $reset = 0; |
1164 | 1164 | foreach ($all_data['states'] as $key => $line) { |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | //$data['emergency'] = ''; // emergency |
1176 | 1176 | //$data['registration'] = $line[2]; |
1177 | 1177 | //$data['aircraft_icao'] = $line[0]; |
1178 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1178 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
1179 | 1179 | $data['format_source'] = 'opensky'; |
1180 | 1180 | $data['id_source'] = $id_source; |
1181 | 1181 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1192,8 +1192,8 @@ discard block |
||
1192 | 1192 | ) |
1193 | 1193 | ) { |
1194 | 1194 | $buffer = $Common->getData($value['host']); |
1195 | - $all_data = json_decode($buffer,true); |
|
1196 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1195 | + $all_data = json_decode($buffer, true); |
|
1196 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) { |
|
1197 | 1197 | $reset = 0; |
1198 | 1198 | foreach ($all_data['aircraft'] as $key => $line) { |
1199 | 1199 | $data = array(); |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | ) |
1232 | 1232 | ) { |
1233 | 1233 | $buffer = $Common->getData($value['host']); |
1234 | - $all_data = json_decode($buffer,true); |
|
1234 | + $all_data = json_decode($buffer, true); |
|
1235 | 1235 | if (isset($all_data['aircraft'])) { |
1236 | 1236 | $reset = 0; |
1237 | 1237 | foreach ($all_data['aircraft'] as $key => $line) { |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | //$data['emergency'] = ''; // emergency |
1249 | 1249 | if (isset($line['reg'])) $data['registration'] = $line['reg']; |
1250 | 1250 | if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
1251 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1251 | + $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']); |
|
1252 | 1252 | $data['format_source'] = 'planefinderclient'; |
1253 | 1253 | $data['id_source'] = $id_source; |
1254 | 1254 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -1267,7 +1267,7 @@ discard block |
||
1267 | 1267 | ) { |
1268 | 1268 | //$buffer = $Common->getData($hosts[$id]); |
1269 | 1269 | $buffer = $Common->getData($value['host']); |
1270 | - $all_data = json_decode($buffer,true); |
|
1270 | + $all_data = json_decode($buffer, true); |
|
1271 | 1271 | if (!empty($all_data)) $reset = 0; |
1272 | 1272 | foreach ($all_data as $key => $line) { |
1273 | 1273 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1305,11 +1305,11 @@ discard block |
||
1305 | 1305 | ) |
1306 | 1306 | ) { |
1307 | 1307 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
1308 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1308 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1309 | 1309 | //echo $buffer; |
1310 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1311 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1312 | - $all_data = json_decode($buffer,true); |
|
1310 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
1311 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
1312 | + $all_data = json_decode($buffer, true); |
|
1313 | 1313 | if (json_last_error() != JSON_ERROR_NONE) { |
1314 | 1314 | die(json_last_error_msg()); |
1315 | 1315 | } |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | //$data['departure_airport_iata'] = $line[11]; |
1333 | 1333 | //$data['arrival_airport_iata'] = $line[12]; |
1334 | 1334 | //$data['emergency'] = ''; // emergency |
1335 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
1335 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1336 | 1336 | $data['format_source'] = 'radarvirtueljson'; |
1337 | 1337 | $data['id_source'] = $id_source; |
1338 | 1338 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1353,14 +1353,14 @@ discard block |
||
1353 | 1353 | ) { |
1354 | 1354 | //$buffer = $Common->getData($hosts[$id]); |
1355 | 1355 | $buffer = $Common->getData($value['host'].'?'.time()); |
1356 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1356 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
1357 | 1357 | |
1358 | 1358 | if (isset($all_data['pireps'])) { |
1359 | 1359 | $reset = 0; |
1360 | 1360 | foreach ($all_data['pireps'] as $line) { |
1361 | 1361 | $data = array(); |
1362 | 1362 | $data['id'] = $line['id']; |
1363 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1363 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1364 | 1364 | $data['ident'] = $line['callsign']; // ident |
1365 | 1365 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
1366 | 1366 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1390,9 +1390,9 @@ discard block |
||
1390 | 1390 | $SI->add($data); |
1391 | 1391 | // print_r($data); |
1392 | 1392 | } elseif ($line['icon'] === 'ct') { |
1393 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1394 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1395 | - $typec = substr($data['ident'],-3); |
|
1393 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1394 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1395 | + $typec = substr($data['ident'], -3); |
|
1396 | 1396 | $data['type'] = ''; |
1397 | 1397 | if ($typec === 'APP') $data['type'] = 'Approach'; |
1398 | 1398 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
@@ -1403,7 +1403,7 @@ discard block |
||
1403 | 1403 | elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
1404 | 1404 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1405 | 1405 | else $data['type'] = 'Observer'; |
1406 | - 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']); |
|
1406 | + 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']); |
|
1407 | 1407 | } |
1408 | 1408 | unset($data); |
1409 | 1409 | } |
@@ -1420,14 +1420,14 @@ discard block |
||
1420 | 1420 | //$buffer = $Common->getData($hosts[$id]); |
1421 | 1421 | if ($globalDebug) echo 'Get Data...'."\n"; |
1422 | 1422 | $buffer = $Common->getData($value['host']); |
1423 | - $all_data = json_decode($buffer,true); |
|
1423 | + $all_data = json_decode($buffer, true); |
|
1424 | 1424 | if ($buffer != '' && is_array($all_data)) { |
1425 | 1425 | $reset = 0; |
1426 | 1426 | foreach ($all_data as $line) { |
1427 | 1427 | $data = array(); |
1428 | 1428 | //$data['id'] = $line['id']; // id not usable |
1429 | 1429 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1430 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1430 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1431 | 1431 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1432 | 1432 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1433 | 1433 | $data['ident'] = $line['flightnum']; // ident |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | //$data['datetime'] = $line['lastupdate']; |
1443 | 1443 | //$data['last_update'] = $line['lastupdate']; |
1444 | 1444 | if (isset($value['timezone'])) { |
1445 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1445 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1446 | 1446 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1447 | 1447 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1448 | 1448 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1458,14 +1458,14 @@ discard block |
||
1458 | 1458 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1459 | 1459 | if (isset($line['aircraftname'])) { |
1460 | 1460 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1461 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1462 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1461 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1462 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1463 | 1463 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1464 | 1464 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1465 | 1465 | else { |
1466 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1467 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1468 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1466 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1467 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1468 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1469 | 1469 | } |
1470 | 1470 | } |
1471 | 1471 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1490,7 +1490,7 @@ discard block |
||
1490 | 1490 | //$buffer = $Common->getData($hosts[$id]); |
1491 | 1491 | if ($globalDebug) echo 'Get Data...'."\n"; |
1492 | 1492 | $buffer = $Common->getData($value['host']); |
1493 | - $all_data = json_decode($buffer,true); |
|
1493 | + $all_data = json_decode($buffer, true); |
|
1494 | 1494 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
1495 | 1495 | $reset = 0; |
1496 | 1496 | foreach ($all_data['ACARSData'] as $line) { |
@@ -1501,7 +1501,7 @@ discard block |
||
1501 | 1501 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1502 | 1502 | if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
1503 | 1503 | if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
1504 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1504 | + $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
1505 | 1505 | if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
1506 | 1506 | $data['altitude'] = $line['altitude']; // altitude |
1507 | 1507 | $data['speed'] = $line['groundspeed']; // speed |
@@ -1512,7 +1512,7 @@ discard block |
||
1512 | 1512 | //$data['squawk'] = ''; // squawk |
1513 | 1513 | //$data['emergency'] = ''; // emergency |
1514 | 1514 | if (isset($value['timezone'])) { |
1515 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1515 | + $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
1516 | 1516 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1517 | 1517 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1518 | 1518 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1548,14 +1548,14 @@ discard block |
||
1548 | 1548 | //$buffer = $Common->getData($hosts[$id]); |
1549 | 1549 | if ($globalDebug) echo 'Get Data...'."\n"; |
1550 | 1550 | $buffer = $Common->getData($value['host']); |
1551 | - $all_data = json_decode($buffer,true); |
|
1551 | + $all_data = json_decode($buffer, true); |
|
1552 | 1552 | if ($buffer != '' && is_array($all_data)) { |
1553 | 1553 | $reset = 0; |
1554 | 1554 | foreach ($all_data as $line) { |
1555 | 1555 | $data = array(); |
1556 | 1556 | //$data['id'] = $line['id']; // id not usable |
1557 | 1557 | $data['id'] = trim($line['flight_id']); |
1558 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1558 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1559 | 1559 | $data['pilot_name'] = $line['pilot_name']; |
1560 | 1560 | $data['pilot_id'] = $line['pilot_id']; |
1561 | 1561 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1599,24 +1599,24 @@ discard block |
||
1599 | 1599 | //$buffer = $Common->getData($hosts[$id]); |
1600 | 1600 | if ($globalDebug) echo 'Get Data...'."\n"; |
1601 | 1601 | $buffer = $Common->getData($value['host']); |
1602 | - $all_data = json_decode($buffer,true); |
|
1602 | + $all_data = json_decode($buffer, true); |
|
1603 | 1603 | if ($buffer != '') { |
1604 | 1604 | $Source->deleteLocationBySource('blitzortung'); |
1605 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1606 | - $buffer = explode('\n',$buffer); |
|
1605 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1606 | + $buffer = explode('\n', $buffer); |
|
1607 | 1607 | foreach ($buffer as $buffer_line) { |
1608 | - $line = json_decode($buffer_line,true); |
|
1608 | + $line = json_decode($buffer_line, true); |
|
1609 | 1609 | if (isset($line['time'])) { |
1610 | 1610 | $data = array(); |
1611 | 1611 | $data['altitude'] = $line['alt']; // altitude |
1612 | 1612 | $data['latitude'] = $line['lat']; // lat |
1613 | 1613 | $data['longitude'] = $line['lon']; // long |
1614 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
1614 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1615 | 1615 | $data['id_source'] = $id_source; |
1616 | 1616 | $data['format_source'] = 'blitzortung'; |
1617 | 1617 | $SI->add($data); |
1618 | 1618 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1619 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
1619 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1620 | 1620 | unset($data); |
1621 | 1621 | } |
1622 | 1622 | } |
@@ -1628,15 +1628,15 @@ discard block |
||
1628 | 1628 | $arr = $httpfeeds; |
1629 | 1629 | $w = $e = null; |
1630 | 1630 | if (isset($arr[$id])) { |
1631 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
1631 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
1632 | 1632 | if ($nn > 0) { |
1633 | 1633 | foreach ($httpfeeds as $feed) { |
1634 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
1634 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
1635 | 1635 | if ($buffer === FALSE) { |
1636 | 1636 | connect_all($globalSources); |
1637 | 1637 | } |
1638 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1639 | - $buffer = explode('\n',$buffer); |
|
1638 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1639 | + $buffer = explode('\n', $buffer); |
|
1640 | 1640 | foreach ($buffer as $line) { |
1641 | 1641 | if ($line != '') { |
1642 | 1642 | $line = json_decode($line, true); |
@@ -1676,11 +1676,11 @@ discard block |
||
1676 | 1676 | //$value = $formats[$nb]; |
1677 | 1677 | $format = $globalSources[$nb]['format']; |
1678 | 1678 | if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
1679 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1679 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1680 | 1680 | } elseif ($format === 'vrstcp') { |
1681 | 1681 | $buffer = @socket_read($r, 6000); |
1682 | 1682 | } else { |
1683 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1683 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1684 | 1684 | } |
1685 | 1685 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1686 | 1686 | //echo $buffer."\n"; |
@@ -1690,8 +1690,8 @@ discard block |
||
1690 | 1690 | //$SI::del(); |
1691 | 1691 | if ($buffer !== FALSE) { |
1692 | 1692 | if ($format === 'vrstcp') { |
1693 | - $buffer = explode('},{',$buffer); |
|
1694 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1693 | + $buffer = explode('},{', $buffer); |
|
1694 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1695 | 1695 | } |
1696 | 1696 | // SBS format is CSV format |
1697 | 1697 | if ($buffer !== FALSE && $buffer !== '') { |
@@ -1718,7 +1718,7 @@ discard block |
||
1718 | 1718 | $ais_data = $AIS->parse_line(trim($buffer)); |
1719 | 1719 | $data = array(); |
1720 | 1720 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
1721 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1721 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
1722 | 1722 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
1723 | 1723 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
1724 | 1724 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -1729,13 +1729,13 @@ discard block |
||
1729 | 1729 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1730 | 1730 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1731 | 1731 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1732 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1732 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1733 | 1733 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1734 | 1734 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1735 | 1735 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1736 | 1736 | |
1737 | 1737 | if (isset($ais_data['timestamp'])) { |
1738 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1738 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1739 | 1739 | } else { |
1740 | 1740 | $data['datetime'] = date('Y-m-d H:i:s'); |
1741 | 1741 | } |
@@ -1746,10 +1746,10 @@ discard block |
||
1746 | 1746 | } elseif ($format === 'flightgearsp') { |
1747 | 1747 | //echo $buffer."\n"; |
1748 | 1748 | if (strlen($buffer) > 5) { |
1749 | - $line = explode(',',$buffer); |
|
1749 | + $line = explode(',', $buffer); |
|
1750 | 1750 | $data = array(); |
1751 | 1751 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1752 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1752 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1753 | 1753 | $data['ident'] = $line[6]; |
1754 | 1754 | $data['aircraft_name'] = $line[7]; |
1755 | 1755 | $data['longitude'] = $line[1]; |
@@ -1766,16 +1766,16 @@ discard block |
||
1766 | 1766 | } elseif ($format === 'acars') { |
1767 | 1767 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1768 | 1768 | $ACARS->add(trim($buffer)); |
1769 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1769 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1770 | 1770 | $ACARS->deleteLiveAcarsData(); |
1771 | 1771 | } elseif ($format === 'flightgearmp') { |
1772 | - if (substr($buffer,0,1) != '#') { |
|
1772 | + if (substr($buffer, 0, 1) != '#') { |
|
1773 | 1773 | $data = array(); |
1774 | 1774 | //echo $buffer."\n"; |
1775 | - $line = explode(' ',$buffer); |
|
1775 | + $line = explode(' ', $buffer); |
|
1776 | 1776 | if (count($line) === 11) { |
1777 | - $userserver = explode('@',$line[0]); |
|
1778 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1777 | + $userserver = explode('@', $line[0]); |
|
1778 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1779 | 1779 | $data['ident'] = $userserver[0]; |
1780 | 1780 | $data['registration'] = $userserver[0]; |
1781 | 1781 | $data['latitude'] = $line[4]; |
@@ -1783,8 +1783,8 @@ discard block |
||
1783 | 1783 | $data['altitude'] = $line[6]; |
1784 | 1784 | $data['datetime'] = date('Y-m-d H:i:s'); |
1785 | 1785 | $aircraft_type = $line[10]; |
1786 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1787 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1786 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1787 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1788 | 1788 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1789 | 1789 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1790 | 1790 | } |
@@ -1793,8 +1793,8 @@ discard block |
||
1793 | 1793 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1794 | 1794 | die; |
1795 | 1795 | } elseif ($format === 'vrstcp') { |
1796 | - foreach($buffer as $all_data) { |
|
1797 | - $line = json_decode('{'.$all_data.'}',true); |
|
1796 | + foreach ($buffer as $all_data) { |
|
1797 | + $line = json_decode('{'.$all_data.'}', true); |
|
1798 | 1798 | $data = array(); |
1799 | 1799 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1800 | 1800 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1820,16 +1820,16 @@ discard block |
||
1820 | 1820 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1821 | 1821 | unset($data); |
1822 | 1822 | } |
1823 | - } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
|
1823 | + } elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') { |
|
1824 | 1824 | $line = explode("\t", $buffer); |
1825 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1825 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1826 | 1826 | $key = $line[$k]; |
1827 | - $lined[$key] = $line[$k+1]; |
|
1827 | + $lined[$key] = $line[$k + 1]; |
|
1828 | 1828 | } |
1829 | 1829 | if (count($lined) > 3) { |
1830 | 1830 | $data['hex'] = $lined['hexid']; |
1831 | 1831 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1832 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1832 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1833 | 1833 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1834 | 1834 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1835 | 1835 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1848,23 +1848,23 @@ discard block |
||
1848 | 1848 | } else $error = true; |
1849 | 1849 | } elseif ($format === 'aprs' && $use_aprs) { |
1850 | 1850 | if ($aprs_connect === 0) { |
1851 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1851 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1852 | 1852 | $aprs_connect = 1; |
1853 | 1853 | } |
1854 | 1854 | |
1855 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1855 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1856 | 1856 | $aprs_last_tx = time(); |
1857 | 1857 | $data_aprs = "# Keep alive"; |
1858 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1858 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1859 | 1859 | } |
1860 | 1860 | |
1861 | 1861 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1862 | 1862 | //echo 'APRS data : '.$buffer."\n"; |
1863 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1864 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1863 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1864 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1865 | 1865 | //echo $buffer."\n"; |
1866 | 1866 | date_default_timezone_set('UTC'); |
1867 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1867 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1868 | 1868 | $line = $APRS->parse($buffer); |
1869 | 1869 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1870 | 1870 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1879,7 +1879,7 @@ discard block |
||
1879 | 1879 | if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
1880 | 1880 | if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
1881 | 1881 | if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
1882 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1882 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1883 | 1883 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1884 | 1884 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1885 | 1885 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1967,29 +1967,29 @@ discard block |
||
1967 | 1967 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1968 | 1968 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1969 | 1969 | $Source->deleteOldLocationByType('gs'); |
1970 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1971 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1970 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
1971 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1972 | 1972 | } else { |
1973 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1973 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1974 | 1974 | } |
1975 | 1975 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
1976 | 1976 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1977 | 1977 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1978 | 1978 | $Source->deleteOldLocationByType('wx'); |
1979 | 1979 | $weather_data = json_encode($line); |
1980 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1981 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1980 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
1981 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1982 | 1982 | } else { |
1983 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1983 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1984 | 1984 | } |
1985 | 1985 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
1986 | 1986 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1987 | 1987 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1988 | 1988 | $Source->deleteOldLocationByType('lightning'); |
1989 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
1990 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1989 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
1990 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1991 | 1991 | } else { |
1992 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1992 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1993 | 1993 | } |
1994 | 1994 | } elseif ($globalDebug) { |
1995 | 1995 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1998,7 +1998,7 @@ discard block |
||
1998 | 1998 | unset($data); |
1999 | 1999 | } |
2000 | 2000 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
2001 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
2001 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
2002 | 2002 | } |
2003 | 2003 | /* |
2004 | 2004 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) { |
@@ -2007,7 +2007,7 @@ discard block |
||
2007 | 2007 | */ |
2008 | 2008 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
2009 | 2009 | elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
2010 | - if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
2010 | + if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
2011 | 2011 | $Source->deleteOldLocationByType('lightning'); |
2012 | 2012 | $Source->deleteOldLocationByType('wx'); |
2013 | 2013 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -2094,7 +2094,7 @@ discard block |
||
2094 | 2094 | connect_all($sourceee); |
2095 | 2095 | $sourceee = array(); |
2096 | 2096 | //connect_all($globalSources); |
2097 | - $tt[$format]=0; |
|
2097 | + $tt[$format] = 0; |
|
2098 | 2098 | break; |
2099 | 2099 | } |
2100 | 2100 | //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
@@ -2104,14 +2104,14 @@ discard block |
||
2104 | 2104 | } else { |
2105 | 2105 | $error = socket_strerror(socket_last_error()); |
2106 | 2106 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
2107 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2107 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
2108 | 2108 | if (isset($globalDebug)) echo "Restarting...\n"; |
2109 | 2109 | // Restart the script if possible |
2110 | 2110 | if (is_array($sockets)) { |
2111 | 2111 | if ($globalDebug) echo "Shutdown all sockets..."; |
2112 | 2112 | |
2113 | 2113 | foreach ($sockets as $sock) { |
2114 | - @socket_shutdown($sock,2); |
|
2114 | + @socket_shutdown($sock, 2); |
|
2115 | 2115 | @socket_close($sock); |
2116 | 2116 | } |
2117 | 2117 |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
23 | 23 | } |
24 | 24 | |
25 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
26 | 28 | |
27 | 29 | if ($globalInstalled === FALSE) { |
28 | 30 | echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
@@ -68,66 +70,107 @@ discard block |
||
68 | 70 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
69 | 71 | if (isset($options['s'])) { |
70 | 72 | $globalSources = array(); |
71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
72 | - else $globalSources[] = array('host' => $options['s']); |
|
73 | -} elseif (isset($options['source'])) { |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['s']); |
|
77 | + } |
|
78 | + } elseif (isset($options['source'])) { |
|
74 | 79 | $globalSources = array(); |
75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
76 | - else $globalSources[] = array('host' => $options['source']); |
|
77 | -} |
|
80 | + if (isset($options['format'])) { |
|
81 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
82 | + } else { |
|
83 | + $globalSources[] = array('host' => $options['source']); |
|
84 | + } |
|
85 | + } |
|
78 | 86 | if (isset($options['aprsserverhost'])) { |
79 | 87 | $globalServerAPRS = TRUE; |
80 | 88 | $globalServerAPRShost = $options['aprsserverhost']; |
81 | 89 | } |
82 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
83 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
84 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
85 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
90 | +if (isset($options['aprsserverport'])) { |
|
91 | + $globalServerAPRSport = $options['aprsserverport']; |
|
92 | +} |
|
93 | +if (isset($options['aprsserverssid'])) { |
|
94 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
95 | +} |
|
96 | +if (isset($options['aprsserverpass'])) { |
|
97 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
98 | +} |
|
99 | +if (isset($options['noaprsserver'])) { |
|
100 | + $globalServerAPRS = FALSE; |
|
101 | +} |
|
86 | 102 | if (isset($options['enable-aircraft'])) { |
87 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
103 | + if ($globalDebug) { |
|
104 | + echo 'Enable Aircraft mode'."\n"; |
|
105 | + } |
|
88 | 106 | $globalAircraft = TRUE; |
89 | 107 | } |
90 | 108 | if (isset($options['disable-aircraft'])) { |
91 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
109 | + if ($globalDebug) { |
|
110 | + echo 'Disable Aircraft mode'."\n"; |
|
111 | + } |
|
92 | 112 | $globalAircraft = FALSE; |
93 | 113 | } |
94 | 114 | if (isset($options['enable-tracker'])) { |
95 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
115 | + if ($globalDebug) { |
|
116 | + echo 'Enable Tracker mode'."\n"; |
|
117 | + } |
|
96 | 118 | $globalTracker = TRUE; |
97 | 119 | } |
98 | 120 | if (isset($options['disable-tracker'])) { |
99 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
121 | + if ($globalDebug) { |
|
122 | + echo 'Disable Tracker mode'."\n"; |
|
123 | + } |
|
100 | 124 | $globalTracker = FALSE; |
101 | 125 | } |
102 | 126 | if (isset($options['enable-marine'])) { |
103 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
127 | + if ($globalDebug) { |
|
128 | + echo 'Enable Marine mode'."\n"; |
|
129 | + } |
|
104 | 130 | $globalMarine = TRUE; |
105 | 131 | } |
106 | 132 | if (isset($options['disable-marine'])) { |
107 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
133 | + if ($globalDebug) { |
|
134 | + echo 'Disable Marine mode'."\n"; |
|
135 | + } |
|
108 | 136 | $globalMarine = FALSE; |
109 | 137 | } |
110 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
111 | -if (isset($options['server'])) $globalServer = TRUE; |
|
112 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
113 | -else $id_source = 1; |
|
138 | +if (isset($options['nodaemon'])) { |
|
139 | + $globalDaemon = FALSE; |
|
140 | +} |
|
141 | +if (isset($options['server'])) { |
|
142 | + $globalServer = TRUE; |
|
143 | +} |
|
144 | +if (isset($options['idsource'])) { |
|
145 | + $id_source = $options['idsource']; |
|
146 | +} else { |
|
147 | + $id_source = 1; |
|
148 | +} |
|
114 | 149 | if (isset($globalServer) && $globalServer) { |
115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
150 | + if ($globalDebug) { |
|
151 | + echo "Using Server Mode\n"; |
|
152 | + } |
|
116 | 153 | $SI=new SpotterServer(); |
117 | 154 | /* |
118 | 155 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
119 | 156 | $SI = new adsb2aprs(); |
120 | 157 | $SI->connect(); |
121 | 158 | */ |
122 | -} else $SI=new SpotterImport($Connection->db); |
|
159 | +} else { |
|
160 | + $SI=new SpotterImport($Connection->db); |
|
161 | +} |
|
123 | 162 | |
124 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
163 | +if (isset($globalTracker) && $globalTracker) { |
|
164 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
165 | +} |
|
125 | 166 | if (isset($globalMarine) && $globalMarine) { |
126 | 167 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
127 | 168 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
128 | 169 | } |
129 | 170 | |
130 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
171 | +if (isset($globalTracker) && $globalTracker) { |
|
172 | + $TI = new TrackerImport($Connection->db); |
|
173 | +} |
|
131 | 174 | if (isset($globalMarine) && $globalMarine) { |
132 | 175 | $AIS = new AIS(); |
133 | 176 | $MI = new MarineImport($Connection->db); |
@@ -152,7 +195,9 @@ discard block |
||
152 | 195 | } |
153 | 196 | |
154 | 197 | // let's try and connect |
155 | -if ($globalDebug) echo "Connecting...\n"; |
|
198 | +if ($globalDebug) { |
|
199 | + echo "Connecting...\n"; |
|
200 | +} |
|
156 | 201 | $use_aprs = false; |
157 | 202 | $aprs_full = false; |
158 | 203 | $reset = 0; |
@@ -161,7 +206,9 @@ discard block |
||
161 | 206 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
162 | 207 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
163 | 208 | $reset++; |
164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
209 | + if ($globalDebug) { |
|
210 | + echo 'Connect to all...'."\n"; |
|
211 | + } |
|
165 | 212 | foreach ($hosts as $id => $value) { |
166 | 213 | $host = $value['host']; |
167 | 214 | $globalSources[$id]['last_exec'] = 0; |
@@ -171,32 +218,44 @@ discard block |
||
171 | 218 | //$formats[$id] = 'deltadbtxt'; |
172 | 219 | $globalSources[$id]['format'] = 'deltadbtxt'; |
173 | 220 | //$last_exec['deltadbtxt'] = 0; |
174 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
221 | + if ($globalDebug) { |
|
222 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
223 | + } |
|
175 | 224 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
176 | 225 | //$formats[$id] = 'vatsimtxt'; |
177 | 226 | $globalSources[$id]['format'] = 'vatsimtxt'; |
178 | 227 | //$last_exec['vatsimtxt'] = 0; |
179 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
228 | + if ($globalDebug) { |
|
229 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
230 | + } |
|
180 | 231 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
181 | 232 | //$formats[$id] = 'aircraftlistjson'; |
182 | 233 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
183 | 234 | //$last_exec['aircraftlistjson'] = 0; |
184 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
237 | + } |
|
185 | 238 | } else if (preg_match('/aircraft.json$/i',$host)) { |
186 | 239 | //$formats[$id] = 'aircraftjson'; |
187 | 240 | $globalSources[$id]['format'] = 'aircraftjson'; |
188 | 241 | //$last_exec['aircraftlistjson'] = 0; |
189 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
244 | + } |
|
190 | 245 | } else if (preg_match('/aircraft$/i',$host)) { |
191 | 246 | //$formats[$id] = 'planefinderclient'; |
192 | 247 | $globalSources[$id]['format'] = 'planefinderclient'; |
193 | 248 | //$last_exec['aircraftlistjson'] = 0; |
194 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
249 | + if ($globalDebug) { |
|
250 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
251 | + } |
|
195 | 252 | } else if (preg_match('/opensky/i',$host)) { |
196 | 253 | //$formats[$id] = 'aircraftlistjson'; |
197 | 254 | $globalSources[$id]['format'] = 'opensky'; |
198 | 255 | //$last_exec['aircraftlistjson'] = 0; |
199 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
256 | + if ($globalDebug) { |
|
257 | + echo "Connect to opensky source (".$host.")...\n"; |
|
258 | + } |
|
200 | 259 | /* |
201 | 260 | // Disabled for now, site change source format |
202 | 261 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -213,7 +272,9 @@ discard block |
||
213 | 272 | //$formats[$id] = 'planeupdatefaa'; |
214 | 273 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
215 | 274 | //$last_exec['planeupdatefaa'] = 0; |
216 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
275 | + if ($globalDebug) { |
|
276 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
277 | + } |
|
217 | 278 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
218 | 279 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
219 | 280 | exit(0); |
@@ -222,37 +283,53 @@ discard block |
||
222 | 283 | //$formats[$id] = 'phpvmacars'; |
223 | 284 | $globalSources[$id]['format'] = 'phpvmacars'; |
224 | 285 | //$last_exec['phpvmacars'] = 0; |
225 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
286 | + if ($globalDebug) { |
|
287 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
288 | + } |
|
226 | 289 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
227 | 290 | //$formats[$id] = 'phpvmacars'; |
228 | 291 | $globalSources[$id]['format'] = 'vaos'; |
229 | 292 | //$last_exec['phpvmacars'] = 0; |
230 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
293 | + if ($globalDebug) { |
|
294 | + echo "Connect to vaos source (".$host.")...\n"; |
|
295 | + } |
|
231 | 296 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
232 | 297 | //$formats[$id] = 'phpvmacars'; |
233 | 298 | $globalSources[$id]['format'] = 'vam'; |
234 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
299 | + if ($globalDebug) { |
|
300 | + echo "Connect to Vam source (".$host.")...\n"; |
|
301 | + } |
|
235 | 302 | } else if (preg_match('/whazzup/i',$host)) { |
236 | 303 | //$formats[$id] = 'whazzup'; |
237 | 304 | $globalSources[$id]['format'] = 'whazzup'; |
238 | 305 | //$last_exec['whazzup'] = 0; |
239 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
306 | + if ($globalDebug) { |
|
307 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
308 | + } |
|
240 | 309 | } else if (preg_match('/blitzortung/i',$host)) { |
241 | 310 | $globalSources[$id]['format'] = 'blitzortung'; |
242 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
311 | + if ($globalDebug) { |
|
312 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
313 | + } |
|
243 | 314 | } else if (preg_match('/airwhere/i',$host)) { |
244 | 315 | $globalSources[$id]['format'] = 'airwhere'; |
245 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
316 | + if ($globalDebug) { |
|
317 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
318 | + } |
|
246 | 319 | } else if (preg_match('/recentpireps/i',$host)) { |
247 | 320 | //$formats[$id] = 'pirepsjson'; |
248 | 321 | $globalSources[$id]['format'] = 'pirepsjson'; |
249 | 322 | //$last_exec['pirepsjson'] = 0; |
250 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
323 | + if ($globalDebug) { |
|
324 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
325 | + } |
|
251 | 326 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
252 | 327 | //$formats[$id] = 'fr24json'; |
253 | 328 | $globalSources[$id]['format'] = 'fr24json'; |
254 | 329 | //$last_exec['fr24json'] = 0; |
255 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
330 | + if ($globalDebug) { |
|
331 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
332 | + } |
|
256 | 333 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
257 | 334 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
258 | 335 | exit(0); |
@@ -261,7 +338,9 @@ discard block |
||
261 | 338 | //$formats[$id] = 'fr24json'; |
262 | 339 | $globalSources[$id]['format'] = 'myshiptracking'; |
263 | 340 | //$last_exec['fr24json'] = 0; |
264 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
341 | + if ($globalDebug) { |
|
342 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
343 | + } |
|
265 | 344 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
266 | 345 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
267 | 346 | exit(0); |
@@ -270,17 +349,26 @@ discard block |
||
270 | 349 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
271 | 350 | //$formats[$id] = 'tsv'; |
272 | 351 | $globalSources[$id]['format'] = 'tsv'; |
273 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
352 | + if ($globalDebug) { |
|
353 | + echo "Connect to tsv source (".$host.")...\n"; |
|
354 | + } |
|
274 | 355 | } |
275 | 356 | } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
276 | 357 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
277 | 358 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
278 | 359 | if ($idf !== false) { |
279 | 360 | $httpfeeds[$id] = $idf; |
280 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
281 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
282 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
283 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
361 | + if ($globalDebug) { |
|
362 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
363 | + } |
|
364 | + } elseif ($globalDebug) { |
|
365 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
366 | + } |
|
367 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
368 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
369 | + } elseif ($globalDebug) { |
|
370 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
371 | + } |
|
284 | 372 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
285 | 373 | $hostport = explode(':',$host); |
286 | 374 | if (isset($hostport[1])) { |
@@ -320,19 +408,27 @@ discard block |
||
320 | 408 | //$formats[$id] = 'beast'; |
321 | 409 | $globalSources[$id]['format'] = 'beast'; |
322 | 410 | //} else $formats[$id] = 'sbs'; |
323 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
411 | + } else { |
|
412 | + $globalSources[$id]['format'] = 'sbs'; |
|
413 | + } |
|
324 | 414 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
325 | 415 | } |
326 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
416 | + if ($globalDebug) { |
|
417 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
418 | + } |
|
327 | 419 | } else { |
328 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
420 | + if ($globalDebug) { |
|
421 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
422 | + } |
|
329 | 423 | sleep(10); |
330 | 424 | connect_all($hosts); |
331 | 425 | } |
332 | 426 | } |
333 | 427 | } |
334 | 428 | } |
335 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
429 | +if (!isset($globalMinFetch)) { |
|
430 | + $globalMinFetch = 15; |
|
431 | +} |
|
336 | 432 | |
337 | 433 | // Initialize all |
338 | 434 | $status = array(); |
@@ -341,13 +437,19 @@ discard block |
||
341 | 437 | $formats = array(); |
342 | 438 | $last_exec = array(); |
343 | 439 | $time = time(); |
344 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
345 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
346 | -else $timeout = 20; |
|
440 | +if (isset($globalSourcesTimeout)) { |
|
441 | + $timeout = $globalSourcesTimeOut; |
|
442 | +} else if (isset($globalSBS1TimeOut)) { |
|
443 | + $timeout = $globalSBS1TimeOut; |
|
444 | +} else { |
|
445 | + $timeout = 20; |
|
446 | +} |
|
347 | 447 | $errno = ''; |
348 | 448 | $errstr=''; |
349 | 449 | |
350 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
450 | +if (!isset($globalDaemon)) { |
|
451 | + $globalDaemon = TRUE; |
|
452 | +} |
|
351 | 453 | /* Initiate connections to all the hosts simultaneously */ |
352 | 454 | //connect_all($hosts); |
353 | 455 | //connect_all($globalSources); |
@@ -376,7 +478,9 @@ discard block |
||
376 | 478 | if (isset($source['format']) && $source['format'] == 'aprs') { |
377 | 479 | $aprs_connect = 0; |
378 | 480 | $use_aprs = true; |
379 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
481 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
482 | + $aprs_full = true; |
|
483 | + } |
|
380 | 484 | break; |
381 | 485 | } |
382 | 486 | } |
@@ -387,25 +491,46 @@ discard block |
||
387 | 491 | $aprs_connect = 0; |
388 | 492 | $aprs_keep = 120; |
389 | 493 | $aprs_last_tx = time(); |
390 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
391 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
392 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
393 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
394 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
395 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
396 | - if ($aprs_full) $aprs_filter = ''; |
|
397 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
398 | - else $aprs_pass = '-1'; |
|
494 | + if (isset($globalAPRSversion)) { |
|
495 | + $aprs_version = $globalAPRSversion; |
|
496 | + } else { |
|
497 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
498 | + } |
|
499 | + if (isset($globalAPRSssid)) { |
|
500 | + $aprs_ssid = $globalAPRSssid; |
|
501 | + } else { |
|
502 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
503 | + } |
|
504 | + if (isset($globalAPRSfilter)) { |
|
505 | + $aprs_filter = $globalAPRSfilter; |
|
506 | + } else { |
|
507 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
508 | + } |
|
509 | + if ($aprs_full) { |
|
510 | + $aprs_filter = ''; |
|
511 | + } |
|
512 | + if (isset($globalAPRSpass)) { |
|
513 | + $aprs_pass = $globalAPRSpass; |
|
514 | + } else { |
|
515 | + $aprs_pass = '-1'; |
|
516 | + } |
|
399 | 517 | |
400 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
401 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
402 | -} |
|
518 | + if ($aprs_filter != '') { |
|
519 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
520 | + } else { |
|
521 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
522 | + } |
|
523 | + } |
|
403 | 524 | |
404 | 525 | // connected - lets do some work |
405 | 526 | //if ($globalDebug) echo "Connected!\n"; |
406 | 527 | sleep(1); |
407 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
408 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
528 | +if ($globalDebug) { |
|
529 | + echo "SCAN MODE \n\n"; |
|
530 | +} |
|
531 | +if (!isset($globalCronEnd)) { |
|
532 | + $globalCronEnd = 60; |
|
533 | +} |
|
409 | 534 | $endtime = time()+$globalCronEnd; |
410 | 535 | $i = 1; |
411 | 536 | $tt = array(); |
@@ -419,22 +544,32 @@ discard block |
||
419 | 544 | |
420 | 545 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
421 | 546 | while ($i > 0) { |
422 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
547 | + if (function_exists('pcntl_fork')) { |
|
548 | + pcntl_signal_dispatch(); |
|
549 | + } |
|
423 | 550 | |
424 | - if (!$globalDaemon) $i = $endtime-time(); |
|
551 | + if (!$globalDaemon) { |
|
552 | + $i = $endtime-time(); |
|
553 | + } |
|
425 | 554 | // Delete old ATC |
426 | 555 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
427 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
556 | + if ($globalDebug) { |
|
557 | + echo 'Delete old ATC...'."\n"; |
|
558 | + } |
|
428 | 559 | $ATC->deleteOldATC(); |
429 | 560 | } |
430 | 561 | |
431 | 562 | if (count($last_exec) == count($globalSources)) { |
432 | 563 | $max = $globalMinFetch; |
433 | 564 | foreach ($last_exec as $last) { |
434 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
565 | + if ((time() - $last['last']) < $max) { |
|
566 | + $max = time() - $last['last']; |
|
567 | + } |
|
435 | 568 | } |
436 | 569 | if ($max < $globalMinFetch) { |
437 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
570 | + if ($globalDebug) { |
|
571 | + echo 'Sleeping...'."\n"; |
|
572 | + } |
|
438 | 573 | sleep($globalMinFetch-$max+2); |
439 | 574 | } |
440 | 575 | } |
@@ -444,7 +579,9 @@ discard block |
||
444 | 579 | foreach ($globalSources as $id => $value) { |
445 | 580 | date_default_timezone_set('UTC'); |
446 | 581 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
447 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
582 | + if (!isset($last_exec[$id]['last'])) { |
|
583 | + $last_exec[$id]['last'] = 0; |
|
584 | + } |
|
448 | 585 | if ($value['format'] === 'deltadbtxt' && |
449 | 586 | ( |
450 | 587 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -453,7 +590,9 @@ discard block |
||
453 | 590 | ) { |
454 | 591 | //$buffer = $Common->getData($hosts[$id]); |
455 | 592 | $buffer = $Common->getData($value['host']); |
456 | - if ($buffer != '') $reset = 0; |
|
593 | + if ($buffer != '') { |
|
594 | + $reset = 0; |
|
595 | + } |
|
457 | 596 | $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
458 | 597 | $buffer = explode('\n', $buffer); |
459 | 598 | foreach ($buffer as $line) { |
@@ -462,20 +601,41 @@ discard block |
||
462 | 601 | $data = array(); |
463 | 602 | $data['hex'] = $line[1]; // hex |
464 | 603 | $data['ident'] = $line[2]; // ident |
465 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
466 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
467 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
468 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
469 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
604 | + if (isset($line[3])) { |
|
605 | + $data['altitude'] = $line[3]; |
|
606 | + } |
|
607 | + // altitude |
|
608 | + if (isset($line[4])) { |
|
609 | + $data['speed'] = $line[4]; |
|
610 | + } |
|
611 | + // speed |
|
612 | + if (isset($line[5])) { |
|
613 | + $data['heading'] = $line[5]; |
|
614 | + } |
|
615 | + // heading |
|
616 | + if (isset($line[6])) { |
|
617 | + $data['latitude'] = $line[6]; |
|
618 | + } |
|
619 | + // lat |
|
620 | + if (isset($line[7])) { |
|
621 | + $data['longitude'] = $line[7]; |
|
622 | + } |
|
623 | + // long |
|
470 | 624 | $data['verticalrate'] = ''; // vertical rate |
471 | 625 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
472 | 626 | $data['emergency'] = ''; // emergency |
473 | 627 | $data['datetime'] = date('Y-m-d H:i:s'); |
474 | 628 | $data['format_source'] = 'deltadbtxt'; |
475 | 629 | $data['id_source'] = $id_source; |
476 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
477 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
478 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
630 | + if (isset($value['name']) && $value['name'] != '') { |
|
631 | + $data['source_name'] = $value['name']; |
|
632 | + } |
|
633 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
634 | + $data['noarchive'] = true; |
|
635 | + } |
|
636 | + if (isset($value['sourcestats'])) { |
|
637 | + $data['sourcestats'] = $value['sourcestats']; |
|
638 | + } |
|
479 | 639 | $SI->add($data); |
480 | 640 | unset($data); |
481 | 641 | } |
@@ -508,9 +668,15 @@ discard block |
||
508 | 668 | $data['datetime'] = date('Y-m-d H:i:s'); |
509 | 669 | $data['format_source'] = 'radarcapejson'; |
510 | 670 | $data['id_source'] = $id_source; |
511 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
512 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
513 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
671 | + if (isset($value['name']) && $value['name'] != '') { |
|
672 | + $data['source_name'] = $value['name']; |
|
673 | + } |
|
674 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
675 | + $data['noarchive'] = true; |
|
676 | + } |
|
677 | + if (isset($value['sourcestats'])) { |
|
678 | + $data['sourcestats'] = $value['sourcestats']; |
|
679 | + } |
|
514 | 680 | $SI->add($data); |
515 | 681 | unset($data); |
516 | 682 | } |
@@ -525,7 +691,9 @@ discard block |
||
525 | 691 | date_default_timezone_set('CET'); |
526 | 692 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
527 | 693 | date_default_timezone_set('UTC'); |
528 | - if ($buffer != '') $reset = 0; |
|
694 | + if ($buffer != '') { |
|
695 | + $reset = 0; |
|
696 | + } |
|
529 | 697 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
530 | 698 | $buffer = explode('\n',$buffer); |
531 | 699 | foreach ($buffer as $line) { |
@@ -534,18 +702,42 @@ discard block |
||
534 | 702 | $add = false; |
535 | 703 | $ais_data = $AIS->parse_line(trim($line)); |
536 | 704 | $data = array(); |
537 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
538 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
539 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
540 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
541 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
542 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
543 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
544 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
545 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
546 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
547 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
548 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
705 | + if (isset($ais_data['ident'])) { |
|
706 | + $data['ident'] = $ais_data['ident']; |
|
707 | + } |
|
708 | + if (isset($ais_data['mmsi'])) { |
|
709 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
710 | + } |
|
711 | + if (isset($ais_data['speed'])) { |
|
712 | + $data['speed'] = $ais_data['speed']; |
|
713 | + } |
|
714 | + if (isset($ais_data['heading'])) { |
|
715 | + $data['heading'] = $ais_data['heading']; |
|
716 | + } |
|
717 | + if (isset($ais_data['latitude'])) { |
|
718 | + $data['latitude'] = $ais_data['latitude']; |
|
719 | + } |
|
720 | + if (isset($ais_data['longitude'])) { |
|
721 | + $data['longitude'] = $ais_data['longitude']; |
|
722 | + } |
|
723 | + if (isset($ais_data['status'])) { |
|
724 | + $data['status'] = $ais_data['status']; |
|
725 | + } |
|
726 | + if (isset($ais_data['statusid'])) { |
|
727 | + $data['status_id'] = $ais_data['statusid']; |
|
728 | + } |
|
729 | + if (isset($ais_data['type'])) { |
|
730 | + $data['type'] = $ais_data['type']; |
|
731 | + } |
|
732 | + if (isset($ais_data['typeid'])) { |
|
733 | + $data['type_id'] = $ais_data['typeid']; |
|
734 | + } |
|
735 | + if (isset($ais_data['imo'])) { |
|
736 | + $data['imo'] = $ais_data['imo']; |
|
737 | + } |
|
738 | + if (isset($ais_data['callsign'])) { |
|
739 | + $data['callsign'] = $ais_data['callsign']; |
|
740 | + } |
|
549 | 741 | if (isset($ais_data['timestamp'])) { |
550 | 742 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
551 | 743 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -559,8 +751,12 @@ discard block |
||
559 | 751 | $data['format_source'] = 'aisnmeatxt'; |
560 | 752 | $data['id_source'] = $id_source; |
561 | 753 | //print_r($data); |
562 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
563 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
754 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
755 | + $data['noarchive'] = true; |
|
756 | + } |
|
757 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
758 | + $MI->add($data); |
|
759 | + } |
|
564 | 760 | unset($data); |
565 | 761 | } |
566 | 762 | } |
@@ -583,20 +779,48 @@ discard block |
||
583 | 779 | if ($line != '') { |
584 | 780 | $ais_data = $AIS->parse_line(trim($line)); |
585 | 781 | $data = array(); |
586 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
587 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
588 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
589 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
590 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
591 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
592 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
593 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
594 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
595 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
596 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
597 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
598 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
599 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
782 | + if (isset($ais_data['ident'])) { |
|
783 | + $data['ident'] = $ais_data['ident']; |
|
784 | + } |
|
785 | + if (isset($ais_data['mmsi'])) { |
|
786 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
787 | + } |
|
788 | + if (isset($ais_data['speed'])) { |
|
789 | + $data['speed'] = $ais_data['speed']; |
|
790 | + } |
|
791 | + if (isset($ais_data['heading'])) { |
|
792 | + $data['heading'] = $ais_data['heading']; |
|
793 | + } |
|
794 | + if (isset($ais_data['latitude'])) { |
|
795 | + $data['latitude'] = $ais_data['latitude']; |
|
796 | + } |
|
797 | + if (isset($ais_data['longitude'])) { |
|
798 | + $data['longitude'] = $ais_data['longitude']; |
|
799 | + } |
|
800 | + if (isset($ais_data['status'])) { |
|
801 | + $data['status'] = $ais_data['status']; |
|
802 | + } |
|
803 | + if (isset($ais_data['statusid'])) { |
|
804 | + $data['status_id'] = $ais_data['statusid']; |
|
805 | + } |
|
806 | + if (isset($ais_data['type'])) { |
|
807 | + $data['type'] = $ais_data['type']; |
|
808 | + } |
|
809 | + if (isset($ais_data['typeid'])) { |
|
810 | + $data['type_id'] = $ais_data['typeid']; |
|
811 | + } |
|
812 | + if (isset($ais_data['imo'])) { |
|
813 | + $data['imo'] = $ais_data['imo']; |
|
814 | + } |
|
815 | + if (isset($ais_data['callsign'])) { |
|
816 | + $data['callsign'] = $ais_data['callsign']; |
|
817 | + } |
|
818 | + if (isset($ais_data['destination'])) { |
|
819 | + $data['arrival_code'] = $ais_data['destination']; |
|
820 | + } |
|
821 | + if (isset($ais_data['eta_ts'])) { |
|
822 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
823 | + } |
|
600 | 824 | if (isset($ais_data['timestamp'])) { |
601 | 825 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
602 | 826 | } else { |
@@ -604,18 +828,27 @@ discard block |
||
604 | 828 | } |
605 | 829 | $data['format_source'] = 'aisnmeahttp'; |
606 | 830 | $data['id_source'] = $id_source; |
607 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
608 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
831 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
832 | + $data['noarchive'] = true; |
|
833 | + } |
|
834 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
835 | + $MI->add($data); |
|
836 | + } |
|
609 | 837 | unset($data); |
610 | 838 | } |
611 | 839 | } |
612 | 840 | } |
613 | 841 | } else { |
614 | 842 | $format = $value['format']; |
615 | - if (isset($tt[$format])) $tt[$format]++; |
|
616 | - else $tt[$format] = 0; |
|
843 | + if (isset($tt[$format])) { |
|
844 | + $tt[$format]++; |
|
845 | + } else { |
|
846 | + $tt[$format] = 0; |
|
847 | + } |
|
617 | 848 | if ($tt[$format] > 30) { |
618 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
849 | + if ($globalDebug) { |
|
850 | + echo 'Reconnect...'."\n"; |
|
851 | + } |
|
619 | 852 | sleep(2); |
620 | 853 | //$sourceeen[] = $value; |
621 | 854 | //connect_all($sourceeen); |
@@ -651,12 +884,18 @@ discard block |
||
651 | 884 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
652 | 885 | //$data['type_id'] = $line['TYPE']; |
653 | 886 | $data['imo'] = $line['IMO']; |
654 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
655 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
887 | + if ($line['DEST'] != '') { |
|
888 | + $data['arrival_code'] = $line['DEST']; |
|
889 | + } |
|
890 | + if ($line['ARV'] != '') { |
|
891 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
892 | + } |
|
656 | 893 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
657 | 894 | $data['format_source'] = 'myshiptracking'; |
658 | 895 | $data['id_source'] = $id_source; |
659 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
896 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
897 | + $data['noarchive'] = true; |
|
898 | + } |
|
660 | 899 | $MI->add($data); |
661 | 900 | unset($data); |
662 | 901 | } |
@@ -681,7 +920,9 @@ discard block |
||
681 | 920 | $data['callsign'] = $line['callsign']; |
682 | 921 | $data['mmsi'] = substr($line['mmsi'],-9); |
683 | 922 | $data['speed'] = $line['sog']; |
684 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
923 | + if ($line['heading'] != '511') { |
|
924 | + $data['heading'] = $line['heading']; |
|
925 | + } |
|
685 | 926 | $data['latitude'] = $line['latitude']; |
686 | 927 | $data['longitude'] = $line['longitude']; |
687 | 928 | $data['type_id'] = $line['shiptype']; |
@@ -689,7 +930,9 @@ discard block |
||
689 | 930 | $data['datetime'] = $line['time']; |
690 | 931 | $data['format_source'] = 'boatbeaconapp'; |
691 | 932 | $data['id_source'] = $id_source; |
692 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
933 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
934 | + $data['noarchive'] = true; |
|
935 | + } |
|
693 | 936 | $MI->add($data); |
694 | 937 | unset($data); |
695 | 938 | } |
@@ -711,22 +954,44 @@ discard block |
||
711 | 954 | foreach ($all_data['features'] as $line) { |
712 | 955 | print_r($line); |
713 | 956 | $data = array(); |
714 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
715 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
716 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
717 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
718 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
719 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
957 | + if (isset($line['properties']['name'])) { |
|
958 | + $data['ident'] = $line['properties']['name']; |
|
959 | + } |
|
960 | + if (isset($line['properties']['callsign'])) { |
|
961 | + $data['callsign'] = $line['properties']['callsign']; |
|
962 | + } |
|
963 | + if (isset($line['properties']['mmsi'])) { |
|
964 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
965 | + } |
|
966 | + if (isset($line['properties']['imo'])) { |
|
967 | + $data['imo'] = $line['properties']['imo']; |
|
968 | + } |
|
969 | + if (isset($line['properties']['speed'])) { |
|
970 | + $data['speed'] = $line['properties']['speed']; |
|
971 | + } |
|
972 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
973 | + $data['heading'] = $line['properties']['heading']; |
|
974 | + } |
|
720 | 975 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
721 | 976 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
722 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
723 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
724 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
977 | + if (isset($line['properties']['vesselType'])) { |
|
978 | + $data['type'] = $line['properties']['vesselType']; |
|
979 | + } |
|
980 | + if (isset($line['properties']['destination'])) { |
|
981 | + $data['arrival_code'] = $line['properties']['destination']; |
|
982 | + } |
|
983 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
984 | + $data['arrival_date'] = $line['properties']['eta']; |
|
985 | + } |
|
725 | 986 | $data['format_source'] = 'boatnerd'; |
726 | 987 | $data['id_source'] = $id_source; |
727 | 988 | $data['datetime'] = date('Y-m-d H:i:s'); |
728 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
729 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
989 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
990 | + $data['noarchive'] = true; |
|
991 | + } |
|
992 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
993 | + $MI->add($data); |
|
994 | + } |
|
730 | 995 | unset($data); |
731 | 996 | } |
732 | 997 | } |
@@ -739,11 +1004,17 @@ discard block |
||
739 | 1004 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
740 | 1005 | ) |
741 | 1006 | ) { |
742 | - if ($globalDebug) echo 'download...'; |
|
1007 | + if ($globalDebug) { |
|
1008 | + echo 'download...'; |
|
1009 | + } |
|
743 | 1010 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
744 | - if ($globalDebug) echo 'done !'."\n"; |
|
1011 | + if ($globalDebug) { |
|
1012 | + echo 'done !'."\n"; |
|
1013 | + } |
|
745 | 1014 | // FIXME: Need more work |
746 | - if ($buffer != '') $reset = 0; |
|
1015 | + if ($buffer != '') { |
|
1016 | + $reset = 0; |
|
1017 | + } |
|
747 | 1018 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
748 | 1019 | $buffer = explode('\n',$buffer); |
749 | 1020 | foreach ($buffer as $line) { |
@@ -769,7 +1040,9 @@ discard block |
||
769 | 1040 | //$data['etaTime'] = substr($line,135,5); |
770 | 1041 | $data['format_source'] = 'shipplotter'; |
771 | 1042 | $data['id_source'] = $id_source; |
772 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1043 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1044 | + $data['noarchive'] = true; |
|
1045 | + } |
|
773 | 1046 | //print_r($data); |
774 | 1047 | //echo 'Add...'."\n"; |
775 | 1048 | $MI->add($data); |
@@ -792,11 +1065,17 @@ discard block |
||
792 | 1065 | } |
793 | 1066 | } |
794 | 1067 | |
795 | - if ($globalDebug) echo '! Download... '; |
|
1068 | + if ($globalDebug) { |
|
1069 | + echo '! Download... '; |
|
1070 | + } |
|
796 | 1071 | for ($i =0; $i <= 1; $i++) { |
797 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
1072 | + if ($globalDebug) { |
|
1073 | + echo 'Racetype: '.$i.' '; |
|
1074 | + } |
|
798 | 1075 | $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
799 | - if ($globalDebug) echo 'done'."\n"; |
|
1076 | + if ($globalDebug) { |
|
1077 | + echo 'done'."\n"; |
|
1078 | + } |
|
800 | 1079 | if ($buffer != '') { |
801 | 1080 | $all_data = json_decode($buffer,true); |
802 | 1081 | if (isset($all_data['missions'])) { |
@@ -804,8 +1083,11 @@ discard block |
||
804 | 1083 | $mission_user = $mission['usrname']; |
805 | 1084 | $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
806 | 1085 | if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
807 | - if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
808 | - else $racebuffer = ''; |
|
1086 | + if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { |
|
1087 | + $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
1088 | + } else { |
|
1089 | + $racebuffer = ''; |
|
1090 | + } |
|
809 | 1091 | $bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
810 | 1092 | } else { |
811 | 1093 | $bufferm = ''; |
@@ -869,7 +1151,9 @@ discard block |
||
869 | 1151 | $data['captain_id'] = $sail['usrnr']; |
870 | 1152 | $data['captain_name'] = $sail['usrname']; |
871 | 1153 | $data['race_id'] = $sail['misnr']; |
872 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; |
|
1154 | + if ($sail['rank'] != 'DNF') { |
|
1155 | + $data['race_rank'] = $sail['rank']; |
|
1156 | + } |
|
873 | 1157 | $data['race_time'] = $sail['racetime']; |
874 | 1158 | if ($mission_user != '') { |
875 | 1159 | $data['race_name'] = $mission_name.' ('.$mission_user.')'; |
@@ -879,7 +1163,9 @@ discard block |
||
879 | 1163 | //$data['callsign'] = trim(substr($line,100,7); |
880 | 1164 | $data['format_source'] = 'sailaway'; |
881 | 1165 | $data['id_source'] = $id_source; |
882 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1166 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1167 | + $data['noarchive'] = true; |
|
1168 | + } |
|
883 | 1169 | //print_r($data); |
884 | 1170 | //if ($data['race_id'] == '48') print_r($data); |
885 | 1171 | //echo 'Add...'."\n"; |
@@ -921,16 +1207,28 @@ discard block |
||
921 | 1207 | $line = explode(':', $line); |
922 | 1208 | if (count($line) > 30 && $line[0] != 'callsign') { |
923 | 1209 | $data = array(); |
924 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
925 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1210 | + if (isset($line[37]) && $line[37] != '') { |
|
1211 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
1212 | + } else { |
|
1213 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1214 | + } |
|
926 | 1215 | $data['pilot_id'] = $line[1]; |
927 | 1216 | $data['pilot_name'] = $line[2]; |
928 | 1217 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
929 | 1218 | $data['ident'] = $line[0]; // ident |
930 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
1219 | + if ($line[7] != '' && $line[7] != 0) { |
|
1220 | + $data['altitude'] = $line[7]; |
|
1221 | + } |
|
1222 | + // altitude |
|
931 | 1223 | $data['speed'] = $line[8]; // speed |
932 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
933 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
1224 | + if (isset($line[45])) { |
|
1225 | + $data['heading'] = $line[45]; |
|
1226 | + } |
|
1227 | + // heading |
|
1228 | + elseif (isset($line[38])) { |
|
1229 | + $data['heading'] = $line[38]; |
|
1230 | + } |
|
1231 | + // heading |
|
934 | 1232 | $data['latitude'] = $line[5]; // lat |
935 | 1233 | $data['longitude'] = $line[6]; // long |
936 | 1234 | $data['verticalrate'] = ''; // vertical rate |
@@ -946,7 +1244,9 @@ discard block |
||
946 | 1244 | $data['frequency'] = $line[4]; |
947 | 1245 | $data['type'] = $line[18]; |
948 | 1246 | $data['range'] = $line[19]; |
949 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
1247 | + if (isset($line[35])) { |
|
1248 | + $data['info'] = $line[35]; |
|
1249 | + } |
|
950 | 1250 | $data['id_source'] = $id_source; |
951 | 1251 | //$data['arrival_airport_time'] = ; |
952 | 1252 | if ($line[9] != '') { |
@@ -960,27 +1260,47 @@ discard block |
||
960 | 1260 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
961 | 1261 | */ |
962 | 1262 | $data['format_source'] = $value['format']; |
963 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
964 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
965 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
966 | - elseif ($line[3] === 'ATC') { |
|
1263 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1264 | + $data['noarchive'] = true; |
|
1265 | + } |
|
1266 | + if (isset($value['name']) && $value['name'] != '') { |
|
1267 | + $data['source_name'] = $value['name']; |
|
1268 | + } |
|
1269 | + if ($line[3] === 'PILOT') { |
|
1270 | + $SI->add($data); |
|
1271 | + } elseif ($line[3] === 'ATC') { |
|
967 | 1272 | //print_r($data); |
968 | 1273 | $data['info'] = str_replace('^§','<br />',$data['info']); |
969 | 1274 | $data['info'] = str_replace('&sect;','',$data['info']); |
970 | 1275 | $typec = substr($data['ident'],-3); |
971 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
972 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
973 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
974 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
975 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
976 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
977 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
978 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
979 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
980 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1276 | + if ($typec === 'APP') { |
|
1277 | + $data['type'] = 'Approach'; |
|
1278 | + } elseif ($typec === 'TWR') { |
|
1279 | + $data['type'] = 'Tower'; |
|
1280 | + } elseif ($typec === 'OBS') { |
|
1281 | + $data['type'] = 'Observer'; |
|
1282 | + } elseif ($typec === 'GND') { |
|
1283 | + $data['type'] = 'Ground'; |
|
1284 | + } elseif ($typec === 'DEL') { |
|
1285 | + $data['type'] = 'Delivery'; |
|
1286 | + } elseif ($typec === 'DEP') { |
|
1287 | + $data['type'] = 'Departure'; |
|
1288 | + } elseif ($typec === 'FSS') { |
|
1289 | + $data['type'] = 'Flight Service Station'; |
|
1290 | + } elseif ($typec === 'CTR') { |
|
1291 | + $data['type'] = 'Control Radar or Centre'; |
|
1292 | + } elseif ($data['type'] === '') { |
|
1293 | + $data['type'] = 'Observer'; |
|
1294 | + } |
|
1295 | + if (!isset($data['source_name'])) { |
|
1296 | + $data['source_name'] = ''; |
|
1297 | + } |
|
981 | 1298 | if (isset($ATC)) { |
982 | - 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']); |
|
983 | - 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']); |
|
1299 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1300 | + 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']); |
|
1301 | + } else { |
|
1302 | + 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']); |
|
1303 | + } |
|
984 | 1304 | } |
985 | 1305 | } |
986 | 1306 | unset($data); |
@@ -1007,14 +1327,20 @@ discard block |
||
1007 | 1327 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
1008 | 1328 | $data['latitude'] = (float)$line['pktLatitude']; |
1009 | 1329 | $data['longitude'] = (float)$line['pktLongitude']; |
1010 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
1011 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1330 | + if ((float)$line['pktTrack'] != 0) { |
|
1331 | + $data['heading'] = (float)$line['pktTrack']; |
|
1332 | + } |
|
1333 | + if ((int)$line['pktSpeed'] != 0) { |
|
1334 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1335 | + } |
|
1012 | 1336 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
1013 | 1337 | $data['altitude_relative'] = 'AMSL'; |
1014 | 1338 | $data['pilot_id'] = (int)$line['pktPilotID']; |
1015 | 1339 | $data['aircraft_icao'] = 'PARAGLIDER'; |
1016 | 1340 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
1017 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1341 | + if (isset($pilot_data[4])) { |
|
1342 | + $data['pilot_name'] = $pilot_data[4]; |
|
1343 | + } |
|
1018 | 1344 | $data['format_source'] = $value['format']; |
1019 | 1345 | $SI->add($data); |
1020 | 1346 | unset($data); |
@@ -1062,25 +1388,59 @@ discard block |
||
1062 | 1388 | foreach ($all_data['acList'] as $line) { |
1063 | 1389 | $data = array(); |
1064 | 1390 | $data['hex'] = $line['Icao']; // hex |
1065 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1066 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1067 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1068 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1069 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1070 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1391 | + if (isset($line['Call'])) { |
|
1392 | + $data['ident'] = $line['Call']; |
|
1393 | + } |
|
1394 | + // ident |
|
1395 | + if (isset($line['Alt'])) { |
|
1396 | + $data['altitude'] = $line['Alt']; |
|
1397 | + } |
|
1398 | + // altitude |
|
1399 | + if (isset($line['Spd'])) { |
|
1400 | + $data['speed'] = $line['Spd']; |
|
1401 | + } |
|
1402 | + // speed |
|
1403 | + if (isset($line['Trak'])) { |
|
1404 | + $data['heading'] = $line['Trak']; |
|
1405 | + } |
|
1406 | + // heading |
|
1407 | + if (isset($line['Lat'])) { |
|
1408 | + $data['latitude'] = $line['Lat']; |
|
1409 | + } |
|
1410 | + // lat |
|
1411 | + if (isset($line['Long'])) { |
|
1412 | + $data['longitude'] = $line['Long']; |
|
1413 | + } |
|
1414 | + // long |
|
1071 | 1415 | //$data['verticalrate'] = $line['']; // verticale rate |
1072 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1416 | + if (isset($line['Sqk'])) { |
|
1417 | + $data['squawk'] = $line['Sqk']; |
|
1418 | + } |
|
1419 | + // squawk |
|
1073 | 1420 | $data['emergency'] = ''; // emergency |
1074 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1075 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1076 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1421 | + if (isset($line['Reg'])) { |
|
1422 | + $data['registration'] = $line['Reg']; |
|
1423 | + } |
|
1424 | + if (isset($line['PosTime'])) { |
|
1425 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1426 | + } else { |
|
1427 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1428 | + } |
|
1077 | 1429 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1078 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1430 | + if (isset($line['Type'])) { |
|
1431 | + $data['aircraft_icao'] = $line['Type']; |
|
1432 | + } |
|
1079 | 1433 | $data['format_source'] = 'aircraftlistjson'; |
1080 | 1434 | $data['id_source'] = $id_source; |
1081 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1082 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1083 | - if (isset($data['latitude'])) $SI->add($data); |
|
1435 | + if (isset($value['name']) && $value['name'] != '') { |
|
1436 | + $data['source_name'] = $value['name']; |
|
1437 | + } |
|
1438 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1439 | + $data['noarchive'] = true; |
|
1440 | + } |
|
1441 | + if (isset($data['latitude'])) { |
|
1442 | + $SI->add($data); |
|
1443 | + } |
|
1084 | 1444 | unset($data); |
1085 | 1445 | } |
1086 | 1446 | } elseif (is_array($all_data)) { |
@@ -1097,17 +1457,26 @@ discard block |
||
1097 | 1457 | $data['verticalrate'] = $line['vrt']; // verticale rate |
1098 | 1458 | $data['squawk'] = $line['squawk']; // squawk |
1099 | 1459 | $data['emergency'] = ''; // emergency |
1100 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1101 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1460 | + if (isset($line['PosTime'])) { |
|
1461 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1462 | + } else { |
|
1463 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1464 | + } |
|
1102 | 1465 | $data['format_source'] = 'aircraftlistjson'; |
1103 | 1466 | $data['id_source'] = $id_source; |
1104 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1105 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1467 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1468 | + $data['noarchive'] = true; |
|
1469 | + } |
|
1470 | + if (isset($value['name']) && $value['name'] != '') { |
|
1471 | + $data['source_name'] = $value['name']; |
|
1472 | + } |
|
1106 | 1473 | $SI->add($data); |
1107 | 1474 | unset($data); |
1108 | 1475 | } |
1109 | 1476 | } |
1110 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1477 | + } elseif ($globalDebug) { |
|
1478 | + echo 'No data'."\n"; |
|
1479 | + } |
|
1111 | 1480 | //$last_exec['aircraftlistjson'] = time(); |
1112 | 1481 | $last_exec[$id]['last'] = time(); |
1113 | 1482 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1143,8 +1512,12 @@ discard block |
||
1143 | 1512 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
1144 | 1513 | $data['format_source'] = 'planeupdatefaa'; |
1145 | 1514 | $data['id_source'] = $id_source; |
1146 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1147 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1515 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1516 | + $data['noarchive'] = true; |
|
1517 | + } |
|
1518 | + if (isset($value['name']) && $value['name'] != '') { |
|
1519 | + $data['source_name'] = $value['name']; |
|
1520 | + } |
|
1148 | 1521 | $SI->add($data); |
1149 | 1522 | unset($data); |
1150 | 1523 | } |
@@ -1178,7 +1551,9 @@ discard block |
||
1178 | 1551 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
1179 | 1552 | $data['format_source'] = 'opensky'; |
1180 | 1553 | $data['id_source'] = $id_source; |
1181 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1554 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1555 | + $data['noarchive'] = true; |
|
1556 | + } |
|
1182 | 1557 | $SI->add($data); |
1183 | 1558 | unset($data); |
1184 | 1559 | } |
@@ -1198,15 +1573,42 @@ discard block |
||
1198 | 1573 | foreach ($all_data['aircraft'] as $key => $line) { |
1199 | 1574 | $data = array(); |
1200 | 1575 | // add support for ground vehicule with ~ in front of hex |
1201 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1202 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1203 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1204 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1205 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1206 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1207 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1208 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1209 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1576 | + if (isset($line['hex'])) { |
|
1577 | + $data['hex'] = $line['hex']; |
|
1578 | + } |
|
1579 | + // hex |
|
1580 | + if (isset($line['flight'])) { |
|
1581 | + $data['ident'] = trim($line['flight']); |
|
1582 | + } |
|
1583 | + // ident |
|
1584 | + if (isset($line['altitude'])) { |
|
1585 | + $data['altitude'] = $line['altitude']; |
|
1586 | + } |
|
1587 | + // altitude |
|
1588 | + if (isset($line['speed'])) { |
|
1589 | + $data['speed'] = $line['speed']; |
|
1590 | + } |
|
1591 | + // speed |
|
1592 | + if (isset($line['track'])) { |
|
1593 | + $data['heading'] = $line['track']; |
|
1594 | + } |
|
1595 | + // heading |
|
1596 | + if (isset($line['lat'])) { |
|
1597 | + $data['latitude'] = $line['lat']; |
|
1598 | + } |
|
1599 | + // lat |
|
1600 | + if (isset($line['lon'])) { |
|
1601 | + $data['longitude'] = $line['lon']; |
|
1602 | + } |
|
1603 | + // long |
|
1604 | + if (isset($line['vert_rate'])) { |
|
1605 | + $data['verticalrate'] = $line['vert_rate']; |
|
1606 | + } |
|
1607 | + // verticale rate |
|
1608 | + if (isset($line['squawk'])) { |
|
1609 | + $data['squawk'] = $line['squawk']; |
|
1610 | + } |
|
1611 | + // squawk |
|
1210 | 1612 | //$data['emergency'] = ''; // emergency |
1211 | 1613 | //$data['registration'] = $line[2]; |
1212 | 1614 | //$data['aircraft_icao'] = $line[0]; |
@@ -1214,10 +1616,17 @@ discard block |
||
1214 | 1616 | $data['format_source'] = 'aircraftjson'; |
1215 | 1617 | $data['id_source'] = $id_source; |
1216 | 1618 | if (isset($value['name']) && $value['name'] != '') { |
1217 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1218 | - else $data['source_name'] = $value['name']; |
|
1219 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1220 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1619 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1620 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
1621 | + } else { |
|
1622 | + $data['source_name'] = $value['name']; |
|
1623 | + } |
|
1624 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1625 | + $data['source_name'] = 'MLAT'; |
|
1626 | + } |
|
1627 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1628 | + $data['noarchive'] = true; |
|
1629 | + } |
|
1221 | 1630 | $SI->add($data); |
1222 | 1631 | unset($data); |
1223 | 1632 | } |
@@ -1237,22 +1646,54 @@ discard block |
||
1237 | 1646 | foreach ($all_data['aircraft'] as $key => $line) { |
1238 | 1647 | $data = array(); |
1239 | 1648 | $data['hex'] = $key; // hex |
1240 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1241 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1242 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1243 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1244 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1245 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1246 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1247 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1649 | + if (isset($line['callsign'])) { |
|
1650 | + $data['ident'] = trim($line['callsign']); |
|
1651 | + } |
|
1652 | + // ident |
|
1653 | + if (isset($line['altitude'])) { |
|
1654 | + $data['altitude'] = $line['altitude']; |
|
1655 | + } |
|
1656 | + // altitude |
|
1657 | + if (isset($line['speed'])) { |
|
1658 | + $data['speed'] = $line['speed']; |
|
1659 | + } |
|
1660 | + // speed |
|
1661 | + if (isset($line['heading'])) { |
|
1662 | + $data['heading'] = $line['heading']; |
|
1663 | + } |
|
1664 | + // heading |
|
1665 | + if (isset($line['lat'])) { |
|
1666 | + $data['latitude'] = $line['lat']; |
|
1667 | + } |
|
1668 | + // lat |
|
1669 | + if (isset($line['lon'])) { |
|
1670 | + $data['longitude'] = $line['lon']; |
|
1671 | + } |
|
1672 | + // long |
|
1673 | + if (isset($line['vert_rate'])) { |
|
1674 | + $data['verticalrate'] = $line['vert_rate']; |
|
1675 | + } |
|
1676 | + // verticale rate |
|
1677 | + if (isset($line['squawk'])) { |
|
1678 | + $data['squawk'] = $line['squawk']; |
|
1679 | + } |
|
1680 | + // squawk |
|
1248 | 1681 | //$data['emergency'] = ''; // emergency |
1249 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1250 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1682 | + if (isset($line['reg'])) { |
|
1683 | + $data['registration'] = $line['reg']; |
|
1684 | + } |
|
1685 | + if (isset($line['type'])) { |
|
1686 | + $data['aircraft_icao'] = $line['type']; |
|
1687 | + } |
|
1251 | 1688 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
1252 | 1689 | $data['format_source'] = 'planefinderclient'; |
1253 | 1690 | $data['id_source'] = $id_source; |
1254 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1255 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1691 | + if (isset($value['name']) && $value['name'] != '') { |
|
1692 | + $data['source_name'] = $value['name']; |
|
1693 | + } |
|
1694 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1695 | + $data['noarchive'] = true; |
|
1696 | + } |
|
1256 | 1697 | $SI->add($data); |
1257 | 1698 | unset($data); |
1258 | 1699 | } |
@@ -1268,7 +1709,9 @@ discard block |
||
1268 | 1709 | //$buffer = $Common->getData($hosts[$id]); |
1269 | 1710 | $buffer = $Common->getData($value['host']); |
1270 | 1711 | $all_data = json_decode($buffer,true); |
1271 | - if (!empty($all_data)) $reset = 0; |
|
1712 | + if (!empty($all_data)) { |
|
1713 | + $reset = 0; |
|
1714 | + } |
|
1272 | 1715 | foreach ($all_data as $key => $line) { |
1273 | 1716 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1274 | 1717 | $data = array(); |
@@ -1289,8 +1732,12 @@ discard block |
||
1289 | 1732 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1290 | 1733 | $data['format_source'] = 'fr24json'; |
1291 | 1734 | $data['id_source'] = $id_source; |
1292 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1293 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1735 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1736 | + $data['noarchive'] = true; |
|
1737 | + } |
|
1738 | + if (isset($value['name']) && $value['name'] != '') { |
|
1739 | + $data['source_name'] = $value['name']; |
|
1740 | + } |
|
1294 | 1741 | $SI->add($data); |
1295 | 1742 | unset($data); |
1296 | 1743 | } |
@@ -1319,24 +1766,42 @@ discard block |
||
1319 | 1766 | if (isset($line['inf'])) { |
1320 | 1767 | $data = array(); |
1321 | 1768 | $data['hex'] = $line['inf']['ia']; |
1322 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1769 | + if (isset($line['inf']['cs'])) { |
|
1770 | + $data['ident'] = $line['inf']['cs']; |
|
1771 | + } |
|
1772 | + //$line[13] |
|
1323 | 1773 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1324 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1325 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1774 | + if (isset($line['inf']['gs'])) { |
|
1775 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1776 | + } |
|
1777 | + // speed |
|
1778 | + if (isset($line['inf']['tr'])) { |
|
1779 | + $data['heading'] = $line['inf']['tr']; |
|
1780 | + } |
|
1781 | + // heading |
|
1326 | 1782 | $data['latitude'] = $line['pt'][0]; // lat |
1327 | 1783 | $data['longitude'] = $line['pt'][1]; // long |
1328 | 1784 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1329 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1785 | + if (isset($line['inf']['sq'])) { |
|
1786 | + $data['squawk'] = $line['inf']['sq']; |
|
1787 | + } |
|
1788 | + // squawk |
|
1330 | 1789 | //$data['aircraft_icao'] = $line[8]; |
1331 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1790 | + if (isset($line['inf']['rc'])) { |
|
1791 | + $data['registration'] = $line['inf']['rc']; |
|
1792 | + } |
|
1332 | 1793 | //$data['departure_airport_iata'] = $line[11]; |
1333 | 1794 | //$data['arrival_airport_iata'] = $line[12]; |
1334 | 1795 | //$data['emergency'] = ''; // emergency |
1335 | 1796 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1336 | 1797 | $data['format_source'] = 'radarvirtueljson'; |
1337 | 1798 | $data['id_source'] = $id_source; |
1338 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1339 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1799 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1800 | + $data['noarchive'] = true; |
|
1801 | + } |
|
1802 | + if (isset($value['name']) && $value['name'] != '') { |
|
1803 | + $data['source_name'] = $value['name']; |
|
1804 | + } |
|
1340 | 1805 | $SI->add($data); |
1341 | 1806 | unset($data); |
1342 | 1807 | } |
@@ -1362,30 +1827,65 @@ discard block |
||
1362 | 1827 | $data['id'] = $line['id']; |
1363 | 1828 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1364 | 1829 | $data['ident'] = $line['callsign']; // ident |
1365 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1366 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1367 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1368 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1369 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1370 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1830 | + if (isset($line['pilotid'])) { |
|
1831 | + $data['pilot_id'] = $line['pilotid']; |
|
1832 | + } |
|
1833 | + // pilot id |
|
1834 | + if (isset($line['name'])) { |
|
1835 | + $data['pilot_name'] = $line['name']; |
|
1836 | + } |
|
1837 | + // pilot name |
|
1838 | + if (isset($line['alt'])) { |
|
1839 | + $data['altitude'] = $line['alt']; |
|
1840 | + } |
|
1841 | + // altitude |
|
1842 | + if (isset($line['gs'])) { |
|
1843 | + $data['speed'] = $line['gs']; |
|
1844 | + } |
|
1845 | + // speed |
|
1846 | + if (isset($line['heading'])) { |
|
1847 | + $data['heading'] = $line['heading']; |
|
1848 | + } |
|
1849 | + // heading |
|
1850 | + if (isset($line['route'])) { |
|
1851 | + $data['waypoints'] = $line['route']; |
|
1852 | + } |
|
1853 | + // route |
|
1371 | 1854 | $data['latitude'] = $line['lat']; // lat |
1372 | 1855 | $data['longitude'] = $line['lon']; // long |
1373 | 1856 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1374 | 1857 | //$data['squawk'] = $line['squawk']; // squawk |
1375 | 1858 | //$data['emergency'] = ''; // emergency |
1376 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1377 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1378 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1859 | + if (isset($line['depicao'])) { |
|
1860 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1861 | + } |
|
1862 | + if (isset($line['deptime'])) { |
|
1863 | + $data['departure_airport_time'] = $line['deptime']; |
|
1864 | + } |
|
1865 | + if (isset($line['arricao'])) { |
|
1866 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1867 | + } |
|
1379 | 1868 | //$data['arrival_airport_time'] = $line['arrtime']; |
1380 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1381 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1382 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1383 | - else $data['info'] = ''; |
|
1869 | + if (isset($line['aircraft'])) { |
|
1870 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1871 | + } |
|
1872 | + if (isset($line['transponder'])) { |
|
1873 | + $data['squawk'] = $line['transponder']; |
|
1874 | + } |
|
1875 | + if (isset($line['atis'])) { |
|
1876 | + $data['info'] = $line['atis']; |
|
1877 | + } else { |
|
1878 | + $data['info'] = ''; |
|
1879 | + } |
|
1384 | 1880 | $data['format_source'] = 'pireps'; |
1385 | 1881 | $data['id_source'] = $id_source; |
1386 | 1882 | $data['datetime'] = date('Y-m-d H:i:s'); |
1387 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1388 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1883 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1884 | + $data['noarchive'] = true; |
|
1885 | + } |
|
1886 | + if (isset($value['name']) && $value['name'] != '') { |
|
1887 | + $data['source_name'] = $value['name']; |
|
1888 | + } |
|
1389 | 1889 | if ($line['icon'] === 'plane') { |
1390 | 1890 | $SI->add($data); |
1391 | 1891 | // print_r($data); |
@@ -1394,16 +1894,28 @@ discard block |
||
1394 | 1894 | $data['info'] = str_replace('&sect;','',$data['info']); |
1395 | 1895 | $typec = substr($data['ident'],-3); |
1396 | 1896 | $data['type'] = ''; |
1397 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1398 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
1399 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
1400 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
1401 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
1402 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
1403 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1404 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1405 | - else $data['type'] = 'Observer'; |
|
1406 | - 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']); |
|
1897 | + if ($typec === 'APP') { |
|
1898 | + $data['type'] = 'Approach'; |
|
1899 | + } elseif ($typec === 'TWR') { |
|
1900 | + $data['type'] = 'Tower'; |
|
1901 | + } elseif ($typec === 'OBS') { |
|
1902 | + $data['type'] = 'Observer'; |
|
1903 | + } elseif ($typec === 'GND') { |
|
1904 | + $data['type'] = 'Ground'; |
|
1905 | + } elseif ($typec === 'DEL') { |
|
1906 | + $data['type'] = 'Delivery'; |
|
1907 | + } elseif ($typec === 'DEP') { |
|
1908 | + $data['type'] = 'Departure'; |
|
1909 | + } elseif ($typec === 'FSS') { |
|
1910 | + $data['type'] = 'Flight Service Station'; |
|
1911 | + } elseif ($typec === 'CTR') { |
|
1912 | + $data['type'] = 'Control Radar or Centre'; |
|
1913 | + } else { |
|
1914 | + $data['type'] = 'Observer'; |
|
1915 | + } |
|
1916 | + if (isset($ATC)) { |
|
1917 | + 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']); |
|
1918 | + } |
|
1407 | 1919 | } |
1408 | 1920 | unset($data); |
1409 | 1921 | } |
@@ -1418,7 +1930,9 @@ discard block |
||
1418 | 1930 | ) |
1419 | 1931 | ) { |
1420 | 1932 | //$buffer = $Common->getData($hosts[$id]); |
1421 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1933 | + if ($globalDebug) { |
|
1934 | + echo 'Get Data...'."\n"; |
|
1935 | + } |
|
1422 | 1936 | $buffer = $Common->getData($value['host']); |
1423 | 1937 | $all_data = json_decode($buffer,true); |
1424 | 1938 | if ($buffer != '' && is_array($all_data)) { |
@@ -1426,10 +1940,16 @@ discard block |
||
1426 | 1940 | foreach ($all_data as $line) { |
1427 | 1941 | $data = array(); |
1428 | 1942 | //$data['id'] = $line['id']; // id not usable |
1429 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1943 | + if (isset($line['pilotid'])) { |
|
1944 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1945 | + } |
|
1430 | 1946 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1431 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1432 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1947 | + if (isset($line['pilotname'])) { |
|
1948 | + $data['pilot_name'] = $line['pilotname']; |
|
1949 | + } |
|
1950 | + if (isset($line['pilotid'])) { |
|
1951 | + $data['pilot_id'] = $line['pilotid']; |
|
1952 | + } |
|
1433 | 1953 | $data['ident'] = $line['flightnum']; // ident |
1434 | 1954 | $data['altitude'] = $line['alt']; // altitude |
1435 | 1955 | $data['speed'] = $line['gs']; // speed |
@@ -1445,7 +1965,9 @@ discard block |
||
1445 | 1965 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1446 | 1966 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1447 | 1967 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1448 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1968 | + } else { |
|
1969 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1970 | + } |
|
1449 | 1971 | $data['departure_airport_icao'] = $line['depicao']; |
1450 | 1972 | $data['departure_airport_time'] = $line['deptime']; |
1451 | 1973 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1453,29 +1975,47 @@ discard block |
||
1453 | 1975 | if (isset($line['registration'])) { |
1454 | 1976 | $data['registration'] = $line['registration']; |
1455 | 1977 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
1456 | - } else $data['registration'] = $line['aircraft']; |
|
1457 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1458 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1978 | + } else { |
|
1979 | + $data['registration'] = $line['aircraft']; |
|
1980 | + } |
|
1981 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1982 | + $data['noarchive'] = true; |
|
1983 | + } |
|
1984 | + if (isset($line['route'])) { |
|
1985 | + $data['waypoints'] = $line['route']; |
|
1986 | + } |
|
1987 | + // route |
|
1459 | 1988 | if (isset($line['aircraftname'])) { |
1460 | 1989 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1461 | 1990 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1462 | 1991 | $aircraft_data = explode('-',$line['aircraftname']); |
1463 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1464 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1465 | - else { |
|
1992 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1993 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1994 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1995 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1996 | + } else { |
|
1466 | 1997 | $aircraft_data = explode(' ',$line['aircraftname']); |
1467 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1468 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1998 | + if (isset($aircraft_data[1])) { |
|
1999 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
2000 | + } else { |
|
2001 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
2002 | + } |
|
1469 | 2003 | } |
1470 | 2004 | } |
1471 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
2005 | + if (isset($line['route'])) { |
|
2006 | + $data['waypoints'] = $line['route']; |
|
2007 | + } |
|
1472 | 2008 | $data['id_source'] = $id_source; |
1473 | 2009 | $data['format_source'] = 'phpvmacars'; |
1474 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
2010 | + if (isset($value['name']) && $value['name'] != '') { |
|
2011 | + $data['source_name'] = $value['name']; |
|
2012 | + } |
|
1475 | 2013 | $SI->add($data); |
1476 | 2014 | unset($data); |
1477 | 2015 | } |
1478 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2016 | + if ($globalDebug) { |
|
2017 | + echo 'No more data...'."\n"; |
|
2018 | + } |
|
1479 | 2019 | unset($buffer); |
1480 | 2020 | unset($all_data); |
1481 | 2021 | } |
@@ -1488,7 +2028,9 @@ discard block |
||
1488 | 2028 | ) |
1489 | 2029 | ) { |
1490 | 2030 | //$buffer = $Common->getData($hosts[$id]); |
1491 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
2031 | + if ($globalDebug) { |
|
2032 | + echo 'Get Data...'."\n"; |
|
2033 | + } |
|
1492 | 2034 | $buffer = $Common->getData($value['host']); |
1493 | 2035 | $all_data = json_decode($buffer,true); |
1494 | 2036 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1499,10 +2041,16 @@ discard block |
||
1499 | 2041 | //$data['id'] = $line['id']; // id not usable |
1500 | 2042 | $data['id'] = $line['id']; |
1501 | 2043 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1502 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1503 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
2044 | + if (isset($line['user']['username'])) { |
|
2045 | + $data['pilot_name'] = $line['user']['username']; |
|
2046 | + } |
|
2047 | + if (isset($line['user_id'])) { |
|
2048 | + $data['pilot_id'] = $line['user_id']; |
|
2049 | + } |
|
1504 | 2050 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
1505 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
2051 | + if (is_numeric($data['ident'])) { |
|
2052 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
2053 | + } |
|
1506 | 2054 | $data['altitude'] = $line['altitude']; // altitude |
1507 | 2055 | $data['speed'] = $line['groundspeed']; // speed |
1508 | 2056 | $data['heading'] = $line['heading']; // heading |
@@ -1515,7 +2063,9 @@ discard block |
||
1515 | 2063 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
1516 | 2064 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1517 | 2065 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1518 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2066 | + } else { |
|
2067 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2068 | + } |
|
1519 | 2069 | |
1520 | 2070 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
1521 | 2071 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1523,17 +2073,26 @@ discard block |
||
1523 | 2073 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
1524 | 2074 | $data['registration'] = $line['bid']['aircraft']['registration']; |
1525 | 2075 | |
1526 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1527 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
2076 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
2077 | + $data['noarchive'] = true; |
|
2078 | + } |
|
2079 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
2080 | + $data['waypoints'] = $line['bid']['route']; |
|
2081 | + } |
|
2082 | + // route |
|
1528 | 2083 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
1529 | 2084 | |
1530 | 2085 | $data['id_source'] = $id_source; |
1531 | 2086 | $data['format_source'] = 'vaos'; |
1532 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
2087 | + if (isset($value['name']) && $value['name'] != '') { |
|
2088 | + $data['source_name'] = $value['name']; |
|
2089 | + } |
|
1533 | 2090 | $SI->add($data); |
1534 | 2091 | unset($data); |
1535 | 2092 | } |
1536 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2093 | + if ($globalDebug) { |
|
2094 | + echo 'No more data...'."\n"; |
|
2095 | + } |
|
1537 | 2096 | unset($buffer); |
1538 | 2097 | unset($all_data); |
1539 | 2098 | } |
@@ -1546,7 +2105,9 @@ discard block |
||
1546 | 2105 | ) |
1547 | 2106 | ) { |
1548 | 2107 | //$buffer = $Common->getData($hosts[$id]); |
1549 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
2108 | + if ($globalDebug) { |
|
2109 | + echo 'Get Data...'."\n"; |
|
2110 | + } |
|
1550 | 2111 | $buffer = $Common->getData($value['host']); |
1551 | 2112 | $all_data = json_decode($buffer,true); |
1552 | 2113 | if ($buffer != '' && is_array($all_data)) { |
@@ -1575,16 +2136,25 @@ discard block |
||
1575 | 2136 | $data['arrival_airport_icao'] = $line['arrival']; |
1576 | 2137 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1577 | 2138 | //$data['registration'] = $line['aircraft']; |
1578 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
2139 | + if (isset($line['route'])) { |
|
2140 | + $data['waypoints'] = $line['route']; |
|
2141 | + } |
|
2142 | + // route |
|
1579 | 2143 | $data['aircraft_icao'] = $line['plane_type']; |
1580 | 2144 | $data['id_source'] = $id_source; |
1581 | 2145 | $data['format_source'] = 'vam'; |
1582 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1583 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
2146 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
2147 | + $data['noarchive'] = true; |
|
2148 | + } |
|
2149 | + if (isset($value['name']) && $value['name'] != '') { |
|
2150 | + $data['source_name'] = $value['name']; |
|
2151 | + } |
|
1584 | 2152 | $SI->add($data); |
1585 | 2153 | unset($data); |
1586 | 2154 | } |
1587 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2155 | + if ($globalDebug) { |
|
2156 | + echo 'No more data...'."\n"; |
|
2157 | + } |
|
1588 | 2158 | unset($buffer); |
1589 | 2159 | unset($all_data); |
1590 | 2160 | } |
@@ -1597,7 +2167,9 @@ discard block |
||
1597 | 2167 | ) |
1598 | 2168 | ) { |
1599 | 2169 | //$buffer = $Common->getData($hosts[$id]); |
1600 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
2170 | + if ($globalDebug) { |
|
2171 | + echo 'Get Data...'."\n"; |
|
2172 | + } |
|
1601 | 2173 | $buffer = $Common->getData($value['host']); |
1602 | 2174 | $all_data = json_decode($buffer,true); |
1603 | 2175 | if ($buffer != '') { |
@@ -1615,12 +2187,16 @@ discard block |
||
1615 | 2187 | $data['id_source'] = $id_source; |
1616 | 2188 | $data['format_source'] = 'blitzortung'; |
1617 | 2189 | $SI->add($data); |
1618 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2190 | + if ($globalDebug) { |
|
2191 | + echo '☈ Lightning added'."\n"; |
|
2192 | + } |
|
1619 | 2193 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1620 | 2194 | unset($data); |
1621 | 2195 | } |
1622 | 2196 | } |
1623 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2197 | + if ($globalDebug) { |
|
2198 | + echo 'No more data...'."\n"; |
|
2199 | + } |
|
1624 | 2200 | unset($buffer); |
1625 | 2201 | } |
1626 | 2202 | $last_exec[$id]['last'] = time(); |
@@ -1649,10 +2225,15 @@ discard block |
||
1649 | 2225 | } |
1650 | 2226 | } else { |
1651 | 2227 | $format = $value['format']; |
1652 | - if (isset($tt[$format])) $tt[$format]++; |
|
1653 | - else $tt[$format] = 0; |
|
2228 | + if (isset($tt[$format])) { |
|
2229 | + $tt[$format]++; |
|
2230 | + } else { |
|
2231 | + $tt[$format] = 0; |
|
2232 | + } |
|
1654 | 2233 | if ($tt[$format] > 30) { |
1655 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
2234 | + if ($globalDebug) { |
|
2235 | + echo 'Reconnect...'."\n"; |
|
2236 | + } |
|
1656 | 2237 | sleep(2); |
1657 | 2238 | //$sourceeen[] = $value; |
1658 | 2239 | //connect_all($sourceeen); |
@@ -1669,7 +2250,9 @@ discard block |
||
1669 | 2250 | $write = NULL; |
1670 | 2251 | $e = NULL; |
1671 | 2252 | $n = socket_select($read, $write, $e, $timeout); |
1672 | - if ($e != NULL) var_dump($e); |
|
2253 | + if ($e != NULL) { |
|
2254 | + var_dump($e); |
|
2255 | + } |
|
1673 | 2256 | if ($n > 0) { |
1674 | 2257 | $reset = 0; |
1675 | 2258 | foreach ($read as $nb => $r) { |
@@ -1691,13 +2274,17 @@ discard block |
||
1691 | 2274 | if ($buffer !== FALSE) { |
1692 | 2275 | if ($format === 'vrstcp') { |
1693 | 2276 | $buffer = explode('},{',$buffer); |
1694 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
2277 | + } else { |
|
2278 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
2279 | + } |
|
1695 | 2280 | } |
1696 | 2281 | // SBS format is CSV format |
1697 | 2282 | if ($buffer !== FALSE && $buffer !== '') { |
1698 | 2283 | $tt[$format] = 0; |
1699 | 2284 | if ($format === 'acarssbs3') { |
1700 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2285 | + if ($globalDebug) { |
|
2286 | + echo 'ACARS : '.$buffer."\n"; |
|
2287 | + } |
|
1701 | 2288 | $ACARS->add(trim($buffer)); |
1702 | 2289 | $ACARS->deleteLiveAcarsData(); |
1703 | 2290 | } elseif ($format === 'raw') { |
@@ -1707,9 +2294,15 @@ discard block |
||
1707 | 2294 | //if (!empty($data)) print_r($data); |
1708 | 2295 | $data['datetime'] = date('Y-m-d H:i:s'); |
1709 | 2296 | $data['format_source'] = 'raw'; |
1710 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1711 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1712 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2297 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2298 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2299 | + } |
|
2300 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2301 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2302 | + } |
|
2303 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2304 | + $data['noarchive'] = true; |
|
2305 | + } |
|
1713 | 2306 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1714 | 2307 | $SI->add($data); |
1715 | 2308 | unset($data); |
@@ -1717,22 +2310,54 @@ discard block |
||
1717 | 2310 | } elseif ($format === 'ais') { |
1718 | 2311 | $ais_data = $AIS->parse_line(trim($buffer)); |
1719 | 2312 | $data = array(); |
1720 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1721 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1722 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1723 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1724 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1725 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1726 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1727 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1728 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1729 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1730 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1731 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1732 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1733 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1734 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1735 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2313 | + if (isset($ais_data['ident'])) { |
|
2314 | + $data['ident'] = $ais_data['ident']; |
|
2315 | + } |
|
2316 | + if (isset($ais_data['mmsi'])) { |
|
2317 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
2318 | + } |
|
2319 | + if (isset($ais_data['speed'])) { |
|
2320 | + $data['speed'] = $ais_data['speed']; |
|
2321 | + } |
|
2322 | + if (isset($ais_data['heading'])) { |
|
2323 | + $data['heading'] = $ais_data['heading']; |
|
2324 | + } |
|
2325 | + if (isset($ais_data['latitude'])) { |
|
2326 | + $data['latitude'] = $ais_data['latitude']; |
|
2327 | + } |
|
2328 | + if (isset($ais_data['longitude'])) { |
|
2329 | + $data['longitude'] = $ais_data['longitude']; |
|
2330 | + } |
|
2331 | + if (isset($ais_data['status'])) { |
|
2332 | + $data['status'] = $ais_data['status']; |
|
2333 | + } |
|
2334 | + if (isset($ais_data['statusid'])) { |
|
2335 | + $data['status_id'] = $ais_data['statusid']; |
|
2336 | + } |
|
2337 | + if (isset($ais_data['type'])) { |
|
2338 | + $data['type'] = $ais_data['type']; |
|
2339 | + } |
|
2340 | + if (isset($ais_data['imo'])) { |
|
2341 | + $data['imo'] = $ais_data['imo']; |
|
2342 | + } |
|
2343 | + if (isset($ais_data['callsign'])) { |
|
2344 | + $data['callsign'] = $ais_data['callsign']; |
|
2345 | + } |
|
2346 | + if (isset($ais_data['destination'])) { |
|
2347 | + $data['arrival_code'] = $ais_data['destination']; |
|
2348 | + } |
|
2349 | + if (isset($ais_data['eta_ts'])) { |
|
2350 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
2351 | + } |
|
2352 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2353 | + $data['noarchive'] = true; |
|
2354 | + } |
|
2355 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2356 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2357 | + } |
|
2358 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2359 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2360 | + } |
|
1736 | 2361 | |
1737 | 2362 | if (isset($ais_data['timestamp'])) { |
1738 | 2363 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1741,7 +2366,9 @@ discard block |
||
1741 | 2366 | } |
1742 | 2367 | $data['format_source'] = 'aisnmea'; |
1743 | 2368 | $data['id_source'] = $id_source; |
1744 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
2369 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
2370 | + $MI->add($data); |
|
2371 | + } |
|
1745 | 2372 | unset($data); |
1746 | 2373 | } elseif ($format === 'flightgearsp') { |
1747 | 2374 | //echo $buffer."\n"; |
@@ -1759,12 +2386,18 @@ discard block |
||
1759 | 2386 | $data['speed'] = round($line[5]*1.94384); |
1760 | 2387 | $data['datetime'] = date('Y-m-d H:i:s'); |
1761 | 2388 | $data['format_source'] = 'flightgearsp'; |
1762 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1763 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2389 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2390 | + $data['noarchive'] = true; |
|
2391 | + } |
|
2392 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2393 | + $SI->add($data); |
|
2394 | + } |
|
1764 | 2395 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1765 | 2396 | } |
1766 | 2397 | } elseif ($format === 'acars') { |
1767 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2398 | + if ($globalDebug) { |
|
2399 | + echo 'ACARS : '.$buffer."\n"; |
|
2400 | + } |
|
1768 | 2401 | $ACARS->add(trim($buffer)); |
1769 | 2402 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1770 | 2403 | $ACARS->deleteLiveAcarsData(); |
@@ -1785,8 +2418,12 @@ discard block |
||
1785 | 2418 | $aircraft_type = $line[10]; |
1786 | 2419 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1787 | 2420 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1788 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1789 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2421 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2422 | + $data['noarchive'] = true; |
|
2423 | + } |
|
2424 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2425 | + $SI->add($data); |
|
2426 | + } |
|
1790 | 2427 | } |
1791 | 2428 | } |
1792 | 2429 | } elseif ($format === 'beast') { |
@@ -1796,28 +2433,62 @@ discard block |
||
1796 | 2433 | foreach($buffer as $all_data) { |
1797 | 2434 | $line = json_decode('{'.$all_data.'}',true); |
1798 | 2435 | $data = array(); |
1799 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1800 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1801 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1802 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1803 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1804 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1805 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
2436 | + if (isset($line['Icao'])) { |
|
2437 | + $data['hex'] = $line['Icao']; |
|
2438 | + } |
|
2439 | + // hex |
|
2440 | + if (isset($line['Call'])) { |
|
2441 | + $data['ident'] = $line['Call']; |
|
2442 | + } |
|
2443 | + // ident |
|
2444 | + if (isset($line['Alt'])) { |
|
2445 | + $data['altitude'] = $line['Alt']; |
|
2446 | + } |
|
2447 | + // altitude |
|
2448 | + if (isset($line['Spd'])) { |
|
2449 | + $data['speed'] = $line['Spd']; |
|
2450 | + } |
|
2451 | + // speed |
|
2452 | + if (isset($line['Trak'])) { |
|
2453 | + $data['heading'] = $line['Trak']; |
|
2454 | + } |
|
2455 | + // heading |
|
2456 | + if (isset($line['Lat'])) { |
|
2457 | + $data['latitude'] = $line['Lat']; |
|
2458 | + } |
|
2459 | + // lat |
|
2460 | + if (isset($line['Long'])) { |
|
2461 | + $data['longitude'] = $line['Long']; |
|
2462 | + } |
|
2463 | + // long |
|
1806 | 2464 | //$data['verticalrate'] = $line['']; // verticale rate |
1807 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
2465 | + if (isset($line['Sqk'])) { |
|
2466 | + $data['squawk'] = $line['Sqk']; |
|
2467 | + } |
|
2468 | + // squawk |
|
1808 | 2469 | $data['emergency'] = ''; // emergency |
1809 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
2470 | + if (isset($line['Reg'])) { |
|
2471 | + $data['registration'] = $line['Reg']; |
|
2472 | + } |
|
1810 | 2473 | /* |
1811 | 2474 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1812 | 2475 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1813 | 2476 | */ |
1814 | 2477 | $data['datetime'] = date('Y-m-d H:i:s'); |
1815 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
2478 | + if (isset($line['Type'])) { |
|
2479 | + $data['aircraft_icao'] = $line['Type']; |
|
2480 | + } |
|
1816 | 2481 | $data['format_source'] = 'vrstcp'; |
1817 | 2482 | $data['id_source'] = $id_source; |
1818 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1819 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1820 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
2483 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2484 | + $data['noarchive'] = true; |
|
2485 | + } |
|
2486 | + if (isset($value['name']) && $value['name'] != '') { |
|
2487 | + $data['source_name'] = $value['name']; |
|
2488 | + } |
|
2489 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
2490 | + $SI->add($data); |
|
2491 | + } |
|
1821 | 2492 | unset($data); |
1822 | 2493 | } |
1823 | 2494 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1830,22 +2501,46 @@ discard block |
||
1830 | 2501 | $data['hex'] = $lined['hexid']; |
1831 | 2502 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1832 | 2503 | $data['datetime'] = date('Y-m-d H:i:s');; |
1833 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1834 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1835 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1836 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1837 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1838 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1839 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
2504 | + if (isset($lined['ident'])) { |
|
2505 | + $data['ident'] = $lined['ident']; |
|
2506 | + } |
|
2507 | + if (isset($lined['lat'])) { |
|
2508 | + $data['latitude'] = $lined['lat']; |
|
2509 | + } |
|
2510 | + if (isset($lined['lon'])) { |
|
2511 | + $data['longitude'] = $lined['lon']; |
|
2512 | + } |
|
2513 | + if (isset($lined['speed'])) { |
|
2514 | + $data['speed'] = $lined['speed']; |
|
2515 | + } |
|
2516 | + if (isset($lined['squawk'])) { |
|
2517 | + $data['squawk'] = $lined['squawk']; |
|
2518 | + } |
|
2519 | + if (isset($lined['alt'])) { |
|
2520 | + $data['altitude'] = $lined['alt']; |
|
2521 | + } |
|
2522 | + if (isset($lined['heading'])) { |
|
2523 | + $data['heading'] = $lined['heading']; |
|
2524 | + } |
|
1840 | 2525 | $data['id_source'] = $id_source; |
1841 | 2526 | $data['format_source'] = 'tsv'; |
1842 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1843 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1844 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1845 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2527 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2528 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2529 | + } |
|
2530 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2531 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2532 | + } |
|
2533 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2534 | + $data['noarchive'] = true; |
|
2535 | + } |
|
2536 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2537 | + $SI->add($data); |
|
2538 | + } |
|
1846 | 2539 | unset($lined); |
1847 | 2540 | unset($data); |
1848 | - } else $error = true; |
|
2541 | + } else { |
|
2542 | + $error = true; |
|
2543 | + } |
|
1849 | 2544 | } elseif ($format === 'aprs' && $use_aprs) { |
1850 | 2545 | if ($aprs_connect === 0) { |
1851 | 2546 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1871,47 +2566,96 @@ discard block |
||
1871 | 2566 | $aprs_last_tx = time(); |
1872 | 2567 | $data = array(); |
1873 | 2568 | //print_r($line); |
1874 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1875 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1876 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1877 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1878 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1879 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1880 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1881 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1882 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1883 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2569 | + if (isset($line['address'])) { |
|
2570 | + $data['hex'] = $line['address']; |
|
2571 | + } |
|
2572 | + if (isset($line['mmsi'])) { |
|
2573 | + $data['mmsi'] = $line['mmsi']; |
|
2574 | + } |
|
2575 | + if (isset($line['imo'])) { |
|
2576 | + $data['imo'] = $line['imo']; |
|
2577 | + } |
|
2578 | + if (isset($line['squawk'])) { |
|
2579 | + $data['squawk'] = $line['squawk']; |
|
2580 | + } |
|
2581 | + if (isset($line['arrival_code'])) { |
|
2582 | + $data['arrival_code'] = $line['arrival_code']; |
|
2583 | + } |
|
2584 | + if (isset($line['arrival_date'])) { |
|
2585 | + $data['arrival_date'] = $line['arrival_date']; |
|
2586 | + } |
|
2587 | + if (isset($line['typeid'])) { |
|
2588 | + $data['type_id'] = $line['typeid']; |
|
2589 | + } |
|
2590 | + if (isset($line['statusid'])) { |
|
2591 | + $data['status_id'] = $line['statusid']; |
|
2592 | + } |
|
2593 | + if (isset($line['timestamp'])) { |
|
2594 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2595 | + } else { |
|
2596 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2597 | + } |
|
1884 | 2598 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1885 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2599 | + if (isset($line['ident'])) { |
|
2600 | + $data['ident'] = $line['ident']; |
|
2601 | + } |
|
1886 | 2602 | $data['latitude'] = $line['latitude']; |
1887 | 2603 | $data['longitude'] = $line['longitude']; |
1888 | 2604 | //$data['verticalrate'] = $line[16]; |
1889 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2605 | + if (isset($line['speed'])) { |
|
2606 | + $data['speed'] = $line['speed']; |
|
2607 | + } |
|
1890 | 2608 | //else $data['speed'] = 0; |
1891 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1892 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1893 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2609 | + if (isset($line['altitude'])) { |
|
2610 | + $data['altitude'] = $line['altitude']; |
|
2611 | + } |
|
2612 | + if (isset($line['comment'])) { |
|
2613 | + $data['comment'] = $line['comment']; |
|
2614 | + } |
|
2615 | + if (isset($line['symbol'])) { |
|
2616 | + $data['type'] = $line['symbol']; |
|
2617 | + } |
|
1894 | 2618 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1895 | 2619 | |
1896 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2620 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2621 | + $data['heading'] = $line['heading']; |
|
2622 | + } |
|
1897 | 2623 | //else echo 'No heading...'."\n"; |
1898 | 2624 | //else $data['heading'] = 0; |
1899 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2625 | + if (isset($line['stealth'])) { |
|
2626 | + $data['aircraft_type'] = $line['stealth']; |
|
2627 | + } |
|
1900 | 2628 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1901 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1902 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1903 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1904 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2629 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2630 | + $data['noarchive'] = true; |
|
2631 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2632 | + $data['noarchive'] = false; |
|
2633 | + } |
|
2634 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2635 | + $data['noarchive'] = true; |
|
2636 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2637 | + $data['noarchive'] = false; |
|
2638 | + } |
|
1905 | 2639 | $data['id_source'] = $id_source; |
1906 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1907 | - else $data['format_source'] = 'aprs'; |
|
2640 | + if (isset($line['format_source'])) { |
|
2641 | + $data['format_source'] = $line['format_source']; |
|
2642 | + } else { |
|
2643 | + $data['format_source'] = 'aprs'; |
|
2644 | + } |
|
1908 | 2645 | $data['source_name'] = $line['source']; |
1909 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1910 | - else $data['source_type'] = 'flarm'; |
|
1911 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2646 | + if (isset($line['source_type'])) { |
|
2647 | + $data['source_type'] = $line['source_type']; |
|
2648 | + } else { |
|
2649 | + $data['source_type'] = 'flarm'; |
|
2650 | + } |
|
2651 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2652 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2653 | + } |
|
1912 | 2654 | $currentdate = date('Y-m-d H:i:s'); |
1913 | 2655 | $aprsdate = strtotime($data['datetime']); |
1914 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2656 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2657 | + $data['altitude_relative'] = 'AMSL'; |
|
2658 | + } |
|
1915 | 2659 | // Accept data if time <= system time + 20s |
1916 | 2660 | //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'])))) { |
1917 | 2661 | if ( |
@@ -1923,7 +2667,9 @@ discard block |
||
1923 | 2667 | $send = $SI->add($data); |
1924 | 2668 | } elseif ($data['source_type'] === 'ais') { |
1925 | 2669 | $data['type'] = ''; |
1926 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2670 | + if (isset($globalMarine) && $globalMarine) { |
|
2671 | + $send = $MI->add($data); |
|
2672 | + } |
|
1927 | 2673 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
1928 | 2674 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1929 | 2675 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -1931,8 +2677,12 @@ discard block |
||
1931 | 2677 | $line['symbol'] === 'Glider' || |
1932 | 2678 | $line['symbol'] === 'No. Plane' || |
1933 | 2679 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
1934 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1935 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2680 | + if ($line['symbol'] === 'Ballon') { |
|
2681 | + $data['aircraft_icao'] = 'BALL'; |
|
2682 | + } |
|
2683 | + if ($line['symbol'] === 'Glider') { |
|
2684 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2685 | + } |
|
1936 | 2686 | $send = $SI->add($data); |
1937 | 2687 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1938 | 2688 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1963,9 +2713,13 @@ discard block |
||
1963 | 2713 | //} 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') { |
1964 | 2714 | // } 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') { |
1965 | 2715 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1966 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2716 | + if (isset($globalTracker) && $globalTracker) { |
|
2717 | + $send = $TI->add($data); |
|
2718 | + } |
|
1967 | 2719 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1968 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2720 | + if (!isset($data['altitude'])) { |
|
2721 | + $data['altitude'] = 0; |
|
2722 | + } |
|
1969 | 2723 | $Source->deleteOldLocationByType('gs'); |
1970 | 2724 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1971 | 2725 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1974,7 +2728,9 @@ discard block |
||
1974 | 2728 | } |
1975 | 2729 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
1976 | 2730 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1977 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2731 | + if ($globalDebug) { |
|
2732 | + echo '# Weather Station added'."\n"; |
|
2733 | + } |
|
1978 | 2734 | $Source->deleteOldLocationByType('wx'); |
1979 | 2735 | $weather_data = json_encode($line); |
1980 | 2736 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1984,7 +2740,9 @@ discard block |
||
1984 | 2740 | } |
1985 | 2741 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
1986 | 2742 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1987 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2743 | + if ($globalDebug) { |
|
2744 | + echo '☈ Lightning added'."\n"; |
|
2745 | + } |
|
1988 | 2746 | $Source->deleteOldLocationByType('lightning'); |
1989 | 2747 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1990 | 2748 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1996,8 +2754,7 @@ discard block |
||
1996 | 2754 | print_r($line); |
1997 | 2755 | } |
1998 | 2756 | unset($data); |
1999 | - } |
|
2000 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2757 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2001 | 2758 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
2002 | 2759 | } |
2003 | 2760 | /* |
@@ -2006,7 +2763,9 @@ discard block |
||
2006 | 2763 | } |
2007 | 2764 | */ |
2008 | 2765 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
2009 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2766 | + elseif ($line === true && $globalDebug) { |
|
2767 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2768 | + } |
|
2010 | 2769 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
2011 | 2770 | $Source->deleteOldLocationByType('lightning'); |
2012 | 2771 | $Source->deleteOldLocationByType('wx'); |
@@ -2043,27 +2802,47 @@ discard block |
||
2043 | 2802 | $data['ground'] = $line[21]; |
2044 | 2803 | $data['emergency'] = $line[19]; |
2045 | 2804 | $data['format_source'] = 'sbs'; |
2046 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
2047 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
2048 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2049 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2805 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2806 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2807 | + } elseif ($line[0] == 'MLAT') { |
|
2808 | + $data['source_name'] = 'MLAT'; |
|
2809 | + } |
|
2810 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2811 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2812 | + } |
|
2813 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2814 | + $data['noarchive'] = true; |
|
2815 | + } |
|
2050 | 2816 | $data['id_source'] = $id_source; |
2051 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2052 | - else $error = true; |
|
2817 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2818 | + $send = $SI->add($data); |
|
2819 | + } else { |
|
2820 | + $error = true; |
|
2821 | + } |
|
2053 | 2822 | unset($data); |
2054 | - } else $error = true; |
|
2823 | + } else { |
|
2824 | + $error = true; |
|
2825 | + } |
|
2055 | 2826 | if ($error) { |
2056 | 2827 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
2057 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2828 | + if ($globalDebug) { |
|
2829 | + echo "Not a message. Ignoring... \n"; |
|
2830 | + } |
|
2058 | 2831 | } else { |
2059 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2832 | + if ($globalDebug) { |
|
2833 | + echo "Wrong line format. Ignoring... \n"; |
|
2834 | + } |
|
2060 | 2835 | if ($globalDebug) { |
2061 | 2836 | echo $buffer; |
2062 | 2837 | //print_r($line); |
2063 | 2838 | } |
2064 | 2839 | //socket_close($r); |
2065 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
2066 | - if ($format === 'aprs') $aprs_connect = 0; |
|
2840 | + if ($globalDebug) { |
|
2841 | + echo "Reconnect after an error...\n"; |
|
2842 | + } |
|
2843 | + if ($format === 'aprs') { |
|
2844 | + $aprs_connect = 0; |
|
2845 | + } |
|
2067 | 2846 | $sourceer[$nb] = $globalSources[$nb]; |
2068 | 2847 | connect_all($sourceer); |
2069 | 2848 | $sourceer = array(); |
@@ -2071,10 +2850,14 @@ discard block |
||
2071 | 2850 | } |
2072 | 2851 | } |
2073 | 2852 | // Sleep for xxx microseconds |
2074 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2853 | + if (isset($globalSBSSleep)) { |
|
2854 | + usleep($globalSBSSleep); |
|
2855 | + } |
|
2075 | 2856 | } else { |
2076 | 2857 | if ($format === 'flightgearmp') { |
2077 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2858 | + if ($globalDebug) { |
|
2859 | + echo "Reconnect FlightGear MP..."; |
|
2860 | + } |
|
2078 | 2861 | //@socket_close($r); |
2079 | 2862 | sleep($globalMinFetch); |
2080 | 2863 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2083,10 +2866,15 @@ discard block |
||
2083 | 2866 | break; |
2084 | 2867 | |
2085 | 2868 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
2086 | - if (isset($tt[$format])) $tt[$format]++; |
|
2087 | - else $tt[$format] = 0; |
|
2869 | + if (isset($tt[$format])) { |
|
2870 | + $tt[$format]++; |
|
2871 | + } else { |
|
2872 | + $tt[$format] = 0; |
|
2873 | + } |
|
2088 | 2874 | if ($tt[$format] > 30 || $buffer === FALSE) { |
2089 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2875 | + if ($globalDebug) { |
|
2876 | + echo "ERROR : Reconnect ".$format."..."; |
|
2877 | + } |
|
2090 | 2878 | //@socket_close($r); |
2091 | 2879 | sleep(2); |
2092 | 2880 | $aprs_connect = 0; |
@@ -2104,11 +2892,17 @@ discard block |
||
2104 | 2892 | } else { |
2105 | 2893 | $error = socket_strerror(socket_last_error()); |
2106 | 2894 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
2107 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2108 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2895 | + if ($globalDebug) { |
|
2896 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2897 | + } |
|
2898 | + if (isset($globalDebug)) { |
|
2899 | + echo "Restarting...\n"; |
|
2900 | + } |
|
2109 | 2901 | // Restart the script if possible |
2110 | 2902 | if (is_array($sockets)) { |
2111 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2903 | + if ($globalDebug) { |
|
2904 | + echo "Shutdown all sockets..."; |
|
2905 | + } |
|
2112 | 2906 | |
2113 | 2907 | foreach ($sockets as $sock) { |
2114 | 2908 | @socket_shutdown($sock,2); |
@@ -2116,25 +2910,45 @@ discard block |
||
2116 | 2910 | } |
2117 | 2911 | |
2118 | 2912 | } |
2119 | - if ($globalDebug) echo "Waiting..."; |
|
2913 | + if ($globalDebug) { |
|
2914 | + echo "Waiting..."; |
|
2915 | + } |
|
2120 | 2916 | sleep(2); |
2121 | 2917 | $time = time(); |
2122 | 2918 | //connect_all($hosts); |
2123 | 2919 | $aprs_connect = 0; |
2124 | - if ($reset%5 === 0) sleep(20); |
|
2125 | - if ($reset%10 === 0) sleep(100); |
|
2126 | - if ($reset%20 === 0) sleep(200); |
|
2127 | - if ($reset > 100) exit('Too many attempts...'); |
|
2128 | - if ($globalDebug) echo "Restart all connections..."; |
|
2920 | + if ($reset%5 === 0) { |
|
2921 | + sleep(20); |
|
2922 | + } |
|
2923 | + if ($reset%10 === 0) { |
|
2924 | + sleep(100); |
|
2925 | + } |
|
2926 | + if ($reset%20 === 0) { |
|
2927 | + sleep(200); |
|
2928 | + } |
|
2929 | + if ($reset > 100) { |
|
2930 | + exit('Too many attempts...'); |
|
2931 | + } |
|
2932 | + if ($globalDebug) { |
|
2933 | + echo "Restart all connections..."; |
|
2934 | + } |
|
2129 | 2935 | connect_all($globalSources); |
2130 | 2936 | } |
2131 | 2937 | } |
2132 | 2938 | } |
2133 | 2939 | if ($globalDaemon === false) { |
2134 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
2135 | - if (isset($SI)) $SI->checkAll(); |
|
2136 | - if (isset($TI)) $TI->checkAll(); |
|
2137 | - if (isset($MI)) $MI->checkAll(); |
|
2940 | + if ($globalDebug) { |
|
2941 | + echo 'Check all...'."\n"; |
|
2942 | + } |
|
2943 | + if (isset($SI)) { |
|
2944 | + $SI->checkAll(); |
|
2945 | + } |
|
2946 | + if (isset($TI)) { |
|
2947 | + $TI->checkAll(); |
|
2948 | + } |
|
2949 | + if (isset($MI)) { |
|
2950 | + $MI->checkAll(); |
|
2951 | + } |
|
2138 | 2952 | } |
2139 | 2953 | } |
2140 | 2954 | } |
@@ -4,12 +4,22 @@ discard block |
||
4 | 4 | if (isset($_SESSION['error'])) { |
5 | 5 | header('Content-Encoding: none;'); |
6 | 6 | echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.'; |
7 | - if (isset($_SESSION['error'])) unset($_SESSION['error']); |
|
8 | - if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']); |
|
9 | - if (isset($_SESSION['next'])) unset($_SESSION['next']); |
|
10 | - if (isset($_SESSION['install'])) unset($_SESSION['install']); |
|
11 | - if (isset($_SESSION['identitied'])) unset($_SESSION['identified']); |
|
12 | -} |
|
7 | + if (isset($_SESSION['error'])) { |
|
8 | + unset($_SESSION['error']); |
|
9 | + } |
|
10 | + if (isset($_SESSION['errorlst'])) { |
|
11 | + unset($_SESSION['errorlst']); |
|
12 | + } |
|
13 | + if (isset($_SESSION['next'])) { |
|
14 | + unset($_SESSION['next']); |
|
15 | + } |
|
16 | + if (isset($_SESSION['install'])) { |
|
17 | + unset($_SESSION['install']); |
|
18 | + } |
|
19 | + if (isset($_SESSION['identitied'])) { |
|
20 | + unset($_SESSION['identified']); |
|
21 | + } |
|
22 | + } |
|
13 | 23 | /* |
14 | 24 | if (isset($_SESSION['errorlst'])) { |
15 | 25 | header('Content-Encoding: none;'); |
@@ -131,7 +141,9 @@ discard block |
||
131 | 141 | if (count($alllng) != count($availablelng)) { |
132 | 142 | $notavailable = array(); |
133 | 143 | foreach($alllng as $lng) { |
134 | - if (!isset($availablelng[$lng])) $notavailable[] = $lng; |
|
144 | + if (!isset($availablelng[$lng])) { |
|
145 | + $notavailable[] = $lng; |
|
146 | + } |
|
135 | 147 | } |
136 | 148 | print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>'; |
137 | 149 | } |
@@ -170,7 +182,10 @@ discard block |
||
170 | 182 | <legend>Install script configuration</legend> |
171 | 183 | <p> |
172 | 184 | <label for="installpass">Install password</label> |
173 | - <input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" /> |
|
185 | + <input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) { |
|
186 | + print $globalInstallPassword; |
|
187 | +} |
|
188 | +?>" /> |
|
174 | 189 | </p> |
175 | 190 | <p class="help-block">Password needed to access this install script. If empty, to access this script, you will need to change the $globalInstalled setting in require/settings.php to FALSE</p> |
176 | 191 | </fieldset> |
@@ -200,31 +215,49 @@ discard block |
||
200 | 215 | </div> |
201 | 216 | <p> |
202 | 217 | <label for="dbhost">Database hostname</label> |
203 | - <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" /> |
|
218 | + <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) { |
|
219 | + print $globalDBhost; |
|
220 | +} |
|
221 | +?>" /> |
|
204 | 222 | </p> |
205 | 223 | <p> |
206 | 224 | <label for="dbport">Database port</label> |
207 | - <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" /> |
|
225 | + <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) { |
|
226 | + print $globalDBport; |
|
227 | +} |
|
228 | +?>" /> |
|
208 | 229 | <p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p> |
209 | 230 | </p> |
210 | 231 | <p> |
211 | 232 | <label for="dbname">Database name</label> |
212 | - <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" /> |
|
233 | + <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) { |
|
234 | + print $globalDBname; |
|
235 | +} |
|
236 | +?>" /> |
|
213 | 237 | </p> |
214 | 238 | <p> |
215 | 239 | <label for="dbuser">Database user</label> |
216 | - <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" /> |
|
240 | + <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) { |
|
241 | + print $globalDBuser; |
|
242 | +} |
|
243 | +?>" /> |
|
217 | 244 | </p> |
218 | 245 | <p> |
219 | 246 | <label for="dbuserpass">Database user password</label> |
220 | - <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" /> |
|
247 | + <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) { |
|
248 | + print $globalDBpass; |
|
249 | +} |
|
250 | +?>" /> |
|
221 | 251 | </p> |
222 | 252 | </fieldset> |
223 | 253 | <fieldset id="site"> |
224 | 254 | <legend>Site configuration</legend> |
225 | 255 | <p> |
226 | 256 | <label for="sitename">Site name</label> |
227 | - <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" /> |
|
257 | + <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) { |
|
258 | + print $globalName; |
|
259 | +} |
|
260 | +?>" /> |
|
228 | 261 | </p> |
229 | 262 | <p> |
230 | 263 | <label for="siteurl">Site directory</label> |
@@ -237,18 +270,27 @@ discard block |
||
237 | 270 | } |
238 | 271 | } |
239 | 272 | ?> |
240 | - <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" /> |
|
273 | + <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) { |
|
274 | + print $globalURL; |
|
275 | +} |
|
276 | +?>" /> |
|
241 | 277 | <p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p> |
242 | 278 | <p class="help-block">Can be empty</p> |
243 | 279 | </p> |
244 | 280 | <p> |
245 | 281 | <label for="timezone">Timezone</label> |
246 | - <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" /> |
|
282 | + <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) { |
|
283 | + print $globalTimezone; |
|
284 | +} |
|
285 | +?>" /> |
|
247 | 286 | <p class="help-block">ex : UTC, Europe/Paris,...</p> |
248 | 287 | </p> |
249 | 288 | <p> |
250 | 289 | <label for="language">Language</label> |
251 | - <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" /> |
|
290 | + <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) { |
|
291 | + print $globalLanguage; |
|
292 | +} |
|
293 | +?>" /> |
|
252 | 294 | <p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p> |
253 | 295 | </p> |
254 | 296 | </fieldset> |
@@ -268,11 +310,17 @@ discard block |
||
268 | 310 | <div id="mapbox_data"> |
269 | 311 | <p> |
270 | 312 | <label for="mapboxid">Mapbox id</label> |
271 | - <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" /> |
|
313 | + <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) { |
|
314 | + print $globalMapboxId; |
|
315 | +} |
|
316 | +?>" /> |
|
272 | 317 | </p> |
273 | 318 | <p> |
274 | 319 | <label for="mapboxtoken">Mapbox token</label> |
275 | - <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" /> |
|
320 | + <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) { |
|
321 | + print $globalMapboxToken; |
|
322 | +} |
|
323 | +?>" /> |
|
276 | 324 | </p> |
277 | 325 | <p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p> |
278 | 326 | </div> |
@@ -280,7 +328,10 @@ discard block |
||
280 | 328 | <div id="google_data"> |
281 | 329 | <p> |
282 | 330 | <label for="googlekey">Google API key</label> |
283 | - <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" /> |
|
331 | + <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) { |
|
332 | + print $globalGoogleAPIKey; |
|
333 | +} |
|
334 | +?>" /> |
|
284 | 335 | <p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p> |
285 | 336 | </p> |
286 | 337 | </div> |
@@ -288,7 +339,10 @@ discard block |
||
288 | 339 | <div id="bing_data"> |
289 | 340 | <p> |
290 | 341 | <label for="bingkey">Bing Map key</label> |
291 | - <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" /> |
|
342 | + <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) { |
|
343 | + print $globalBingMapKey; |
|
344 | +} |
|
345 | +?>" /> |
|
292 | 346 | <p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p> |
293 | 347 | </p> |
294 | 348 | </div> |
@@ -296,7 +350,10 @@ discard block |
||
296 | 350 | <div id="mapquest_data"> |
297 | 351 | <p> |
298 | 352 | <label for="mapquestkey">MapQuest key</label> |
299 | - <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" /> |
|
353 | + <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) { |
|
354 | + print $globalMapQuestKey; |
|
355 | +} |
|
356 | +?>" /> |
|
300 | 357 | <p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p> |
301 | 358 | </p> |
302 | 359 | </div> |
@@ -304,11 +361,17 @@ discard block |
||
304 | 361 | <div id="here_data"> |
305 | 362 | <p> |
306 | 363 | <label for="hereappid">Here App_Id</label> |
307 | - <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" /> |
|
364 | + <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) { |
|
365 | + print $globalHereappId; |
|
366 | +} |
|
367 | +?>" /> |
|
308 | 368 | </p> |
309 | 369 | <p> |
310 | 370 | <label for="hereappcode">Here App_Code</label> |
311 | - <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" /> |
|
371 | + <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) { |
|
372 | + print $globalHereappCode; |
|
373 | +} |
|
374 | +?>" /> |
|
312 | 375 | </p> |
313 | 376 | <p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p> |
314 | 377 | </div> |
@@ -316,7 +379,10 @@ discard block |
||
316 | 379 | <div id="openweathermap_data"> |
317 | 380 | <p> |
318 | 381 | <label for="openweathermapkey">OpenWeatherMap key (weather layer)</label> |
319 | - <input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" /> |
|
382 | + <input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) { |
|
383 | + print $globalOpenWeatherMapKey; |
|
384 | +} |
|
385 | +?>" /> |
|
320 | 386 | <p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p> |
321 | 387 | </p> |
322 | 388 | </div> |
@@ -345,42 +411,86 @@ discard block |
||
345 | 411 | <legend>Coverage area</legend> |
346 | 412 | <p> |
347 | 413 | <label for="latitudemax">The maximum latitude (north)</label> |
348 | - <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" /> |
|
414 | + <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) { |
|
415 | + print $globalLatitudeMax; |
|
416 | +} |
|
417 | +?>" /> |
|
349 | 418 | </p> |
350 | 419 | <p> |
351 | 420 | <label for="latitudemin">The minimum latitude (south)</label> |
352 | - <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" /> |
|
421 | + <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) { |
|
422 | + print $globalLatitudeMin; |
|
423 | +} |
|
424 | +?>" /> |
|
353 | 425 | </p> |
354 | 426 | <p> |
355 | 427 | <label for="longitudemax">The maximum longitude (west)</label> |
356 | - <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" /> |
|
428 | + <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) { |
|
429 | + print $globalLongitudeMax; |
|
430 | +} |
|
431 | +?>" /> |
|
357 | 432 | </p> |
358 | 433 | <p> |
359 | 434 | <label for="longitudemin">The minimum longitude (east)</label> |
360 | - <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" /> |
|
435 | + <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) { |
|
436 | + print $globalLongitudeMin; |
|
437 | +} |
|
438 | +?>" /> |
|
361 | 439 | </p> |
362 | 440 | <p> |
363 | 441 | <label for="latitudecenter">The latitude center</label> |
364 | - <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" /> |
|
442 | + <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) { |
|
443 | + print $globalCenterLatitude; |
|
444 | +} |
|
445 | +?>" /> |
|
365 | 446 | </p> |
366 | 447 | <p> |
367 | 448 | <label for="longitudecenter">The longitude center</label> |
368 | - <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" /> |
|
449 | + <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) { |
|
450 | + print $globalCenterLongitude; |
|
451 | +} |
|
452 | +?>" /> |
|
369 | 453 | </p> |
370 | 454 | <p> |
371 | 455 | <label for="livezoom">Default Zoom on live map</label> |
372 | - <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" /> |
|
456 | + <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) { |
|
457 | + print $globalLiveZoom; |
|
458 | +} else { |
|
459 | + print '9'; |
|
460 | +} |
|
461 | +?>" /> |
|
373 | 462 | </p> |
374 | 463 | <p> |
375 | 464 | <label for="squawk_country">Country for squawk usage</label> |
376 | 465 | <select name="squawk_country" id="squawk_country"> |
377 | - <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option> |
|
378 | - <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option> |
|
379 | - <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option> |
|
380 | - <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option> |
|
381 | - <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option> |
|
382 | - <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option> |
|
383 | - <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option> |
|
466 | + <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') { |
|
467 | + print ' selected '; |
|
468 | +} |
|
469 | +?>>UK</option> |
|
470 | + <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') { |
|
471 | + print ' selected '; |
|
472 | +} |
|
473 | +?>>NZ</option> |
|
474 | + <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') { |
|
475 | + print ' selected '; |
|
476 | +} |
|
477 | +?>>US</option> |
|
478 | + <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') { |
|
479 | + print ' selected '; |
|
480 | +} |
|
481 | +?>>AU</option> |
|
482 | + <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') { |
|
483 | + print ' selected '; |
|
484 | +} |
|
485 | +?>>NL</option> |
|
486 | + <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') { |
|
487 | + print ' selected '; |
|
488 | +} |
|
489 | +?>>FR</option> |
|
490 | + <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') { |
|
491 | + print ' selected '; |
|
492 | +} |
|
493 | +?>>TR</option> |
|
384 | 494 | </select> |
385 | 495 | </p> |
386 | 496 | </fieldset> |
@@ -389,15 +499,24 @@ discard block |
||
389 | 499 | <p><i>Only put in DB flights that are inside a circle</i></p> |
390 | 500 | <p> |
391 | 501 | <label for="latitude">Center latitude</label> |
392 | - <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" /> |
|
502 | + <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) { |
|
503 | + echo $globalDistanceIgnore['latitude']; |
|
504 | +} |
|
505 | +?>" /> |
|
393 | 506 | </p> |
394 | 507 | <p> |
395 | 508 | <label for="longitude">Center longitude</label> |
396 | - <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" /> |
|
509 | + <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) { |
|
510 | + echo $globalDistanceIgnore['longitude']; |
|
511 | +} |
|
512 | +?>" /> |
|
397 | 513 | </p> |
398 | 514 | <p> |
399 | 515 | <label for="Distance">Distance (in km)</label> |
400 | - <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" /> |
|
516 | + <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) { |
|
517 | + echo $globalDistanceIgnore['distance']; |
|
518 | +} |
|
519 | +?>" /> |
|
401 | 520 | </p> |
402 | 521 | </fieldset> |
403 | 522 | <fieldset id="sourceloc"> |
@@ -523,22 +642,34 @@ discard block |
||
523 | 642 | <div id="flightaware_data"> |
524 | 643 | <p> |
525 | 644 | <label for="flightawareusername">FlightAware username</label> |
526 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
645 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
646 | + print $globalFlightAwareUsername; |
|
647 | +} |
|
648 | +?>" /> |
|
527 | 649 | </p> |
528 | 650 | <p> |
529 | 651 | <label for="flightawarepassword">FlightAware password/API key</label> |
530 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
652 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
653 | + print $globalFlightAwarePassword; |
|
654 | +} |
|
655 | +?>" /> |
|
531 | 656 | </p> |
532 | 657 | </div> |
533 | 658 | --> |
534 | 659 | <div id="sailaway_data"> |
535 | 660 | <p> |
536 | 661 | <label for="sailawayemail">Sailaway email</label> |
537 | - <input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" /> |
|
662 | + <input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) { |
|
663 | + print $globalSailaway['email']; |
|
664 | +} |
|
665 | +?>" /> |
|
538 | 666 | </p> |
539 | 667 | <p> |
540 | 668 | <label for="sailawaypassword">Sailaway password</label> |
541 | - <input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" /> |
|
669 | + <input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) { |
|
670 | + print $globalSailaway['password']; |
|
671 | +} |
|
672 | +?>" /> |
|
542 | 673 | </p> |
543 | 674 | </div> |
544 | 675 | |
@@ -580,7 +711,10 @@ discard block |
||
580 | 711 | if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
581 | 712 | ?> |
582 | 713 | <td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td> |
583 | - <td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
|
714 | + <td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) { |
|
715 | + print $source['port']; |
|
716 | +} |
|
717 | +?>" /></td> |
|
584 | 718 | <?php |
585 | 719 | } else { |
586 | 720 | $hostport = explode(':',$source['host']); |
@@ -599,39 +733,126 @@ discard block |
||
599 | 733 | ?> |
600 | 734 | <td> |
601 | 735 | <select name="format[]"> |
602 | - <option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option> |
|
603 | - <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option> |
|
604 | - <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option> |
|
605 | - <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option> |
|
606 | - <option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option> |
|
607 | - <option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option> |
|
608 | - <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option> |
|
609 | - <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option> |
|
610 | - <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') print 'selected'; ?>>Radarcape json</option> |
|
611 | - <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option> |
|
612 | - <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option> |
|
613 | - <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option> |
|
614 | - <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option> |
|
615 | - <option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option> |
|
616 | - <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option> |
|
617 | - <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option> |
|
618 | - <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option> |
|
619 | - <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option> |
|
620 | - <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
621 | - <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option> |
|
622 | - <option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json</option> |
|
623 | - <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option> |
|
624 | - <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option> |
|
625 | - <option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option> |
|
626 | - <option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option> |
|
627 | - <option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option> |
|
736 | + <option value="auto" <?php if (!isset($source['format'])) { |
|
737 | + print 'selected'; |
|
738 | +} |
|
739 | +?>>Auto</option> |
|
740 | + <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') { |
|
741 | + print 'selected'; |
|
742 | +} |
|
743 | +?>>SBS</option> |
|
744 | + <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') { |
|
745 | + print 'selected'; |
|
746 | +} |
|
747 | +?>>TSV</option> |
|
748 | + <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') { |
|
749 | + print 'selected'; |
|
750 | +} |
|
751 | +?>>Raw</option> |
|
752 | + <option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') { |
|
753 | + print 'selected'; |
|
754 | +} |
|
755 | +?>>Dump1090 aircraft.json</option> |
|
756 | + <option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') { |
|
757 | + print 'selected'; |
|
758 | +} |
|
759 | +?>>Planefinder client</option> |
|
760 | + <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') { |
|
761 | + print 'selected'; |
|
762 | +} |
|
763 | +?>>APRS</option> |
|
764 | + <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') { |
|
765 | + print 'selected'; |
|
766 | +} |
|
767 | +?>>Radarcape deltadb.txt</option> |
|
768 | + <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') { |
|
769 | + print 'selected'; |
|
770 | +} |
|
771 | +?>>Radarcape json</option> |
|
772 | + <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') { |
|
773 | + print 'selected'; |
|
774 | +} |
|
775 | +?>>Vatsim</option> |
|
776 | + <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') { |
|
777 | + print 'selected'; |
|
778 | +} |
|
779 | +?>>Virtual Radar Server AircraftList.json</option> |
|
780 | + <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') { |
|
781 | + print 'selected'; |
|
782 | +} |
|
783 | +?>>Virtual Radar Server TCP</option> |
|
784 | + <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
785 | + print 'selected'; |
|
786 | +} |
|
787 | +?>>phpVMS</option> |
|
788 | + <option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
789 | + print 'selected'; |
|
790 | +} |
|
791 | +?>>Virtual Airline Operations System (VAOS)</option> |
|
792 | + <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') { |
|
793 | + print 'selected'; |
|
794 | +} |
|
795 | +?>>Virtual Airlines Manager</option> |
|
796 | + <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') { |
|
797 | + print 'selected'; |
|
798 | +} |
|
799 | +?>>IVAO</option> |
|
800 | + <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') { |
|
801 | + print 'selected'; |
|
802 | +} |
|
803 | +?>>FlightGear Multiplayer</option> |
|
804 | + <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') { |
|
805 | + print 'selected'; |
|
806 | +} |
|
807 | +?>>FlightGear Singleplayer</option> |
|
808 | + <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') { |
|
809 | + print 'selected'; |
|
810 | +} |
|
811 | +?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
812 | + <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') { |
|
813 | + print 'selected'; |
|
814 | +} |
|
815 | +?>>ACARS SBS-3 over TCP</option> |
|
816 | + <option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') { |
|
817 | + print 'selected'; |
|
818 | +} |
|
819 | +?>>ACARS from acarsdec json</option> |
|
820 | + <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') { |
|
821 | + print 'selected'; |
|
822 | +} |
|
823 | +?>>NMEA AIS over TCP</option> |
|
824 | + <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') { |
|
825 | + print 'selected'; |
|
826 | +} |
|
827 | +?>>AirWhere website</option> |
|
828 | + <option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') { |
|
829 | + print 'selected'; |
|
830 | +} |
|
831 | +?>>HidnSeek Callback</option> |
|
832 | + <option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') { |
|
833 | + print 'selected'; |
|
834 | +} |
|
835 | +?>>Blitzortung</option> |
|
836 | + <option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') { |
|
837 | + print 'selected'; |
|
838 | +} |
|
839 | +?>>Sailaway</option> |
|
628 | 840 | </select> |
629 | 841 | </td> |
630 | 842 | <td> |
631 | - <input type="text" name="name[]" value="<?php if (isset($source['name'])) print $source['name']; ?>" /> |
|
843 | + <input type="text" name="name[]" value="<?php if (isset($source['name'])) { |
|
844 | + print $source['name']; |
|
845 | +} |
|
846 | +?>" /> |
|
632 | 847 | </td> |
633 | - <td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td> |
|
634 | - <td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td> |
|
848 | + <td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) { |
|
849 | + print 'checked'; |
|
850 | +} |
|
851 | +?> /></td> |
|
852 | + <td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) { |
|
853 | + print 'checked'; |
|
854 | +} |
|
855 | +?> /></td> |
|
635 | 856 | <td> |
636 | 857 | <select name="timezones[]"> |
637 | 858 | <?php |
@@ -641,7 +862,9 @@ discard block |
||
641 | 862 | print '<option selected>'.$timezones.'</option>'; |
642 | 863 | } elseif (!isset($source['timezone']) && $timezones == 'UTC') { |
643 | 864 | print '<option selected>'.$timezones.'</option>'; |
644 | - } else print '<option>'.$timezones.'</option>'; |
|
865 | + } else { |
|
866 | + print '<option>'.$timezones.'</option>'; |
|
867 | + } |
|
645 | 868 | } |
646 | 869 | ?> |
647 | 870 | </select> |
@@ -697,7 +920,9 @@ discard block |
||
697 | 920 | foreach($timezonelist as $timezones){ |
698 | 921 | if ($timezones == 'UTC') { |
699 | 922 | print '<option selected>'.$timezones.'</option>'; |
700 | - } else print '<option>'.$timezones.'</option>'; |
|
923 | + } else { |
|
924 | + print '<option>'.$timezones.'</option>'; |
|
925 | + } |
|
701 | 926 | } |
702 | 927 | ?> |
703 | 928 | </select> |
@@ -722,11 +947,17 @@ discard block |
||
722 | 947 | <p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p> |
723 | 948 | <p> |
724 | 949 | <label for="acarshost">ACARS UDP host</label> |
725 | - <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" /> |
|
950 | + <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) { |
|
951 | + print $globalACARSHost; |
|
952 | +} |
|
953 | +?>" /> |
|
726 | 954 | </p> |
727 | 955 | <p> |
728 | 956 | <label for="acarsport">ACARS UDP port</label> |
729 | - <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" /> |
|
957 | + <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) { |
|
958 | + print $globalACARSPort; |
|
959 | +} |
|
960 | +?>" /> |
|
730 | 961 | </p> |
731 | 962 | <p class="help-block"><i>daemon-acars.php</i> can only be run as daemon. It's an alternate script for ACARS data, <i>daemon-spotter.php</i> may be better.</p> |
732 | 963 | </fieldset> |
@@ -753,17 +984,38 @@ discard block |
||
753 | 984 | <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td> |
754 | 985 | <td> |
755 | 986 | <select name="newslang[]"> |
756 | - <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option> |
|
757 | - <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option> |
|
987 | + <option value="en"<?php if ($lng == 'en') { |
|
988 | + print ' selected'; |
|
989 | +} |
|
990 | +?>>English</option> |
|
991 | + <option value="fr"<?php if ($lng == 'fr') { |
|
992 | + print ' selected'; |
|
993 | +} |
|
994 | +?>>French</option> |
|
758 | 995 | </select> |
759 | 996 | </td> |
760 | 997 | <td> |
761 | 998 | <select name="newstype[]"> |
762 | - <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option> |
|
763 | - <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option> |
|
764 | - <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option> |
|
765 | - <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option> |
|
766 | - <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option> |
|
999 | + <option value="global"<?php if ($type == 'global') { |
|
1000 | + print ' selected'; |
|
1001 | +} |
|
1002 | +?>>Global</option> |
|
1003 | + <option value="aircraft"<?php if ($type == 'aircraft') { |
|
1004 | + print ' selected'; |
|
1005 | +} |
|
1006 | +?>>Aircraft</option> |
|
1007 | + <option value="marine"<?php if ($type == 'marine') { |
|
1008 | + print ' selected'; |
|
1009 | +} |
|
1010 | +?>>Marine</option> |
|
1011 | + <option value="tracker"<?php if ($type == 'tracker') { |
|
1012 | + print ' selected'; |
|
1013 | +} |
|
1014 | +?>>Tracker</option> |
|
1015 | + <option value="satellite"<?php if ($type == 'Satellite') { |
|
1016 | + print ' selected'; |
|
1017 | +} |
|
1018 | +?>>Satellite</option> |
|
767 | 1019 | </select> |
768 | 1020 | </td> |
769 | 1021 | <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td> |
@@ -847,7 +1099,10 @@ discard block |
||
847 | 1099 | </p> |
848 | 1100 | <p> |
849 | 1101 | <label for="corsproxy">CORS proxy</label> |
850 | - <input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" /> |
|
1102 | + <input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) { |
|
1103 | + print $globalCORSproxy; |
|
1104 | +} else { |
|
1105 | + print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" /> |
|
851 | 1106 | <p class="help-block">CORS proxy used for some WMS servers</p> |
852 | 1107 | </p> |
853 | 1108 | <!-- |
@@ -910,13 +1165,18 @@ discard block |
||
910 | 1165 | <div id="schedules_options"> |
911 | 1166 | <p> |
912 | 1167 | <label for="britishairways">British Airways API Key</label> |
913 | - <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" /> |
|
1168 | + <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; |
|
1169 | +} |
|
1170 | +?>" /> |
|
914 | 1171 | <p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p> |
915 | 1172 | </p> |
916 | 1173 | <!-- |
917 | 1174 | <p> |
918 | 1175 | <label for="transavia">Transavia Test API Consumer Key</label> |
919 | - <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" /> |
|
1176 | + <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) { |
|
1177 | + print $globalTransaviaKey; |
|
1178 | +} |
|
1179 | +?>" /> |
|
920 | 1180 | <p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p> |
921 | 1181 | </p> |
922 | 1182 | --> |
@@ -925,10 +1185,16 @@ discard block |
||
925 | 1185 | <b>Lufthansa API Key</b> |
926 | 1186 | <p> |
927 | 1187 | <label for="lufthansakey">Key</label> |
928 | - <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" /> |
|
1188 | + <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) { |
|
1189 | + print $globalLufthansaKey['key']; |
|
1190 | +} |
|
1191 | +?>" /> |
|
929 | 1192 | </p><p> |
930 | 1193 | <label for="lufthansasecret">Secret</label> |
931 | - <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" /> |
|
1194 | + <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) { |
|
1195 | + print $globalLufthansaKey['secret']; |
|
1196 | +} |
|
1197 | +?>" /> |
|
932 | 1198 | </p> |
933 | 1199 | </div> |
934 | 1200 | <p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p> |
@@ -938,11 +1204,17 @@ discard block |
||
938 | 1204 | <b>FlightAware API Key</b> |
939 | 1205 | <p> |
940 | 1206 | <label for="flightawareusername">Username</label> |
941 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
1207 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
1208 | + print $globalFlightAwareUsername; |
|
1209 | +} |
|
1210 | +?>" /> |
|
942 | 1211 | </p> |
943 | 1212 | <p> |
944 | 1213 | <label for="flightawarepassword">API key</label> |
945 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
1214 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
1215 | + print $globalFlightAwarePassword; |
|
1216 | +} |
|
1217 | +?>" /> |
|
946 | 1218 | </p> |
947 | 1219 | </div> |
948 | 1220 | <p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p> |
@@ -959,10 +1231,22 @@ discard block |
||
959 | 1231 | <p> |
960 | 1232 | <label for="mapmatchingsource">Map Matching source</label> |
961 | 1233 | <select name="mapmatchingsource" id="mapmatchingsource"> |
962 | - <option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option> |
|
963 | - <option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option> |
|
964 | - <option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option> |
|
965 | - <option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option> |
|
1234 | + <option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) { |
|
1235 | + print 'selected="selected" '; |
|
1236 | +} |
|
1237 | +?>>FlightAirMap Map Matching</option> |
|
1238 | + <option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') { |
|
1239 | + print 'selected="selected" '; |
|
1240 | +} |
|
1241 | +?>>GraphHopper</option> |
|
1242 | + <option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') { |
|
1243 | + print 'selected="selected" '; |
|
1244 | +} |
|
1245 | +?>>OSMR</option> |
|
1246 | + <option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') { |
|
1247 | + print 'selected="selected" '; |
|
1248 | +} |
|
1249 | +?>>Mapbox</option> |
|
966 | 1250 | </select> |
967 | 1251 | <p class="help-block">Mapbox need the API Key defined in map section.</p> |
968 | 1252 | <p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p> |
@@ -970,7 +1254,10 @@ discard block |
||
970 | 1254 | <br /> |
971 | 1255 | <p> |
972 | 1256 | <label for="graphhopper">GraphHopper API Key</label> |
973 | - <input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" /> |
|
1257 | + <input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) { |
|
1258 | + print $globalGraphHopperKey; |
|
1259 | +} |
|
1260 | +?>" /> |
|
974 | 1261 | <p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p> |
975 | 1262 | </p> |
976 | 1263 | </div> |
@@ -988,7 +1275,10 @@ discard block |
||
988 | 1275 | </p> |
989 | 1276 | <p> |
990 | 1277 | <label for="notamsource">URL of your feed from notaminfo.com</label> |
991 | - <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" /> |
|
1278 | + <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) { |
|
1279 | + print $globalNOTAMSource; |
|
1280 | +} |
|
1281 | +?>" /> |
|
992 | 1282 | <p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p> |
993 | 1283 | </p> |
994 | 1284 | <br /> |
@@ -1004,14 +1294,20 @@ discard block |
||
1004 | 1294 | <div id="metarsrc"> |
1005 | 1295 | <p> |
1006 | 1296 | <label for="metarsource">URL of your METAR source</label> |
1007 | - <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" /> |
|
1297 | + <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) { |
|
1298 | + print $globalMETARurl; |
|
1299 | +} |
|
1300 | +?>" /> |
|
1008 | 1301 | <p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p> |
1009 | 1302 | </p> |
1010 | 1303 | </div> |
1011 | 1304 | <br /> |
1012 | 1305 | <p> |
1013 | 1306 | <label for="bitly">Bit.ly access token api (used in search page)</label> |
1014 | - <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" /> |
|
1307 | + <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) { |
|
1308 | + print $globalBitlyAccessToken; |
|
1309 | +} |
|
1310 | +?>" /> |
|
1015 | 1311 | </p> |
1016 | 1312 | <br /> |
1017 | 1313 | <p> |
@@ -1027,11 +1323,26 @@ discard block |
||
1027 | 1323 | <p> |
1028 | 1324 | <label for="geoid_source">Geoid Source</label> |
1029 | 1325 | <select name="geoid_source" id="geoid_source"> |
1030 | - <option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option> |
|
1031 | - <option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option> |
|
1032 | - <option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option> |
|
1033 | - <option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option> |
|
1034 | - <option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option> |
|
1326 | + <option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') { |
|
1327 | + print ' selected="selected"'; |
|
1328 | +} |
|
1329 | +?>>EGM96 15' (2.1MB)</option> |
|
1330 | + <option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') { |
|
1331 | + print ' selected="selected"'; |
|
1332 | +} |
|
1333 | +?>>EGM96 5' (19MB)</option> |
|
1334 | + <option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') { |
|
1335 | + print ' selected="selected"'; |
|
1336 | +} |
|
1337 | +?>>EGM2008 5' (19MB)</option> |
|
1338 | + <option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') { |
|
1339 | + print ' selected="selected"'; |
|
1340 | +} |
|
1341 | +?>>EGM2008 2.5' (75MB)</option> |
|
1342 | + <option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') { |
|
1343 | + print ' selected="selected"'; |
|
1344 | +} |
|
1345 | +?>>EGM2008 1' (470MB)</option> |
|
1035 | 1346 | </select> |
1036 | 1347 | <p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p> |
1037 | 1348 | </p> |
@@ -1053,7 +1364,12 @@ discard block |
||
1053 | 1364 | </p> |
1054 | 1365 | <p> |
1055 | 1366 | <label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label> |
1056 | - <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" /> |
|
1367 | + <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) { |
|
1368 | + print $globalArchiveMonths; |
|
1369 | +} else { |
|
1370 | + echo '1'; |
|
1371 | +} |
|
1372 | +?>" /> |
|
1057 | 1373 | <p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p> |
1058 | 1374 | </p> |
1059 | 1375 | <p> |
@@ -1063,12 +1379,22 @@ discard block |
||
1063 | 1379 | </p> |
1064 | 1380 | <p> |
1065 | 1381 | <label for="archivekeepmonths">Keep flights data for xx months in archive</label> |
1066 | - <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" /> |
|
1382 | + <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) { |
|
1383 | + print $globalArchiveKeepMonths; |
|
1384 | +} else { |
|
1385 | + echo '1'; |
|
1386 | +} |
|
1387 | +?>" /> |
|
1067 | 1388 | <p class="help-block">0 to disable</p> |
1068 | 1389 | </p> |
1069 | 1390 | <p> |
1070 | 1391 | <label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label> |
1071 | - <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" /> |
|
1392 | + <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) { |
|
1393 | + print $globalArchiveKeepTrackMonths; |
|
1394 | +} else { |
|
1395 | + echo '1'; |
|
1396 | +} |
|
1397 | +?>" /> |
|
1072 | 1398 | <p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p> |
1073 | 1399 | </p> |
1074 | 1400 | <br /> |
@@ -1078,7 +1404,12 @@ discard block |
||
1078 | 1404 | <p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p> |
1079 | 1405 | <div id="cronends"> |
1080 | 1406 | <label for="cronend">Run script for xx seconds</label> |
1081 | - <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" /> |
|
1407 | + <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) { |
|
1408 | + print $globalCronEnd; |
|
1409 | +} else { |
|
1410 | + print '0'; |
|
1411 | +} |
|
1412 | +?>" /> |
|
1082 | 1413 | <p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p> |
1083 | 1414 | </div> |
1084 | 1415 | </p> |
@@ -1137,20 +1468,40 @@ discard block |
||
1137 | 1468 | <br /> |
1138 | 1469 | <p> |
1139 | 1470 | <label for="refresh">Show flights detected since xxx seconds</label> |
1140 | - <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" /> |
|
1471 | + <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) { |
|
1472 | + echo $globalLiveInterval; |
|
1473 | +} else { |
|
1474 | + echo '200'; |
|
1475 | +} |
|
1476 | +?>" /> |
|
1141 | 1477 | </p> |
1142 | 1478 | <p> |
1143 | 1479 | <label for="maprefresh">Live map refresh (in seconds)</label> |
1144 | - <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" /> |
|
1480 | + <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) { |
|
1481 | + echo $globalMapRefresh; |
|
1482 | +} else { |
|
1483 | + echo '30'; |
|
1484 | +} |
|
1485 | +?>" /> |
|
1145 | 1486 | </p> |
1146 | 1487 | <p> |
1147 | 1488 | <label for="mapidle">Map idle timeout (in minutes)</label> |
1148 | - <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" /> |
|
1489 | + <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) { |
|
1490 | + echo $globalMapIdleTimeout; |
|
1491 | +} else { |
|
1492 | + echo '30'; |
|
1493 | +} |
|
1494 | +?>" /> |
|
1149 | 1495 | <p class="help-block">0 to disable</p> |
1150 | 1496 | </p> |
1151 | 1497 | <p> |
1152 | 1498 | <label for="minfetch">HTTP/file source fetch every xxx seconds</label> |
1153 | - <input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" /> |
|
1499 | + <input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) { |
|
1500 | + echo $globalMinFetch; |
|
1501 | +} else { |
|
1502 | + echo '20'; |
|
1503 | +} |
|
1504 | +?>" /> |
|
1154 | 1505 | </p> |
1155 | 1506 | <p> |
1156 | 1507 | <label for="bbox">Only display flights that we can see on screen (bounding box)</label> |
@@ -1169,12 +1520,20 @@ discard block |
||
1169 | 1520 | <br /> |
1170 | 1521 | <p> |
1171 | 1522 | <label for="closestmindist">Distance to airport set as arrival (in km)</label> |
1172 | - <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" /> |
|
1523 | + <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) { |
|
1524 | + echo $globalClosestMinDist; |
|
1525 | +} else { |
|
1526 | + echo '50'; |
|
1527 | +} |
|
1528 | +?>" /> |
|
1173 | 1529 | </p> |
1174 | 1530 | <br /> |
1175 | 1531 | <p> |
1176 | 1532 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
1177 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
1533 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) { |
|
1534 | + echo $globalAircraftSize; |
|
1535 | +} |
|
1536 | +?>" /> |
|
1178 | 1537 | </p> |
1179 | 1538 | <br /> |
1180 | 1539 | <p> |
@@ -1193,22 +1552,42 @@ discard block |
||
1193 | 1552 | <br /> |
1194 | 1553 | <p> |
1195 | 1554 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
1196 | - <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
|
1555 | + <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) { |
|
1556 | + echo $globalAircraftIconColor; |
|
1557 | +} else { |
|
1558 | + echo '1a3151'; |
|
1559 | +} |
|
1560 | +?>" /> |
|
1197 | 1561 | </p> |
1198 | 1562 | <br /> |
1199 | 1563 | <p> |
1200 | 1564 | <label for="marineiconcolor">Color of marine icon on map</label> |
1201 | - <input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" /> |
|
1565 | + <input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) { |
|
1566 | + echo $globalMarineIconColor; |
|
1567 | +} else { |
|
1568 | + echo '43d1d8'; |
|
1569 | +} |
|
1570 | +?>" /> |
|
1202 | 1571 | </p> |
1203 | 1572 | <br /> |
1204 | 1573 | <p> |
1205 | 1574 | <label for="trackericoncolor">Color of tracker icon on map</label> |
1206 | - <input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" /> |
|
1575 | + <input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) { |
|
1576 | + echo $globalTrackerIconColor; |
|
1577 | +} else { |
|
1578 | + echo '1a3151'; |
|
1579 | +} |
|
1580 | +?>" /> |
|
1207 | 1581 | </p> |
1208 | 1582 | <br /> |
1209 | 1583 | <p> |
1210 | 1584 | <label for="satelliteiconcolor">Color of satellite icon on map</label> |
1211 | - <input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" /> |
|
1585 | + <input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) { |
|
1586 | + echo $globalSatelliteIconColor; |
|
1587 | +} else { |
|
1588 | + echo '1a3151'; |
|
1589 | +} |
|
1590 | +?>" /> |
|
1212 | 1591 | </p> |
1213 | 1592 | <?php |
1214 | 1593 | if (!is_writable('../cache')) { |
@@ -1232,14 +1611,27 @@ discard block |
||
1232 | 1611 | <p> |
1233 | 1612 | <label for="airportzoom">Zoom level minimum to see airports icons</label> |
1234 | 1613 | <div class="range"> |
1235 | - <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" /> |
|
1236 | - <output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output> |
|
1614 | + <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) { |
|
1615 | + echo $globalAirportZoom; |
|
1616 | +} else { |
|
1617 | + echo '7'; |
|
1618 | +} |
|
1619 | +?>" /> |
|
1620 | + <output id="range"><?php if (isset($globalAirportZoom)) { |
|
1621 | + echo $globalAirportZoom; |
|
1622 | +} else { |
|
1623 | + echo '7'; |
|
1624 | +} |
|
1625 | +?></output> |
|
1237 | 1626 | </div> |
1238 | 1627 | </p> |
1239 | 1628 | <br /> |
1240 | 1629 | <p> |
1241 | 1630 | <label for="customcss">Custom CSS web path</label> |
1242 | - <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" /> |
|
1631 | + <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) { |
|
1632 | + echo $globalCustomCSS; |
|
1633 | +} |
|
1634 | +?>" /> |
|
1243 | 1635 | </p> |
1244 | 1636 | </fieldset> |
1245 | 1637 | <input type="submit" name="submit" value="Create/Update database & write setup" /> |
@@ -1269,8 +1661,12 @@ discard block |
||
1269 | 1661 | $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
1270 | 1662 | $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
1271 | 1663 | |
1272 | - if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
|
1273 | - if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
1664 | + if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) { |
|
1665 | + $error .= 'Mysql driver for PDO must be loaded'; |
|
1666 | + } |
|
1667 | + if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) { |
|
1668 | + $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
1669 | + } |
|
1274 | 1670 | |
1275 | 1671 | $_SESSION['database_root'] = $dbroot; |
1276 | 1672 | $_SESSION['database_rootpass'] = $dbrootpass; |
@@ -1348,15 +1744,23 @@ discard block |
||
1348 | 1744 | $source_city = $_POST['source_city']; |
1349 | 1745 | $source_country = $_POST['source_country']; |
1350 | 1746 | $source_ref = $_POST['source_ref']; |
1351 | - if (isset($source_id)) $source_id = $_POST['source_id']; |
|
1352 | - else $source_id = array(); |
|
1747 | + if (isset($source_id)) { |
|
1748 | + $source_id = $_POST['source_id']; |
|
1749 | + } else { |
|
1750 | + $source_id = array(); |
|
1751 | + } |
|
1353 | 1752 | |
1354 | 1753 | $sources = array(); |
1355 | 1754 | foreach ($source_name as $keys => $name) { |
1356 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1357 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1755 | + if (isset($source_id[$keys])) { |
|
1756 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1757 | + } else { |
|
1758 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1759 | + } |
|
1760 | + } |
|
1761 | + if (count($sources) > 0) { |
|
1762 | + $_SESSION['sources'] = $sources; |
|
1358 | 1763 | } |
1359 | - if (count($sources) > 0) $_SESSION['sources'] = $sources; |
|
1360 | 1764 | |
1361 | 1765 | $newsurl = $_POST['newsurl']; |
1362 | 1766 | $newslng = $_POST['newslang']; |
@@ -1369,7 +1773,9 @@ discard block |
||
1369 | 1773 | $lng = $newslng[$newskey]; |
1370 | 1774 | if (isset($newsfeeds[$type][$lng])) { |
1371 | 1775 | $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url)); |
1372 | - } else $newsfeeds[$type][$lng] = array($url); |
|
1776 | + } else { |
|
1777 | + $newsfeeds[$type][$lng] = array($url); |
|
1778 | + } |
|
1373 | 1779 | } |
1374 | 1780 | } |
1375 | 1781 | $settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds)); |
@@ -1394,17 +1800,29 @@ discard block |
||
1394 | 1800 | $datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING); |
1395 | 1801 | |
1396 | 1802 | $globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING); |
1397 | - if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
1398 | - else $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
1803 | + if ($globalaircraft == 'aircraft') { |
|
1804 | + $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
1805 | + } else { |
|
1806 | + $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
1807 | + } |
|
1399 | 1808 | $globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING); |
1400 | - if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
1401 | - else $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
1809 | + if ($globaltracker == 'tracker') { |
|
1810 | + $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
1811 | + } else { |
|
1812 | + $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
1813 | + } |
|
1402 | 1814 | $globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING); |
1403 | - if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
1404 | - else $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
1815 | + if ($globalmarine == 'marine') { |
|
1816 | + $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
1817 | + } else { |
|
1818 | + $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
1819 | + } |
|
1405 | 1820 | $globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING); |
1406 | - if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE')); |
|
1407 | - else $settings = array_merge($settings,array('globalSatellite' => 'FALSE')); |
|
1821 | + if ($globalsatellite == 'satellite') { |
|
1822 | + $settings = array_merge($settings,array('globalSatellite' => 'TRUE')); |
|
1823 | + } else { |
|
1824 | + $settings = array_merge($settings,array('globalSatellite' => 'FALSE')); |
|
1825 | + } |
|
1408 | 1826 | |
1409 | 1827 | /* |
1410 | 1828 | $globalSBS1Hosts = array(); |
@@ -1426,23 +1844,37 @@ discard block |
||
1426 | 1844 | $name = $_POST['name']; |
1427 | 1845 | $format = $_POST['format']; |
1428 | 1846 | $timezones = $_POST['timezones']; |
1429 | - if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats']; |
|
1430 | - else $sourcestats = array(); |
|
1431 | - if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive']; |
|
1432 | - else $noarchive = array(); |
|
1847 | + if (isset($_POST['sourcestats'])) { |
|
1848 | + $sourcestats = $_POST['sourcestats']; |
|
1849 | + } else { |
|
1850 | + $sourcestats = array(); |
|
1851 | + } |
|
1852 | + if (isset($_POST['noarchive'])) { |
|
1853 | + $noarchive = $_POST['noarchive']; |
|
1854 | + } else { |
|
1855 | + $noarchive = array(); |
|
1856 | + } |
|
1433 | 1857 | $gSources = array(); |
1434 | 1858 | $forcepilots = false; |
1435 | 1859 | foreach ($host as $key => $h) { |
1436 | - if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE'; |
|
1437 | - else $cov = 'FALSE'; |
|
1438 | - if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE'; |
|
1439 | - else $arch = 'FALSE'; |
|
1860 | + if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) { |
|
1861 | + $cov = 'TRUE'; |
|
1862 | + } else { |
|
1863 | + $cov = 'FALSE'; |
|
1864 | + } |
|
1865 | + if (isset($noarchive[$key]) && $noarchive[$key] == 1) { |
|
1866 | + $arch = 'TRUE'; |
|
1867 | + } else { |
|
1868 | + $arch = 'FALSE'; |
|
1869 | + } |
|
1440 | 1870 | if (strpos($format[$key],'_callback')) { |
1441 | 1871 | $gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE'); |
1442 | 1872 | } elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) { |
1443 | 1873 | $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE'); |
1444 | 1874 | } |
1445 | - if ($format[$key] == 'airwhere') $forcepilots = true; |
|
1875 | + if ($format[$key] == 'airwhere') { |
|
1876 | + $forcepilots = true; |
|
1877 | + } |
|
1446 | 1878 | } |
1447 | 1879 | $settings = array_merge($settings,array('globalSources' => $gSources)); |
1448 | 1880 | |
@@ -1473,7 +1905,9 @@ discard block |
||
1473 | 1905 | $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
1474 | 1906 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
1475 | 1907 | $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
1476 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1908 | + } else { |
|
1909 | + $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1910 | + } |
|
1477 | 1911 | |
1478 | 1912 | $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
1479 | 1913 | $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
@@ -1514,7 +1948,9 @@ discard block |
||
1514 | 1948 | |
1515 | 1949 | // Create in settings.php keys not yet configurable if not already here |
1516 | 1950 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
1517 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1951 | + if (!isset($globalDebug)) { |
|
1952 | + $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1953 | + } |
|
1518 | 1954 | |
1519 | 1955 | $resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING); |
1520 | 1956 | if ($resetyearstats == 'resetyearstats') { |
@@ -1557,37 +1993,56 @@ discard block |
||
1557 | 1993 | } |
1558 | 1994 | */ |
1559 | 1995 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
1560 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1561 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
1562 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
1563 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
1996 | + if ($globalsbs == 'sbs') { |
|
1997 | + $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1998 | + } else { |
|
1999 | + $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
2000 | + } |
|
2001 | + if ($globalaprs == 'aprs') { |
|
2002 | + $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
2003 | + } else { |
|
2004 | + $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
2005 | + } |
|
1564 | 2006 | $va = false; |
1565 | 2007 | if ($globalivao == 'ivao') { |
1566 | 2008 | $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
1567 | 2009 | $va = true; |
1568 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
2010 | + } else { |
|
2011 | + $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
2012 | + } |
|
1569 | 2013 | if ($globalvatsim == 'vatsim') { |
1570 | 2014 | $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
1571 | 2015 | $va = true; |
1572 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
2016 | + } else { |
|
2017 | + $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
2018 | + } |
|
1573 | 2019 | if ($globalphpvms == 'phpvms') { |
1574 | 2020 | $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
1575 | 2021 | $va = true; |
1576 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
2022 | + } else { |
|
2023 | + $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
2024 | + } |
|
1577 | 2025 | if ($globalvam == 'vam') { |
1578 | 2026 | $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
1579 | 2027 | $va = true; |
1580 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
2028 | + } else { |
|
2029 | + $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
2030 | + } |
|
1581 | 2031 | if ($va) { |
1582 | 2032 | $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
1583 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
2033 | + } else { |
|
2034 | + $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
2035 | + } |
|
1584 | 2036 | if ($globalva == 'va' || $va) { |
1585 | 2037 | $settings = array_merge($settings,array('globalVA' => 'TRUE')); |
1586 | 2038 | $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
1587 | 2039 | } else { |
1588 | 2040 | $settings = array_merge($settings,array('globalVA' => 'FALSE')); |
1589 | - if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1590 | - else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
2041 | + if ($forcepilots) { |
|
2042 | + $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
2043 | + } else { |
|
2044 | + $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
2045 | + } |
|
1591 | 2046 | } |
1592 | 2047 | if ($globalvm == 'vm') { |
1593 | 2048 | $settings = array_merge($settings,array('globalVM' => 'TRUE')); |
@@ -1847,7 +2302,9 @@ discard block |
||
1847 | 2302 | $graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING); |
1848 | 2303 | $settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper)); |
1849 | 2304 | |
1850 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
2305 | + if (!isset($globalTransaction)) { |
|
2306 | + $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
2307 | + } |
|
1851 | 2308 | |
1852 | 2309 | // Set some defaults values... |
1853 | 2310 | if (!isset($globalAircraftImageSources)) { |
@@ -1862,15 +2319,23 @@ discard block |
||
1862 | 2319 | |
1863 | 2320 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1864 | 2321 | |
1865 | - if ($error == '') settings::modify_settings($settings); |
|
1866 | - if ($error == '') settings::comment_settings($settings_comment); |
|
2322 | + if ($error == '') { |
|
2323 | + settings::modify_settings($settings); |
|
2324 | + } |
|
2325 | + if ($error == '') { |
|
2326 | + settings::comment_settings($settings_comment); |
|
2327 | + } |
|
1867 | 2328 | if ($error != '') { |
1868 | 2329 | print '<div class="info column">'.$error.'</div>'; |
1869 | 2330 | require('../footer.php'); |
1870 | 2331 | exit; |
1871 | 2332 | } else { |
1872 | - if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1; |
|
1873 | - if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1; |
|
2333 | + if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') { |
|
2334 | + $_SESSION['waypoints'] = 1; |
|
2335 | + } |
|
2336 | + if (isset($_POST['owner']) && $_POST['owner'] == 'owner') { |
|
2337 | + $_SESSION['owner'] = 1; |
|
2338 | + } |
|
1874 | 2339 | if (isset($_POST['createdb'])) { |
1875 | 2340 | $_SESSION['install'] = 'database_create'; |
1876 | 2341 | } else { |
@@ -1907,10 +2372,18 @@ discard block |
||
1907 | 2372 | $popw = false; |
1908 | 2373 | foreach ($_SESSION['done'] as $done) { |
1909 | 2374 | print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
1910 | - if ($done == 'Create database') $pop = true; |
|
1911 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1912 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1913 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
2375 | + if ($done == 'Create database') { |
|
2376 | + $pop = true; |
|
2377 | + } |
|
2378 | + if ($_SESSION['install'] == 'database_create') { |
|
2379 | + $pop = true; |
|
2380 | + } |
|
2381 | + if ($_SESSION['install'] == 'database_import') { |
|
2382 | + $popi = true; |
|
2383 | + } |
|
2384 | + if ($_SESSION['install'] == 'waypoints') { |
|
2385 | + $popw = true; |
|
2386 | + } |
|
1914 | 2387 | } |
1915 | 2388 | if ($pop) { |
1916 | 2389 | sleep(5); |
@@ -1921,7 +2394,9 @@ discard block |
||
1921 | 2394 | } else if ($popw) { |
1922 | 2395 | sleep(5); |
1923 | 2396 | print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
1924 | - } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
2397 | + } else { |
|
2398 | + print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
2399 | + } |
|
1925 | 2400 | print '</div></ul>'; |
1926 | 2401 | print '<div id="error"></div>'; |
1927 | 2402 | /* foreach ($_SESSION['done'] as $done) { |