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