@@ -15,65 +15,65 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) { |
18 | - require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | 19 | } |
20 | 20 | if (isset($globalMarine) && $globalMarine) { |
21 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
22 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
22 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | if (!isset($globalDebug)) $globalDebug = FALSE; |
26 | 26 | |
27 | 27 | if ($globalInstalled === FALSE) { |
28 | - echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
|
29 | - sleep(5); |
|
30 | - die(); |
|
28 | + echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
|
29 | + sleep(5); |
|
30 | + die(); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | // Check if schema is at latest version |
35 | 35 | $Connection = new Connection(); |
36 | 36 | if ($Connection->connectionExists() === false) { |
37 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
38 | - exit(); |
|
37 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
38 | + exit(); |
|
39 | 39 | } |
40 | 40 | if ($Connection->latest() === false) { |
41 | - echo "You MUST update to latest schema. Use your web browser to run install/index.php"; |
|
42 | - exit(); |
|
41 | + echo "You MUST update to latest schema. Use your web browser to run install/index.php"; |
|
42 | + exit(); |
|
43 | 43 | } |
44 | 44 | if (PHP_SAPI != 'cli') { |
45 | - echo "This script MUST be called from console, not a web browser."; |
|
45 | + echo "This script MUST be called from console, not a web browser."; |
|
46 | 46 | // exit(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | // This is to be compatible with old version of settings.php |
50 | 50 | if (!isset($globalSources)) { |
51 | - if (isset($globalSBS1Hosts)) { |
|
52 | - //$hosts = $globalSBS1Hosts; |
|
53 | - foreach ($globalSBS1Hosts as $host) { |
|
54 | - $globalSources[] = array('host' => $host); |
|
55 | - } |
|
56 | - } else { |
|
57 | - if (!isset($globalSBS1Host)) { |
|
58 | - echo '$globalSources MUST be defined !'; |
|
59 | - die; |
|
51 | + if (isset($globalSBS1Hosts)) { |
|
52 | + //$hosts = $globalSBS1Hosts; |
|
53 | + foreach ($globalSBS1Hosts as $host) { |
|
54 | + $globalSources[] = array('host' => $host); |
|
55 | + } |
|
56 | + } else { |
|
57 | + if (!isset($globalSBS1Host)) { |
|
58 | + echo '$globalSources MUST be defined !'; |
|
59 | + die; |
|
60 | 60 | } |
61 | 61 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
62 | 62 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
63 | - } |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
67 | 67 | //if (isset($options['s'])) $hosts = array($options['s']); |
68 | 68 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
69 | 69 | if (isset($options['s'])) { |
70 | - $globalSources = array(); |
|
71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
72 | - else $globalSources[] = array('host' => $options['s']); |
|
70 | + $globalSources = array(); |
|
71 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
72 | + else $globalSources[] = array('host' => $options['s']); |
|
73 | 73 | } elseif (isset($options['source'])) { |
74 | - $globalSources = array(); |
|
75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
76 | - else $globalSources[] = array('host' => $options['source']); |
|
74 | + $globalSources = array(); |
|
75 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
76 | + else $globalSources[] = array('host' => $options['source']); |
|
77 | 77 | } |
78 | 78 | if (isset($options['aprsserverhost'])) { |
79 | 79 | $globalServerAPRS = TRUE; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
113 | 113 | else $id_source = 1; |
114 | 114 | if (isset($globalServer) && $globalServer) { |
115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
116 | - $SI=new SpotterServer(); |
|
115 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
116 | + $SI=new SpotterServer(); |
|
117 | 117 | /* |
118 | 118 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
119 | 119 | $SI = new adsb2aprs(); |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | |
124 | 124 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
125 | 125 | if (isset($globalMarine) && $globalMarine) { |
126 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
127 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
126 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
127 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
131 | 131 | if (isset($globalMarine) && $globalMarine) { |
132 | - $AIS = new AIS(); |
|
133 | - $MI = new MarineImport($Connection->db); |
|
132 | + $AIS = new AIS(); |
|
133 | + $MI = new MarineImport($Connection->db); |
|
134 | 134 | } |
135 | 135 | //$APRS=new APRS($Connection->db); |
136 | 136 | $SBS=new SBS(); |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | //$servertz = system('date +%Z'); |
144 | 144 | // signal handler - playing nice with sockets and dump1090 |
145 | 145 | if (function_exists('pcntl_fork')) { |
146 | - pcntl_signal(SIGINT, function() { |
|
147 | - global $sockets; |
|
148 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
149 | - die("Bye!\n"); |
|
150 | - }); |
|
151 | - pcntl_signal_dispatch(); |
|
146 | + pcntl_signal(SIGINT, function() { |
|
147 | + global $sockets; |
|
148 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
149 | + die("Bye!\n"); |
|
150 | + }); |
|
151 | + pcntl_signal_dispatch(); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // let's try and connect |
@@ -158,47 +158,47 @@ discard block |
||
158 | 158 | $reset = 0; |
159 | 159 | |
160 | 160 | function connect_all($hosts) { |
161 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
162 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
163 | - $reset++; |
|
164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
165 | - foreach ($hosts as $id => $value) { |
|
161 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
162 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
163 | + $reset++; |
|
164 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
165 | + foreach ($hosts as $id => $value) { |
|
166 | 166 | $host = $value['host']; |
167 | 167 | $udp = false; |
168 | 168 | $globalSources[$id]['last_exec'] = 0; |
169 | 169 | // Here we check type of source(s) |
170 | 170 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
171 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
172 | - //$formats[$id] = 'deltadbtxt'; |
|
173 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
174 | - //$last_exec['deltadbtxt'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
176 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
177 | - //$formats[$id] = 'vatsimtxt'; |
|
178 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
179 | - //$last_exec['vatsimtxt'] = 0; |
|
180 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
181 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
182 | - //$formats[$id] = 'aircraftlistjson'; |
|
183 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
184 | - //$last_exec['aircraftlistjson'] = 0; |
|
185 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
186 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
187 | - //$formats[$id] = 'aircraftjson'; |
|
188 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
189 | - //$last_exec['aircraftlistjson'] = 0; |
|
190 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
191 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
192 | - //$formats[$id] = 'planefinderclient'; |
|
193 | - $globalSources[$id]['format'] = 'planefinderclient'; |
|
194 | - //$last_exec['aircraftlistjson'] = 0; |
|
195 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
196 | - } else if (preg_match('/opensky/i',$host)) { |
|
197 | - //$formats[$id] = 'aircraftlistjson'; |
|
198 | - $globalSources[$id]['format'] = 'opensky'; |
|
199 | - //$last_exec['aircraftlistjson'] = 0; |
|
200 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
201 | - /* |
|
171 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
172 | + //$formats[$id] = 'deltadbtxt'; |
|
173 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
174 | + //$last_exec['deltadbtxt'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
176 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
177 | + //$formats[$id] = 'vatsimtxt'; |
|
178 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
179 | + //$last_exec['vatsimtxt'] = 0; |
|
180 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
181 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
182 | + //$formats[$id] = 'aircraftlistjson'; |
|
183 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
184 | + //$last_exec['aircraftlistjson'] = 0; |
|
185 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
186 | + } else if (preg_match('/aircraft.json$/i',$host)) { |
|
187 | + //$formats[$id] = 'aircraftjson'; |
|
188 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
189 | + //$last_exec['aircraftlistjson'] = 0; |
|
190 | + if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
191 | + } else if (preg_match('/aircraft$/i',$host)) { |
|
192 | + //$formats[$id] = 'planefinderclient'; |
|
193 | + $globalSources[$id]['format'] = 'planefinderclient'; |
|
194 | + //$last_exec['aircraftlistjson'] = 0; |
|
195 | + if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
196 | + } else if (preg_match('/opensky/i',$host)) { |
|
197 | + //$formats[$id] = 'aircraftlistjson'; |
|
198 | + $globalSources[$id]['format'] = 'opensky'; |
|
199 | + //$last_exec['aircraftlistjson'] = 0; |
|
200 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
201 | + /* |
|
202 | 202 | // Disabled for now, site change source format |
203 | 203 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
204 | 204 | //$formats[$id] = 'radarvirtueljson'; |
@@ -210,131 +210,131 @@ discard block |
||
210 | 210 | exit(0); |
211 | 211 | } |
212 | 212 | */ |
213 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
214 | - //$formats[$id] = 'planeupdatefaa'; |
|
215 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
216 | - //$last_exec['planeupdatefaa'] = 0; |
|
217 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
218 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
219 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
220 | - exit(0); |
|
221 | - } |
|
222 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
223 | - //$formats[$id] = 'phpvmacars'; |
|
224 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
225 | - //$last_exec['phpvmacars'] = 0; |
|
226 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
227 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
228 | - //$formats[$id] = 'phpvmacars'; |
|
229 | - $globalSources[$id]['format'] = 'vaos'; |
|
230 | - //$last_exec['phpvmacars'] = 0; |
|
231 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
232 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
233 | - //$formats[$id] = 'phpvmacars'; |
|
234 | - $globalSources[$id]['format'] = 'vam'; |
|
235 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
236 | - } else if (preg_match('/whazzup/i',$host)) { |
|
237 | - //$formats[$id] = 'whazzup'; |
|
238 | - $globalSources[$id]['format'] = 'whazzup'; |
|
239 | - //$last_exec['whazzup'] = 0; |
|
240 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
241 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
242 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
243 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
244 | - } else if (preg_match('/airwhere/i',$host)) { |
|
245 | - $globalSources[$id]['format'] = 'airwhere'; |
|
246 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
247 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
248 | - //$formats[$id] = 'pirepsjson'; |
|
249 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
250 | - //$last_exec['pirepsjson'] = 0; |
|
251 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
252 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
253 | - //$formats[$id] = 'fr24json'; |
|
254 | - $globalSources[$id]['format'] = 'fr24json'; |
|
255 | - //$last_exec['fr24json'] = 0; |
|
256 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
257 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
258 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
259 | - exit(0); |
|
260 | - } |
|
261 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
262 | - //$formats[$id] = 'fr24json'; |
|
263 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
264 | - //$last_exec['fr24json'] = 0; |
|
265 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
266 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
267 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
268 | - exit(0); |
|
269 | - } |
|
270 | - //} else if (preg_match('/10001/',$host)) { |
|
271 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
272 | - //$formats[$id] = 'tsv'; |
|
273 | - $globalSources[$id]['format'] = 'tsv'; |
|
274 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
275 | - } |
|
276 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
277 | - if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
278 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
279 | - if ($idf !== false) { |
|
280 | - $httpfeeds[$id] = $idf; |
|
281 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
282 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
283 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
284 | - elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
285 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
286 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
287 | - $hostport = explode(':',$host); |
|
288 | - if (isset($hostport[1])) { |
|
213 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
214 | + //$formats[$id] = 'planeupdatefaa'; |
|
215 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
216 | + //$last_exec['planeupdatefaa'] = 0; |
|
217 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
218 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
219 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
220 | + exit(0); |
|
221 | + } |
|
222 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
223 | + //$formats[$id] = 'phpvmacars'; |
|
224 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
225 | + //$last_exec['phpvmacars'] = 0; |
|
226 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
227 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
228 | + //$formats[$id] = 'phpvmacars'; |
|
229 | + $globalSources[$id]['format'] = 'vaos'; |
|
230 | + //$last_exec['phpvmacars'] = 0; |
|
231 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
232 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
233 | + //$formats[$id] = 'phpvmacars'; |
|
234 | + $globalSources[$id]['format'] = 'vam'; |
|
235 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
236 | + } else if (preg_match('/whazzup/i',$host)) { |
|
237 | + //$formats[$id] = 'whazzup'; |
|
238 | + $globalSources[$id]['format'] = 'whazzup'; |
|
239 | + //$last_exec['whazzup'] = 0; |
|
240 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
241 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
242 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
243 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
244 | + } else if (preg_match('/airwhere/i',$host)) { |
|
245 | + $globalSources[$id]['format'] = 'airwhere'; |
|
246 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
247 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
248 | + //$formats[$id] = 'pirepsjson'; |
|
249 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
250 | + //$last_exec['pirepsjson'] = 0; |
|
251 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
252 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
253 | + //$formats[$id] = 'fr24json'; |
|
254 | + $globalSources[$id]['format'] = 'fr24json'; |
|
255 | + //$last_exec['fr24json'] = 0; |
|
256 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
257 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
258 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
259 | + exit(0); |
|
260 | + } |
|
261 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
262 | + //$formats[$id] = 'fr24json'; |
|
263 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
264 | + //$last_exec['fr24json'] = 0; |
|
265 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
266 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
267 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
268 | + exit(0); |
|
269 | + } |
|
270 | + //} else if (preg_match('/10001/',$host)) { |
|
271 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
272 | + //$formats[$id] = 'tsv'; |
|
273 | + $globalSources[$id]['format'] = 'tsv'; |
|
274 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
275 | + } |
|
276 | + } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
277 | + if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
278 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
279 | + if ($idf !== false) { |
|
280 | + $httpfeeds[$id] = $idf; |
|
281 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
282 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
283 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
284 | + elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
285 | + elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
286 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
287 | + $hostport = explode(':',$host); |
|
288 | + if (isset($hostport[1])) { |
|
289 | 289 | $port = $hostport[1]; |
290 | 290 | $hostn = $hostport[0]; |
291 | - } else { |
|
291 | + } else { |
|
292 | 292 | $port = $globalSources[$id]['port']; |
293 | 293 | $hostn = $globalSources[$id]['host']; |
294 | - } |
|
295 | - $Common = new Common(); |
|
296 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
297 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
298 | - } else { |
|
299 | - $udp = true; |
|
300 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
301 | - } |
|
302 | - if ($s) { |
|
303 | - $sockets[$id] = $s; |
|
304 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
305 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
294 | + } |
|
295 | + $Common = new Common(); |
|
296 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
297 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
298 | + } else { |
|
299 | + $udp = true; |
|
300 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
301 | + } |
|
302 | + if ($s) { |
|
303 | + $sockets[$id] = $s; |
|
304 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
305 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
306 | 306 | //$formats[$id] = 'aprs'; |
307 | 307 | $globalSources[$id]['format'] = 'aprs'; |
308 | 308 | //$aprs_connect = 0; |
309 | 309 | //$use_aprs = true; |
310 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
310 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
311 | 311 | $globalSources[$id]['format'] = 'vrstcp'; |
312 | - } elseif ($port == '10001') { |
|
313 | - //$formats[$id] = 'tsv'; |
|
314 | - $globalSources[$id]['format'] = 'tsv'; |
|
315 | - } elseif ($port == '30002') { |
|
316 | - //$formats[$id] = 'raw'; |
|
317 | - $globalSources[$id]['format'] = 'raw'; |
|
318 | - } elseif ($port == '5001') { |
|
319 | - //$formats[$id] = 'raw'; |
|
320 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
321 | - } elseif ($port == '30005') { |
|
312 | + } elseif ($port == '10001') { |
|
313 | + //$formats[$id] = 'tsv'; |
|
314 | + $globalSources[$id]['format'] = 'tsv'; |
|
315 | + } elseif ($port == '30002') { |
|
316 | + //$formats[$id] = 'raw'; |
|
317 | + $globalSources[$id]['format'] = 'raw'; |
|
318 | + } elseif ($port == '5001') { |
|
319 | + //$formats[$id] = 'raw'; |
|
320 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
321 | + } elseif ($port == '30005') { |
|
322 | 322 | // Not yet supported |
323 | - //$formats[$id] = 'beast'; |
|
324 | - $globalSources[$id]['format'] = 'beast'; |
|
325 | - //} else $formats[$id] = 'sbs'; |
|
326 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
327 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
323 | + //$formats[$id] = 'beast'; |
|
324 | + $globalSources[$id]['format'] = 'beast'; |
|
325 | + //} else $formats[$id] = 'sbs'; |
|
326 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
327 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
328 | 328 | } |
329 | 329 | if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
330 | 330 | elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
331 | - } else { |
|
331 | + } else { |
|
332 | 332 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
333 | 333 | sleep(10); |
334 | 334 | connect_all($hosts); |
335 | - } |
|
336 | - } |
|
337 | - } |
|
335 | + } |
|
336 | + } |
|
337 | + } |
|
338 | 338 | } |
339 | 339 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
340 | 340 | |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | //connect_all($globalSources); |
358 | 358 | |
359 | 359 | if (isset($globalProxy) && $globalProxy) { |
360 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
360 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
361 | 361 | } else { |
362 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
362 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | // APRS Configuration |
@@ -368,21 +368,21 @@ discard block |
||
368 | 368 | die; |
369 | 369 | } |
370 | 370 | foreach ($globalSources as $key => $source) { |
371 | - if (!isset($source['format'])) { |
|
372 | - $globalSources[$key]['format'] = 'auto'; |
|
373 | - } |
|
374 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
375 | - unset($globalSources[$key]); |
|
376 | - } |
|
371 | + if (!isset($source['format'])) { |
|
372 | + $globalSources[$key]['format'] = 'auto'; |
|
373 | + } |
|
374 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
375 | + unset($globalSources[$key]); |
|
376 | + } |
|
377 | 377 | } |
378 | 378 | connect_all($globalSources); |
379 | 379 | foreach ($globalSources as $key => $source) { |
380 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
380 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
381 | 381 | $aprs_connect = 0; |
382 | 382 | $use_aprs = true; |
383 | 383 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
384 | 384 | break; |
385 | - } |
|
385 | + } |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | if ($use_aprs) { |
@@ -423,173 +423,173 @@ discard block |
||
423 | 423 | |
424 | 424 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
425 | 425 | while ($i > 0) { |
426 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
426 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
427 | 427 | |
428 | - if (!$globalDaemon) $i = $endtime-time(); |
|
429 | - // Delete old ATC |
|
430 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
428 | + if (!$globalDaemon) $i = $endtime-time(); |
|
429 | + // Delete old ATC |
|
430 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
431 | 431 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
432 | - $ATC->deleteOldATC(); |
|
433 | - } |
|
432 | + $ATC->deleteOldATC(); |
|
433 | + } |
|
434 | 434 | |
435 | - if (count($last_exec) == count($globalSources)) { |
|
435 | + if (count($last_exec) == count($globalSources)) { |
|
436 | 436 | $max = $globalMinFetch; |
437 | 437 | foreach ($last_exec as $last) { |
438 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
438 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
439 | 439 | } |
440 | 440 | if ($max < $globalMinFetch) { |
441 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
442 | - sleep($globalMinFetch-$max+2); |
|
441 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
442 | + sleep($globalMinFetch-$max+2); |
|
443 | + } |
|
443 | 444 | } |
444 | - } |
|
445 | 445 | |
446 | 446 | |
447 | - //foreach ($formats as $id => $value) { |
|
448 | - foreach ($globalSources as $id => $value) { |
|
447 | + //foreach ($formats as $id => $value) { |
|
448 | + foreach ($globalSources as $id => $value) { |
|
449 | 449 | date_default_timezone_set('UTC'); |
450 | 450 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
451 | 451 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
452 | 452 | if ($value['format'] === 'deltadbtxt' && |
453 | - ( |
|
453 | + ( |
|
454 | 454 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
455 | 455 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
456 | - ) |
|
456 | + ) |
|
457 | 457 | ) { |
458 | - //$buffer = $Common->getData($hosts[$id]); |
|
459 | - $buffer = $Common->getData($value['host']); |
|
460 | - if ($buffer != '') $reset = 0; |
|
461 | - $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
462 | - $buffer = explode('\n', $buffer); |
|
463 | - foreach ($buffer as $line) { |
|
464 | - if ($line != '' && count($line) > 7) { |
|
465 | - $line = explode(',', $line); |
|
466 | - $data = array(); |
|
467 | - $data['hex'] = $line[1]; // hex |
|
468 | - $data['ident'] = $line[2]; // ident |
|
469 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
470 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
471 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
472 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
473 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
474 | - $data['verticalrate'] = ''; // vertical rate |
|
475 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
476 | - $data['emergency'] = ''; // emergency |
|
477 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
478 | - $data['format_source'] = 'deltadbtxt'; |
|
479 | - $data['id_source'] = $id_source; |
|
480 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
481 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
482 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
483 | - $SI->add($data); |
|
484 | - unset($data); |
|
485 | - } |
|
486 | - } |
|
487 | - $last_exec[$id]['last'] = time(); |
|
488 | - } elseif ($value['format'] === 'radarcapejson' && |
|
489 | - ( |
|
490 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
491 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
492 | - ) |
|
493 | - ) { |
|
494 | - //$buffer = $Common->getData($hosts[$id]); |
|
495 | - $buffer = $Common->getData($value['host']); |
|
496 | - if ($buffer != '') { |
|
497 | - $all_data = json_decode($buffer,true); |
|
498 | - foreach ($all_data as $line) { |
|
499 | - $data = array(); |
|
500 | - $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
501 | - $data['hex'] = $line['hex']; // hex |
|
502 | - $data['ident'] = $line['fli']; // ident |
|
503 | - $data['altitude'] = $line['alt']; // altitude |
|
504 | - $data['speed'] = $line['spd']; // speed |
|
505 | - $data['heading'] = $line['trk']; // heading |
|
506 | - $data['latitude'] = $line['lat']; // lat |
|
507 | - $data['longitude'] = $line['lon']; // long |
|
508 | - $data['verticalrate'] = $line['vrt']; // vertical rate |
|
509 | - $data['squawk'] = $line['squ']; // squawk |
|
510 | - $data['ground'] = $line['gda']; // ground |
|
511 | - $data['registration'] = $line['reg']; |
|
512 | - //$data['emergency'] = ''; // emergency |
|
513 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
514 | - $data['format_source'] = 'radarcapejson'; |
|
515 | - $data['id_source'] = $id_source; |
|
516 | - if (isset($value['name']) && $value['name'] != '') { |
|
517 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
518 | - else $data['source_name'] = $value['name']; |
|
519 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
520 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
521 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
458 | + //$buffer = $Common->getData($hosts[$id]); |
|
459 | + $buffer = $Common->getData($value['host']); |
|
460 | + if ($buffer != '') $reset = 0; |
|
461 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
462 | + $buffer = explode('\n', $buffer); |
|
463 | + foreach ($buffer as $line) { |
|
464 | + if ($line != '' && count($line) > 7) { |
|
465 | + $line = explode(',', $line); |
|
466 | + $data = array(); |
|
467 | + $data['hex'] = $line[1]; // hex |
|
468 | + $data['ident'] = $line[2]; // ident |
|
469 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
470 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
471 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
472 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
473 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
474 | + $data['verticalrate'] = ''; // vertical rate |
|
475 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
476 | + $data['emergency'] = ''; // emergency |
|
477 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
478 | + $data['format_source'] = 'deltadbtxt'; |
|
479 | + $data['id_source'] = $id_source; |
|
480 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
481 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
482 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
483 | + $SI->add($data); |
|
484 | + unset($data); |
|
485 | + } |
|
486 | + } |
|
487 | + $last_exec[$id]['last'] = time(); |
|
488 | + } elseif ($value['format'] === 'radarcapejson' && |
|
489 | + ( |
|
490 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
491 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
492 | + ) |
|
493 | + ) { |
|
494 | + //$buffer = $Common->getData($hosts[$id]); |
|
495 | + $buffer = $Common->getData($value['host']); |
|
496 | + if ($buffer != '') { |
|
497 | + $all_data = json_decode($buffer,true); |
|
498 | + foreach ($all_data as $line) { |
|
499 | + $data = array(); |
|
500 | + $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
501 | + $data['hex'] = $line['hex']; // hex |
|
502 | + $data['ident'] = $line['fli']; // ident |
|
503 | + $data['altitude'] = $line['alt']; // altitude |
|
504 | + $data['speed'] = $line['spd']; // speed |
|
505 | + $data['heading'] = $line['trk']; // heading |
|
506 | + $data['latitude'] = $line['lat']; // lat |
|
507 | + $data['longitude'] = $line['lon']; // long |
|
508 | + $data['verticalrate'] = $line['vrt']; // vertical rate |
|
509 | + $data['squawk'] = $line['squ']; // squawk |
|
510 | + $data['ground'] = $line['gda']; // ground |
|
511 | + $data['registration'] = $line['reg']; |
|
512 | + //$data['emergency'] = ''; // emergency |
|
513 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
514 | + $data['format_source'] = 'radarcapejson'; |
|
515 | + $data['id_source'] = $id_source; |
|
516 | + if (isset($value['name']) && $value['name'] != '') { |
|
517 | + if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
518 | + else $data['source_name'] = $value['name']; |
|
519 | + } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
520 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
521 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
522 | 522 | |
523 | - $SI->add($data); |
|
524 | - unset($data); |
|
525 | - } |
|
526 | - } |
|
527 | - $last_exec[$id]['last'] = time(); |
|
523 | + $SI->add($data); |
|
524 | + unset($data); |
|
525 | + } |
|
526 | + } |
|
527 | + $last_exec[$id]['last'] = time(); |
|
528 | 528 | } elseif ($value['format'] === 'aisnmeatxt' && |
529 | - ( |
|
529 | + ( |
|
530 | 530 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
531 | 531 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
532 | - ) |
|
532 | + ) |
|
533 | 533 | ) { |
534 | - date_default_timezone_set('CET'); |
|
535 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
536 | - date_default_timezone_set('UTC'); |
|
537 | - if ($buffer != '') $reset = 0; |
|
538 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
539 | - $buffer = explode('\n',$buffer); |
|
540 | - foreach ($buffer as $line) { |
|
534 | + date_default_timezone_set('CET'); |
|
535 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
536 | + date_default_timezone_set('UTC'); |
|
537 | + if ($buffer != '') $reset = 0; |
|
538 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
539 | + $buffer = explode('\n',$buffer); |
|
540 | + foreach ($buffer as $line) { |
|
541 | 541 | if ($line != '') { |
542 | - //echo "'".$line."'\n"; |
|
543 | - $add = false; |
|
544 | - $ais_data = $AIS->parse_line(trim($line)); |
|
545 | - $data = array(); |
|
546 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
547 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
548 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
549 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
550 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
551 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
552 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
553 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
554 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
555 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
556 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
557 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
558 | - if (isset($ais_data['timestamp'])) { |
|
542 | + //echo "'".$line."'\n"; |
|
543 | + $add = false; |
|
544 | + $ais_data = $AIS->parse_line(trim($line)); |
|
545 | + $data = array(); |
|
546 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
547 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
548 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
549 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
550 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
551 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
552 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
553 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
554 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
555 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
556 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
557 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
558 | + if (isset($ais_data['timestamp'])) { |
|
559 | 559 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
560 | 560 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
561 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
562 | - $add = true; |
|
561 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
562 | + $add = true; |
|
563 | 563 | } |
564 | - } else { |
|
564 | + } else { |
|
565 | 565 | $data['datetime'] = date('Y-m-d H:i:s'); |
566 | 566 | $add = true; |
567 | - } |
|
568 | - $data['format_source'] = 'aisnmeatxt'; |
|
569 | - $data['id_source'] = $id_source; |
|
570 | - //print_r($data); |
|
571 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
572 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
573 | - unset($data); |
|
567 | + } |
|
568 | + $data['format_source'] = 'aisnmeatxt'; |
|
569 | + $data['id_source'] = $id_source; |
|
570 | + //print_r($data); |
|
571 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
572 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
573 | + unset($data); |
|
574 | 574 | } |
575 | - } |
|
576 | - $last_exec[$id]['last'] = time(); |
|
575 | + } |
|
576 | + $last_exec[$id]['last'] = time(); |
|
577 | 577 | } elseif ($value['format'] === 'aisnmeahttp') { |
578 | - $arr = $httpfeeds; |
|
579 | - $w = $e = null; |
|
578 | + $arr = $httpfeeds; |
|
579 | + $w = $e = null; |
|
580 | 580 | |
581 | - if (isset($arr[$id])) { |
|
581 | + if (isset($arr[$id])) { |
|
582 | 582 | $nn = stream_select($arr,$w,$e,$timeout); |
583 | 583 | if ($nn > 0) { |
584 | - foreach ($httpfeeds as $feed) { |
|
584 | + foreach ($httpfeeds as $feed) { |
|
585 | 585 | $buffer = stream_get_line($feed,2000,"\n"); |
586 | 586 | if ($buffer === FALSE) { |
587 | - connect_all($globalSources); |
|
587 | + connect_all($globalSources); |
|
588 | 588 | } |
589 | 589 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
590 | 590 | $buffer = explode('\n',$buffer); |
591 | 591 | foreach ($buffer as $line) { |
592 | - if ($line != '') { |
|
592 | + if ($line != '') { |
|
593 | 593 | $ais_data = $AIS->parse_line(trim($line)); |
594 | 594 | $data = array(); |
595 | 595 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -607,117 +607,117 @@ discard block |
||
607 | 607 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
608 | 608 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
609 | 609 | if (isset($ais_data['timestamp'])) { |
610 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
610 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
611 | 611 | } else { |
612 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
612 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
613 | 613 | } |
614 | 614 | $data['format_source'] = 'aisnmeahttp'; |
615 | 615 | $data['id_source'] = $id_source; |
616 | 616 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
617 | 617 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
618 | 618 | unset($data); |
619 | - } |
|
619 | + } |
|
620 | + } |
|
620 | 621 | } |
621 | - } |
|
622 | 622 | } else { |
623 | - $format = $value['format']; |
|
624 | - if (isset($tt[$format])) $tt[$format]++; |
|
625 | - else $tt[$format] = 0; |
|
626 | - if ($tt[$format] > 30) { |
|
623 | + $format = $value['format']; |
|
624 | + if (isset($tt[$format])) $tt[$format]++; |
|
625 | + else $tt[$format] = 0; |
|
626 | + if ($tt[$format] > 30) { |
|
627 | 627 | if ($globalDebug) echo 'Reconnect...'."\n"; |
628 | 628 | sleep(2); |
629 | 629 | //$sourceeen[] = $value; |
630 | 630 | //connect_all($sourceeen); |
631 | 631 | //$sourceeen = array(); |
632 | 632 | connect_all($globalSources); |
633 | - } |
|
633 | + } |
|
634 | + } |
|
634 | 635 | } |
635 | - } |
|
636 | 636 | } elseif ($value['format'] === 'myshiptracking' && |
637 | - ( |
|
637 | + ( |
|
638 | 638 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
639 | 639 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
640 | - ) |
|
640 | + ) |
|
641 | 641 | ) { |
642 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
643 | - if ($buffer != '') { |
|
642 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
643 | + if ($buffer != '') { |
|
644 | 644 | //echo $buffer; |
645 | 645 | $all_data = json_decode($buffer,true); |
646 | 646 | //print_r($all_data); |
647 | 647 | if (isset($all_data[0]['DATA'])) { |
648 | - foreach ($all_data[0]['DATA'] as $line) { |
|
648 | + foreach ($all_data[0]['DATA'] as $line) { |
|
649 | 649 | if ($line != '') { |
650 | - $data = array(); |
|
651 | - $data['ident'] = $line['NAME']; |
|
652 | - $data['mmsi'] = $line['MMSI']; |
|
653 | - if (strlen($data['mmsi']) > 9) { |
|
650 | + $data = array(); |
|
651 | + $data['ident'] = $line['NAME']; |
|
652 | + $data['mmsi'] = $line['MMSI']; |
|
653 | + if (strlen($data['mmsi']) > 9) { |
|
654 | 654 | $data['mmsi'] = substr($data['mmsi'],-9); |
655 | - } |
|
656 | - $data['speed'] = $line['SOG']; |
|
657 | - $data['heading'] = $line['COG']; |
|
658 | - $data['latitude'] = $line['LAT']; |
|
659 | - $data['longitude'] = $line['LNG']; |
|
660 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
661 | - //$data['type_id'] = $line['TYPE']; |
|
662 | - $data['imo'] = $line['IMO']; |
|
663 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
664 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
665 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
666 | - $data['format_source'] = 'myshiptracking'; |
|
667 | - $data['id_source'] = $id_source; |
|
668 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
669 | - $MI->add($data); |
|
670 | - unset($data); |
|
655 | + } |
|
656 | + $data['speed'] = $line['SOG']; |
|
657 | + $data['heading'] = $line['COG']; |
|
658 | + $data['latitude'] = $line['LAT']; |
|
659 | + $data['longitude'] = $line['LNG']; |
|
660 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
661 | + //$data['type_id'] = $line['TYPE']; |
|
662 | + $data['imo'] = $line['IMO']; |
|
663 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
664 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
665 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
666 | + $data['format_source'] = 'myshiptracking'; |
|
667 | + $data['id_source'] = $id_source; |
|
668 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
669 | + $MI->add($data); |
|
670 | + unset($data); |
|
671 | + } |
|
671 | 672 | } |
672 | - } |
|
673 | 673 | } |
674 | - } |
|
675 | - $last_exec[$id]['last'] = time(); |
|
674 | + } |
|
675 | + $last_exec[$id]['last'] = time(); |
|
676 | 676 | } elseif ($value['format'] === 'boatbeaconapp' && |
677 | - ( |
|
677 | + ( |
|
678 | 678 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
679 | 679 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
680 | - ) |
|
680 | + ) |
|
681 | 681 | ) { |
682 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
683 | - if ($buffer != '') { |
|
682 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
683 | + if ($buffer != '') { |
|
684 | 684 | $all_data = json_decode($buffer,true); |
685 | 685 | if (isset($all_data[0]['mmsi'])) { |
686 | - foreach ($all_data as $line) { |
|
686 | + foreach ($all_data as $line) { |
|
687 | 687 | if ($line != '') { |
688 | - $data = array(); |
|
689 | - $data['ident'] = $line['shipname']; |
|
690 | - $data['callsign'] = $line['callsign']; |
|
691 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
692 | - $data['speed'] = $line['sog']; |
|
693 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
694 | - $data['latitude'] = $line['latitude']; |
|
695 | - $data['longitude'] = $line['longitude']; |
|
696 | - $data['type_id'] = $line['shiptype']; |
|
697 | - $data['arrival_code'] = $line['destination']; |
|
698 | - $data['datetime'] = $line['time']; |
|
699 | - $data['format_source'] = 'boatbeaconapp'; |
|
700 | - $data['id_source'] = $id_source; |
|
701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
702 | - $MI->add($data); |
|
703 | - unset($data); |
|
688 | + $data = array(); |
|
689 | + $data['ident'] = $line['shipname']; |
|
690 | + $data['callsign'] = $line['callsign']; |
|
691 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
692 | + $data['speed'] = $line['sog']; |
|
693 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
694 | + $data['latitude'] = $line['latitude']; |
|
695 | + $data['longitude'] = $line['longitude']; |
|
696 | + $data['type_id'] = $line['shiptype']; |
|
697 | + $data['arrival_code'] = $line['destination']; |
|
698 | + $data['datetime'] = $line['time']; |
|
699 | + $data['format_source'] = 'boatbeaconapp'; |
|
700 | + $data['id_source'] = $id_source; |
|
701 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
702 | + $MI->add($data); |
|
703 | + unset($data); |
|
704 | + } |
|
704 | 705 | } |
705 | - } |
|
706 | 706 | } |
707 | 707 | |
708 | - } |
|
709 | - $last_exec[$id]['last'] = time(); |
|
708 | + } |
|
709 | + $last_exec[$id]['last'] = time(); |
|
710 | 710 | } elseif ($value['format'] === 'boatnerd' && |
711 | - ( |
|
711 | + ( |
|
712 | 712 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
713 | 713 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
714 | - ) |
|
714 | + ) |
|
715 | 715 | ) { |
716 | - $buffer = $Common->getData($value['host']); |
|
717 | - if ($buffer != '') { |
|
716 | + $buffer = $Common->getData($value['host']); |
|
717 | + if ($buffer != '') { |
|
718 | 718 | $all_data = json_decode($buffer,true); |
719 | 719 | if (isset($all_data['features'][0]['id'])) { |
720 | - foreach ($all_data['features'] as $line) { |
|
720 | + foreach ($all_data['features'] as $line) { |
|
721 | 721 | print_r($line); |
722 | 722 | $data = array(); |
723 | 723 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -737,75 +737,75 @@ discard block |
||
737 | 737 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
738 | 738 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
739 | 739 | unset($data); |
740 | - } |
|
740 | + } |
|
741 | 741 | } |
742 | 742 | |
743 | - } |
|
744 | - $last_exec[$id]['last'] = time(); |
|
743 | + } |
|
744 | + $last_exec[$id]['last'] = time(); |
|
745 | 745 | } elseif ($value['format'] === 'shipplotter' && |
746 | - ( |
|
746 | + ( |
|
747 | 747 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
748 | 748 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
749 | - ) |
|
749 | + ) |
|
750 | 750 | ) { |
751 | - if ($globalDebug) echo 'download...'; |
|
752 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
753 | - if ($globalDebug) echo 'done !'."\n"; |
|
754 | - // FIXME: Need more work |
|
755 | - if ($buffer != '') $reset = 0; |
|
756 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
757 | - $buffer = explode('\n',$buffer); |
|
758 | - foreach ($buffer as $line) { |
|
751 | + if ($globalDebug) echo 'download...'; |
|
752 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
753 | + if ($globalDebug) echo 'done !'."\n"; |
|
754 | + // FIXME: Need more work |
|
755 | + if ($buffer != '') $reset = 0; |
|
756 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
757 | + $buffer = explode('\n',$buffer); |
|
758 | + foreach ($buffer as $line) { |
|
759 | 759 | if ($line != '') { |
760 | - $data = array(); |
|
761 | - //echo $line."\n"; |
|
762 | - $data['mmsi'] = (int)substr($line,0,9); |
|
763 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
764 | - $data['status_id'] = substr($line,21,2); |
|
765 | - $data['type_id'] = substr($line,24,3); |
|
766 | - $data['latitude'] = substr($line,29,9); |
|
767 | - $data['longitude'] = substr($line,41,9); |
|
768 | - $data['speed'] = round(substr($line,51,5)); |
|
769 | - //$data['course'] = substr($line,57,5); |
|
770 | - $data['heading'] = round(substr($line,63,3)); |
|
771 | - //$data['draft'] = substr($line,67,4); |
|
772 | - //$data['length'] = substr($line,72,3); |
|
773 | - //$data['beam'] = substr($line,76,2); |
|
774 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
775 | - //$data['callsign'] = trim(substr($line,100,7); |
|
776 | - $data['arrival_code'] = substr($line,108,20); |
|
777 | - //$data['etaDate'] = substr($line,129,5); |
|
778 | - //$data['etaTime'] = substr($line,135,5); |
|
779 | - $data['format_source'] = 'shipplotter'; |
|
780 | - $data['id_source'] = $id_source; |
|
781 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
782 | - //print_r($data); |
|
783 | - //echo 'Add...'."\n"; |
|
784 | - $MI->add($data); |
|
785 | - unset($data); |
|
760 | + $data = array(); |
|
761 | + //echo $line."\n"; |
|
762 | + $data['mmsi'] = (int)substr($line,0,9); |
|
763 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
764 | + $data['status_id'] = substr($line,21,2); |
|
765 | + $data['type_id'] = substr($line,24,3); |
|
766 | + $data['latitude'] = substr($line,29,9); |
|
767 | + $data['longitude'] = substr($line,41,9); |
|
768 | + $data['speed'] = round(substr($line,51,5)); |
|
769 | + //$data['course'] = substr($line,57,5); |
|
770 | + $data['heading'] = round(substr($line,63,3)); |
|
771 | + //$data['draft'] = substr($line,67,4); |
|
772 | + //$data['length'] = substr($line,72,3); |
|
773 | + //$data['beam'] = substr($line,76,2); |
|
774 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
775 | + //$data['callsign'] = trim(substr($line,100,7); |
|
776 | + $data['arrival_code'] = substr($line,108,20); |
|
777 | + //$data['etaDate'] = substr($line,129,5); |
|
778 | + //$data['etaTime'] = substr($line,135,5); |
|
779 | + $data['format_source'] = 'shipplotter'; |
|
780 | + $data['id_source'] = $id_source; |
|
781 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
782 | + //print_r($data); |
|
783 | + //echo 'Add...'."\n"; |
|
784 | + $MI->add($data); |
|
785 | + unset($data); |
|
786 | 786 | } |
787 | - } |
|
788 | - $last_exec[$id]['last'] = time(); |
|
787 | + } |
|
788 | + $last_exec[$id]['last'] = time(); |
|
789 | 789 | } elseif ($value['format'] === 'sailawayfull' && |
790 | - ( |
|
790 | + ( |
|
791 | 791 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 5*60)) |
792 | - ) |
|
792 | + ) |
|
793 | 793 | ) { |
794 | - if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
794 | + if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
795 | 795 | $authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true); |
796 | 796 | //echo $authsailaway; |
797 | 797 | preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie); |
798 | 798 | if (isset($setcookie[1][0])) { |
799 | - $sailaway_authcookie = $setcookie[1][0]; |
|
799 | + $sailaway_authcookie = $setcookie[1][0]; |
|
800 | + } |
|
800 | 801 | } |
801 | - } |
|
802 | 802 | |
803 | - if ($globalDebug) echo '! Download... '; |
|
804 | - for ($i =0; $i <= 1; $i++) { |
|
803 | + if ($globalDebug) echo '! Download... '; |
|
804 | + for ($i =0; $i <= 1; $i++) { |
|
805 | 805 | if ($globalDebug) echo 'Racetype: '.$i.' '; |
806 | 806 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
807 | - if ($globalDebug) echo 'done'."\n"; |
|
808 | - if ($buffer != '') { |
|
807 | + if ($globalDebug) echo 'done'."\n"; |
|
808 | + if ($buffer != '') { |
|
809 | 809 | $all_data = json_decode($buffer,true); |
810 | 810 | if (isset($all_data['missions'])) { |
811 | 811 | foreach ($all_data['missions'] as $mission) { |
@@ -826,19 +826,19 @@ discard block |
||
826 | 826 | //print_r($race_data); |
827 | 827 | unset($racebuffer); |
828 | 828 | if (isset($race_data['mission'])) { |
829 | - $datar = array(); |
|
830 | - $datar['id'] = $mission['misnr']; |
|
831 | - $datar['desc'] = $race_data['mission']['misdescr']; |
|
832 | - $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
833 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
834 | - $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
835 | - $markers = array(); |
|
836 | - foreach ($race_data['mission']['course'] as $course) { |
|
829 | + $datar = array(); |
|
830 | + $datar['id'] = $mission['misnr']; |
|
831 | + $datar['desc'] = $race_data['mission']['misdescr']; |
|
832 | + $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
833 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
834 | + $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
835 | + $markers = array(); |
|
836 | + foreach ($race_data['mission']['course'] as $course) { |
|
837 | 837 | $markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']); |
838 | - } |
|
839 | - $datar['markers'] = json_encode($markers); |
|
840 | - //print_r($datar); |
|
841 | - $MI->race_add($datar); |
|
838 | + } |
|
839 | + $datar['markers'] = json_encode($markers); |
|
840 | + //print_r($datar); |
|
841 | + $MI->race_add($datar); |
|
842 | 842 | } |
843 | 843 | } |
844 | 844 | if ($bufferm != '') { |
@@ -903,16 +903,16 @@ discard block |
||
903 | 903 | sleep(30); |
904 | 904 | } |
905 | 905 | } |
906 | - } |
|
907 | - sleep(5); |
|
908 | - } |
|
909 | - $last_exec[$id]['last'] = time(); |
|
906 | + } |
|
907 | + sleep(5); |
|
908 | + } |
|
909 | + $last_exec[$id]['last'] = time(); |
|
910 | 910 | } elseif ($value['format'] === 'sailaway' && |
911 | - ( |
|
911 | + ( |
|
912 | 912 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 5*60)) |
913 | - ) |
|
913 | + ) |
|
914 | 914 | ) { |
915 | - /* |
|
915 | + /* |
|
916 | 916 | if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
917 | 917 | $authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true); |
918 | 918 | //echo $authsailaway; |
@@ -923,17 +923,17 @@ discard block |
||
923 | 923 | } |
924 | 924 | } |
925 | 925 | */ |
926 | - if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') { |
|
926 | + if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') { |
|
927 | 927 | echo 'Sailaway API key MUST be defined'; |
928 | 928 | exit(0); |
929 | - } |
|
930 | - if ($globalDebug) echo '! Download... '; |
|
931 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key']); |
|
932 | - if ($buffer != '') { |
|
929 | + } |
|
930 | + if ($globalDebug) echo '! Download... '; |
|
931 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key']); |
|
932 | + if ($buffer != '') { |
|
933 | 933 | $data = json_decode($buffer,true); |
934 | 934 | //print_r($race_data); |
935 | 935 | if (isset($data['boats'])) { |
936 | - foreach ($data['boats'] as $sail) { |
|
936 | + foreach ($data['boats'] as $sail) { |
|
937 | 937 | $data = array(); |
938 | 938 | $data['id'] = $sail['ubtnr']; |
939 | 939 | $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -949,35 +949,35 @@ discard block |
||
949 | 949 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
950 | 950 | $MI->add($data); |
951 | 951 | unset($data); |
952 | - } |
|
952 | + } |
|
953 | 953 | } |
954 | - } |
|
955 | - $last_exec[$id]['last'] = time(); |
|
954 | + } |
|
955 | + $last_exec[$id]['last'] = time(); |
|
956 | 956 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
957 | 957 | } elseif ( |
958 | - ( |
|
958 | + ( |
|
959 | 959 | $value['format'] === 'whazzup' && |
960 | 960 | ( |
961 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
962 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
961 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
962 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
963 | 963 | ) |
964 | - ) || ( |
|
964 | + ) || ( |
|
965 | 965 | $value['format'] === 'vatsimtxt' && |
966 | 966 | ( |
967 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
968 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
967 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
968 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
969 | + ) |
|
969 | 970 | ) |
970 | - ) |
|
971 | 971 | ) { |
972 | - //$buffer = $Common->getData($hosts[$id]); |
|
973 | - $buffer = $Common->getData($value['host']); |
|
974 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
975 | - $buffer = explode('\n',$buffer); |
|
976 | - $reset = 0; |
|
977 | - foreach ($buffer as $line) { |
|
978 | - if ($line != '') { |
|
979 | - $line = explode(':', $line); |
|
980 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
972 | + //$buffer = $Common->getData($hosts[$id]); |
|
973 | + $buffer = $Common->getData($value['host']); |
|
974 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
975 | + $buffer = explode('\n',$buffer); |
|
976 | + $reset = 0; |
|
977 | + foreach ($buffer as $line) { |
|
978 | + if ($line != '') { |
|
979 | + $line = explode(':', $line); |
|
980 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
981 | 981 | $data = array(); |
982 | 982 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
983 | 983 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -990,37 +990,37 @@ discard block |
||
990 | 990 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
991 | 991 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
992 | 992 | $data['latitude'] = $line[5]; // lat |
993 | - $data['longitude'] = $line[6]; // long |
|
994 | - $data['verticalrate'] = ''; // vertical rate |
|
995 | - $data['squawk'] = ''; // squawk |
|
996 | - $data['emergency'] = ''; // emergency |
|
997 | - $data['waypoints'] = $line[30]; |
|
993 | + $data['longitude'] = $line[6]; // long |
|
994 | + $data['verticalrate'] = ''; // vertical rate |
|
995 | + $data['squawk'] = ''; // squawk |
|
996 | + $data['emergency'] = ''; // emergency |
|
997 | + $data['waypoints'] = $line[30]; |
|
998 | 998 | $data['datetime'] = date('Y-m-d H:i:s'); |
999 | 999 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
1000 | 1000 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
1001 | - $data['departure_airport_icao'] = $line[11]; |
|
1002 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
1003 | - $data['arrival_airport_icao'] = $line[13]; |
|
1001 | + $data['departure_airport_icao'] = $line[11]; |
|
1002 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
1003 | + $data['arrival_airport_icao'] = $line[13]; |
|
1004 | 1004 | $data['frequency'] = $line[4]; |
1005 | 1005 | $data['type'] = $line[18]; |
1006 | 1006 | $data['range'] = $line[19]; |
1007 | 1007 | if (isset($line[35])) $data['info'] = $line[35]; |
1008 | - $data['id_source'] = $id_source; |
|
1009 | - //$data['arrival_airport_time'] = ; |
|
1010 | - if ($line[9] != '') { |
|
1011 | - $aircraft_data = explode('/',$line[9]); |
|
1012 | - if (isset($aircraft_data[1])) { |
|
1013 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
1014 | - } |
|
1015 | - } |
|
1016 | - /* |
|
1008 | + $data['id_source'] = $id_source; |
|
1009 | + //$data['arrival_airport_time'] = ; |
|
1010 | + if ($line[9] != '') { |
|
1011 | + $aircraft_data = explode('/',$line[9]); |
|
1012 | + if (isset($aircraft_data[1])) { |
|
1013 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1014 | + } |
|
1015 | + } |
|
1016 | + /* |
|
1017 | 1017 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
1018 | 1018 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
1019 | 1019 | */ |
1020 | - $data['format_source'] = $value['format']; |
|
1020 | + $data['format_source'] = $value['format']; |
|
1021 | 1021 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1022 | 1022 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1023 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
1023 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
1024 | 1024 | elseif ($line[3] === 'ATC') { |
1025 | 1025 | //print_r($data); |
1026 | 1026 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -1041,21 +1041,21 @@ discard block |
||
1041 | 1041 | 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']); |
1042 | 1042 | } |
1043 | 1043 | } |
1044 | - unset($data); |
|
1045 | - } |
|
1046 | - } |
|
1047 | - } |
|
1048 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
1049 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
1050 | - $last_exec[$id]['last'] = time(); |
|
1051 | - } elseif ($value['format'] === 'airwhere' && |
|
1052 | - ( |
|
1053 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1054 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1055 | - ) |
|
1056 | - ) { |
|
1057 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
1058 | - if ($buffer != '') { |
|
1044 | + unset($data); |
|
1045 | + } |
|
1046 | + } |
|
1047 | + } |
|
1048 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
1049 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
1050 | + $last_exec[$id]['last'] = time(); |
|
1051 | + } elseif ($value['format'] === 'airwhere' && |
|
1052 | + ( |
|
1053 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1054 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1055 | + ) |
|
1056 | + ) { |
|
1057 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
1058 | + if ($buffer != '') { |
|
1059 | 1059 | $all_data = simplexml_load_string($buffer); |
1060 | 1060 | foreach($all_data->children() as $childdata) { |
1061 | 1061 | $data = array(); |
@@ -1077,10 +1077,10 @@ discard block |
||
1077 | 1077 | $SI->add($data); |
1078 | 1078 | unset($data); |
1079 | 1079 | } |
1080 | - } |
|
1081 | - $Source->deleteOldLocationByType('gs'); |
|
1082 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
1083 | - if ($buffer != '') { |
|
1080 | + } |
|
1081 | + $Source->deleteOldLocationByType('gs'); |
|
1082 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
1083 | + if ($buffer != '') { |
|
1084 | 1084 | $all_data = simplexml_load_string($buffer); |
1085 | 1085 | foreach($all_data->children() as $childdata) { |
1086 | 1086 | $data = array(); |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | } |
1099 | 1099 | unset($data); |
1100 | 1100 | } |
1101 | - } |
|
1102 | - $last_exec[$id]['last'] = time(); |
|
1101 | + } |
|
1102 | + $last_exec[$id]['last'] = time(); |
|
1103 | 1103 | /* |
1104 | 1104 | } if ($value['format'] === 'aircraftlistjson') { |
1105 | 1105 | print_r($globalSources); |
@@ -1107,17 +1107,17 @@ discard block |
||
1107 | 1107 | echo $globalMinFetch; |
1108 | 1108 | */ |
1109 | 1109 | } elseif ($value['format'] === 'aircraftlistjson' && |
1110 | - ( |
|
1110 | + ( |
|
1111 | 1111 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1112 | 1112 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1113 | - ) |
|
1113 | + ) |
|
1114 | 1114 | ) { |
1115 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
1116 | - if ($buffer != '') { |
|
1117 | - $all_data = json_decode($buffer,true); |
|
1115 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
1116 | + if ($buffer != '') { |
|
1117 | + $all_data = json_decode($buffer,true); |
|
1118 | 1118 | if (isset($all_data['acList'])) { |
1119 | - $reset = 0; |
|
1120 | - foreach ($all_data['acList'] as $line) { |
|
1119 | + $reset = 0; |
|
1120 | + foreach ($all_data['acList'] as $line) { |
|
1121 | 1121 | $data = array(); |
1122 | 1122 | $data['hex'] = $line['Icao']; // hex |
1123 | 1123 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1140,10 +1140,10 @@ discard block |
||
1140 | 1140 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1141 | 1141 | if (isset($data['latitude'])) $SI->add($data); |
1142 | 1142 | unset($data); |
1143 | - } |
|
1143 | + } |
|
1144 | 1144 | } elseif (is_array($all_data)) { |
1145 | - $reset = 0; |
|
1146 | - foreach ($all_data as $line) { |
|
1145 | + $reset = 0; |
|
1146 | + foreach ($all_data as $line) { |
|
1147 | 1147 | $data = array(); |
1148 | 1148 | $data['hex'] = $line['hex']; // hex |
1149 | 1149 | $data['ident'] = $line['flight']; // ident |
@@ -1163,291 +1163,291 @@ discard block |
||
1163 | 1163 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1164 | 1164 | $SI->add($data); |
1165 | 1165 | unset($data); |
1166 | - } |
|
1166 | + } |
|
1167 | 1167 | } |
1168 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1169 | - //$last_exec['aircraftlistjson'] = time(); |
|
1170 | - $last_exec[$id]['last'] = time(); |
|
1171 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
1172 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
1173 | - ( |
|
1174 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1175 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1176 | - ) |
|
1177 | - ) { |
|
1178 | - $buffer = $Common->getData($value['host']); |
|
1179 | - $all_data = json_decode($buffer,true); |
|
1180 | - if (isset($all_data['planes'])) { |
|
1168 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
1169 | + //$last_exec['aircraftlistjson'] = time(); |
|
1170 | + $last_exec[$id]['last'] = time(); |
|
1171 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
1172 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
1173 | + ( |
|
1174 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
1175 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1176 | + ) |
|
1177 | + ) { |
|
1178 | + $buffer = $Common->getData($value['host']); |
|
1179 | + $all_data = json_decode($buffer,true); |
|
1180 | + if (isset($all_data['planes'])) { |
|
1181 | 1181 | $reset = 0; |
1182 | 1182 | foreach ($all_data['planes'] as $key => $line) { |
1183 | - $data = array(); |
|
1184 | - $data['hex'] = $key; // hex |
|
1185 | - $data['ident'] = $line[3]; // ident |
|
1186 | - $data['altitude'] = $line[6]; // altitude |
|
1187 | - $data['speed'] = $line[8]; // speed |
|
1188 | - $data['heading'] = $line[7]; // heading |
|
1189 | - $data['latitude'] = $line[4]; // lat |
|
1190 | - $data['longitude'] = $line[5]; // long |
|
1191 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
1192 | - $data['squawk'] = $line[10]; // squawk |
|
1193 | - $data['emergency'] = ''; // emergency |
|
1194 | - $data['registration'] = $line[2]; |
|
1195 | - $data['aircraft_icao'] = $line[0]; |
|
1196 | - $deparr = explode('-',$line[1]); |
|
1197 | - if (count($deparr) === 2) { |
|
1183 | + $data = array(); |
|
1184 | + $data['hex'] = $key; // hex |
|
1185 | + $data['ident'] = $line[3]; // ident |
|
1186 | + $data['altitude'] = $line[6]; // altitude |
|
1187 | + $data['speed'] = $line[8]; // speed |
|
1188 | + $data['heading'] = $line[7]; // heading |
|
1189 | + $data['latitude'] = $line[4]; // lat |
|
1190 | + $data['longitude'] = $line[5]; // long |
|
1191 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
1192 | + $data['squawk'] = $line[10]; // squawk |
|
1193 | + $data['emergency'] = ''; // emergency |
|
1194 | + $data['registration'] = $line[2]; |
|
1195 | + $data['aircraft_icao'] = $line[0]; |
|
1196 | + $deparr = explode('-',$line[1]); |
|
1197 | + if (count($deparr) === 2) { |
|
1198 | 1198 | $data['departure_airport_icao'] = $deparr[0]; |
1199 | 1199 | $data['arrival_airport_icao'] = $deparr[1]; |
1200 | - } |
|
1201 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
1202 | - $data['format_source'] = 'planeupdatefaa'; |
|
1203 | - $data['id_source'] = $id_source; |
|
1204 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1205 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1206 | - $SI->add($data); |
|
1207 | - unset($data); |
|
1200 | + } |
|
1201 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
1202 | + $data['format_source'] = 'planeupdatefaa'; |
|
1203 | + $data['id_source'] = $id_source; |
|
1204 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1205 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1206 | + $SI->add($data); |
|
1207 | + unset($data); |
|
1208 | 1208 | } |
1209 | - } |
|
1210 | - //$last_exec['planeupdatefaa'] = time(); |
|
1211 | - $last_exec[$id]['last'] = time(); |
|
1209 | + } |
|
1210 | + //$last_exec['planeupdatefaa'] = time(); |
|
1211 | + $last_exec[$id]['last'] = time(); |
|
1212 | 1212 | } elseif ($value['format'] === 'opensky' && |
1213 | - ( |
|
1213 | + ( |
|
1214 | 1214 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1215 | 1215 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1216 | - ) |
|
1216 | + ) |
|
1217 | 1217 | ) { |
1218 | - $buffer = $Common->getData($value['host']); |
|
1219 | - $all_data = json_decode($buffer,true); |
|
1220 | - if (isset($all_data['states'])) { |
|
1218 | + $buffer = $Common->getData($value['host']); |
|
1219 | + $all_data = json_decode($buffer,true); |
|
1220 | + if (isset($all_data['states'])) { |
|
1221 | 1221 | $reset = 0; |
1222 | 1222 | foreach ($all_data['states'] as $key => $line) { |
1223 | - $data = array(); |
|
1224 | - $data['hex'] = $line[0]; // hex |
|
1225 | - $data['ident'] = trim($line[1]); // ident |
|
1226 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1227 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
1228 | - $data['heading'] = round($line[10]); // heading |
|
1229 | - $data['latitude'] = $line[6]; // lat |
|
1230 | - $data['longitude'] = $line[5]; // long |
|
1231 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
1232 | - //$data['squawk'] = $line[10]; // squawk |
|
1233 | - //$data['emergency'] = ''; // emergency |
|
1234 | - //$data['registration'] = $line[2]; |
|
1235 | - //$data['aircraft_icao'] = $line[0]; |
|
1236 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1237 | - $data['format_source'] = 'opensky'; |
|
1238 | - $data['id_source'] = $id_source; |
|
1239 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1240 | - $SI->add($data); |
|
1241 | - unset($data); |
|
1223 | + $data = array(); |
|
1224 | + $data['hex'] = $line[0]; // hex |
|
1225 | + $data['ident'] = trim($line[1]); // ident |
|
1226 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1227 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
1228 | + $data['heading'] = round($line[10]); // heading |
|
1229 | + $data['latitude'] = $line[6]; // lat |
|
1230 | + $data['longitude'] = $line[5]; // long |
|
1231 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
1232 | + //$data['squawk'] = $line[10]; // squawk |
|
1233 | + //$data['emergency'] = ''; // emergency |
|
1234 | + //$data['registration'] = $line[2]; |
|
1235 | + //$data['aircraft_icao'] = $line[0]; |
|
1236 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1237 | + $data['format_source'] = 'opensky'; |
|
1238 | + $data['id_source'] = $id_source; |
|
1239 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1240 | + $SI->add($data); |
|
1241 | + unset($data); |
|
1242 | 1242 | } |
1243 | - } |
|
1244 | - //$last_exec['planeupdatefaa'] = time(); |
|
1245 | - $last_exec[$id]['last'] = time(); |
|
1243 | + } |
|
1244 | + //$last_exec['planeupdatefaa'] = time(); |
|
1245 | + $last_exec[$id]['last'] = time(); |
|
1246 | 1246 | } elseif ($value['format'] === 'aircraftjson' && |
1247 | - ( |
|
1247 | + ( |
|
1248 | 1248 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1249 | 1249 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1250 | - ) |
|
1250 | + ) |
|
1251 | 1251 | ) { |
1252 | - $buffer = $Common->getData($value['host']); |
|
1253 | - $all_data = json_decode($buffer,true); |
|
1254 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1252 | + $buffer = $Common->getData($value['host']); |
|
1253 | + $all_data = json_decode($buffer,true); |
|
1254 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1255 | 1255 | $reset = 0; |
1256 | 1256 | foreach ($all_data['aircraft'] as $key => $line) { |
1257 | - $data = array(); |
|
1258 | - // add support for ground vehicule with ~ in front of hex |
|
1259 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1260 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1261 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1262 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1263 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1264 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1265 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1266 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1267 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1268 | - //$data['emergency'] = ''; // emergency |
|
1269 | - //$data['registration'] = $line[2]; |
|
1270 | - //$data['aircraft_icao'] = $line[0]; |
|
1271 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1272 | - $data['format_source'] = 'aircraftjson'; |
|
1273 | - $data['id_source'] = $id_source; |
|
1274 | - if (isset($value['name']) && $value['name'] != '') { |
|
1275 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1276 | - else $data['source_name'] = $value['name']; |
|
1277 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1278 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1279 | - $SI->add($data); |
|
1280 | - unset($data); |
|
1257 | + $data = array(); |
|
1258 | + // add support for ground vehicule with ~ in front of hex |
|
1259 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1260 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1261 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1262 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1263 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1264 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1265 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1266 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1267 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1268 | + //$data['emergency'] = ''; // emergency |
|
1269 | + //$data['registration'] = $line[2]; |
|
1270 | + //$data['aircraft_icao'] = $line[0]; |
|
1271 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1272 | + $data['format_source'] = 'aircraftjson'; |
|
1273 | + $data['id_source'] = $id_source; |
|
1274 | + if (isset($value['name']) && $value['name'] != '') { |
|
1275 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1276 | + else $data['source_name'] = $value['name']; |
|
1277 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1278 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1279 | + $SI->add($data); |
|
1280 | + unset($data); |
|
1281 | 1281 | } |
1282 | - } |
|
1283 | - //$last_exec['planeupdatefaa'] = time(); |
|
1284 | - $last_exec[$id]['last'] = time(); |
|
1282 | + } |
|
1283 | + //$last_exec['planeupdatefaa'] = time(); |
|
1284 | + $last_exec[$id]['last'] = time(); |
|
1285 | 1285 | } elseif ($value['format'] === 'planefinderclient' && |
1286 | - ( |
|
1286 | + ( |
|
1287 | 1287 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1288 | 1288 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1289 | - ) |
|
1289 | + ) |
|
1290 | 1290 | ) { |
1291 | - $buffer = $Common->getData($value['host']); |
|
1292 | - $all_data = json_decode($buffer,true); |
|
1293 | - if (isset($all_data['aircraft'])) { |
|
1291 | + $buffer = $Common->getData($value['host']); |
|
1292 | + $all_data = json_decode($buffer,true); |
|
1293 | + if (isset($all_data['aircraft'])) { |
|
1294 | 1294 | $reset = 0; |
1295 | 1295 | foreach ($all_data['aircraft'] as $key => $line) { |
1296 | - $data = array(); |
|
1297 | - $data['hex'] = $key; // hex |
|
1298 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1299 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1300 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1301 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1302 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1303 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1304 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1305 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1306 | - //$data['emergency'] = ''; // emergency |
|
1307 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1308 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1309 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1310 | - $data['format_source'] = 'planefinderclient'; |
|
1311 | - $data['id_source'] = $id_source; |
|
1312 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1313 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1314 | - $SI->add($data); |
|
1315 | - unset($data); |
|
1296 | + $data = array(); |
|
1297 | + $data['hex'] = $key; // hex |
|
1298 | + if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1299 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1300 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1301 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1302 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1303 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1304 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1305 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1306 | + //$data['emergency'] = ''; // emergency |
|
1307 | + if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1308 | + if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1309 | + $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1310 | + $data['format_source'] = 'planefinderclient'; |
|
1311 | + $data['id_source'] = $id_source; |
|
1312 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1313 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1314 | + $SI->add($data); |
|
1315 | + unset($data); |
|
1316 | 1316 | } |
1317 | - } |
|
1318 | - $last_exec[$id]['last'] = time(); |
|
1317 | + } |
|
1318 | + $last_exec[$id]['last'] = time(); |
|
1319 | 1319 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1320 | 1320 | } elseif ($value['format'] === 'fr24json' && |
1321 | - ( |
|
1321 | + ( |
|
1322 | 1322 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1323 | 1323 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1324 | - ) |
|
1324 | + ) |
|
1325 | 1325 | ) { |
1326 | - //$buffer = $Common->getData($hosts[$id]); |
|
1327 | - $buffer = $Common->getData($value['host']); |
|
1328 | - $all_data = json_decode($buffer,true); |
|
1329 | - if (!empty($all_data)) $reset = 0; |
|
1330 | - foreach ($all_data as $key => $line) { |
|
1326 | + //$buffer = $Common->getData($hosts[$id]); |
|
1327 | + $buffer = $Common->getData($value['host']); |
|
1328 | + $all_data = json_decode($buffer,true); |
|
1329 | + if (!empty($all_data)) $reset = 0; |
|
1330 | + foreach ($all_data as $key => $line) { |
|
1331 | 1331 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1332 | - $data = array(); |
|
1333 | - $data['hex'] = $line[0]; |
|
1334 | - $data['ident'] = $line[16]; //$line[13] |
|
1335 | - $data['altitude'] = $line[4]; // altitude |
|
1336 | - $data['speed'] = $line[5]; // speed |
|
1337 | - $data['heading'] = $line[3]; // heading |
|
1338 | - $data['latitude'] = $line[1]; // lat |
|
1339 | - $data['longitude'] = $line[2]; // long |
|
1340 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1341 | - $data['squawk'] = $line[6]; // squawk |
|
1342 | - $data['aircraft_icao'] = $line[8]; |
|
1343 | - $data['registration'] = $line[9]; |
|
1344 | - $data['departure_airport_iata'] = $line[11]; |
|
1345 | - $data['arrival_airport_iata'] = $line[12]; |
|
1346 | - $data['emergency'] = ''; // emergency |
|
1347 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1348 | - $data['format_source'] = 'fr24json'; |
|
1349 | - $data['id_source'] = $id_source; |
|
1350 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1351 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1352 | - $SI->add($data); |
|
1353 | - unset($data); |
|
1332 | + $data = array(); |
|
1333 | + $data['hex'] = $line[0]; |
|
1334 | + $data['ident'] = $line[16]; //$line[13] |
|
1335 | + $data['altitude'] = $line[4]; // altitude |
|
1336 | + $data['speed'] = $line[5]; // speed |
|
1337 | + $data['heading'] = $line[3]; // heading |
|
1338 | + $data['latitude'] = $line[1]; // lat |
|
1339 | + $data['longitude'] = $line[2]; // long |
|
1340 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1341 | + $data['squawk'] = $line[6]; // squawk |
|
1342 | + $data['aircraft_icao'] = $line[8]; |
|
1343 | + $data['registration'] = $line[9]; |
|
1344 | + $data['departure_airport_iata'] = $line[11]; |
|
1345 | + $data['arrival_airport_iata'] = $line[12]; |
|
1346 | + $data['emergency'] = ''; // emergency |
|
1347 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1348 | + $data['format_source'] = 'fr24json'; |
|
1349 | + $data['id_source'] = $id_source; |
|
1350 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1351 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1352 | + $SI->add($data); |
|
1353 | + unset($data); |
|
1354 | 1354 | } |
1355 | - } |
|
1356 | - //$last_exec['fr24json'] = time(); |
|
1357 | - $last_exec[$id]['last'] = time(); |
|
1355 | + } |
|
1356 | + //$last_exec['fr24json'] = time(); |
|
1357 | + $last_exec[$id]['last'] = time(); |
|
1358 | 1358 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1359 | 1359 | } elseif ($value['format'] === 'radarvirtueljson' && |
1360 | - ( |
|
1360 | + ( |
|
1361 | 1361 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1362 | 1362 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1363 | - ) |
|
1363 | + ) |
|
1364 | 1364 | ) { |
1365 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1366 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1367 | - //echo $buffer; |
|
1368 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1369 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1370 | - $all_data = json_decode($buffer,true); |
|
1371 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1365 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1366 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1367 | + //echo $buffer; |
|
1368 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1369 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1370 | + $all_data = json_decode($buffer,true); |
|
1371 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1372 | 1372 | die(json_last_error_msg()); |
1373 | - } |
|
1374 | - if (isset($all_data['mrkrs'])) { |
|
1373 | + } |
|
1374 | + if (isset($all_data['mrkrs'])) { |
|
1375 | 1375 | $reset = 0; |
1376 | 1376 | foreach ($all_data['mrkrs'] as $key => $line) { |
1377 | - if (isset($line['inf'])) { |
|
1377 | + if (isset($line['inf'])) { |
|
1378 | 1378 | $data = array(); |
1379 | 1379 | $data['hex'] = $line['inf']['ia']; |
1380 | 1380 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1381 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1382 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1383 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1384 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1385 | - $data['longitude'] = $line['pt'][1]; // long |
|
1386 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1387 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1388 | - //$data['aircraft_icao'] = $line[8]; |
|
1389 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1381 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1382 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1383 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1384 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1385 | + $data['longitude'] = $line['pt'][1]; // long |
|
1386 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1387 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1388 | + //$data['aircraft_icao'] = $line[8]; |
|
1389 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1390 | 1390 | //$data['departure_airport_iata'] = $line[11]; |
1391 | 1391 | //$data['arrival_airport_iata'] = $line[12]; |
1392 | - //$data['emergency'] = ''; // emergency |
|
1392 | + //$data['emergency'] = ''; // emergency |
|
1393 | 1393 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1394 | - $data['format_source'] = 'radarvirtueljson'; |
|
1395 | - $data['id_source'] = $id_source; |
|
1394 | + $data['format_source'] = 'radarvirtueljson'; |
|
1395 | + $data['id_source'] = $id_source; |
|
1396 | 1396 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1397 | 1397 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1398 | 1398 | $SI->add($data); |
1399 | 1399 | unset($data); |
1400 | - } |
|
1400 | + } |
|
1401 | 1401 | } |
1402 | - } |
|
1403 | - //$last_exec['radarvirtueljson'] = time(); |
|
1404 | - $last_exec[$id]['last'] = time(); |
|
1402 | + } |
|
1403 | + //$last_exec['radarvirtueljson'] = time(); |
|
1404 | + $last_exec[$id]['last'] = time(); |
|
1405 | 1405 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1406 | 1406 | } elseif ($value['format'] === 'pirepsjson' && |
1407 | - ( |
|
1407 | + ( |
|
1408 | 1408 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1409 | 1409 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1410 | - ) |
|
1410 | + ) |
|
1411 | 1411 | ) { |
1412 | - //$buffer = $Common->getData($hosts[$id]); |
|
1413 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1414 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1412 | + //$buffer = $Common->getData($hosts[$id]); |
|
1413 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1414 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1415 | 1415 | |
1416 | - if (isset($all_data['pireps'])) { |
|
1416 | + if (isset($all_data['pireps'])) { |
|
1417 | 1417 | $reset = 0; |
1418 | - foreach ($all_data['pireps'] as $line) { |
|
1419 | - $data = array(); |
|
1420 | - $data['id'] = $line['id']; |
|
1421 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1422 | - $data['ident'] = $line['callsign']; // ident |
|
1423 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1424 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1425 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1426 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1427 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1428 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1429 | - $data['latitude'] = $line['lat']; // lat |
|
1430 | - $data['longitude'] = $line['lon']; // long |
|
1431 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1432 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1433 | - //$data['emergency'] = ''; // emergency |
|
1434 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1435 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1436 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1437 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1438 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1439 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1440 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1441 | - else $data['info'] = ''; |
|
1442 | - $data['format_source'] = 'pireps'; |
|
1443 | - $data['id_source'] = $id_source; |
|
1444 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1445 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1446 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1447 | - if ($line['icon'] === 'plane') { |
|
1418 | + foreach ($all_data['pireps'] as $line) { |
|
1419 | + $data = array(); |
|
1420 | + $data['id'] = $line['id']; |
|
1421 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1422 | + $data['ident'] = $line['callsign']; // ident |
|
1423 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1424 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1425 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1426 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1427 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1428 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1429 | + $data['latitude'] = $line['lat']; // lat |
|
1430 | + $data['longitude'] = $line['lon']; // long |
|
1431 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1432 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1433 | + //$data['emergency'] = ''; // emergency |
|
1434 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1435 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1436 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1437 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1438 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1439 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1440 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1441 | + else $data['info'] = ''; |
|
1442 | + $data['format_source'] = 'pireps'; |
|
1443 | + $data['id_source'] = $id_source; |
|
1444 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1445 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1446 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1447 | + if ($line['icon'] === 'plane') { |
|
1448 | 1448 | $SI->add($data); |
1449 | - // print_r($data); |
|
1450 | - } elseif ($line['icon'] === 'ct') { |
|
1449 | + // print_r($data); |
|
1450 | + } elseif ($line['icon'] === 'ct') { |
|
1451 | 1451 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1452 | 1452 | $data['info'] = str_replace('&sect;','',$data['info']); |
1453 | 1453 | $typec = substr($data['ident'],-3); |
@@ -1462,209 +1462,209 @@ discard block |
||
1462 | 1462 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1463 | 1463 | else $data['type'] = 'Observer'; |
1464 | 1464 | 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']); |
1465 | - } |
|
1466 | - unset($data); |
|
1465 | + } |
|
1466 | + unset($data); |
|
1467 | 1467 | } |
1468 | - } |
|
1469 | - //$last_exec['pirepsjson'] = time(); |
|
1470 | - $last_exec[$id]['last'] = time(); |
|
1468 | + } |
|
1469 | + //$last_exec['pirepsjson'] = time(); |
|
1470 | + $last_exec[$id]['last'] = time(); |
|
1471 | 1471 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1472 | 1472 | } elseif ($value['format'] === 'phpvmacars' && |
1473 | - ( |
|
1473 | + ( |
|
1474 | 1474 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1475 | 1475 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1476 | - ) |
|
1476 | + ) |
|
1477 | 1477 | ) { |
1478 | - //$buffer = $Common->getData($hosts[$id]); |
|
1479 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1480 | - $buffer = $Common->getData($value['host']); |
|
1481 | - $all_data = json_decode($buffer,true); |
|
1482 | - if ($buffer != '' && is_array($all_data)) { |
|
1478 | + //$buffer = $Common->getData($hosts[$id]); |
|
1479 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1480 | + $buffer = $Common->getData($value['host']); |
|
1481 | + $all_data = json_decode($buffer,true); |
|
1482 | + if ($buffer != '' && is_array($all_data)) { |
|
1483 | 1483 | $reset = 0; |
1484 | 1484 | foreach ($all_data as $line) { |
1485 | - $data = array(); |
|
1486 | - //$data['id'] = $line['id']; // id not usable |
|
1487 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1488 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1489 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1490 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1491 | - $data['ident'] = $line['flightnum']; // ident |
|
1492 | - $data['altitude'] = $line['alt']; // altitude |
|
1493 | - $data['speed'] = $line['gs']; // speed |
|
1494 | - $data['heading'] = $line['heading']; // heading |
|
1495 | - $data['latitude'] = $line['lat']; // lat |
|
1496 | - $data['longitude'] = $line['lng']; // long |
|
1497 | - $data['verticalrate'] = ''; // verticale rate |
|
1498 | - $data['squawk'] = ''; // squawk |
|
1499 | - $data['emergency'] = ''; // emergency |
|
1500 | - //$data['datetime'] = $line['lastupdate']; |
|
1501 | - //$data['last_update'] = $line['lastupdate']; |
|
1502 | - if (isset($value['timezone'])) { |
|
1503 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1504 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1505 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1506 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1507 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1508 | - $data['departure_airport_time'] = $line['deptime']; |
|
1509 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1510 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1511 | - if (isset($line['registration'])) { |
|
1512 | - $data['registration'] = $line['registration']; |
|
1513 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1514 | - } else $data['registration'] = $line['aircraft']; |
|
1515 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1516 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1517 | - if (isset($line['aircraftname'])) { |
|
1485 | + $data = array(); |
|
1486 | + //$data['id'] = $line['id']; // id not usable |
|
1487 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1488 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1489 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1490 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1491 | + $data['ident'] = $line['flightnum']; // ident |
|
1492 | + $data['altitude'] = $line['alt']; // altitude |
|
1493 | + $data['speed'] = $line['gs']; // speed |
|
1494 | + $data['heading'] = $line['heading']; // heading |
|
1495 | + $data['latitude'] = $line['lat']; // lat |
|
1496 | + $data['longitude'] = $line['lng']; // long |
|
1497 | + $data['verticalrate'] = ''; // verticale rate |
|
1498 | + $data['squawk'] = ''; // squawk |
|
1499 | + $data['emergency'] = ''; // emergency |
|
1500 | + //$data['datetime'] = $line['lastupdate']; |
|
1501 | + //$data['last_update'] = $line['lastupdate']; |
|
1502 | + if (isset($value['timezone'])) { |
|
1503 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1504 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1505 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1506 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1507 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1508 | + $data['departure_airport_time'] = $line['deptime']; |
|
1509 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1510 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1511 | + if (isset($line['registration'])) { |
|
1512 | + $data['registration'] = $line['registration']; |
|
1513 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1514 | + } else $data['registration'] = $line['aircraft']; |
|
1515 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1516 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1517 | + if (isset($line['aircraftname'])) { |
|
1518 | 1518 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1519 | 1519 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1520 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1521 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1522 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1523 | - else { |
|
1524 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1525 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1526 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1527 | - } |
|
1528 | - } |
|
1529 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1530 | - $data['id_source'] = $id_source; |
|
1531 | - $data['format_source'] = 'phpvmacars'; |
|
1532 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1533 | - $SI->add($data); |
|
1534 | - unset($data); |
|
1520 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1521 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1522 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1523 | + else { |
|
1524 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1525 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1526 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1527 | + } |
|
1528 | + } |
|
1529 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1530 | + $data['id_source'] = $id_source; |
|
1531 | + $data['format_source'] = 'phpvmacars'; |
|
1532 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1533 | + $SI->add($data); |
|
1534 | + unset($data); |
|
1535 | 1535 | } |
1536 | 1536 | if ($globalDebug) echo 'No more data...'."\n"; |
1537 | 1537 | unset($buffer); |
1538 | 1538 | unset($all_data); |
1539 | - } |
|
1540 | - //$last_exec['phpvmacars'] = time(); |
|
1541 | - $last_exec[$id]['last'] = time(); |
|
1539 | + } |
|
1540 | + //$last_exec['phpvmacars'] = time(); |
|
1541 | + $last_exec[$id]['last'] = time(); |
|
1542 | 1542 | } elseif ($value['format'] === 'vaos' && |
1543 | - ( |
|
1543 | + ( |
|
1544 | 1544 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1545 | 1545 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1546 | - ) |
|
1546 | + ) |
|
1547 | 1547 | ) { |
1548 | - //$buffer = $Common->getData($hosts[$id]); |
|
1549 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1550 | - $buffer = $Common->getData($value['host']); |
|
1551 | - $all_data = json_decode($buffer,true); |
|
1552 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1548 | + //$buffer = $Common->getData($hosts[$id]); |
|
1549 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1550 | + $buffer = $Common->getData($value['host']); |
|
1551 | + $all_data = json_decode($buffer,true); |
|
1552 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1553 | 1553 | $reset = 0; |
1554 | 1554 | foreach ($all_data['ACARSData'] as $line) { |
1555 | - //print_r($line); |
|
1556 | - $data = array(); |
|
1557 | - //$data['id'] = $line['id']; // id not usable |
|
1558 | - $data['id'] = $line['id']; |
|
1559 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1560 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1561 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1562 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1563 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1564 | - $data['altitude'] = $line['altitude']; // altitude |
|
1565 | - $data['speed'] = $line['groundspeed']; // speed |
|
1566 | - $data['heading'] = $line['heading']; // heading |
|
1567 | - $data['latitude'] = $line['lat']; // lat |
|
1568 | - $data['longitude'] = $line['lon']; // long |
|
1569 | - //$data['verticalrate'] = ''; // verticale rate |
|
1570 | - //$data['squawk'] = ''; // squawk |
|
1571 | - //$data['emergency'] = ''; // emergency |
|
1572 | - if (isset($value['timezone'])) { |
|
1573 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1574 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1575 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1576 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1555 | + //print_r($line); |
|
1556 | + $data = array(); |
|
1557 | + //$data['id'] = $line['id']; // id not usable |
|
1558 | + $data['id'] = $line['id']; |
|
1559 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1560 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1561 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1562 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1563 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1564 | + $data['altitude'] = $line['altitude']; // altitude |
|
1565 | + $data['speed'] = $line['groundspeed']; // speed |
|
1566 | + $data['heading'] = $line['heading']; // heading |
|
1567 | + $data['latitude'] = $line['lat']; // lat |
|
1568 | + $data['longitude'] = $line['lon']; // long |
|
1569 | + //$data['verticalrate'] = ''; // verticale rate |
|
1570 | + //$data['squawk'] = ''; // squawk |
|
1571 | + //$data['emergency'] = ''; // emergency |
|
1572 | + if (isset($value['timezone'])) { |
|
1573 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1574 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1575 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1576 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1577 | 1577 | |
1578 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1579 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1580 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1581 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1582 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1578 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1579 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1580 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1581 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1582 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1583 | 1583 | |
1584 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1585 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1586 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1584 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1585 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1586 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1587 | 1587 | |
1588 | - $data['id_source'] = $id_source; |
|
1589 | - $data['format_source'] = 'vaos'; |
|
1590 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1591 | - $SI->add($data); |
|
1592 | - unset($data); |
|
1588 | + $data['id_source'] = $id_source; |
|
1589 | + $data['format_source'] = 'vaos'; |
|
1590 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1591 | + $SI->add($data); |
|
1592 | + unset($data); |
|
1593 | 1593 | } |
1594 | 1594 | if ($globalDebug) echo 'No more data...'."\n"; |
1595 | 1595 | unset($buffer); |
1596 | 1596 | unset($all_data); |
1597 | - } |
|
1598 | - //$last_exec['phpvmacars'] = time(); |
|
1599 | - $last_exec[$id]['last'] = time(); |
|
1597 | + } |
|
1598 | + //$last_exec['phpvmacars'] = time(); |
|
1599 | + $last_exec[$id]['last'] = time(); |
|
1600 | 1600 | } elseif ($value['format'] === 'vam' && |
1601 | - ( |
|
1601 | + ( |
|
1602 | 1602 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1603 | 1603 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1604 | - ) |
|
1604 | + ) |
|
1605 | 1605 | ) { |
1606 | - //$buffer = $Common->getData($hosts[$id]); |
|
1607 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1608 | - $buffer = $Common->getData($value['host']); |
|
1609 | - $all_data = json_decode($buffer,true); |
|
1610 | - if ($buffer != '' && is_array($all_data)) { |
|
1606 | + //$buffer = $Common->getData($hosts[$id]); |
|
1607 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1608 | + $buffer = $Common->getData($value['host']); |
|
1609 | + $all_data = json_decode($buffer,true); |
|
1610 | + if ($buffer != '' && is_array($all_data)) { |
|
1611 | 1611 | $reset = 0; |
1612 | 1612 | foreach ($all_data as $line) { |
1613 | - $data = array(); |
|
1614 | - //$data['id'] = $line['id']; // id not usable |
|
1615 | - $data['id'] = trim($line['flight_id']); |
|
1616 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1617 | - $data['pilot_name'] = $line['pilot_name']; |
|
1618 | - $data['pilot_id'] = $line['pilot_id']; |
|
1619 | - $data['ident'] = trim($line['callsign']); // ident |
|
1620 | - $data['altitude'] = $line['altitude']; // altitude |
|
1621 | - $data['speed'] = $line['gs']; // speed |
|
1622 | - $data['heading'] = $line['heading']; // heading |
|
1623 | - $data['latitude'] = $line['latitude']; // lat |
|
1624 | - $data['longitude'] = $line['longitude']; // long |
|
1625 | - $data['verticalrate'] = ''; // verticale rate |
|
1626 | - $data['squawk'] = ''; // squawk |
|
1627 | - $data['emergency'] = ''; // emergency |
|
1628 | - //$data['datetime'] = $line['lastupdate']; |
|
1629 | - $data['last_update'] = $line['last_update']; |
|
1630 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1631 | - $data['departure_airport_icao'] = $line['departure']; |
|
1632 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1633 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1634 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1635 | - //$data['registration'] = $line['aircraft']; |
|
1636 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1637 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1638 | - $data['id_source'] = $id_source; |
|
1639 | - $data['format_source'] = 'vam'; |
|
1640 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1641 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1642 | - $SI->add($data); |
|
1643 | - unset($data); |
|
1613 | + $data = array(); |
|
1614 | + //$data['id'] = $line['id']; // id not usable |
|
1615 | + $data['id'] = trim($line['flight_id']); |
|
1616 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1617 | + $data['pilot_name'] = $line['pilot_name']; |
|
1618 | + $data['pilot_id'] = $line['pilot_id']; |
|
1619 | + $data['ident'] = trim($line['callsign']); // ident |
|
1620 | + $data['altitude'] = $line['altitude']; // altitude |
|
1621 | + $data['speed'] = $line['gs']; // speed |
|
1622 | + $data['heading'] = $line['heading']; // heading |
|
1623 | + $data['latitude'] = $line['latitude']; // lat |
|
1624 | + $data['longitude'] = $line['longitude']; // long |
|
1625 | + $data['verticalrate'] = ''; // verticale rate |
|
1626 | + $data['squawk'] = ''; // squawk |
|
1627 | + $data['emergency'] = ''; // emergency |
|
1628 | + //$data['datetime'] = $line['lastupdate']; |
|
1629 | + $data['last_update'] = $line['last_update']; |
|
1630 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1631 | + $data['departure_airport_icao'] = $line['departure']; |
|
1632 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1633 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1634 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1635 | + //$data['registration'] = $line['aircraft']; |
|
1636 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1637 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1638 | + $data['id_source'] = $id_source; |
|
1639 | + $data['format_source'] = 'vam'; |
|
1640 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1641 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1642 | + $SI->add($data); |
|
1643 | + unset($data); |
|
1644 | 1644 | } |
1645 | 1645 | if ($globalDebug) echo 'No more data...'."\n"; |
1646 | 1646 | unset($buffer); |
1647 | 1647 | unset($all_data); |
1648 | - } |
|
1649 | - //$last_exec['phpvmacars'] = time(); |
|
1650 | - $last_exec[$id]['last'] = time(); |
|
1648 | + } |
|
1649 | + //$last_exec['phpvmacars'] = time(); |
|
1650 | + $last_exec[$id]['last'] = time(); |
|
1651 | 1651 | } elseif ($value['format'] === 'blitzortung' && |
1652 | - ( |
|
1652 | + ( |
|
1653 | 1653 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1654 | 1654 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1655 | - ) |
|
1655 | + ) |
|
1656 | 1656 | ) { |
1657 | - //$buffer = $Common->getData($hosts[$id]); |
|
1658 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1659 | - $buffer = $Common->getData($value['host']); |
|
1660 | - $all_data = json_decode($buffer,true); |
|
1661 | - if ($buffer != '') { |
|
1657 | + //$buffer = $Common->getData($hosts[$id]); |
|
1658 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1659 | + $buffer = $Common->getData($value['host']); |
|
1660 | + $all_data = json_decode($buffer,true); |
|
1661 | + if ($buffer != '') { |
|
1662 | 1662 | $Source->deleteLocationBySource('blitzortung'); |
1663 | 1663 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1664 | 1664 | $buffer = explode('\n',$buffer); |
1665 | 1665 | foreach ($buffer as $buffer_line) { |
1666 | - $line = json_decode($buffer_line,true); |
|
1667 | - if (isset($line['time'])) { |
|
1666 | + $line = json_decode($buffer_line,true); |
|
1667 | + if (isset($line['time'])) { |
|
1668 | 1668 | $data = array(); |
1669 | 1669 | $data['altitude'] = $line['alt']; // altitude |
1670 | 1670 | $data['latitude'] = $line['lat']; // lat |
@@ -1676,92 +1676,92 @@ discard block |
||
1676 | 1676 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1677 | 1677 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1678 | 1678 | unset($data); |
1679 | - } |
|
1679 | + } |
|
1680 | 1680 | } |
1681 | 1681 | if ($globalDebug) echo 'No more data...'."\n"; |
1682 | 1682 | unset($buffer); |
1683 | - } |
|
1684 | - $last_exec[$id]['last'] = time(); |
|
1683 | + } |
|
1684 | + $last_exec[$id]['last'] = time(); |
|
1685 | 1685 | } elseif ($value['format'] === 'acarsjson') { |
1686 | - $arr = $httpfeeds; |
|
1687 | - $w = $e = null; |
|
1688 | - if (isset($arr[$id])) { |
|
1689 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
1690 | - if ($nn > 0) { |
|
1691 | - foreach ($httpfeeds as $feed) { |
|
1692 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
1693 | - if ($buffer === FALSE) { |
|
1694 | - connect_all($globalSources); |
|
1695 | - } |
|
1696 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1697 | - $buffer = explode('\n',$buffer); |
|
1698 | - foreach ($buffer as $line) { |
|
1699 | - if ($line != '') { |
|
1700 | - $line = json_decode($line, true); |
|
1701 | - if (!empty($line)) { |
|
1702 | - $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
1703 | - $ACARS->deleteLiveAcarsData(); |
|
1704 | - } |
|
1705 | - } |
|
1706 | - } |
|
1707 | - } |
|
1708 | - } else { |
|
1709 | - $format = $value['format']; |
|
1710 | - if (isset($tt[$format])) $tt[$format]++; |
|
1711 | - else $tt[$format] = 0; |
|
1712 | - if ($tt[$format] > 30) { |
|
1713 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
1714 | - sleep(2); |
|
1715 | - //$sourceeen[] = $value; |
|
1716 | - //connect_all($sourceeen); |
|
1717 | - //$sourceeen = array(); |
|
1718 | - connect_all($globalSources); |
|
1719 | - } |
|
1720 | - } |
|
1721 | - } |
|
1686 | + $arr = $httpfeeds; |
|
1687 | + $w = $e = null; |
|
1688 | + if (isset($arr[$id])) { |
|
1689 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
1690 | + if ($nn > 0) { |
|
1691 | + foreach ($httpfeeds as $feed) { |
|
1692 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
1693 | + if ($buffer === FALSE) { |
|
1694 | + connect_all($globalSources); |
|
1695 | + } |
|
1696 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1697 | + $buffer = explode('\n',$buffer); |
|
1698 | + foreach ($buffer as $line) { |
|
1699 | + if ($line != '') { |
|
1700 | + $line = json_decode($line, true); |
|
1701 | + if (!empty($line)) { |
|
1702 | + $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
1703 | + $ACARS->deleteLiveAcarsData(); |
|
1704 | + } |
|
1705 | + } |
|
1706 | + } |
|
1707 | + } |
|
1708 | + } else { |
|
1709 | + $format = $value['format']; |
|
1710 | + if (isset($tt[$format])) $tt[$format]++; |
|
1711 | + else $tt[$format] = 0; |
|
1712 | + if ($tt[$format] > 30) { |
|
1713 | + if ($globalDebug) echo 'Reconnect...'."\n"; |
|
1714 | + sleep(2); |
|
1715 | + //$sourceeen[] = $value; |
|
1716 | + //connect_all($sourceeen); |
|
1717 | + //$sourceeen = array(); |
|
1718 | + connect_all($globalSources); |
|
1719 | + } |
|
1720 | + } |
|
1721 | + } |
|
1722 | 1722 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
1723 | 1723 | } 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'] === 'acarsjsonudp' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') { |
1724 | - //$last_exec[$id]['last'] = time(); |
|
1725 | - //$read = array( $sockets[$id] ); |
|
1726 | - $read = $sockets; |
|
1727 | - $write = NULL; |
|
1728 | - $e = NULL; |
|
1729 | - $n = socket_select($read, $write, $e, $timeout); |
|
1730 | - if ($e != NULL) var_dump($e); |
|
1731 | - if ($n > 0) { |
|
1724 | + //$last_exec[$id]['last'] = time(); |
|
1725 | + //$read = array( $sockets[$id] ); |
|
1726 | + $read = $sockets; |
|
1727 | + $write = NULL; |
|
1728 | + $e = NULL; |
|
1729 | + $n = socket_select($read, $write, $e, $timeout); |
|
1730 | + if ($e != NULL) var_dump($e); |
|
1731 | + if ($n > 0) { |
|
1732 | 1732 | $reset = 0; |
1733 | 1733 | foreach ($read as $nb => $r) { |
1734 | - //$value = $formats[$nb]; |
|
1735 | - $format = $globalSources[$nb]['format']; |
|
1736 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1734 | + //$value = $formats[$nb]; |
|
1735 | + $format = $globalSources[$nb]['format']; |
|
1736 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1737 | 1737 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1738 | - } elseif ($format === 'vrstcp') { |
|
1738 | + } elseif ($format === 'vrstcp') { |
|
1739 | 1739 | $buffer = @socket_read($r, 6000); |
1740 | - } else { |
|
1740 | + } else { |
|
1741 | 1741 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1742 | - } |
|
1743 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1744 | - //echo $buffer."\n"; |
|
1745 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1746 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1747 | - $error = false; |
|
1748 | - //$SI::del(); |
|
1749 | - if ($buffer !== FALSE) { |
|
1742 | + } |
|
1743 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1744 | + //echo $buffer."\n"; |
|
1745 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1746 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1747 | + $error = false; |
|
1748 | + //$SI::del(); |
|
1749 | + if ($buffer !== FALSE) { |
|
1750 | 1750 | if ($format === 'vrstcp') { |
1751 | - $buffer = explode('},{',$buffer); |
|
1751 | + $buffer = explode('},{',$buffer); |
|
1752 | 1752 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1753 | - } |
|
1754 | - // SBS format is CSV format |
|
1755 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1753 | + } |
|
1754 | + // SBS format is CSV format |
|
1755 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1756 | 1756 | $tt[$format] = 0; |
1757 | 1757 | if ($format === 'acarssbs3') { |
1758 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1759 | - $ACARS->add(trim($buffer)); |
|
1760 | - $ACARS->deleteLiveAcarsData(); |
|
1758 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1759 | + $ACARS->add(trim($buffer)); |
|
1760 | + $ACARS->deleteLiveAcarsData(); |
|
1761 | 1761 | } elseif ($format === 'raw') { |
1762 | - // AVR format |
|
1763 | - $data = $SBS->parse($buffer); |
|
1764 | - if (is_array($data)) { |
|
1762 | + // AVR format |
|
1763 | + $data = $SBS->parse($buffer); |
|
1764 | + if (is_array($data)) { |
|
1765 | 1765 | //if (!empty($data)) print_r($data); |
1766 | 1766 | $data['datetime'] = date('Y-m-d H:i:s'); |
1767 | 1767 | $data['format_source'] = 'raw'; |
@@ -1771,39 +1771,39 @@ discard block |
||
1771 | 1771 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1772 | 1772 | $SI->add($data); |
1773 | 1773 | unset($data); |
1774 | - } |
|
1774 | + } |
|
1775 | 1775 | } elseif ($format === 'ais') { |
1776 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1777 | - $data = array(); |
|
1778 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1779 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1780 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1781 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1782 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1783 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1784 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1785 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1786 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1787 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1788 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1789 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1790 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1791 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1792 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1793 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1776 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1777 | + $data = array(); |
|
1778 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1779 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1780 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1781 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1782 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1783 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1784 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1785 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1786 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1787 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1788 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1789 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1790 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1791 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1792 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1793 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1794 | 1794 | |
1795 | - if (isset($ais_data['timestamp'])) { |
|
1795 | + if (isset($ais_data['timestamp'])) { |
|
1796 | 1796 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1797 | - } else { |
|
1797 | + } else { |
|
1798 | 1798 | $data['datetime'] = date('Y-m-d H:i:s'); |
1799 | - } |
|
1800 | - $data['format_source'] = 'aisnmea'; |
|
1801 | - $data['id_source'] = $id_source; |
|
1802 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1803 | - unset($data); |
|
1804 | - } elseif ($format === 'flightgearsp') { |
|
1805 | - //echo $buffer."\n"; |
|
1806 | - if (strlen($buffer) > 5) { |
|
1799 | + } |
|
1800 | + $data['format_source'] = 'aisnmea'; |
|
1801 | + $data['id_source'] = $id_source; |
|
1802 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1803 | + unset($data); |
|
1804 | + } elseif ($format === 'flightgearsp') { |
|
1805 | + //echo $buffer."\n"; |
|
1806 | + if (strlen($buffer) > 5) { |
|
1807 | 1807 | $line = explode(',',$buffer); |
1808 | 1808 | $data = array(); |
1809 | 1809 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1820,47 +1820,47 @@ discard block |
||
1820 | 1820 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1821 | 1821 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1822 | 1822 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1823 | - } |
|
1824 | - } elseif ($format === 'acars') { |
|
1825 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1826 | - $ACARS->add(trim($buffer)); |
|
1827 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1828 | - $ACARS->deleteLiveAcarsData(); |
|
1823 | + } |
|
1824 | + } elseif ($format === 'acars') { |
|
1825 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1826 | + $ACARS->add(trim($buffer)); |
|
1827 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1828 | + $ACARS->deleteLiveAcarsData(); |
|
1829 | 1829 | } elseif ($format === 'acarsjsonudp') { |
1830 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1831 | - $line = json_decode(trim($buffer), true); |
|
1832 | - if (!empty($line)) { |
|
1830 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1831 | + $line = json_decode(trim($buffer), true); |
|
1832 | + if (!empty($line)) { |
|
1833 | 1833 | $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
1834 | - $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
1835 | - $ACARS->deleteLiveAcarsData(); |
|
1836 | - } |
|
1837 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1834 | + $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
1835 | + $ACARS->deleteLiveAcarsData(); |
|
1836 | + } |
|
1837 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1838 | 1838 | } elseif ($format === 'flightgearmp') { |
1839 | - if (substr($buffer,0,1) != '#') { |
|
1839 | + if (substr($buffer,0,1) != '#') { |
|
1840 | 1840 | $data = array(); |
1841 | 1841 | //echo $buffer."\n"; |
1842 | 1842 | $line = explode(' ',$buffer); |
1843 | 1843 | if (count($line) === 11) { |
1844 | - $userserver = explode('@',$line[0]); |
|
1845 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1846 | - $data['ident'] = $userserver[0]; |
|
1847 | - $data['registration'] = $userserver[0]; |
|
1848 | - $data['latitude'] = $line[4]; |
|
1849 | - $data['longitude'] = $line[5]; |
|
1850 | - $data['altitude'] = $line[6]; |
|
1851 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1852 | - $aircraft_type = $line[10]; |
|
1853 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1854 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1855 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1856 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1844 | + $userserver = explode('@',$line[0]); |
|
1845 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1846 | + $data['ident'] = $userserver[0]; |
|
1847 | + $data['registration'] = $userserver[0]; |
|
1848 | + $data['latitude'] = $line[4]; |
|
1849 | + $data['longitude'] = $line[5]; |
|
1850 | + $data['altitude'] = $line[6]; |
|
1851 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1852 | + $aircraft_type = $line[10]; |
|
1853 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1854 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1855 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1856 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1857 | + } |
|
1857 | 1858 | } |
1858 | - } |
|
1859 | 1859 | } elseif ($format === 'beast') { |
1860 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1861 | - die; |
|
1860 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1861 | + die; |
|
1862 | 1862 | } elseif ($format === 'vrstcp') { |
1863 | - foreach($buffer as $all_data) { |
|
1863 | + foreach($buffer as $all_data) { |
|
1864 | 1864 | $line = json_decode('{'.$all_data.'}',true); |
1865 | 1865 | $data = array(); |
1866 | 1866 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1880,158 +1880,158 @@ discard block |
||
1880 | 1880 | */ |
1881 | 1881 | $data['datetime'] = date('Y-m-d H:i:s'); |
1882 | 1882 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1883 | - $data['format_source'] = 'vrstcp'; |
|
1883 | + $data['format_source'] = 'vrstcp'; |
|
1884 | 1884 | $data['id_source'] = $id_source; |
1885 | 1885 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1886 | 1886 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1887 | 1887 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1888 | 1888 | unset($data); |
1889 | - } |
|
1889 | + } |
|
1890 | 1890 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
1891 | - $line = explode("\t", $buffer); |
|
1892 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1891 | + $line = explode("\t", $buffer); |
|
1892 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1893 | 1893 | $key = $line[$k]; |
1894 | - $lined[$key] = $line[$k+1]; |
|
1895 | - } |
|
1896 | - if (count($lined) > 3) { |
|
1897 | - $data['hex'] = $lined['hexid']; |
|
1898 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1899 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1900 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1901 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1902 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1903 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1904 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1905 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1906 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1907 | - $data['id_source'] = $id_source; |
|
1908 | - $data['format_source'] = 'tsv'; |
|
1909 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1910 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1894 | + $lined[$key] = $line[$k+1]; |
|
1895 | + } |
|
1896 | + if (count($lined) > 3) { |
|
1897 | + $data['hex'] = $lined['hexid']; |
|
1898 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1899 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1900 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1901 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1902 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1903 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1904 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1905 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1906 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1907 | + $data['id_source'] = $id_source; |
|
1908 | + $data['format_source'] = 'tsv'; |
|
1909 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1910 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1911 | 1911 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1912 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1913 | - unset($lined); |
|
1914 | - unset($data); |
|
1915 | - } else $error = true; |
|
1912 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1913 | + unset($lined); |
|
1914 | + unset($data); |
|
1915 | + } else $error = true; |
|
1916 | 1916 | } elseif ($format === 'aprs' && $use_aprs) { |
1917 | - if ($aprs_connect === 0) { |
|
1917 | + if ($aprs_connect === 0) { |
|
1918 | 1918 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1919 | 1919 | $aprs_connect = 1; |
1920 | - } |
|
1920 | + } |
|
1921 | 1921 | |
1922 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1922 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1923 | 1923 | $aprs_last_tx = time(); |
1924 | 1924 | $data_aprs = "# Keep alive"; |
1925 | 1925 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1926 | - } |
|
1926 | + } |
|
1927 | 1927 | |
1928 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1929 | - //echo 'APRS data : '.$buffer."\n"; |
|
1930 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1931 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1932 | - //echo $buffer."\n"; |
|
1933 | - date_default_timezone_set('UTC'); |
|
1934 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1928 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1929 | + //echo 'APRS data : '.$buffer."\n"; |
|
1930 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1931 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1932 | + //echo $buffer."\n"; |
|
1933 | + date_default_timezone_set('UTC'); |
|
1934 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1935 | 1935 | $line = $APRS->parse($buffer); |
1936 | 1936 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1937 | 1937 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1938 | - $aprs_last_tx = time(); |
|
1939 | - $data = array(); |
|
1940 | - //print_r($line); |
|
1941 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1942 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1943 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1944 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1945 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1946 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1947 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1948 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1949 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1950 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1951 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1952 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1953 | - $data['latitude'] = $line['latitude']; |
|
1954 | - $data['longitude'] = $line['longitude']; |
|
1955 | - //$data['verticalrate'] = $line[16]; |
|
1956 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1957 | - //else $data['speed'] = 0; |
|
1958 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1959 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1960 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1961 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1938 | + $aprs_last_tx = time(); |
|
1939 | + $data = array(); |
|
1940 | + //print_r($line); |
|
1941 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1942 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1943 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1944 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1945 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1946 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1947 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1948 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1949 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1950 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1951 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1952 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1953 | + $data['latitude'] = $line['latitude']; |
|
1954 | + $data['longitude'] = $line['longitude']; |
|
1955 | + //$data['verticalrate'] = $line[16]; |
|
1956 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1957 | + //else $data['speed'] = 0; |
|
1958 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1959 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1960 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1961 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1962 | 1962 | |
1963 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1964 | - //else echo 'No heading...'."\n"; |
|
1965 | - //else $data['heading'] = 0; |
|
1966 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1967 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1968 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1969 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1970 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1971 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1972 | - $data['id_source'] = $id_source; |
|
1973 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1974 | - else $data['format_source'] = 'aprs'; |
|
1975 | - $data['source_name'] = $line['source']; |
|
1976 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1977 | - else $data['source_type'] = 'flarm'; |
|
1978 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1979 | - $currentdate = date('Y-m-d H:i:s'); |
|
1980 | - $aprsdate = strtotime($data['datetime']); |
|
1981 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1982 | - // Accept data if time <= system time + 20s |
|
1983 | - //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'])))) { |
|
1984 | - if ( |
|
1963 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1964 | + //else echo 'No heading...'."\n"; |
|
1965 | + //else $data['heading'] = 0; |
|
1966 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1967 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1968 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1969 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1970 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1971 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1972 | + $data['id_source'] = $id_source; |
|
1973 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1974 | + else $data['format_source'] = 'aprs'; |
|
1975 | + $data['source_name'] = $line['source']; |
|
1976 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1977 | + else $data['source_type'] = 'flarm'; |
|
1978 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1979 | + $currentdate = date('Y-m-d H:i:s'); |
|
1980 | + $aprsdate = strtotime($data['datetime']); |
|
1981 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1982 | + // Accept data if time <= system time + 20s |
|
1983 | + //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'])))) { |
|
1984 | + if ( |
|
1985 | 1985 | ($data['source_type'] === 'modes') || |
1986 | 1986 | isset($line['stealth']) && |
1987 | 1987 | (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && |
1988 | 1988 | ($line['stealth'] === 0 || $line['stealth'] == '') && |
1989 | 1989 | (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1990 | 1990 | $send = $SI->add($data); |
1991 | - } elseif ($data['source_type'] === 'ais') { |
|
1991 | + } elseif ($data['source_type'] === 'ais') { |
|
1992 | 1992 | $data['type'] = ''; |
1993 | 1993 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1994 | - } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
1994 | + } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
1995 | 1995 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1996 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1997 | - //$line['symbol'] === 'Balloon' || |
|
1998 | - $line['symbol'] === 'Glider' || |
|
1999 | - $line['symbol'] === 'No. Plane' || |
|
2000 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
2001 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
2002 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2003 | - $send = $SI->add($data); |
|
2004 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
2005 | - $line['symbol'] === 'Yacht (Sail)' || |
|
2006 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
2007 | - $send = $MI->add($data); |
|
2008 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
2009 | - $line['symbol'] === 'Car' || |
|
2010 | - $line['symbol'] === 'Ambulance' || |
|
2011 | - $line['symbol'] === 'Van' || |
|
2012 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
2013 | - $line['symbol'] === 'Motorcycle' || |
|
2014 | - $line['symbol'] === 'Tractor' || |
|
2015 | - $line['symbol'] === 'Police' || |
|
2016 | - $line['symbol'] === 'Bike' || |
|
2017 | - $line['symbol'] === 'Jogger' || |
|
2018 | - $line['symbol'] === 'Horse' || |
|
2019 | - $line['symbol'] === 'Bus' || |
|
2020 | - $line['symbol'] === 'Jeep' || |
|
2021 | - $line['symbol'] === 'Recreational Vehicle' || |
|
2022 | - $line['symbol'] === 'Yacht (Sail)' || |
|
2023 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
2024 | - $line['symbol'] === 'Firetruck' || |
|
2025 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
2026 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
2027 | - $line['symbol'] === 'SUV' || |
|
2028 | - $line['symbol'] === 'Snowmobile' || |
|
2029 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
2030 | - //} 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') { |
|
1996 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1997 | + //$line['symbol'] === 'Balloon' || |
|
1998 | + $line['symbol'] === 'Glider' || |
|
1999 | + $line['symbol'] === 'No. Plane' || |
|
2000 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
2001 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
2002 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2003 | + $send = $SI->add($data); |
|
2004 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
2005 | + $line['symbol'] === 'Yacht (Sail)' || |
|
2006 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
2007 | + $send = $MI->add($data); |
|
2008 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
2009 | + $line['symbol'] === 'Car' || |
|
2010 | + $line['symbol'] === 'Ambulance' || |
|
2011 | + $line['symbol'] === 'Van' || |
|
2012 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
2013 | + $line['symbol'] === 'Motorcycle' || |
|
2014 | + $line['symbol'] === 'Tractor' || |
|
2015 | + $line['symbol'] === 'Police' || |
|
2016 | + $line['symbol'] === 'Bike' || |
|
2017 | + $line['symbol'] === 'Jogger' || |
|
2018 | + $line['symbol'] === 'Horse' || |
|
2019 | + $line['symbol'] === 'Bus' || |
|
2020 | + $line['symbol'] === 'Jeep' || |
|
2021 | + $line['symbol'] === 'Recreational Vehicle' || |
|
2022 | + $line['symbol'] === 'Yacht (Sail)' || |
|
2023 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
2024 | + $line['symbol'] === 'Firetruck' || |
|
2025 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
2026 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
2027 | + $line['symbol'] === 'SUV' || |
|
2028 | + $line['symbol'] === 'Snowmobile' || |
|
2029 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
2030 | + //} 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') { |
|
2031 | 2031 | // } 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') { |
2032 | 2032 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
2033 | 2033 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
2034 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
2034 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
2035 | 2035 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
2036 | 2036 | $Source->deleteOldLocationByType('gs'); |
2037 | 2037 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -2039,7 +2039,7 @@ discard block |
||
2039 | 2039 | } else { |
2040 | 2040 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
2041 | 2041 | } |
2042 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
2042 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
2043 | 2043 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
2044 | 2044 | if ($globalDebug) echo '# Weather Station added'."\n"; |
2045 | 2045 | $Source->deleteOldLocationByType('wx'); |
@@ -2049,7 +2049,7 @@ discard block |
||
2049 | 2049 | } else { |
2050 | 2050 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
2051 | 2051 | } |
2052 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
2052 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
2053 | 2053 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
2054 | 2054 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
2055 | 2055 | $Source->deleteOldLocationByType('lightning'); |
@@ -2058,11 +2058,11 @@ discard block |
||
2058 | 2058 | } else { |
2059 | 2059 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
2060 | 2060 | } |
2061 | - } elseif ($globalDebug) { |
|
2062 | - echo '/!\ Not added: '.$buffer."\n"; |
|
2063 | - print_r($line); |
|
2064 | - } |
|
2065 | - unset($data); |
|
2061 | + } elseif ($globalDebug) { |
|
2062 | + echo '/!\ Not added: '.$buffer."\n"; |
|
2063 | + print_r($line); |
|
2064 | + } |
|
2065 | + unset($data); |
|
2066 | 2066 | } |
2067 | 2067 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
2068 | 2068 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -2081,13 +2081,13 @@ discard block |
||
2081 | 2081 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
2082 | 2082 | $globalSources[$nb]['last_weather_clean'] = time(); |
2083 | 2083 | } |
2084 | - } |
|
2084 | + } |
|
2085 | 2085 | } else { |
2086 | - $line = explode(',', $buffer); |
|
2087 | - //print_r($line); |
|
2088 | - if (count($line) > 20) { |
|
2089 | - $data['hex'] = $line[4]; |
|
2090 | - /* |
|
2086 | + $line = explode(',', $buffer); |
|
2087 | + //print_r($line); |
|
2088 | + if (count($line) > 20) { |
|
2089 | + $data['hex'] = $line[4]; |
|
2090 | + /* |
|
2091 | 2091 | $data['datetime'] = $line[6].' '.$line[7]; |
2092 | 2092 | date_default_timezone_set($globalTimezone); |
2093 | 2093 | $datetime = new DateTime($data['datetime']); |
@@ -2095,31 +2095,31 @@ discard block |
||
2095 | 2095 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
2096 | 2096 | date_default_timezone_set('UTC'); |
2097 | 2097 | */ |
2098 | - // Force datetime to current UTC datetime |
|
2099 | - date_default_timezone_set('UTC'); |
|
2100 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
2101 | - $data['ident'] = trim($line[10]); |
|
2102 | - $data['latitude'] = $line[14]; |
|
2103 | - $data['longitude'] = $line[15]; |
|
2104 | - $data['verticalrate'] = $line[16]; |
|
2105 | - $data['emergency'] = $line[20]; |
|
2106 | - $data['speed'] = $line[12]; |
|
2107 | - $data['squawk'] = $line[17]; |
|
2108 | - $data['altitude'] = $line[11]; |
|
2109 | - $data['heading'] = $line[13]; |
|
2110 | - $data['ground'] = $line[21]; |
|
2111 | - $data['emergency'] = $line[19]; |
|
2112 | - $data['format_source'] = 'sbs'; |
|
2098 | + // Force datetime to current UTC datetime |
|
2099 | + date_default_timezone_set('UTC'); |
|
2100 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2101 | + $data['ident'] = trim($line[10]); |
|
2102 | + $data['latitude'] = $line[14]; |
|
2103 | + $data['longitude'] = $line[15]; |
|
2104 | + $data['verticalrate'] = $line[16]; |
|
2105 | + $data['emergency'] = $line[20]; |
|
2106 | + $data['speed'] = $line[12]; |
|
2107 | + $data['squawk'] = $line[17]; |
|
2108 | + $data['altitude'] = $line[11]; |
|
2109 | + $data['heading'] = $line[13]; |
|
2110 | + $data['ground'] = $line[21]; |
|
2111 | + $data['emergency'] = $line[19]; |
|
2112 | + $data['format_source'] = 'sbs'; |
|
2113 | 2113 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
2114 | 2114 | elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
2115 | 2115 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
2116 | 2116 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
2117 | - $data['id_source'] = $id_source; |
|
2118 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2119 | - else $error = true; |
|
2120 | - unset($data); |
|
2121 | - } else $error = true; |
|
2122 | - if ($error) { |
|
2117 | + $data['id_source'] = $id_source; |
|
2118 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2119 | + else $error = true; |
|
2120 | + unset($data); |
|
2121 | + } else $error = true; |
|
2122 | + if ($error) { |
|
2123 | 2123 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
2124 | 2124 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
2125 | 2125 | } else { |
@@ -2135,13 +2135,13 @@ discard block |
||
2135 | 2135 | connect_all($sourceer); |
2136 | 2136 | $sourceer = array(); |
2137 | 2137 | } |
2138 | - } |
|
2138 | + } |
|
2139 | 2139 | } |
2140 | 2140 | // Sleep for xxx microseconds |
2141 | 2141 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
2142 | - } else { |
|
2142 | + } else { |
|
2143 | 2143 | if ($format === 'flightgearmp') { |
2144 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2144 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2145 | 2145 | //@socket_close($r); |
2146 | 2146 | sleep($globalMinFetch); |
2147 | 2147 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2150,9 +2150,9 @@ discard block |
||
2150 | 2150 | break; |
2151 | 2151 | |
2152 | 2152 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
2153 | - if (isset($tt[$format])) $tt[$format]++; |
|
2154 | - else $tt[$format] = 0; |
|
2155 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
2153 | + if (isset($tt[$format])) $tt[$format]++; |
|
2154 | + else $tt[$format] = 0; |
|
2155 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
2156 | 2156 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
2157 | 2157 | //@socket_close($r); |
2158 | 2158 | sleep(2); |
@@ -2163,24 +2163,24 @@ discard block |
||
2163 | 2163 | //connect_all($globalSources); |
2164 | 2164 | $tt[$format]=0; |
2165 | 2165 | break; |
2166 | - } |
|
2167 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
2166 | + } |
|
2167 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
2168 | + } |
|
2168 | 2169 | } |
2169 | - } |
|
2170 | 2170 | } |
2171 | - } else { |
|
2171 | + } else { |
|
2172 | 2172 | $error = socket_strerror(socket_last_error()); |
2173 | 2173 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
2174 | 2174 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
2175 | 2175 | if (isset($globalDebug)) echo "Restarting...\n"; |
2176 | 2176 | // Restart the script if possible |
2177 | 2177 | if (is_array($sockets)) { |
2178 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2178 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
2179 | 2179 | |
2180 | - foreach ($sockets as $sock) { |
|
2180 | + foreach ($sockets as $sock) { |
|
2181 | 2181 | @socket_shutdown($sock,2); |
2182 | 2182 | @socket_close($sock); |
2183 | - } |
|
2183 | + } |
|
2184 | 2184 | |
2185 | 2185 | } |
2186 | 2186 | if ($globalDebug) echo "Waiting..."; |
@@ -2195,15 +2195,15 @@ discard block |
||
2195 | 2195 | if ($globalDebug) echo "Restart all connections..."; |
2196 | 2196 | connect_all($globalSources); |
2197 | 2197 | } |
2198 | - } |
|
2198 | + } |
|
2199 | 2199 | } |
2200 | 2200 | if ($globalDaemon === false) { |
2201 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
2202 | - if (isset($SI)) $SI->checkAll(); |
|
2203 | - if (isset($TI)) $TI->checkAll(); |
|
2204 | - if (isset($MI)) $MI->checkAll(); |
|
2201 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
2202 | + if (isset($SI)) $SI->checkAll(); |
|
2203 | + if (isset($TI)) $TI->checkAll(); |
|
2204 | + if (isset($MI)) $MI->checkAll(); |
|
2205 | + } |
|
2205 | 2206 | } |
2206 | - } |
|
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | ?> |
@@ -16,25 +16,25 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/class.Stats.php'); |
17 | 17 | require_once(dirname(__FILE__).'/class.Source.php'); |
18 | 18 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
19 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
19 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class MarineImport { |
23 | - private $all_tracked = array(); |
|
24 | - private $last_delete_hourly = 0; |
|
25 | - private $last_delete = 0; |
|
26 | - private $stats = array(); |
|
27 | - private $tmd = 0; |
|
28 | - private $source_location = array(); |
|
29 | - public $db = null; |
|
30 | - public $nb = 0; |
|
23 | + private $all_tracked = array(); |
|
24 | + private $last_delete_hourly = 0; |
|
25 | + private $last_delete = 0; |
|
26 | + private $stats = array(); |
|
27 | + private $tmd = 0; |
|
28 | + private $source_location = array(); |
|
29 | + public $db = null; |
|
30 | + public $nb = 0; |
|
31 | 31 | |
32 | - public function __construct($dbc = null) { |
|
32 | + public function __construct($dbc = null) { |
|
33 | 33 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
34 | 34 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
35 | - $Connection = new Connection($dbc); |
|
36 | - $this->db = $Connection->db(); |
|
37 | - date_default_timezone_set('UTC'); |
|
35 | + $Connection = new Connection($dbc); |
|
36 | + $this->db = $Connection->db(); |
|
37 | + date_default_timezone_set('UTC'); |
|
38 | 38 | } |
39 | 39 | // Get previous source stats |
40 | 40 | /* |
@@ -53,79 +53,79 @@ discard block |
||
53 | 53 | } |
54 | 54 | */ |
55 | 55 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
56 | - $APRSMarine = new APRSMarine(); |
|
57 | - //$APRSSpotter->connect(); |
|
56 | + $APRSMarine = new APRSMarine(); |
|
57 | + //$APRSSpotter->connect(); |
|
58 | + } |
|
58 | 59 | } |
59 | - } |
|
60 | 60 | |
61 | - public function checkAll() { |
|
61 | + public function checkAll() { |
|
62 | 62 | global $globalDebug, $globalNoDB, $globalVM; |
63 | 63 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
64 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
65 | - foreach ($this->all_tracked as $key => $flight) { |
|
64 | + if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
65 | + foreach ($this->all_tracked as $key => $flight) { |
|
66 | 66 | if (isset($this->all_tracked[$key]['id'])) { |
67 | - //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
68 | - $Marine = new Marine($this->db); |
|
69 | - if (isset($globalVM) && $globalVM) { |
|
67 | + //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
68 | + $Marine = new Marine($this->db); |
|
69 | + if (isset($globalVM) && $globalVM) { |
|
70 | 70 | if ($this->all_tracked[$key]['status'] == 'Racing') { |
71 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
72 | - } else { |
|
73 | - $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
|
74 | - if ($timerace > time()) $finaldatetime = NULL; |
|
75 | - else $finaldatetime = date('Y-m-d H:i:s',$timerace); |
|
76 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
77 | - } |
|
78 | - } else { |
|
71 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
72 | + } else { |
|
73 | + $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
|
74 | + if ($timerace > time()) $finaldatetime = NULL; |
|
75 | + else $finaldatetime = date('Y-m-d H:i:s',$timerace); |
|
76 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
77 | + } |
|
78 | + } else { |
|
79 | 79 | $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
80 | - } |
|
80 | + } |
|
81 | + } |
|
81 | 82 | } |
82 | - } |
|
83 | 83 | } |
84 | - } |
|
84 | + } |
|
85 | 85 | |
86 | - public function del() { |
|
86 | + public function del() { |
|
87 | 87 | global $globalDebug, $globalNoDB, $globalNoImport; |
88 | 88 | // Delete old infos |
89 | 89 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
90 | 90 | foreach ($this->all_tracked as $key => $flight) { |
91 | - if (isset($flight['lastupdate'])) { |
|
92 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
93 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
94 | - if (isset($this->all_tracked[$key]['id'])) { |
|
95 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
96 | - /* |
|
91 | + if (isset($flight['lastupdate'])) { |
|
92 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
93 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
94 | + if (isset($this->all_tracked[$key]['id'])) { |
|
95 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
96 | + /* |
|
97 | 97 | $MarineLive = new MarineLive(); |
98 | 98 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
99 | 99 | $MarineLive->db = null; |
100 | 100 | */ |
101 | - //$real_arrival = $this->arrival($key); |
|
102 | - $Marine = new Marine($this->db); |
|
103 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
101 | + //$real_arrival = $this->arrival($key); |
|
102 | + $Marine = new Marine($this->db); |
|
103 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
104 | 104 | if (isset($globalVM) && $globalVM) { |
105 | - if ($this->all_tracked[$key]['status'] == 'Racing') { |
|
105 | + if ($this->all_tracked[$key]['status'] == 'Racing') { |
|
106 | 106 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
107 | - } else { |
|
107 | + } else { |
|
108 | 108 | $timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']; |
109 | - if ($timerace > time()) $finaldatetime = NULL; |
|
109 | + if ($timerace > time()) $finaldatetime = NULL; |
|
110 | 110 | else $finaldatetime = date('Y-m-d H:i:s',$timerace); |
111 | 111 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
112 | - } |
|
112 | + } |
|
113 | 113 | } else { |
114 | 114 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
115 | 115 | } |
116 | 116 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
117 | - } |
|
118 | - // Put in archive |
|
117 | + } |
|
118 | + // Put in archive |
|
119 | 119 | // $Marine->db = null; |
120 | 120 | } |
121 | - } |
|
122 | - unset($this->all_tracked[$key]); |
|
123 | - } |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
121 | + } |
|
122 | + unset($this->all_tracked[$key]); |
|
123 | + } |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | 127 | |
128 | - public function add($line) { |
|
128 | + public function add($line) { |
|
129 | 129 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
130 | 130 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
131 | 131 | date_default_timezone_set('UTC'); |
@@ -134,106 +134,106 @@ discard block |
||
134 | 134 | |
135 | 135 | // SBS format is CSV format |
136 | 136 | if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
137 | - print_r($line); |
|
138 | - if (isset($line['mmsi']) || isset($line['id'])) { |
|
137 | + print_r($line); |
|
138 | + if (isset($line['mmsi']) || isset($line['id'])) { |
|
139 | 139 | |
140 | 140 | |
141 | 141 | // Increment message number |
142 | 142 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
143 | - $current_date = date('Y-m-d'); |
|
144 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
145 | - else $source = ''; |
|
146 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
147 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
148 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
149 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
150 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
143 | + $current_date = date('Y-m-d'); |
|
144 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
145 | + else $source = ''; |
|
146 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
147 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
148 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
149 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
150 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | 154 | $Common = new Common(); |
155 | 155 | $AIS = new AIS(); |
156 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
157 | - else $id = trim($line['id']); |
|
156 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
157 | + else $id = trim($line['id']); |
|
158 | 158 | |
159 | 159 | if (!isset($this->all_tracked[$id])) { |
160 | - $this->all_tracked[$id] = array(); |
|
161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => '')); |
|
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
164 | - if (!isset($line['id'])) { |
|
160 | + $this->all_tracked[$id] = array(); |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => '')); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
164 | + if (!isset($line['id'])) { |
|
165 | 165 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
166 | 166 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
167 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
168 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
167 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
168 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
173 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
173 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
174 | 174 | $Marine = new Marine($this->db); |
175 | 175 | $identity = $Marine->getIdentity($line['mmsi']); |
176 | 176 | if (!empty($identity)) { |
177 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
178 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
179 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
177 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
178 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
179 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
180 | 180 | } |
181 | 181 | //print_r($identity); |
182 | 182 | unset($Marine); |
183 | 183 | //$dataFound = true; |
184 | - } |
|
184 | + } |
|
185 | 185 | } |
186 | 186 | if (isset($line['type_id'])) { |
187 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
188 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
187 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
188 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
189 | 189 | } |
190 | 190 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
191 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
192 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
191 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
192 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
193 | 193 | } elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') { |
194 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
194 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
195 | 195 | } |
196 | 196 | if (isset($line['status']) && $line['status'] != '') { |
197 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
197 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
198 | 198 | } |
199 | 199 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
200 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
201 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
201 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
202 | 202 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
203 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
203 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
204 | 204 | $Marine = new Marine($this->db); |
205 | 205 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
206 | 206 | unset($Marine); |
207 | - } |
|
207 | + } |
|
208 | + } |
|
208 | 209 | } |
209 | - } |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
213 | 213 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
214 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
214 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
215 | 215 | } |
216 | 216 | if (isset($line['imo']) && $line['imo'] != '') { |
217 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
217 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
218 | 218 | } |
219 | 219 | if (isset($line['callsign']) && $line['callsign'] != '') { |
220 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
220 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
221 | 221 | } |
222 | 222 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
223 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
223 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
224 | 224 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
225 | 225 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
226 | 226 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
227 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
227 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
228 | 228 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
229 | - $Marine = new Marine($this->db); |
|
230 | - $fromsource = NULL; |
|
231 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
232 | - $Marine->db = null; |
|
229 | + $Marine = new Marine($this->db); |
|
230 | + $fromsource = NULL; |
|
231 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
232 | + $Marine->db = null; |
|
233 | + } |
|
233 | 234 | } |
234 | - } |
|
235 | 235 | } |
236 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
236 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
237 | 237 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
238 | 238 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
239 | 239 | if (!isset($line['id'])) { |
@@ -241,50 +241,50 @@ discard block |
||
241 | 241 | $this->all_tracked[$id]['forcenew'] = 1; |
242 | 242 | $this->all_tracked[$id]['addedMarine'] = 0; |
243 | 243 | } |
244 | - } |
|
244 | + } |
|
245 | 245 | } |
246 | 246 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
247 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
247 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
248 | 248 | } |
249 | 249 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
250 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
250 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
251 | 251 | } |
252 | 252 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
253 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
253 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
254 | 254 | } |
255 | 255 | if (isset($line['race_id']) && $line['race_id'] != '') { |
256 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
256 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
257 | 257 | } |
258 | 258 | if (isset($line['race_name']) && $line['race_name'] != '') { |
259 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
259 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
260 | 260 | } |
261 | 261 | if (isset($line['race_rank']) && $line['race_rank'] != '') { |
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
263 | 263 | } |
264 | 264 | if (isset($line['race_time']) && $line['race_time'] != '') { |
265 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
265 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
266 | 266 | } |
267 | 267 | if (isset($line['race_begin']) && $line['race_begin'] != '') { |
268 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin'])); |
|
268 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin'])); |
|
269 | 269 | } |
270 | 270 | if (isset($line['distance']) && $line['distance'] != '') { |
271 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
275 | 275 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
276 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
276 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
277 | 277 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
278 | - $timeelapsed = microtime(true); |
|
279 | - $Marine = new Marine($this->db); |
|
280 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
281 | - $Marine->db = null; |
|
278 | + $timeelapsed = microtime(true); |
|
279 | + $Marine = new Marine($this->db); |
|
280 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
281 | + $Marine->db = null; |
|
282 | + } |
|
282 | 283 | } |
283 | - } |
|
284 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
285 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
284 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
285 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
286 | 286 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
287 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
287 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
288 | 288 | $timeelapsed = microtime(true); |
289 | 289 | $Marine = new Marine($this->db); |
290 | 290 | $fromsource = NULL; |
@@ -292,20 +292,20 @@ discard block |
||
292 | 292 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
293 | 293 | $Marine->db = null; |
294 | 294 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
295 | - } |
|
295 | + } |
|
296 | + } |
|
296 | 297 | } |
297 | - } |
|
298 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
298 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
302 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
302 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
303 | 303 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
304 | - } else { |
|
304 | + } else { |
|
305 | 305 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
306 | 306 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
307 | 307 | return ''; |
308 | - } |
|
308 | + } |
|
309 | 309 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
310 | 310 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
311 | 311 | return ''; |
@@ -322,33 +322,33 @@ discard block |
||
322 | 322 | |
323 | 323 | |
324 | 324 | if (isset($line['speed'])) { |
325 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
326 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
325 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
326 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
327 | 327 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
328 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
329 | - if ($distance > 1000 && $distance < 10000) { |
|
328 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
329 | + if ($distance > 1000 && $distance < 10000) { |
|
330 | 330 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
331 | 331 | $speed = $speed*3.6; |
332 | 332 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
333 | 333 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n"; |
334 | - } |
|
334 | + } |
|
335 | 335 | } |
336 | 336 | |
337 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
338 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
339 | - else unset($timediff); |
|
340 | - if ($this->tmd > 5 || |
|
341 | - !isset($timediff) || |
|
342 | - $timediff > $globalLiveInterval || |
|
343 | - ( |
|
344 | - $timediff > 30 && |
|
345 | - isset($this->all_tracked[$id]['latitude']) && |
|
346 | - isset($this->all_tracked[$id]['longitude']) && |
|
347 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
348 | - ) |
|
349 | - ) { |
|
337 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
338 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
339 | + else unset($timediff); |
|
340 | + if ($this->tmd > 5 || |
|
341 | + !isset($timediff) || |
|
342 | + $timediff > $globalLiveInterval || |
|
343 | + ( |
|
344 | + $timediff > 30 && |
|
345 | + isset($this->all_tracked[$id]['latitude']) && |
|
346 | + isset($this->all_tracked[$id]['longitude']) && |
|
347 | + $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
348 | + ) |
|
349 | + ) { |
|
350 | 350 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
351 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
351 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
352 | 352 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
353 | 353 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
354 | 354 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -356,217 +356,217 @@ discard block |
||
356 | 356 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
357 | 357 | $timeelapsed = microtime(true); |
358 | 358 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
359 | - $Marine = new Marine($this->db); |
|
360 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
361 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
362 | - $Marine->db = null; |
|
363 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
359 | + $Marine = new Marine($this->db); |
|
360 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
361 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
362 | + $Marine->db = null; |
|
363 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
364 | 364 | } |
365 | 365 | $this->tmd = 0; |
366 | 366 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
367 | - } |
|
367 | + } |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
371 | 371 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
372 | 372 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
373 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
374 | - $dataFound = true; |
|
375 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
373 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
374 | + $dataFound = true; |
|
375 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
376 | 376 | } |
377 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
378 | 378 | } |
379 | 379 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
380 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
380 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
381 | 381 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
382 | 382 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
383 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
384 | - $dataFound = true; |
|
385 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
383 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
384 | + $dataFound = true; |
|
385 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
386 | 386 | } |
387 | 387 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
388 | 388 | } |
389 | 389 | |
390 | - } else if ($globalDebug && $timediff > 20) { |
|
390 | + } else if ($globalDebug && $timediff > 20) { |
|
391 | 391 | $this->tmd = $this->tmd + 1; |
392 | 392 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
393 | 393 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
394 | 394 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
395 | 395 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
396 | - } |
|
396 | + } |
|
397 | 397 | } |
398 | 398 | if (isset($line['last_update']) && $line['last_update'] != '') { |
399 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
400 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
399 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
400 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
401 | 401 | } |
402 | 402 | if (isset($line['format_source']) && $line['format_source'] != '') { |
403 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
403 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
404 | 404 | } |
405 | 405 | if (isset($line['source_name']) && $line['source_name'] != '') { |
406 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
406 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
407 | 407 | } |
408 | 408 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
409 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
409 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | if (isset($line['heading']) && $line['heading'] != '') { |
413 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
414 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
415 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
416 | - //$dataFound = true; |
|
413 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
414 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
415 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
416 | + //$dataFound = true; |
|
417 | 417 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
418 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
419 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
420 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
421 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
418 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
419 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
420 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
421 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
422 | 422 | } |
423 | 423 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
424 | 424 | |
425 | 425 | |
426 | 426 | |
427 | 427 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
428 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
429 | - if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) { |
|
430 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
431 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
428 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
429 | + if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) { |
|
430 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
431 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
432 | 432 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
433 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
434 | - $timeelapsed = microtime(true); |
|
435 | - $MarineLive = new MarineLive($this->db); |
|
436 | - if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
433 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
434 | + $timeelapsed = microtime(true); |
|
435 | + $MarineLive = new MarineLive($this->db); |
|
436 | + if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
437 | 437 | $Marine = new Marine($this->db); |
438 | 438 | $recent_ident = $Marine->checkId($line['id']); |
439 | 439 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
440 | 440 | $Marine->db=null; |
441 | - } elseif (isset($line['id'])) { |
|
441 | + } elseif (isset($line['id'])) { |
|
442 | 442 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
443 | 443 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
444 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
444 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
445 | 445 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
446 | 446 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
447 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
447 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
448 | 448 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
449 | 449 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
450 | - } else $recent_ident = ''; |
|
451 | - $MarineLive->db=null; |
|
452 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
453 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
450 | + } else $recent_ident = ''; |
|
451 | + $MarineLive->db=null; |
|
452 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
453 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
454 | 454 | } else $recent_ident = ''; |
455 | - } else { |
|
455 | + } else { |
|
456 | 456 | $recent_ident = ''; |
457 | 457 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
458 | - } |
|
459 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
460 | - if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
|
461 | - { |
|
458 | + } |
|
459 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
460 | + if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
|
461 | + { |
|
462 | 462 | if ($globalDebug) { |
463 | 463 | if ($this->all_tracked[$id]['mmsi'] != '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
464 | 464 | else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
465 | 465 | } |
466 | 466 | //adds the spotter data for the archive |
467 | - $highlight = ''; |
|
468 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
469 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
467 | + $highlight = ''; |
|
468 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
469 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
470 | 470 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
471 | - $timeelapsed = microtime(true); |
|
472 | - $Marine = new Marine($this->db); |
|
473 | - if (isset($globalVM) && $globalVM && ($this->all_tracked[$id]['race_begin'] != '' || $this->all_tracked[$id]['format_source'] == 'sailaway')) { |
|
471 | + $timeelapsed = microtime(true); |
|
472 | + $Marine = new Marine($this->db); |
|
473 | + if (isset($globalVM) && $globalVM && ($this->all_tracked[$id]['race_begin'] != '' || $this->all_tracked[$id]['format_source'] == 'sailaway')) { |
|
474 | 474 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['race_begin'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
475 | - } else { |
|
475 | + } else { |
|
476 | 476 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
477 | - } |
|
478 | - $Marine->db = null; |
|
479 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
480 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
477 | + } |
|
478 | + $Marine->db = null; |
|
479 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
480 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
481 | 481 | } |
482 | - } |
|
483 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
482 | + } |
|
483 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
484 | 484 | // Add source stat in DB |
485 | 485 | $Stats = new Stats($this->db); |
486 | 486 | if (!empty($this->stats)) { |
487 | - if ($globalDebug) echo 'Add source stats : '; |
|
488 | - foreach($this->stats as $date => $data) { |
|
487 | + if ($globalDebug) echo 'Add source stats : '; |
|
488 | + foreach($this->stats as $date => $data) { |
|
489 | 489 | foreach($data as $source => $sourced) { |
490 | - //print_r($sourced); |
|
491 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
492 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
493 | - if (isset($sourced['msg'])) { |
|
494 | - if (time() - $sourced['msg']['date'] > 10) { |
|
495 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
496 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
497 | - unset($this->stats[$date][$source]['msg']); |
|
498 | - } |
|
499 | - } |
|
500 | - } |
|
501 | - if ($date != date('Y-m-d')) { |
|
502 | - unset($this->stats[$date]); |
|
503 | - } |
|
504 | - } |
|
505 | - if ($globalDebug) echo 'Done'."\n"; |
|
490 | + //print_r($sourced); |
|
491 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
492 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
493 | + if (isset($sourced['msg'])) { |
|
494 | + if (time() - $sourced['msg']['date'] > 10) { |
|
495 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
496 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
497 | + unset($this->stats[$date][$source]['msg']); |
|
498 | + } |
|
499 | + } |
|
500 | + } |
|
501 | + if ($date != date('Y-m-d')) { |
|
502 | + unset($this->stats[$date]); |
|
503 | + } |
|
504 | + } |
|
505 | + if ($globalDebug) echo 'Done'."\n"; |
|
506 | 506 | } |
507 | 507 | $Stats->db = null; |
508 | - } |
|
508 | + } |
|
509 | 509 | |
510 | - $this->del(); |
|
510 | + $this->del(); |
|
511 | 511 | //$ignoreImport = false; |
512 | 512 | $this->all_tracked[$id]['addedMarine'] = 1; |
513 | 513 | //print_r($this->all_tracked[$id]); |
514 | 514 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
515 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 12 hours..."; |
|
516 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
517 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
515 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 12 hours..."; |
|
516 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
517 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
518 | 518 | $MarineLive = new MarineLive($this->db); |
519 | 519 | $MarineLive->deleteLiveMarineData(); |
520 | 520 | $MarineLive->db=null; |
521 | 521 | if ($globalDebug) echo " Done\n"; |
522 | - } |
|
523 | - $this->last_delete = time(); |
|
522 | + } |
|
523 | + $this->last_delete = time(); |
|
524 | 524 | } |
525 | - } elseif ($recent_ident != '') { |
|
525 | + } elseif ($recent_ident != '') { |
|
526 | 526 | $this->all_tracked[$id]['id'] = $recent_ident; |
527 | 527 | $this->all_tracked[$id]['addedMarine'] = 1; |
528 | 528 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
529 | - if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) { |
|
529 | + if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) { |
|
530 | 530 | $Marine = new Marine($this->db); |
531 | 531 | if (isset($globalVM) && $globalVM) { |
532 | - if ($this->all_tracked[$id]['status'] == 'Racing') { |
|
532 | + if ($this->all_tracked[$id]['status'] == 'Racing') { |
|
533 | 533 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
534 | - } else { |
|
534 | + } else { |
|
535 | 535 | //$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']); |
536 | 536 | $timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']); |
537 | 537 | if ($timerace > time()) $finaldatetime = NULL; |
538 | 538 | else $finaldatetime = date('Y-m-d H:i:s',$timerace); |
539 | 539 | |
540 | 540 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
541 | - } |
|
541 | + } |
|
542 | 542 | } else { |
543 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
|
543 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
|
544 | 544 | } |
545 | 545 | $Marine->db = null; |
546 | - } |
|
546 | + } |
|
547 | 547 | } |
548 | 548 | |
549 | - } |
|
549 | + } |
|
550 | 550 | } |
551 | - } |
|
552 | - //adds the spotter LIVE data |
|
553 | - if ($globalDebug) { |
|
551 | + } |
|
552 | + //adds the spotter LIVE data |
|
553 | + if ($globalDebug) { |
|
554 | 554 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
555 | - } |
|
556 | - $ignoreImport = false; |
|
557 | - if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
|
558 | - if (!$ignoreImport) { |
|
555 | + } |
|
556 | + $ignoreImport = false; |
|
557 | + if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
|
558 | + if (!$ignoreImport) { |
|
559 | 559 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
560 | 560 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
561 | 561 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
562 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
562 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
563 | 563 | $timeelapsed = microtime(true); |
564 | 564 | $MarineLive = new MarineLive($this->db); |
565 | 565 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
566 | 566 | $MarineLive->db = null; |
567 | 567 | if ($globalDebug) echo $result."\n"; |
568 | 568 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
569 | - } |
|
569 | + } |
|
570 | 570 | } |
571 | 571 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
572 | 572 | $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | if ($stats_heading == 16) $stats_heading = 0; |
602 | 602 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
603 | 603 | for ($i=0;$i<=15;$i++) { |
604 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
604 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
605 | 605 | } |
606 | 606 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
607 | 607 | } else { |
@@ -614,11 +614,11 @@ discard block |
||
614 | 614 | //var_dump($this->stats); |
615 | 615 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
616 | 616 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
617 | - end($this->stats[$current_date][$source]['hist']); |
|
618 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
617 | + end($this->stats[$current_date][$source]['hist']); |
|
618 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
619 | 619 | } else $mini = 0; |
620 | 620 | for ($i=$mini;$i<=$distance;$i+=10) { |
621 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
621 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
622 | 622 | } |
623 | 623 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
624 | 624 | } else { |
@@ -634,30 +634,30 @@ discard block |
||
634 | 634 | |
635 | 635 | |
636 | 636 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
637 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
637 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
638 | 638 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
639 | 639 | $MarineLive = new MarineLive($this->db); |
640 | 640 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
641 | 641 | $MarineLive->db = null; |
642 | 642 | //MarineLive->deleteLiveMarineData(); |
643 | 643 | if ($globalDebug) echo " Done\n"; |
644 | - } |
|
645 | - $this->last_delete_hourly = time(); |
|
644 | + } |
|
645 | + $this->last_delete_hourly = time(); |
|
646 | 646 | } |
647 | 647 | |
648 | - } |
|
649 | - //$ignoreImport = false; |
|
648 | + } |
|
649 | + //$ignoreImport = false; |
|
650 | 650 | } |
651 | 651 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
652 | 652 | if ($send) return $this->all_tracked[$id]; |
653 | - } |
|
653 | + } |
|
654 | + } |
|
654 | 655 | } |
655 | - } |
|
656 | 656 | |
657 | - public function race_add($data) { |
|
658 | - $Marine = new Marine(); |
|
659 | - $Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']); |
|
660 | - $Marine->db = null; |
|
661 | - } |
|
657 | + public function race_add($data) { |
|
658 | + $Marine = new Marine(); |
|
659 | + $Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']); |
|
660 | + $Marine->db = null; |
|
661 | + } |
|
662 | 662 | } |
663 | 663 | ?> |