|
@@ -59,20 +59,20 @@ discard block |
|
|
block discarded – undo |
|
59
|
59
|
die; |
|
60
|
60
|
} |
|
61
|
61
|
//$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
|
62
|
|
- $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
|
62
|
+ $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
63
|
63
|
} |
|
64
|
64
|
} |
|
65
|
65
|
|
|
66
|
|
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
|
|
66
|
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); |
|
67
|
67
|
//if (isset($options['s'])) $hosts = array($options['s']); |
|
68
|
68
|
//elseif (isset($options['source'])) $hosts = array($options['source']); |
|
69
|
69
|
if (isset($options['s'])) { |
|
70
|
70
|
$globalSources = array(); |
|
71
|
|
- if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
|
71
|
+ if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
72
|
72
|
else $globalSources[] = array('host' => $options['s']); |
|
73
|
73
|
} elseif (isset($options['source'])) { |
|
74
|
74
|
$globalSources = array(); |
|
75
|
|
- if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
|
75
|
+ if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
76
|
76
|
else $globalSources[] = array('host' => $options['source']); |
|
77
|
77
|
} |
|
78
|
78
|
if (isset($options['aprsserverhost'])) { |
|
@@ -113,13 +113,13 @@ discard block |
|
|
block discarded – undo |
|
113
|
113
|
else $id_source = 1; |
|
114
|
114
|
if (isset($globalServer) && $globalServer) { |
|
115
|
115
|
if ($globalDebug) echo "Using Server Mode\n"; |
|
116
|
|
- $SI=new SpotterServer(); |
|
|
116
|
+ $SI = new SpotterServer(); |
|
117
|
117
|
/* |
|
118
|
118
|
require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
|
119
|
119
|
$SI = new adsb2aprs(); |
|
120
|
120
|
$SI->connect(); |
|
121
|
121
|
*/ |
|
122
|
|
-} else $SI=new SpotterImport($Connection->db); |
|
|
122
|
+} else $SI = new SpotterImport($Connection->db); |
|
123
|
123
|
|
|
124
|
124
|
if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
125
|
125
|
if (isset($globalMarine) && $globalMarine) { |
|
@@ -133,17 +133,17 @@ discard block |
|
|
block discarded – undo |
|
133
|
133
|
$MI = new MarineImport($Connection->db); |
|
134
|
134
|
} |
|
135
|
135
|
//$APRS=new APRS($Connection->db); |
|
136
|
|
-$SBS=new SBS(); |
|
|
136
|
+$SBS = new SBS(); |
|
137
|
137
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
138
|
|
- $ACARS=new ACARS($Connection->db,true); |
|
139
|
|
- $Source=new Source($Connection->db); |
|
|
138
|
+ $ACARS = new ACARS($Connection->db, true); |
|
|
139
|
+ $Source = new Source($Connection->db); |
|
140
|
140
|
} |
|
141
|
|
-$Common=new Common(); |
|
|
141
|
+$Common = new Common(); |
|
142
|
142
|
date_default_timezone_set('UTC'); |
|
143
|
143
|
//$servertz = system('date +%Z'); |
|
144
|
144
|
// signal handler - playing nice with sockets and dump1090 |
|
145
|
145
|
if (function_exists('pcntl_fork')) { |
|
146
|
|
- pcntl_signal(SIGINT, function() { |
|
|
146
|
+ pcntl_signal(SIGINT, function() { |
|
147
|
147
|
global $sockets; |
|
148
|
148
|
echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
149
|
149
|
die("Bye!\n"); |
|
@@ -159,7 +159,7 @@ discard block |
|
|
block discarded – undo |
|
159
|
159
|
|
|
160
|
160
|
function connect_all($hosts) { |
|
161
|
161
|
//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
162
|
|
- global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
|
162
|
+ global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
163
|
163
|
$reset++; |
|
164
|
164
|
if ($globalDebug) echo 'Connect to all...'."\n"; |
|
165
|
165
|
foreach ($hosts as $id => $value) { |
|
@@ -167,33 +167,33 @@ discard block |
|
|
block discarded – undo |
|
167
|
167
|
$udp = false; |
|
168
|
168
|
$globalSources[$id]['last_exec'] = 0; |
|
169
|
169
|
// Here we check type of source(s) |
|
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)) { |
|
|
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
|
172
|
//$formats[$id] = 'deltadbtxt'; |
|
173
|
173
|
$globalSources[$id]['format'] = 'deltadbtxt'; |
|
174
|
174
|
//$last_exec['deltadbtxt'] = 0; |
|
175
|
175
|
if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
176
|
|
- } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
|
176
|
+ } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
177
|
177
|
//$formats[$id] = 'vatsimtxt'; |
|
178
|
178
|
$globalSources[$id]['format'] = 'vatsimtxt'; |
|
179
|
179
|
//$last_exec['vatsimtxt'] = 0; |
|
180
|
180
|
if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
181
|
|
- } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
|
181
|
+ } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
182
|
182
|
//$formats[$id] = 'aircraftlistjson'; |
|
183
|
183
|
$globalSources[$id]['format'] = 'aircraftlistjson'; |
|
184
|
184
|
//$last_exec['aircraftlistjson'] = 0; |
|
185
|
185
|
if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
186
|
|
- } else if (preg_match('/aircraft.json$/i',$host)) { |
|
|
186
|
+ } else if (preg_match('/aircraft.json$/i', $host)) { |
|
187
|
187
|
//$formats[$id] = 'aircraftjson'; |
|
188
|
188
|
$globalSources[$id]['format'] = 'aircraftjson'; |
|
189
|
189
|
//$last_exec['aircraftlistjson'] = 0; |
|
190
|
190
|
if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
191
|
|
- } else if (preg_match('/aircraft$/i',$host)) { |
|
|
191
|
+ } else if (preg_match('/aircraft$/i', $host)) { |
|
192
|
192
|
//$formats[$id] = 'planefinderclient'; |
|
193
|
193
|
$globalSources[$id]['format'] = 'planefinderclient'; |
|
194
|
194
|
//$last_exec['aircraftlistjson'] = 0; |
|
195
|
195
|
if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
196
|
|
- } else if (preg_match('/opensky/i',$host)) { |
|
|
196
|
+ } else if (preg_match('/opensky/i', $host)) { |
|
197
|
197
|
//$formats[$id] = 'aircraftlistjson'; |
|
198
|
198
|
$globalSources[$id]['format'] = 'opensky'; |
|
199
|
199
|
//$last_exec['aircraftlistjson'] = 0; |
|
@@ -210,7 +210,7 @@ discard block |
|
|
block discarded – undo |
|
210
|
210
|
exit(0); |
|
211
|
211
|
} |
|
212
|
212
|
*/ |
|
213
|
|
- } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
|
213
|
+ } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
214
|
214
|
//$formats[$id] = 'planeupdatefaa'; |
|
215
|
215
|
$globalSources[$id]['format'] = 'planeupdatefaa'; |
|
216
|
216
|
//$last_exec['planeupdatefaa'] = 0; |
|
@@ -219,37 +219,37 @@ discard block |
|
|
block discarded – undo |
|
219
|
219
|
echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
220
|
220
|
exit(0); |
|
221
|
221
|
} |
|
222
|
|
- } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
|
222
|
+ } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
223
|
223
|
//$formats[$id] = 'phpvmacars'; |
|
224
|
224
|
$globalSources[$id]['format'] = 'phpvmacars'; |
|
225
|
225
|
//$last_exec['phpvmacars'] = 0; |
|
226
|
226
|
if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
227
|
|
- } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
|
227
|
+ } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { |
|
228
|
228
|
//$formats[$id] = 'phpvmacars'; |
|
229
|
229
|
$globalSources[$id]['format'] = 'vaos'; |
|
230
|
230
|
//$last_exec['phpvmacars'] = 0; |
|
231
|
231
|
if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
232
|
|
- } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
|
232
|
+ } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
233
|
233
|
//$formats[$id] = 'phpvmacars'; |
|
234
|
234
|
$globalSources[$id]['format'] = 'vam'; |
|
235
|
235
|
if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
236
|
|
- } else if (preg_match('/whazzup/i',$host)) { |
|
|
236
|
+ } else if (preg_match('/whazzup/i', $host)) { |
|
237
|
237
|
//$formats[$id] = 'whazzup'; |
|
238
|
238
|
$globalSources[$id]['format'] = 'whazzup'; |
|
239
|
239
|
//$last_exec['whazzup'] = 0; |
|
240
|
240
|
if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
241
|
|
- } else if (preg_match('/blitzortung/i',$host)) { |
|
|
241
|
+ } else if (preg_match('/blitzortung/i', $host)) { |
|
242
|
242
|
$globalSources[$id]['format'] = 'blitzortung'; |
|
243
|
243
|
if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
244
|
|
- } else if (preg_match('/airwhere/i',$host)) { |
|
|
244
|
+ } else if (preg_match('/airwhere/i', $host)) { |
|
245
|
245
|
$globalSources[$id]['format'] = 'airwhere'; |
|
246
|
246
|
if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
247
|
|
- } else if (preg_match('/recentpireps/i',$host)) { |
|
|
247
|
+ } else if (preg_match('/recentpireps/i', $host)) { |
|
248
|
248
|
//$formats[$id] = 'pirepsjson'; |
|
249
|
249
|
$globalSources[$id]['format'] = 'pirepsjson'; |
|
250
|
250
|
//$last_exec['pirepsjson'] = 0; |
|
251
|
251
|
if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
252
|
|
- } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
|
252
|
+ } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
253
|
253
|
//$formats[$id] = 'fr24json'; |
|
254
|
254
|
$globalSources[$id]['format'] = 'fr24json'; |
|
255
|
255
|
//$last_exec['fr24json'] = 0; |
|
@@ -258,7 +258,7 @@ discard block |
|
|
block discarded – undo |
|
258
|
258
|
echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
259
|
259
|
exit(0); |
|
260
|
260
|
} |
|
261
|
|
- } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
|
261
|
+ } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
262
|
262
|
//$formats[$id] = 'fr24json'; |
|
263
|
263
|
$globalSources[$id]['format'] = 'myshiptracking'; |
|
264
|
264
|
//$last_exec['fr24json'] = 0; |
|
@@ -268,22 +268,22 @@ discard block |
|
|
block discarded – undo |
|
268
|
268
|
exit(0); |
|
269
|
269
|
} |
|
270
|
270
|
//} else if (preg_match('/10001/',$host)) { |
|
271
|
|
- } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
|
271
|
+ } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
272
|
272
|
//$formats[$id] = 'tsv'; |
|
273
|
273
|
$globalSources[$id]['format'] = 'tsv'; |
|
274
|
274
|
if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
275
|
275
|
} |
|
276
|
|
- } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
|
276
|
+ } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
277
|
277
|
if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
278
|
|
- $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
|
278
|
+ $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
279
|
279
|
if ($idf !== false) { |
|
280
|
280
|
$httpfeeds[$id] = $idf; |
|
281
|
281
|
if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
282
|
282
|
} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
283
|
283
|
} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
284
|
284
|
elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
285
|
|
- } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
286
|
|
- $hostport = explode(':',$host); |
|
|
285
|
+ } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
|
286
|
+ $hostport = explode(':', $host); |
|
287
|
287
|
if (isset($hostport[1])) { |
|
288
|
288
|
$port = $hostport[1]; |
|
289
|
289
|
$hostn = $hostport[0]; |
|
@@ -293,20 +293,20 @@ discard block |
|
|
block discarded – undo |
|
293
|
293
|
} |
|
294
|
294
|
$Common = new Common(); |
|
295
|
295
|
if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
296
|
|
- $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
|
296
|
+ $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
297
|
297
|
} else { |
|
298
|
298
|
$udp = true; |
|
299
|
|
- $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
|
299
|
+ $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
300
|
300
|
} |
|
301
|
301
|
if ($s) { |
|
302
|
302
|
$sockets[$id] = $s; |
|
303
|
303
|
if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
304
|
|
- if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
|
304
|
+ if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
305
|
305
|
//$formats[$id] = 'aprs'; |
|
306
|
306
|
$globalSources[$id]['format'] = 'aprs'; |
|
307
|
307
|
//$aprs_connect = 0; |
|
308
|
308
|
//$use_aprs = true; |
|
309
|
|
- } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
|
309
|
+ } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
310
|
310
|
$globalSources[$id]['format'] = 'vrstcp'; |
|
311
|
311
|
} elseif ($port == '10001') { |
|
312
|
312
|
//$formats[$id] = 'tsv'; |
|
@@ -348,7 +348,7 @@ discard block |
|
|
block discarded – undo |
|
348
|
348
|
else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
349
|
349
|
else $timeout = 20; |
|
350
|
350
|
$errno = ''; |
|
351
|
|
-$errstr=''; |
|
|
351
|
+$errstr = ''; |
|
352
|
352
|
|
|
353
|
353
|
if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
354
|
354
|
/* Initiate connections to all the hosts simultaneously */ |
|
@@ -356,7 +356,7 @@ discard block |
|
|
block discarded – undo |
|
356
|
356
|
//connect_all($globalSources); |
|
357
|
357
|
|
|
358
|
358
|
if (isset($globalProxy) && $globalProxy) { |
|
359
|
|
- $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
|
359
|
+ $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
360
|
360
|
} else { |
|
361
|
361
|
$context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
362
|
362
|
} |
|
@@ -386,16 +386,16 @@ discard block |
|
|
block discarded – undo |
|
386
|
386
|
|
|
387
|
387
|
if ($use_aprs) { |
|
388
|
388
|
require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
|
389
|
|
- $APRS=new APRS(); |
|
|
389
|
+ $APRS = new APRS(); |
|
390
|
390
|
$aprs_connect = 0; |
|
391
|
391
|
$aprs_keep = 120; |
|
392
|
392
|
$aprs_last_tx = time(); |
|
393
|
393
|
if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
394
|
|
- else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
|
394
|
+ else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
395
|
395
|
if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
396
|
|
- else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
|
396
|
+ else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
397
|
397
|
if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
398
|
|
- else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
|
398
|
+ else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
399
|
399
|
if ($aprs_full) $aprs_filter = ''; |
|
400
|
400
|
if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
401
|
401
|
else $aprs_pass = '-1'; |
|
@@ -409,12 +409,12 @@ discard block |
|
|
block discarded – undo |
|
409
|
409
|
sleep(1); |
|
410
|
410
|
if ($globalDebug) echo "SCAN MODE \n\n"; |
|
411
|
411
|
if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
412
|
|
-$endtime = time()+$globalCronEnd; |
|
|
412
|
+$endtime = time() + $globalCronEnd; |
|
413
|
413
|
$i = 1; |
|
414
|
414
|
$tt = array(); |
|
415
|
415
|
// Delete all ATC |
|
416
|
416
|
if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
417
|
|
- $ATC=new ATC($Connection->db); |
|
|
417
|
+ $ATC = new ATC($Connection->db); |
|
418
|
418
|
} |
|
419
|
419
|
if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
420
|
420
|
$ATC->deleteAll(); |
|
@@ -424,7 +424,7 @@ discard block |
|
|
block discarded – undo |
|
424
|
424
|
while ($i > 0) { |
|
425
|
425
|
if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
426
|
426
|
|
|
427
|
|
- if (!$globalDaemon) $i = $endtime-time(); |
|
|
427
|
+ if (!$globalDaemon) $i = $endtime - time(); |
|
428
|
428
|
// Delete old ATC |
|
429
|
429
|
if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
430
|
430
|
if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
@@ -438,7 +438,7 @@ discard block |
|
|
block discarded – undo |
|
438
|
438
|
} |
|
439
|
439
|
if ($max < $globalMinFetch) { |
|
440
|
440
|
if ($globalDebug) echo 'Sleeping...'."\n"; |
|
441
|
|
- sleep($globalMinFetch-$max+2); |
|
|
441
|
+ sleep($globalMinFetch - $max + 2); |
|
442
|
442
|
} |
|
443
|
443
|
} |
|
444
|
444
|
|
|
@@ -493,10 +493,10 @@ discard block |
|
|
block discarded – undo |
|
493
|
493
|
//$buffer = $Common->getData($hosts[$id]); |
|
494
|
494
|
$buffer = $Common->getData($value['host']); |
|
495
|
495
|
if ($buffer != '') { |
|
496
|
|
- $all_data = json_decode($buffer,true); |
|
|
496
|
+ $all_data = json_decode($buffer, true); |
|
497
|
497
|
foreach ($all_data as $line) { |
|
498
|
498
|
$data = array(); |
|
499
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
|
499
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line['uti']); |
|
500
|
500
|
$data['hex'] = $line['hex']; // hex |
|
501
|
501
|
$data['ident'] = $line['fli']; // ident |
|
502
|
502
|
$data['altitude'] = $line['alt']; // altitude |
|
@@ -531,11 +531,11 @@ discard block |
|
|
block discarded – undo |
|
531
|
531
|
) |
|
532
|
532
|
) { |
|
533
|
533
|
date_default_timezone_set('CET'); |
|
534
|
|
- $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
|
534
|
+ $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
535
|
535
|
date_default_timezone_set('UTC'); |
|
536
|
536
|
if ($buffer != '') $reset = 0; |
|
537
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
538
|
|
- $buffer = explode('\n',$buffer); |
|
|
537
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
538
|
+ $buffer = explode('\n', $buffer); |
|
539
|
539
|
foreach ($buffer as $line) { |
|
540
|
540
|
if ($line != '') { |
|
541
|
541
|
//echo "'".$line."'\n"; |
|
@@ -543,7 +543,7 @@ discard block |
|
|
block discarded – undo |
|
543
|
543
|
$ais_data = $AIS->parse_line(trim($line)); |
|
544
|
544
|
$data = array(); |
|
545
|
545
|
if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
546
|
|
- if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
|
546
|
+ if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
547
|
547
|
if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
548
|
548
|
if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
549
|
549
|
if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
@@ -555,7 +555,7 @@ discard block |
|
|
block discarded – undo |
|
555
|
555
|
if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
556
|
556
|
if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
557
|
557
|
if (isset($ais_data['timestamp'])) { |
|
558
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
|
558
|
+ $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
559
|
559
|
if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
|
560
|
560
|
$last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
561
|
561
|
$add = true; |
|
@@ -578,21 +578,21 @@ discard block |
|
|
block discarded – undo |
|
578
|
578
|
$w = $e = null; |
|
579
|
579
|
|
|
580
|
580
|
if (isset($arr[$id])) { |
|
581
|
|
- $nn = stream_select($arr,$w,$e,$timeout); |
|
|
581
|
+ $nn = stream_select($arr, $w, $e, $timeout); |
|
582
|
582
|
if ($nn > 0) { |
|
583
|
583
|
foreach ($httpfeeds as $feed) { |
|
584
|
|
- $buffer = stream_get_line($feed,2000,"\n"); |
|
|
584
|
+ $buffer = stream_get_line($feed, 2000, "\n"); |
|
585
|
585
|
if ($buffer === FALSE) { |
|
586
|
586
|
connect_all($globalSources); |
|
587
|
587
|
} |
|
588
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
589
|
|
- $buffer = explode('\n',$buffer); |
|
|
588
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
589
|
+ $buffer = explode('\n', $buffer); |
|
590
|
590
|
foreach ($buffer as $line) { |
|
591
|
591
|
if ($line != '') { |
|
592
|
592
|
$ais_data = $AIS->parse_line(trim($line)); |
|
593
|
593
|
$data = array(); |
|
594
|
594
|
if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
595
|
|
- if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
|
595
|
+ if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
596
|
596
|
if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
597
|
597
|
if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
598
|
598
|
if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
@@ -604,9 +604,9 @@ discard block |
|
|
block discarded – undo |
|
604
|
604
|
if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
605
|
605
|
if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
606
|
606
|
if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
607
|
|
- if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
|
607
|
+ if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
608
|
608
|
if (isset($ais_data['timestamp'])) { |
|
609
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
|
609
|
+ $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
610
|
610
|
} else { |
|
611
|
611
|
$data['datetime'] = date('Y-m-d H:i:s'); |
|
612
|
612
|
} |
|
@@ -638,10 +638,10 @@ discard block |
|
|
block discarded – undo |
|
638
|
638
|
(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
|
639
|
639
|
) |
|
640
|
640
|
) { |
|
641
|
|
- $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
|
641
|
+ $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
642
|
642
|
if ($buffer != '') { |
|
643
|
643
|
//echo $buffer; |
|
644
|
|
- $all_data = json_decode($buffer,true); |
|
|
644
|
+ $all_data = json_decode($buffer, true); |
|
645
|
645
|
//print_r($all_data); |
|
646
|
646
|
if (isset($all_data[0]['DATA'])) { |
|
647
|
647
|
foreach ($all_data[0]['DATA'] as $line) { |
|
@@ -650,7 +650,7 @@ discard block |
|
|
block discarded – undo |
|
650
|
650
|
$data['ident'] = $line['NAME']; |
|
651
|
651
|
$data['mmsi'] = $line['MMSI']; |
|
652
|
652
|
if (strlen($data['mmsi']) > 9) { |
|
653
|
|
- $data['mmsi'] = substr($data['mmsi'],-9); |
|
|
653
|
+ $data['mmsi'] = substr($data['mmsi'], -9); |
|
654
|
654
|
} |
|
655
|
655
|
$data['speed'] = $line['SOG']; |
|
656
|
656
|
$data['heading'] = $line['COG']; |
|
@@ -660,8 +660,8 @@ discard block |
|
|
block discarded – undo |
|
660
|
660
|
//$data['type_id'] = $line['TYPE']; |
|
661
|
661
|
$data['imo'] = $line['IMO']; |
|
662
|
662
|
if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
663
|
|
- if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
664
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
|
663
|
+ if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV'])); |
|
|
664
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
665
|
665
|
$data['format_source'] = 'myshiptracking'; |
|
666
|
666
|
$data['id_source'] = $id_source; |
|
667
|
667
|
if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
@@ -678,16 +678,16 @@ discard block |
|
|
block discarded – undo |
|
678
|
678
|
(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
|
679
|
679
|
) |
|
680
|
680
|
) { |
|
681
|
|
- $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
|
681
|
+ $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
682
|
682
|
if ($buffer != '') { |
|
683
|
|
- $all_data = json_decode($buffer,true); |
|
|
683
|
+ $all_data = json_decode($buffer, true); |
|
684
|
684
|
if (isset($all_data[0]['mmsi'])) { |
|
685
|
685
|
foreach ($all_data as $line) { |
|
686
|
686
|
if ($line != '') { |
|
687
|
687
|
$data = array(); |
|
688
|
688
|
$data['ident'] = $line['shipname']; |
|
689
|
689
|
$data['callsign'] = $line['callsign']; |
|
690
|
|
- $data['mmsi'] = substr($line['mmsi'],-9); |
|
|
690
|
+ $data['mmsi'] = substr($line['mmsi'], -9); |
|
691
|
691
|
$data['speed'] = $line['sog']; |
|
692
|
692
|
if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
693
|
693
|
$data['latitude'] = $line['latitude']; |
|
@@ -714,14 +714,14 @@ discard block |
|
|
block discarded – undo |
|
714
|
714
|
) { |
|
715
|
715
|
$buffer = $Common->getData($value['host']); |
|
716
|
716
|
if ($buffer != '') { |
|
717
|
|
- $all_data = json_decode($buffer,true); |
|
|
717
|
+ $all_data = json_decode($buffer, true); |
|
718
|
718
|
if (isset($all_data['features'][0]['id'])) { |
|
719
|
719
|
foreach ($all_data['features'] as $line) { |
|
720
|
720
|
print_r($line); |
|
721
|
721
|
$data = array(); |
|
722
|
722
|
if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
723
|
723
|
if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
724
|
|
- if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
|
724
|
+ if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9); |
|
725
|
725
|
if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
726
|
726
|
if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
727
|
727
|
if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
@@ -748,31 +748,31 @@ discard block |
|
|
block discarded – undo |
|
748
|
748
|
) |
|
749
|
749
|
) { |
|
750
|
750
|
if ($globalDebug) echo 'download...'; |
|
751
|
|
- $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
|
751
|
+ $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
752
|
752
|
if ($globalDebug) echo 'done !'."\n"; |
|
753
|
753
|
// FIXME: Need more work |
|
754
|
754
|
if ($buffer != '') $reset = 0; |
|
755
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
756
|
|
- $buffer = explode('\n',$buffer); |
|
|
755
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
756
|
+ $buffer = explode('\n', $buffer); |
|
757
|
757
|
foreach ($buffer as $line) { |
|
758
|
758
|
if ($line != '') { |
|
759
|
759
|
$data = array(); |
|
760
|
760
|
//echo $line."\n"; |
|
761
|
|
- $data['mmsi'] = (int)substr($line,0,9); |
|
762
|
|
- $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
763
|
|
- $data['status_id'] = substr($line,21,2); |
|
764
|
|
- $data['type_id'] = substr($line,24,3); |
|
765
|
|
- $data['latitude'] = substr($line,29,9); |
|
766
|
|
- $data['longitude'] = substr($line,41,9); |
|
767
|
|
- $data['speed'] = round(substr($line,51,5)); |
|
|
761
|
+ $data['mmsi'] = (int) substr($line, 0, 9); |
|
|
762
|
+ $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
|
763
|
+ $data['status_id'] = substr($line, 21, 2); |
|
|
764
|
+ $data['type_id'] = substr($line, 24, 3); |
|
|
765
|
+ $data['latitude'] = substr($line, 29, 9); |
|
|
766
|
+ $data['longitude'] = substr($line, 41, 9); |
|
|
767
|
+ $data['speed'] = round(substr($line, 51, 5)); |
|
768
|
768
|
//$data['course'] = substr($line,57,5); |
|
769
|
|
- $data['heading'] = round(substr($line,63,3)); |
|
|
769
|
+ $data['heading'] = round(substr($line, 63, 3)); |
|
770
|
770
|
//$data['draft'] = substr($line,67,4); |
|
771
|
771
|
//$data['length'] = substr($line,72,3); |
|
772
|
772
|
//$data['beam'] = substr($line,76,2); |
|
773
|
|
- $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
|
773
|
+ $data['ident'] = trim(utf8_encode(substr($line, 78, 20))); |
|
774
|
774
|
//$data['callsign'] = trim(substr($line,100,7); |
|
775
|
|
- $data['arrival_code'] = substr($line,108,20); |
|
|
775
|
+ $data['arrival_code'] = substr($line, 108, 20); |
|
776
|
776
|
//$data['etaDate'] = substr($line,129,5); |
|
777
|
777
|
//$data['etaTime'] = substr($line,135,5); |
|
778
|
778
|
$data['format_source'] = 'shipplotter'; |
|
@@ -791,7 +791,7 @@ discard block |
|
|
block discarded – undo |
|
791
|
791
|
) |
|
792
|
792
|
) { |
|
793
|
793
|
if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
794
|
|
- $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); |
|
|
794
|
+ $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); |
|
795
|
795
|
//echo $authsailaway; |
|
796
|
796
|
preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie); |
|
797
|
797
|
if (isset($setcookie[1][0])) { |
|
@@ -800,19 +800,19 @@ discard block |
|
|
block discarded – undo |
|
800
|
800
|
} |
|
801
|
801
|
|
|
802
|
802
|
if ($globalDebug) echo '! Download... '; |
|
803
|
|
- for ($i =0; $i <= 1; $i++) { |
|
|
803
|
+ for ($i = 0; $i <= 1; $i++) { |
|
804
|
804
|
if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
805
|
805
|
$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
|
806
|
806
|
if ($globalDebug) echo 'done'."\n"; |
|
807
|
807
|
if ($buffer != '') { |
|
808
|
|
- $all_data = json_decode($buffer,true); |
|
|
808
|
+ $all_data = json_decode($buffer, true); |
|
809
|
809
|
if (isset($all_data['missions'])) { |
|
810
|
810
|
foreach ($all_data['missions'] as $mission) { |
|
811
|
811
|
$mission_user = $mission['usrname']; |
|
812
|
|
- $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
|
813
|
|
- if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
|
|
812
|
+ $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle'])); |
|
|
813
|
+ if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) { |
|
814
|
814
|
if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { |
|
815
|
|
- $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
|
815
|
+ $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie); |
|
816
|
816
|
sleep(10); |
|
817
|
817
|
} else $racebuffer = ''; |
|
818
|
818
|
$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
|
@@ -821,19 +821,19 @@ discard block |
|
|
block discarded – undo |
|
821
|
821
|
$racebuffer = ''; |
|
822
|
822
|
} |
|
823
|
823
|
if ($racebuffer != '') { |
|
824
|
|
- $race_data = json_decode($racebuffer,true); |
|
|
824
|
+ $race_data = json_decode($racebuffer, true); |
|
825
|
825
|
//print_r($race_data); |
|
826
|
826
|
unset($racebuffer); |
|
827
|
827
|
if (isset($race_data['mission'])) { |
|
828
|
828
|
$datar = array(); |
|
829
|
829
|
$datar['id'] = $mission['misnr']; |
|
830
|
830
|
$datar['desc'] = $race_data['mission']['misdescr']; |
|
831
|
|
- $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
832
|
|
- $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
|
831
|
+ $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname']))); |
|
|
832
|
+ $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle']))); |
|
833
|
833
|
$datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
834
|
834
|
$markers = array(); |
|
835
|
835
|
foreach ($race_data['mission']['course'] as $course) { |
|
836
|
|
- $markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']); |
|
|
836
|
+ $markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']); |
|
837
|
837
|
} |
|
838
|
838
|
$datar['markers'] = json_encode($markers); |
|
839
|
839
|
//print_r($datar); |
|
@@ -841,7 +841,7 @@ discard block |
|
|
block discarded – undo |
|
841
|
841
|
} |
|
842
|
842
|
} |
|
843
|
843
|
if ($bufferm != '') { |
|
844
|
|
- $mission_data = json_decode($bufferm,true); |
|
|
844
|
+ $mission_data = json_decode($bufferm, true); |
|
845
|
845
|
unset($bufferm); |
|
846
|
846
|
if (isset($mission_data['leaderboard'][0]['results'])) { |
|
847
|
847
|
foreach ($mission_data['leaderboard'][0]['results'] as $sail) { |
|
@@ -854,7 +854,7 @@ discard block |
|
|
block discarded – undo |
|
854
|
854
|
//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr']; |
|
855
|
855
|
$data['id'] = $sail['misnr'].'-'.$sail['usrnr']; |
|
856
|
856
|
$data['datetime'] = date('Y-m-d H:i:s'); |
|
857
|
|
- $data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart'])); |
|
|
857
|
+ $data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart'])); |
|
858
|
858
|
$data['last_update'] = date('Y-m-d H:i:s'); |
|
859
|
859
|
$data['status'] = $sail['status']; |
|
860
|
860
|
$data['type'] = $sail['btptype']; |
|
@@ -865,16 +865,16 @@ discard block |
|
|
block discarded – undo |
|
865
|
865
|
$data['longitude'] = $pos['longitude']; |
|
866
|
866
|
} |
|
867
|
867
|
if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') { |
|
868
|
|
- $resultdescr = explode(',',$sail['resultdescr']); |
|
|
868
|
+ $resultdescr = explode(',', $sail['resultdescr']); |
|
869
|
869
|
if (count($resultdescr) > 2) { |
|
870
|
|
- $data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2); |
|
871
|
|
- $data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1])); |
|
|
870
|
+ $data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2); |
|
|
871
|
+ $data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1])); |
|
872
|
872
|
if (isset($resultdescr[3])) { |
|
873
|
|
- $data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3); |
|
|
873
|
+ $data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3); |
|
874
|
874
|
} |
|
875
|
875
|
} |
|
876
|
876
|
} |
|
877
|
|
- $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); |
|
|
877
|
+ $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); |
|
878
|
878
|
$data['captain_id'] = $sail['usrnr']; |
|
879
|
879
|
$data['captain_name'] = $sail['usrname']; |
|
880
|
880
|
$data['race_id'] = $sail['misnr']; |
|
@@ -924,8 +924,8 @@ discard block |
|
|
block discarded – undo |
|
924
|
924
|
) { |
|
925
|
925
|
//$buffer = $Common->getData($hosts[$id]); |
|
926
|
926
|
$buffer = $Common->getData($value['host']); |
|
927
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
928
|
|
- $buffer = explode('\n',$buffer); |
|
|
927
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
928
|
+ $buffer = explode('\n', $buffer); |
|
929
|
929
|
$reset = 0; |
|
930
|
930
|
foreach ($buffer as $line) { |
|
931
|
931
|
if ($line != '') { |
|
@@ -936,7 +936,7 @@ discard block |
|
|
block discarded – undo |
|
936
|
936
|
else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
937
|
937
|
$data['pilot_id'] = $line[1]; |
|
938
|
938
|
$data['pilot_name'] = $line[2]; |
|
939
|
|
- $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
|
939
|
+ $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
940
|
940
|
$data['ident'] = $line[0]; // ident |
|
941
|
941
|
if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
942
|
942
|
$data['speed'] = $line[8]; // speed |
|
@@ -952,7 +952,7 @@ discard block |
|
|
block discarded – undo |
|
952
|
952
|
//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
|
953
|
953
|
//if (isset($line[37])) $data['last_update'] = $line[37]; |
|
954
|
954
|
$data['departure_airport_icao'] = $line[11]; |
|
955
|
|
- $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
|
955
|
+ $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
956
|
956
|
$data['arrival_airport_icao'] = $line[13]; |
|
957
|
957
|
$data['frequency'] = $line[4]; |
|
958
|
958
|
$data['type'] = $line[18]; |
|
@@ -961,7 +961,7 @@ discard block |
|
|
block discarded – undo |
|
961
|
961
|
$data['id_source'] = $id_source; |
|
962
|
962
|
//$data['arrival_airport_time'] = ; |
|
963
|
963
|
if ($line[9] != '') { |
|
964
|
|
- $aircraft_data = explode('/',$line[9]); |
|
|
964
|
+ $aircraft_data = explode('/', $line[9]); |
|
965
|
965
|
if (isset($aircraft_data[1])) { |
|
966
|
966
|
$data['aircraft_icao'] = $aircraft_data[1]; |
|
967
|
967
|
} |
|
@@ -976,9 +976,9 @@ discard block |
|
|
block discarded – undo |
|
976
|
976
|
if ($line[3] === 'PILOT') $SI->add($data); |
|
977
|
977
|
elseif ($line[3] === 'ATC') { |
|
978
|
978
|
//print_r($data); |
|
979
|
|
- $data['info'] = str_replace('^§','<br />',$data['info']); |
|
980
|
|
- $data['info'] = str_replace('&sect;','',$data['info']); |
|
981
|
|
- $typec = substr($data['ident'],-3); |
|
|
979
|
+ $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
|
980
|
+ $data['info'] = str_replace('&sect;', '', $data['info']); |
|
|
981
|
+ $typec = substr($data['ident'], -3); |
|
982
|
982
|
if ($typec === 'APP') $data['type'] = 'Approach'; |
|
983
|
983
|
elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
984
|
984
|
elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
@@ -990,8 +990,8 @@ discard block |
|
|
block discarded – undo |
|
990
|
990
|
elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
991
|
991
|
if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
992
|
992
|
if (isset($ATC)) { |
|
993
|
|
- if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
994
|
|
- 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']); |
|
|
993
|
+ if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
|
994
|
+ 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']); |
|
995
|
995
|
} |
|
996
|
996
|
} |
|
997
|
997
|
unset($data); |
|
@@ -1007,24 +1007,24 @@ discard block |
|
|
block discarded – undo |
|
1007
|
1007
|
(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1008
|
1008
|
) |
|
1009
|
1009
|
) { |
|
1010
|
|
- $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
|
1010
|
+ $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
1011
|
1011
|
if ($buffer != '') { |
|
1012
|
1012
|
$all_data = simplexml_load_string($buffer); |
|
1013
|
|
- foreach($all_data->children() as $childdata) { |
|
|
1013
|
+ foreach ($all_data->children() as $childdata) { |
|
1014
|
1014
|
$data = array(); |
|
1015
|
1015
|
$line = $childdata; |
|
1016
|
1016
|
//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
|
1017
|
|
- $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
1018
|
|
- $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
1019
|
|
- $data['latitude'] = (float)$line['pktLatitude']; |
|
1020
|
|
- $data['longitude'] = (float)$line['pktLongitude']; |
|
1021
|
|
- if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
1022
|
|
- if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1023
|
|
- $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
|
1017
|
+ $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
|
1018
|
+ $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
|
1019
|
+ $data['latitude'] = (float) $line['pktLatitude']; |
|
|
1020
|
+ $data['longitude'] = (float) $line['pktLongitude']; |
|
|
1021
|
+ if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
|
1022
|
+ if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
|
1023
|
+ $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
1024
|
1024
|
$data['altitude_relative'] = 'AMSL'; |
|
1025
|
|
- $data['pilot_id'] = (int)$line['pktPilotID']; |
|
|
1025
|
+ $data['pilot_id'] = (int) $line['pktPilotID']; |
|
1026
|
1026
|
$data['aircraft_icao'] = 'PARAGLIDER'; |
|
1027
|
|
- $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
|
1027
|
+ $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
1028
|
1028
|
if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1029
|
1029
|
$data['format_source'] = $value['format']; |
|
1030
|
1030
|
$SI->add($data); |
|
@@ -1032,22 +1032,22 @@ discard block |
|
|
block discarded – undo |
|
1032
|
1032
|
} |
|
1033
|
1033
|
} |
|
1034
|
1034
|
$Source->deleteOldLocationByType('gs'); |
|
1035
|
|
- $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
|
1035
|
+ $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
1036
|
1036
|
if ($buffer != '') { |
|
1037
|
1037
|
$all_data = simplexml_load_string($buffer); |
|
1038
|
|
- foreach($all_data->children() as $childdata) { |
|
|
1038
|
+ foreach ($all_data->children() as $childdata) { |
|
1039
|
1039
|
$data = array(); |
|
1040
|
1040
|
$line = $childdata; |
|
1041
|
|
- $data['id'] = (int)$line['gsID']; |
|
1042
|
|
- $data['latitude'] = (float)$line['gsLatitude']; |
|
1043
|
|
- $data['longitude'] = (float)$line['gsLongitude']; |
|
1044
|
|
- $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
|
1041
|
+ $data['id'] = (int) $line['gsID']; |
|
|
1042
|
+ $data['latitude'] = (float) $line['gsLatitude']; |
|
|
1043
|
+ $data['longitude'] = (float) $line['gsLongitude']; |
|
|
1044
|
+ $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
1045
|
1045
|
$data['altitude_relative'] = 'AMSL'; |
|
1046
|
|
- $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
|
1046
|
+ $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
1047
|
1047
|
if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
|
1048
|
|
- $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
|
1048
|
+ $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
1049
|
1049
|
} else { |
|
1050
|
|
- $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
|
1050
|
+ $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
1051
|
1051
|
} |
|
1052
|
1052
|
unset($data); |
|
1053
|
1053
|
} |
|
@@ -1065,9 +1065,9 @@ discard block |
|
|
block discarded – undo |
|
1065
|
1065
|
(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
1066
|
1066
|
) |
|
1067
|
1067
|
) { |
|
1068
|
|
- $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
|
1068
|
+ $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
1069
|
1069
|
if ($buffer != '') { |
|
1070
|
|
- $all_data = json_decode($buffer,true); |
|
|
1070
|
+ $all_data = json_decode($buffer, true); |
|
1071
|
1071
|
if (isset($all_data['acList'])) { |
|
1072
|
1072
|
$reset = 0; |
|
1073
|
1073
|
foreach ($all_data['acList'] as $line) { |
|
@@ -1083,7 +1083,7 @@ discard block |
|
|
block discarded – undo |
|
1083
|
1083
|
if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1084
|
1084
|
$data['emergency'] = ''; // emergency |
|
1085
|
1085
|
if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1086
|
|
- if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
|
1086
|
+ if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
1087
|
1087
|
else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1088
|
1088
|
//$data['datetime'] = date('Y-m-d H:i:s'); |
|
1089
|
1089
|
if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
@@ -1108,7 +1108,7 @@ discard block |
|
|
block discarded – undo |
|
1108
|
1108
|
$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1109
|
1109
|
$data['squawk'] = $line['squawk']; // squawk |
|
1110
|
1110
|
$data['emergency'] = ''; // emergency |
|
1111
|
|
- if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
|
1111
|
+ if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
1112
|
1112
|
else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113
|
1113
|
$data['format_source'] = 'aircraftlistjson'; |
|
1114
|
1114
|
$data['id_source'] = $id_source; |
|
@@ -1129,7 +1129,7 @@ discard block |
|
|
block discarded – undo |
|
1129
|
1129
|
) |
|
1130
|
1130
|
) { |
|
1131
|
1131
|
$buffer = $Common->getData($value['host']); |
|
1132
|
|
- $all_data = json_decode($buffer,true); |
|
|
1132
|
+ $all_data = json_decode($buffer, true); |
|
1133
|
1133
|
if (isset($all_data['planes'])) { |
|
1134
|
1134
|
$reset = 0; |
|
1135
|
1135
|
foreach ($all_data['planes'] as $key => $line) { |
|
@@ -1146,12 +1146,12 @@ discard block |
|
|
block discarded – undo |
|
1146
|
1146
|
$data['emergency'] = ''; // emergency |
|
1147
|
1147
|
$data['registration'] = $line[2]; |
|
1148
|
1148
|
$data['aircraft_icao'] = $line[0]; |
|
1149
|
|
- $deparr = explode('-',$line[1]); |
|
|
1149
|
+ $deparr = explode('-', $line[1]); |
|
1150
|
1150
|
if (count($deparr) === 2) { |
|
1151
|
1151
|
$data['departure_airport_icao'] = $deparr[0]; |
|
1152
|
1152
|
$data['arrival_airport_icao'] = $deparr[1]; |
|
1153
|
1153
|
} |
|
1154
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
|
1154
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
1155
|
1155
|
$data['format_source'] = 'planeupdatefaa'; |
|
1156
|
1156
|
$data['id_source'] = $id_source; |
|
1157
|
1157
|
if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
@@ -1169,7 +1169,7 @@ discard block |
|
|
block discarded – undo |
|
1169
|
1169
|
) |
|
1170
|
1170
|
) { |
|
1171
|
1171
|
$buffer = $Common->getData($value['host']); |
|
1172
|
|
- $all_data = json_decode($buffer,true); |
|
|
1172
|
+ $all_data = json_decode($buffer, true); |
|
1173
|
1173
|
if (isset($all_data['states'])) { |
|
1174
|
1174
|
$reset = 0; |
|
1175
|
1175
|
foreach ($all_data['states'] as $key => $line) { |
|
@@ -1186,7 +1186,7 @@ discard block |
|
|
block discarded – undo |
|
1186
|
1186
|
//$data['emergency'] = ''; // emergency |
|
1187
|
1187
|
//$data['registration'] = $line[2]; |
|
1188
|
1188
|
//$data['aircraft_icao'] = $line[0]; |
|
1189
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
|
1189
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
1190
|
1190
|
$data['format_source'] = 'opensky'; |
|
1191
|
1191
|
$data['id_source'] = $id_source; |
|
1192
|
1192
|
if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
@@ -1203,8 +1203,8 @@ discard block |
|
|
block discarded – undo |
|
1203
|
1203
|
) |
|
1204
|
1204
|
) { |
|
1205
|
1205
|
$buffer = $Common->getData($value['host']); |
|
1206
|
|
- $all_data = json_decode($buffer,true); |
|
1207
|
|
- if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
|
1206
|
+ $all_data = json_decode($buffer, true); |
|
|
1207
|
+ if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) { |
|
1208
|
1208
|
$reset = 0; |
|
1209
|
1209
|
foreach ($all_data['aircraft'] as $key => $line) { |
|
1210
|
1210
|
$data = array(); |
|
@@ -1242,7 +1242,7 @@ discard block |
|
|
block discarded – undo |
|
1242
|
1242
|
) |
|
1243
|
1243
|
) { |
|
1244
|
1244
|
$buffer = $Common->getData($value['host']); |
|
1245
|
|
- $all_data = json_decode($buffer,true); |
|
|
1245
|
+ $all_data = json_decode($buffer, true); |
|
1246
|
1246
|
if (isset($all_data['aircraft'])) { |
|
1247
|
1247
|
$reset = 0; |
|
1248
|
1248
|
foreach ($all_data['aircraft'] as $key => $line) { |
|
@@ -1259,7 +1259,7 @@ discard block |
|
|
block discarded – undo |
|
1259
|
1259
|
//$data['emergency'] = ''; // emergency |
|
1260
|
1260
|
if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1261
|
1261
|
if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1262
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
|
1262
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']); |
|
1263
|
1263
|
$data['format_source'] = 'planefinderclient'; |
|
1264
|
1264
|
$data['id_source'] = $id_source; |
|
1265
|
1265
|
if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
@@ -1278,7 +1278,7 @@ discard block |
|
|
block discarded – undo |
|
1278
|
1278
|
) { |
|
1279
|
1279
|
//$buffer = $Common->getData($hosts[$id]); |
|
1280
|
1280
|
$buffer = $Common->getData($value['host']); |
|
1281
|
|
- $all_data = json_decode($buffer,true); |
|
|
1281
|
+ $all_data = json_decode($buffer, true); |
|
1282
|
1282
|
if (!empty($all_data)) $reset = 0; |
|
1283
|
1283
|
foreach ($all_data as $key => $line) { |
|
1284
|
1284
|
if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
|
@@ -1316,11 +1316,11 @@ discard block |
|
|
block discarded – undo |
|
1316
|
1316
|
) |
|
1317
|
1317
|
) { |
|
1318
|
1318
|
//$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1319
|
|
- $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
|
1319
|
+ $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1320
|
1320
|
//echo $buffer; |
|
1321
|
|
- $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1322
|
|
- $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1323
|
|
- $all_data = json_decode($buffer,true); |
|
|
1321
|
+ $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
|
1322
|
+ $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
|
1323
|
+ $all_data = json_decode($buffer, true); |
|
1324
|
1324
|
if (json_last_error() != JSON_ERROR_NONE) { |
|
1325
|
1325
|
die(json_last_error_msg()); |
|
1326
|
1326
|
} |
|
@@ -1343,7 +1343,7 @@ discard block |
|
|
block discarded – undo |
|
1343
|
1343
|
//$data['departure_airport_iata'] = $line[11]; |
|
1344
|
1344
|
//$data['arrival_airport_iata'] = $line[12]; |
|
1345
|
1345
|
//$data['emergency'] = ''; // emergency |
|
1346
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
|
1346
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1347
|
1347
|
$data['format_source'] = 'radarvirtueljson'; |
|
1348
|
1348
|
$data['id_source'] = $id_source; |
|
1349
|
1349
|
if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
@@ -1364,14 +1364,14 @@ discard block |
|
|
block discarded – undo |
|
1364
|
1364
|
) { |
|
1365
|
1365
|
//$buffer = $Common->getData($hosts[$id]); |
|
1366
|
1366
|
$buffer = $Common->getData($value['host'].'?'.time()); |
|
1367
|
|
- $all_data = json_decode(utf8_encode($buffer),true); |
|
|
1367
|
+ $all_data = json_decode(utf8_encode($buffer), true); |
|
1368
|
1368
|
|
|
1369
|
1369
|
if (isset($all_data['pireps'])) { |
|
1370
|
1370
|
$reset = 0; |
|
1371
|
1371
|
foreach ($all_data['pireps'] as $line) { |
|
1372
|
1372
|
$data = array(); |
|
1373
|
1373
|
$data['id'] = $line['id']; |
|
1374
|
|
- $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
|
1374
|
+ $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1375
|
1375
|
$data['ident'] = $line['callsign']; // ident |
|
1376
|
1376
|
if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1377
|
1377
|
if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
@@ -1401,9 +1401,9 @@ discard block |
|
|
block discarded – undo |
|
1401
|
1401
|
$SI->add($data); |
|
1402
|
1402
|
// print_r($data); |
|
1403
|
1403
|
} elseif ($line['icon'] === 'ct') { |
|
1404
|
|
- $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1405
|
|
- $data['info'] = str_replace('&sect;','',$data['info']); |
|
1406
|
|
- $typec = substr($data['ident'],-3); |
|
|
1404
|
+ $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
|
1405
|
+ $data['info'] = str_replace('&sect;', '', $data['info']); |
|
|
1406
|
+ $typec = substr($data['ident'], -3); |
|
1407
|
1407
|
$data['type'] = ''; |
|
1408
|
1408
|
if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1409
|
1409
|
elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
@@ -1414,7 +1414,7 @@ discard block |
|
|
block discarded – undo |
|
1414
|
1414
|
elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1415
|
1415
|
elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1416
|
1416
|
else $data['type'] = 'Observer'; |
|
1417
|
|
- 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']); |
|
|
1417
|
+ 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']); |
|
1418
|
1418
|
} |
|
1419
|
1419
|
unset($data); |
|
1420
|
1420
|
} |
|
@@ -1431,14 +1431,14 @@ discard block |
|
|
block discarded – undo |
|
1431
|
1431
|
//$buffer = $Common->getData($hosts[$id]); |
|
1432
|
1432
|
if ($globalDebug) echo 'Get Data...'."\n"; |
|
1433
|
1433
|
$buffer = $Common->getData($value['host']); |
|
1434
|
|
- $all_data = json_decode($buffer,true); |
|
|
1434
|
+ $all_data = json_decode($buffer, true); |
|
1435
|
1435
|
if ($buffer != '' && is_array($all_data)) { |
|
1436
|
1436
|
$reset = 0; |
|
1437
|
1437
|
foreach ($all_data as $line) { |
|
1438
|
1438
|
$data = array(); |
|
1439
|
1439
|
//$data['id'] = $line['id']; // id not usable |
|
1440
|
1440
|
if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1441
|
|
- $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
|
1441
|
+ $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1442
|
1442
|
if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1443
|
1443
|
if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1444
|
1444
|
$data['ident'] = $line['flightnum']; // ident |
|
@@ -1453,7 +1453,7 @@ discard block |
|
|
block discarded – undo |
|
1453
|
1453
|
//$data['datetime'] = $line['lastupdate']; |
|
1454
|
1454
|
//$data['last_update'] = $line['lastupdate']; |
|
1455
|
1455
|
if (isset($value['timezone'])) { |
|
1456
|
|
- $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
|
1456
|
+ $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1457
|
1457
|
$datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1458
|
1458
|
$data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1459
|
1459
|
} else $data['datetime'] = date('Y-m-d H:i:s'); |
|
@@ -1469,14 +1469,14 @@ discard block |
|
|
block discarded – undo |
|
1469
|
1469
|
if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1470
|
1470
|
if (isset($line['aircraftname'])) { |
|
1471
|
1471
|
$line['aircraftname'] = strtoupper($line['aircraftname']); |
|
1472
|
|
- $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1473
|
|
- $aircraft_data = explode('-',$line['aircraftname']); |
|
|
1472
|
+ $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
|
1473
|
+ $aircraft_data = explode('-', $line['aircraftname']); |
|
1474
|
1474
|
if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1475
|
1475
|
elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1476
|
1476
|
else { |
|
1477
|
|
- $aircraft_data = explode(' ',$line['aircraftname']); |
|
1478
|
|
- if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1479
|
|
- else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
|
1477
|
+ $aircraft_data = explode(' ', $line['aircraftname']); |
|
|
1478
|
+ if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
|
1479
|
+ else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1480
|
1480
|
} |
|
1481
|
1481
|
} |
|
1482
|
1482
|
if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
@@ -1501,7 +1501,7 @@ discard block |
|
|
block discarded – undo |
|
1501
|
1501
|
//$buffer = $Common->getData($hosts[$id]); |
|
1502
|
1502
|
if ($globalDebug) echo 'Get Data...'."\n"; |
|
1503
|
1503
|
$buffer = $Common->getData($value['host']); |
|
1504
|
|
- $all_data = json_decode($buffer,true); |
|
|
1504
|
+ $all_data = json_decode($buffer, true); |
|
1505
|
1505
|
if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1506
|
1506
|
$reset = 0; |
|
1507
|
1507
|
foreach ($all_data['ACARSData'] as $line) { |
|
@@ -1512,7 +1512,7 @@ discard block |
|
|
block discarded – undo |
|
1512
|
1512
|
//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1513
|
1513
|
if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1514
|
1514
|
if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1515
|
|
- $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
|
1515
|
+ $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
1516
|
1516
|
if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1517
|
1517
|
$data['altitude'] = $line['altitude']; // altitude |
|
1518
|
1518
|
$data['speed'] = $line['groundspeed']; // speed |
|
@@ -1523,7 +1523,7 @@ discard block |
|
|
block discarded – undo |
|
1523
|
1523
|
//$data['squawk'] = ''; // squawk |
|
1524
|
1524
|
//$data['emergency'] = ''; // emergency |
|
1525
|
1525
|
if (isset($value['timezone'])) { |
|
1526
|
|
- $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
|
1526
|
+ $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
1527
|
1527
|
$datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1528
|
1528
|
$data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1529
|
1529
|
} else $data['datetime'] = date('Y-m-d H:i:s'); |
|
@@ -1559,14 +1559,14 @@ discard block |
|
|
block discarded – undo |
|
1559
|
1559
|
//$buffer = $Common->getData($hosts[$id]); |
|
1560
|
1560
|
if ($globalDebug) echo 'Get Data...'."\n"; |
|
1561
|
1561
|
$buffer = $Common->getData($value['host']); |
|
1562
|
|
- $all_data = json_decode($buffer,true); |
|
|
1562
|
+ $all_data = json_decode($buffer, true); |
|
1563
|
1563
|
if ($buffer != '' && is_array($all_data)) { |
|
1564
|
1564
|
$reset = 0; |
|
1565
|
1565
|
foreach ($all_data as $line) { |
|
1566
|
1566
|
$data = array(); |
|
1567
|
1567
|
//$data['id'] = $line['id']; // id not usable |
|
1568
|
1568
|
$data['id'] = trim($line['flight_id']); |
|
1569
|
|
- $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
|
1569
|
+ $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1570
|
1570
|
$data['pilot_name'] = $line['pilot_name']; |
|
1571
|
1571
|
$data['pilot_id'] = $line['pilot_id']; |
|
1572
|
1572
|
$data['ident'] = trim($line['callsign']); // ident |
|
@@ -1610,24 +1610,24 @@ discard block |
|
|
block discarded – undo |
|
1610
|
1610
|
//$buffer = $Common->getData($hosts[$id]); |
|
1611
|
1611
|
if ($globalDebug) echo 'Get Data...'."\n"; |
|
1612
|
1612
|
$buffer = $Common->getData($value['host']); |
|
1613
|
|
- $all_data = json_decode($buffer,true); |
|
|
1613
|
+ $all_data = json_decode($buffer, true); |
|
1614
|
1614
|
if ($buffer != '') { |
|
1615
|
1615
|
$Source->deleteLocationBySource('blitzortung'); |
|
1616
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1617
|
|
- $buffer = explode('\n',$buffer); |
|
|
1616
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
1617
|
+ $buffer = explode('\n', $buffer); |
|
1618
|
1618
|
foreach ($buffer as $buffer_line) { |
|
1619
|
|
- $line = json_decode($buffer_line,true); |
|
|
1619
|
+ $line = json_decode($buffer_line, true); |
|
1620
|
1620
|
if (isset($line['time'])) { |
|
1621
|
1621
|
$data = array(); |
|
1622
|
1622
|
$data['altitude'] = $line['alt']; // altitude |
|
1623
|
1623
|
$data['latitude'] = $line['lat']; // lat |
|
1624
|
1624
|
$data['longitude'] = $line['lon']; // long |
|
1625
|
|
- $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
|
1625
|
+ $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1626
|
1626
|
$data['id_source'] = $id_source; |
|
1627
|
1627
|
$data['format_source'] = 'blitzortung'; |
|
1628
|
1628
|
$SI->add($data); |
|
1629
|
1629
|
if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1630
|
|
- $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
|
1630
|
+ $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1631
|
1631
|
unset($data); |
|
1632
|
1632
|
} |
|
1633
|
1633
|
} |
|
@@ -1639,15 +1639,15 @@ discard block |
|
|
block discarded – undo |
|
1639
|
1639
|
$arr = $httpfeeds; |
|
1640
|
1640
|
$w = $e = null; |
|
1641
|
1641
|
if (isset($arr[$id])) { |
|
1642
|
|
- $nn = stream_select($arr,$w,$e,$timeout); |
|
|
1642
|
+ $nn = stream_select($arr, $w, $e, $timeout); |
|
1643
|
1643
|
if ($nn > 0) { |
|
1644
|
1644
|
foreach ($httpfeeds as $feed) { |
|
1645
|
|
- $buffer = stream_get_line($feed,2000,"\n"); |
|
|
1645
|
+ $buffer = stream_get_line($feed, 2000, "\n"); |
|
1646
|
1646
|
if ($buffer === FALSE) { |
|
1647
|
1647
|
connect_all($globalSources); |
|
1648
|
1648
|
} |
|
1649
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1650
|
|
- $buffer = explode('\n',$buffer); |
|
|
1649
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
1650
|
+ $buffer = explode('\n', $buffer); |
|
1651
|
1651
|
foreach ($buffer as $line) { |
|
1652
|
1652
|
if ($line != '') { |
|
1653
|
1653
|
$line = json_decode($line, true); |
|
@@ -1687,11 +1687,11 @@ discard block |
|
|
block discarded – undo |
|
1687
|
1687
|
//$value = $formats[$nb]; |
|
1688
|
1688
|
$format = $globalSources[$nb]['format']; |
|
1689
|
1689
|
if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1690
|
|
- $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
|
1690
|
+ $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1691
|
1691
|
} elseif ($format === 'vrstcp') { |
|
1692
|
1692
|
$buffer = @socket_read($r, 6000); |
|
1693
|
1693
|
} else { |
|
1694
|
|
- $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
|
1694
|
+ $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1695
|
1695
|
} |
|
1696
|
1696
|
//$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1697
|
1697
|
//echo $buffer."\n"; |
|
@@ -1701,8 +1701,8 @@ discard block |
|
|
block discarded – undo |
|
1701
|
1701
|
//$SI::del(); |
|
1702
|
1702
|
if ($buffer !== FALSE) { |
|
1703
|
1703
|
if ($format === 'vrstcp') { |
|
1704
|
|
- $buffer = explode('},{',$buffer); |
|
1705
|
|
- } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
|
1704
|
+ $buffer = explode('},{', $buffer); |
|
|
1705
|
+ } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1706
|
1706
|
} |
|
1707
|
1707
|
// SBS format is CSV format |
|
1708
|
1708
|
if ($buffer !== FALSE && $buffer !== '') { |
|
@@ -1729,7 +1729,7 @@ discard block |
|
|
block discarded – undo |
|
1729
|
1729
|
$ais_data = $AIS->parse_line(trim($buffer)); |
|
1730
|
1730
|
$data = array(); |
|
1731
|
1731
|
if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1732
|
|
- if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
|
1732
|
+ if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
1733
|
1733
|
if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1734
|
1734
|
if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1735
|
1735
|
if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
@@ -1740,13 +1740,13 @@ discard block |
|
|
block discarded – undo |
|
1740
|
1740
|
if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1741
|
1741
|
if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1742
|
1742
|
if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1743
|
|
- if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
|
1743
|
+ if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1744
|
1744
|
if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1745
|
1745
|
if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1746
|
1746
|
if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1747
|
1747
|
|
|
1748
|
1748
|
if (isset($ais_data['timestamp'])) { |
|
1749
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
|
1749
|
+ $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1750
|
1750
|
} else { |
|
1751
|
1751
|
$data['datetime'] = date('Y-m-d H:i:s'); |
|
1752
|
1752
|
} |
|
@@ -1757,10 +1757,10 @@ discard block |
|
|
block discarded – undo |
|
1757
|
1757
|
} elseif ($format === 'flightgearsp') { |
|
1758
|
1758
|
//echo $buffer."\n"; |
|
1759
|
1759
|
if (strlen($buffer) > 5) { |
|
1760
|
|
- $line = explode(',',$buffer); |
|
|
1760
|
+ $line = explode(',', $buffer); |
|
1761
|
1761
|
$data = array(); |
|
1762
|
1762
|
//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
|
1763
|
|
- $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
|
1763
|
+ $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1764
|
1764
|
$data['ident'] = $line[6]; |
|
1765
|
1765
|
$data['aircraft_name'] = $line[7]; |
|
1766
|
1766
|
$data['longitude'] = $line[1]; |
|
@@ -1777,25 +1777,25 @@ discard block |
|
|
block discarded – undo |
|
1777
|
1777
|
} elseif ($format === 'acars') { |
|
1778
|
1778
|
if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1779
|
1779
|
$ACARS->add(trim($buffer)); |
|
1780
|
|
- socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
|
1780
|
+ socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1781
|
1781
|
$ACARS->deleteLiveAcarsData(); |
|
1782
|
1782
|
} elseif ($format === 'acarsjsonudp') { |
|
1783
|
1783
|
if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1784
|
1784
|
$line = json_decode(trim($buffer), true); |
|
1785
|
1785
|
if (!empty($line)) { |
|
1786
|
|
- $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
|
|
1786
|
+ $line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line); |
|
1787
|
1787
|
$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'] : ''))); |
|
1788
|
1788
|
$ACARS->deleteLiveAcarsData(); |
|
1789
|
1789
|
} |
|
1790
|
|
- socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
|
1790
|
+ socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1791
|
1791
|
} elseif ($format === 'flightgearmp') { |
|
1792
|
|
- if (substr($buffer,0,1) != '#') { |
|
|
1792
|
+ if (substr($buffer, 0, 1) != '#') { |
|
1793
|
1793
|
$data = array(); |
|
1794
|
1794
|
//echo $buffer."\n"; |
|
1795
|
|
- $line = explode(' ',$buffer); |
|
|
1795
|
+ $line = explode(' ', $buffer); |
|
1796
|
1796
|
if (count($line) === 11) { |
|
1797
|
|
- $userserver = explode('@',$line[0]); |
|
1798
|
|
- $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
|
1797
|
+ $userserver = explode('@', $line[0]); |
|
|
1798
|
+ $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1799
|
1799
|
$data['ident'] = $userserver[0]; |
|
1800
|
1800
|
$data['registration'] = $userserver[0]; |
|
1801
|
1801
|
$data['latitude'] = $line[4]; |
|
@@ -1803,8 +1803,8 @@ discard block |
|
|
block discarded – undo |
|
1803
|
1803
|
$data['altitude'] = $line[6]; |
|
1804
|
1804
|
$data['datetime'] = date('Y-m-d H:i:s'); |
|
1805
|
1805
|
$aircraft_type = $line[10]; |
|
1806
|
|
- $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1807
|
|
- $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
|
1806
|
+ $aircraft_type = preg_split(':/:', $aircraft_type); |
|
|
1807
|
+ $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1808
|
1808
|
if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1809
|
1809
|
if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1810
|
1810
|
} |
|
@@ -1813,8 +1813,8 @@ discard block |
|
|
block discarded – undo |
|
1813
|
1813
|
echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1814
|
1814
|
die; |
|
1815
|
1815
|
} elseif ($format === 'vrstcp') { |
|
1816
|
|
- foreach($buffer as $all_data) { |
|
1817
|
|
- $line = json_decode('{'.$all_data.'}',true); |
|
|
1816
|
+ foreach ($buffer as $all_data) { |
|
|
1817
|
+ $line = json_decode('{'.$all_data.'}', true); |
|
1818
|
1818
|
$data = array(); |
|
1819
|
1819
|
if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1820
|
1820
|
if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
@@ -1840,16 +1840,16 @@ discard block |
|
|
block discarded – undo |
|
1840
|
1840
|
if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1841
|
1841
|
unset($data); |
|
1842
|
1842
|
} |
|
1843
|
|
- } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
|
|
1843
|
+ } elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') { |
|
1844
|
1844
|
$line = explode("\t", $buffer); |
|
1845
|
|
- for($k = 0; $k < count($line); $k=$k+2) { |
|
|
1845
|
+ for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1846
|
1846
|
$key = $line[$k]; |
|
1847
|
|
- $lined[$key] = $line[$k+1]; |
|
|
1847
|
+ $lined[$key] = $line[$k + 1]; |
|
1848
|
1848
|
} |
|
1849
|
1849
|
if (count($lined) > 3) { |
|
1850
|
1850
|
$data['hex'] = $lined['hexid']; |
|
1851
|
1851
|
//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1852
|
|
- $data['datetime'] = date('Y-m-d H:i:s');; |
|
|
1852
|
+ $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1853
|
1853
|
if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1854
|
1854
|
if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1855
|
1855
|
if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
@@ -1868,23 +1868,23 @@ discard block |
|
|
block discarded – undo |
|
1868
|
1868
|
} else $error = true; |
|
1869
|
1869
|
} elseif ($format === 'aprs' && $use_aprs) { |
|
1870
|
1870
|
if ($aprs_connect === 0) { |
|
1871
|
|
- $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
|
1871
|
+ $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1872
|
1872
|
$aprs_connect = 1; |
|
1873
|
1873
|
} |
|
1874
|
1874
|
|
|
1875
|
|
- if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
|
1875
|
+ if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1876
|
1876
|
$aprs_last_tx = time(); |
|
1877
|
1877
|
$data_aprs = "# Keep alive"; |
|
1878
|
|
- $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
|
1878
|
+ $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1879
|
1879
|
} |
|
1880
|
1880
|
|
|
1881
|
1881
|
//echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1882
|
1882
|
//echo 'APRS data : '.$buffer."\n"; |
|
1883
|
|
- $buffer = str_replace('APRS <- ','',$buffer); |
|
1884
|
|
- $buffer = str_replace('APRS -> ','',$buffer); |
|
|
1883
|
+ $buffer = str_replace('APRS <- ', '', $buffer); |
|
|
1884
|
+ $buffer = str_replace('APRS -> ', '', $buffer); |
|
1885
|
1885
|
//echo $buffer."\n"; |
|
1886
|
1886
|
date_default_timezone_set('UTC'); |
|
1887
|
|
- if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
|
1887
|
+ if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1888
|
1888
|
$line = $APRS->parse($buffer); |
|
1889
|
1889
|
//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
|
1890
|
1890
|
if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
|
@@ -1899,7 +1899,7 @@ discard block |
|
|
block discarded – undo |
|
1899
|
1899
|
if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1900
|
1900
|
if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1901
|
1901
|
if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1902
|
|
- if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
|
1902
|
+ if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1903
|
1903
|
else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1904
|
1904
|
//$data['datetime'] = date('Y-m-d H:i:s'); |
|
1905
|
1905
|
if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
@@ -1987,29 +1987,29 @@ discard block |
|
|
block discarded – undo |
|
1987
|
1987
|
} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1988
|
1988
|
if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
1989
|
1989
|
$Source->deleteOldLocationByType('gs'); |
|
1990
|
|
- if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1991
|
|
- $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
|
1990
|
+ if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
|
1991
|
+ $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1992
|
1992
|
} else { |
|
1993
|
|
- $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
|
1993
|
+ $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1994
|
1994
|
} |
|
1995
|
1995
|
} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1996
|
1996
|
//if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
|
1997
|
1997
|
if ($globalDebug) echo '# Weather Station added'."\n"; |
|
1998
|
1998
|
$Source->deleteOldLocationByType('wx'); |
|
1999
|
1999
|
$weather_data = json_encode($line); |
|
2000
|
|
- if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
2001
|
|
- $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
|
2000
|
+ if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
|
2001
|
+ $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
2002
|
2002
|
} else { |
|
2003
|
|
- $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
|
2003
|
+ $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
2004
|
2004
|
} |
|
2005
|
2005
|
} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
2006
|
2006
|
//if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
|
2007
|
2007
|
if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2008
|
2008
|
$Source->deleteOldLocationByType('lightning'); |
|
2009
|
|
- if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
2010
|
|
- $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
|
2009
|
+ if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
|
2010
|
+ $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
2011
|
2011
|
} else { |
|
2012
|
|
- $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
|
2012
|
+ $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
2013
|
2013
|
} |
|
2014
|
2014
|
} elseif ($globalDebug) { |
|
2015
|
2015
|
echo '/!\ Not added: '.$buffer."\n"; |
|
@@ -2018,7 +2018,7 @@ discard block |
|
|
block discarded – undo |
|
2018
|
2018
|
unset($data); |
|
2019
|
2019
|
} |
|
2020
|
2020
|
elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2021
|
|
- $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
|
2021
|
+ $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
2022
|
2022
|
} |
|
2023
|
2023
|
/* |
|
2024
|
2024
|
elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) { |
|
@@ -2027,7 +2027,7 @@ discard block |
|
|
block discarded – undo |
|
2027
|
2027
|
*/ |
|
2028
|
2028
|
//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
|
2029
|
2029
|
elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2030
|
|
- if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
|
2030
|
+ if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
2031
|
2031
|
$Source->deleteOldLocationByType('lightning'); |
|
2032
|
2032
|
$Source->deleteOldLocationByType('wx'); |
|
2033
|
2033
|
$globalSources[$nb]['last_weather_clean'] = time(); |
|
@@ -2114,7 +2114,7 @@ discard block |
|
|
block discarded – undo |
|
2114
|
2114
|
connect_all($sourceee); |
|
2115
|
2115
|
$sourceee = array(); |
|
2116
|
2116
|
//connect_all($globalSources); |
|
2117
|
|
- $tt[$format]=0; |
|
|
2117
|
+ $tt[$format] = 0; |
|
2118
|
2118
|
break; |
|
2119
|
2119
|
} |
|
2120
|
2120
|
//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
@@ -2124,14 +2124,14 @@ discard block |
|
|
block discarded – undo |
|
2124
|
2124
|
} else { |
|
2125
|
2125
|
$error = socket_strerror(socket_last_error()); |
|
2126
|
2126
|
if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
|
2127
|
|
- if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
|
2127
|
+ if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
2128
|
2128
|
if (isset($globalDebug)) echo "Restarting...\n"; |
|
2129
|
2129
|
// Restart the script if possible |
|
2130
|
2130
|
if (is_array($sockets)) { |
|
2131
|
2131
|
if ($globalDebug) echo "Shutdown all sockets..."; |
|
2132
|
2132
|
|
|
2133
|
2133
|
foreach ($sockets as $sock) { |
|
2134
|
|
- @socket_shutdown($sock,2); |
|
|
2134
|
+ @socket_shutdown($sock, 2); |
|
2135
|
2135
|
@socket_close($sock); |
|
2136
|
2136
|
} |
|
2137
|
2137
|
|