|
@@ -50,20 +50,20 @@ discard block |
|
|
block discarded – undo |
|
50
|
50
|
die; |
|
51
|
51
|
} |
|
52
|
52
|
//$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
|
53
|
|
- $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
|
53
|
+ $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
54
|
54
|
} |
|
55
|
55
|
} |
|
56
|
56
|
|
|
57
|
|
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
|
|
57
|
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); |
|
58
|
58
|
//if (isset($options['s'])) $hosts = array($options['s']); |
|
59
|
59
|
//elseif (isset($options['source'])) $hosts = array($options['source']); |
|
60
|
60
|
if (isset($options['s'])) { |
|
61
|
61
|
$globalSources = array(); |
|
62
|
|
- if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
|
62
|
+ if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
63
|
63
|
else $globalSources[] = array('host' => $options['s']); |
|
64
|
64
|
} elseif (isset($options['source'])) { |
|
65
|
65
|
$globalSources = array(); |
|
66
|
|
- if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
|
66
|
+ if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
67
|
67
|
else $globalSources[] = array('host' => $options['source']); |
|
68
|
68
|
} |
|
69
|
69
|
if (isset($options['aprsserverhost'])) { |
|
@@ -104,13 +104,13 @@ discard block |
|
|
block discarded – undo |
|
104
|
104
|
else $id_source = 1; |
|
105
|
105
|
if (isset($globalServer) && $globalServer) { |
|
106
|
106
|
if ($globalDebug) echo "Using Server Mode\n"; |
|
107
|
|
- $SI=new SpotterServer(); |
|
|
107
|
+ $SI = new SpotterServer(); |
|
108
|
108
|
/* |
|
109
|
109
|
require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
|
110
|
110
|
$SI = new adsb2aprs(); |
|
111
|
111
|
$SI->connect(); |
|
112
|
112
|
*/ |
|
113
|
|
-} else $SI=new SpotterImport($Connection->db); |
|
|
113
|
+} else $SI = new SpotterImport($Connection->db); |
|
114
|
114
|
|
|
115
|
115
|
if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
116
|
116
|
if (isset($globalMarine) && $globalMarine) { |
|
@@ -124,17 +124,17 @@ discard block |
|
|
block discarded – undo |
|
124
|
124
|
$MI = new MarineImport($Connection->db); |
|
125
|
125
|
} |
|
126
|
126
|
//$APRS=new APRS($Connection->db); |
|
127
|
|
-$SBS=new SBS(); |
|
|
127
|
+$SBS = new SBS(); |
|
128
|
128
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
129
|
|
- $ACARS=new ACARS($Connection->db,true); |
|
130
|
|
- $Source=new Source($Connection->db); |
|
|
129
|
+ $ACARS = new ACARS($Connection->db, true); |
|
|
130
|
+ $Source = new Source($Connection->db); |
|
131
|
131
|
} |
|
132
|
|
-$Common=new Common(); |
|
|
132
|
+$Common = new Common(); |
|
133
|
133
|
date_default_timezone_set('UTC'); |
|
134
|
134
|
//$servertz = system('date +%Z'); |
|
135
|
135
|
// signal handler - playing nice with sockets and dump1090 |
|
136
|
136
|
if (function_exists('pcntl_fork')) { |
|
137
|
|
- pcntl_signal(SIGINT, function() { |
|
|
137
|
+ pcntl_signal(SIGINT, function() { |
|
138
|
138
|
global $sockets; |
|
139
|
139
|
echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140
|
140
|
die("Bye!\n"); |
|
@@ -150,40 +150,40 @@ discard block |
|
|
block discarded – undo |
|
150
|
150
|
|
|
151
|
151
|
function connect_all($hosts) { |
|
152
|
152
|
//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153
|
|
- global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
|
153
|
+ global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
154
|
154
|
$reset++; |
|
155
|
155
|
if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156
|
156
|
foreach ($hosts as $id => $value) { |
|
157
|
157
|
$host = $value['host']; |
|
158
|
158
|
$globalSources[$id]['last_exec'] = 0; |
|
159
|
159
|
// Here we check type of source(s) |
|
160
|
|
- if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
161
|
|
- if (preg_match('/deltadb.txt$/i',$host)) { |
|
|
160
|
+ if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
|
161
|
+ if (preg_match('/deltadb.txt$/i', $host)) { |
|
162
|
162
|
//$formats[$id] = 'deltadbtxt'; |
|
163
|
163
|
$globalSources[$id]['format'] = 'deltadbtxt'; |
|
164
|
164
|
//$last_exec['deltadbtxt'] = 0; |
|
165
|
165
|
if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166
|
|
- } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
|
166
|
+ } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
167
|
167
|
//$formats[$id] = 'vatsimtxt'; |
|
168
|
168
|
$globalSources[$id]['format'] = 'vatsimtxt'; |
|
169
|
169
|
//$last_exec['vatsimtxt'] = 0; |
|
170
|
170
|
if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171
|
|
- } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
|
171
|
+ } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
172
|
172
|
//$formats[$id] = 'aircraftlistjson'; |
|
173
|
173
|
$globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174
|
174
|
//$last_exec['aircraftlistjson'] = 0; |
|
175
|
175
|
if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176
|
|
- } else if (preg_match('/aircraft.json$/i',$host)) { |
|
|
176
|
+ } else if (preg_match('/aircraft.json$/i', $host)) { |
|
177
|
177
|
//$formats[$id] = 'aircraftjson'; |
|
178
|
178
|
$globalSources[$id]['format'] = 'aircraftjson'; |
|
179
|
179
|
//$last_exec['aircraftlistjson'] = 0; |
|
180
|
180
|
if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
181
|
|
- } else if (preg_match('/aircraft$/i',$host)) { |
|
|
181
|
+ } else if (preg_match('/aircraft$/i', $host)) { |
|
182
|
182
|
//$formats[$id] = 'planefinderclient'; |
|
183
|
183
|
$globalSources[$id]['format'] = 'planefinderclient'; |
|
184
|
184
|
//$last_exec['aircraftlistjson'] = 0; |
|
185
|
185
|
if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
186
|
|
- } else if (preg_match('/opensky/i',$host)) { |
|
|
186
|
+ } else if (preg_match('/opensky/i', $host)) { |
|
187
|
187
|
//$formats[$id] = 'aircraftlistjson'; |
|
188
|
188
|
$globalSources[$id]['format'] = 'opensky'; |
|
189
|
189
|
//$last_exec['aircraftlistjson'] = 0; |
|
@@ -200,7 +200,7 @@ discard block |
|
|
block discarded – undo |
|
200
|
200
|
exit(0); |
|
201
|
201
|
} |
|
202
|
202
|
*/ |
|
203
|
|
- } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
|
203
|
+ } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
204
|
204
|
//$formats[$id] = 'planeupdatefaa'; |
|
205
|
205
|
$globalSources[$id]['format'] = 'planeupdatefaa'; |
|
206
|
206
|
//$last_exec['planeupdatefaa'] = 0; |
|
@@ -209,37 +209,37 @@ discard block |
|
|
block discarded – undo |
|
209
|
209
|
echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
210
|
210
|
exit(0); |
|
211
|
211
|
} |
|
212
|
|
- } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
|
212
|
+ } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
213
|
213
|
//$formats[$id] = 'phpvmacars'; |
|
214
|
214
|
$globalSources[$id]['format'] = 'phpvmacars'; |
|
215
|
215
|
//$last_exec['phpvmacars'] = 0; |
|
216
|
216
|
if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
217
|
|
- } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
|
217
|
+ } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { |
|
218
|
218
|
//$formats[$id] = 'phpvmacars'; |
|
219
|
219
|
$globalSources[$id]['format'] = 'vaos'; |
|
220
|
220
|
//$last_exec['phpvmacars'] = 0; |
|
221
|
221
|
if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
222
|
|
- } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
|
222
|
+ } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
223
|
223
|
//$formats[$id] = 'phpvmacars'; |
|
224
|
224
|
$globalSources[$id]['format'] = 'vam'; |
|
225
|
225
|
if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
226
|
|
- } else if (preg_match('/whazzup/i',$host)) { |
|
|
226
|
+ } else if (preg_match('/whazzup/i', $host)) { |
|
227
|
227
|
//$formats[$id] = 'whazzup'; |
|
228
|
228
|
$globalSources[$id]['format'] = 'whazzup'; |
|
229
|
229
|
//$last_exec['whazzup'] = 0; |
|
230
|
230
|
if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
231
|
|
- } else if (preg_match('/blitzortung/i',$host)) { |
|
|
231
|
+ } else if (preg_match('/blitzortung/i', $host)) { |
|
232
|
232
|
$globalSources[$id]['format'] = 'blitzortung'; |
|
233
|
233
|
if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
234
|
|
- } else if (preg_match('/airwhere/i',$host)) { |
|
|
234
|
+ } else if (preg_match('/airwhere/i', $host)) { |
|
235
|
235
|
$globalSources[$id]['format'] = 'airwhere'; |
|
236
|
236
|
if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
237
|
|
- } else if (preg_match('/recentpireps/i',$host)) { |
|
|
237
|
+ } else if (preg_match('/recentpireps/i', $host)) { |
|
238
|
238
|
//$formats[$id] = 'pirepsjson'; |
|
239
|
239
|
$globalSources[$id]['format'] = 'pirepsjson'; |
|
240
|
240
|
//$last_exec['pirepsjson'] = 0; |
|
241
|
241
|
if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
242
|
|
- } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
|
242
|
+ } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
243
|
243
|
//$formats[$id] = 'fr24json'; |
|
244
|
244
|
$globalSources[$id]['format'] = 'fr24json'; |
|
245
|
245
|
//$last_exec['fr24json'] = 0; |
|
@@ -248,7 +248,7 @@ discard block |
|
|
block discarded – undo |
|
248
|
248
|
echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
249
|
249
|
exit(0); |
|
250
|
250
|
} |
|
251
|
|
- } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
|
251
|
+ } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
252
|
252
|
//$formats[$id] = 'fr24json'; |
|
253
|
253
|
$globalSources[$id]['format'] = 'myshiptracking'; |
|
254
|
254
|
//$last_exec['fr24json'] = 0; |
|
@@ -258,22 +258,22 @@ discard block |
|
|
block discarded – undo |
|
258
|
258
|
exit(0); |
|
259
|
259
|
} |
|
260
|
260
|
//} else if (preg_match('/10001/',$host)) { |
|
261
|
|
- } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
|
261
|
+ } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
262
|
262
|
//$formats[$id] = 'tsv'; |
|
263
|
263
|
$globalSources[$id]['format'] = 'tsv'; |
|
264
|
264
|
if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
265
|
265
|
} |
|
266
|
|
- } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
|
|
266
|
+ } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
|
267
|
267
|
if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
268
|
|
- $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
|
268
|
+ $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
269
|
269
|
if ($idf !== false) { |
|
270
|
270
|
$httpfeeds[$id] = $idf; |
|
271
|
271
|
if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
272
|
272
|
} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
273
|
273
|
} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
274
|
274
|
elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
275
|
|
- } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
276
|
|
- $hostport = explode(':',$host); |
|
|
275
|
+ } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
|
276
|
+ $hostport = explode(':', $host); |
|
277
|
277
|
if (isset($hostport[1])) { |
|
278
|
278
|
$port = $hostport[1]; |
|
279
|
279
|
$hostn = $hostport[0]; |
|
@@ -283,19 +283,19 @@ discard block |
|
|
block discarded – undo |
|
283
|
283
|
} |
|
284
|
284
|
$Common = new Common(); |
|
285
|
285
|
if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
286
|
|
- $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
|
286
|
+ $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
287
|
287
|
} else { |
|
288
|
|
- $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
|
288
|
+ $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
289
|
289
|
} |
|
290
|
290
|
if ($s) { |
|
291
|
291
|
$sockets[$id] = $s; |
|
292
|
292
|
if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
293
|
|
- if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
|
293
|
+ if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
294
|
294
|
//$formats[$id] = 'aprs'; |
|
295
|
295
|
$globalSources[$id]['format'] = 'aprs'; |
|
296
|
296
|
//$aprs_connect = 0; |
|
297
|
297
|
//$use_aprs = true; |
|
298
|
|
- } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
|
298
|
+ } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
299
|
299
|
$globalSources[$id]['format'] = 'vrstcp'; |
|
300
|
300
|
} elseif ($port == '10001') { |
|
301
|
301
|
//$formats[$id] = 'tsv'; |
|
@@ -336,7 +336,7 @@ discard block |
|
|
block discarded – undo |
|
336
|
336
|
else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
337
|
337
|
else $timeout = 20; |
|
338
|
338
|
$errno = ''; |
|
339
|
|
-$errstr=''; |
|
|
339
|
+$errstr = ''; |
|
340
|
340
|
|
|
341
|
341
|
if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
342
|
342
|
/* Initiate connections to all the hosts simultaneously */ |
|
@@ -344,7 +344,7 @@ discard block |
|
|
block discarded – undo |
|
344
|
344
|
//connect_all($globalSources); |
|
345
|
345
|
|
|
346
|
346
|
if (isset($globalProxy) && $globalProxy) { |
|
347
|
|
- $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
|
347
|
+ $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
348
|
348
|
} else { |
|
349
|
349
|
$context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
350
|
350
|
} |
|
@@ -374,16 +374,16 @@ discard block |
|
|
block discarded – undo |
|
374
|
374
|
|
|
375
|
375
|
if ($use_aprs) { |
|
376
|
376
|
require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
|
377
|
|
- $APRS=new APRS(); |
|
|
377
|
+ $APRS = new APRS(); |
|
378
|
378
|
$aprs_connect = 0; |
|
379
|
379
|
$aprs_keep = 120; |
|
380
|
380
|
$aprs_last_tx = time(); |
|
381
|
381
|
if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
382
|
|
- else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
|
382
|
+ else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
383
|
383
|
if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
384
|
|
- else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
|
384
|
+ else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
385
|
385
|
if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
386
|
|
- else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
|
386
|
+ else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
387
|
387
|
if ($aprs_full) $aprs_filter = ''; |
|
388
|
388
|
if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
389
|
389
|
else $aprs_pass = '-1'; |
|
@@ -397,12 +397,12 @@ discard block |
|
|
block discarded – undo |
|
397
|
397
|
sleep(1); |
|
398
|
398
|
if ($globalDebug) echo "SCAN MODE \n\n"; |
|
399
|
399
|
if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
400
|
|
-$endtime = time()+$globalCronEnd; |
|
|
400
|
+$endtime = time() + $globalCronEnd; |
|
401
|
401
|
$i = 1; |
|
402
|
402
|
$tt = array(); |
|
403
|
403
|
// Delete all ATC |
|
404
|
404
|
if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
405
|
|
- $ATC=new ATC($Connection->db); |
|
|
405
|
+ $ATC = new ATC($Connection->db); |
|
406
|
406
|
} |
|
407
|
407
|
if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
408
|
408
|
$ATC->deleteAll(); |
|
@@ -412,7 +412,7 @@ discard block |
|
|
block discarded – undo |
|
412
|
412
|
while ($i > 0) { |
|
413
|
413
|
if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
414
|
414
|
|
|
415
|
|
- if (!$globalDaemon) $i = $endtime-time(); |
|
|
415
|
+ if (!$globalDaemon) $i = $endtime - time(); |
|
416
|
416
|
// Delete old ATC |
|
417
|
417
|
if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
418
|
418
|
if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
@@ -426,7 +426,7 @@ discard block |
|
|
block discarded – undo |
|
426
|
426
|
} |
|
427
|
427
|
if ($max < $globalMinFetch) { |
|
428
|
428
|
if ($globalDebug) echo 'Sleeping...'."\n"; |
|
429
|
|
- sleep($globalMinFetch-$max+2); |
|
|
429
|
+ sleep($globalMinFetch - $max + 2); |
|
430
|
430
|
} |
|
431
|
431
|
} |
|
432
|
432
|
|
|
@@ -445,8 +445,8 @@ discard block |
|
|
block discarded – undo |
|
445
|
445
|
//$buffer = $Common->getData($hosts[$id]); |
|
446
|
446
|
$buffer = $Common->getData($value['host']); |
|
447
|
447
|
if ($buffer != '') $reset = 0; |
|
448
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
449
|
|
- $buffer = explode('\n',$buffer); |
|
|
448
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
449
|
+ $buffer = explode('\n', $buffer); |
|
450
|
450
|
foreach ($buffer as $line) { |
|
451
|
451
|
if ($line != '' && count($line) > 7) { |
|
452
|
452
|
$line = explode(',', $line); |
|
@@ -479,11 +479,11 @@ discard block |
|
|
block discarded – undo |
|
479
|
479
|
) |
|
480
|
480
|
) { |
|
481
|
481
|
date_default_timezone_set('CET'); |
|
482
|
|
- $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
|
482
|
+ $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
483
|
483
|
date_default_timezone_set('UTC'); |
|
484
|
484
|
if ($buffer != '') $reset = 0; |
|
485
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
486
|
|
- $buffer = explode('\n',$buffer); |
|
|
485
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
486
|
+ $buffer = explode('\n', $buffer); |
|
487
|
487
|
foreach ($buffer as $line) { |
|
488
|
488
|
if ($line != '') { |
|
489
|
489
|
//echo "'".$line."'\n"; |
|
@@ -491,7 +491,7 @@ discard block |
|
|
block discarded – undo |
|
491
|
491
|
$ais_data = $AIS->parse_line(trim($line)); |
|
492
|
492
|
$data = array(); |
|
493
|
493
|
if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
494
|
|
- if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
|
494
|
+ if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
495
|
495
|
if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
496
|
496
|
if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
497
|
497
|
if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
@@ -503,7 +503,7 @@ discard block |
|
|
block discarded – undo |
|
503
|
503
|
if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
504
|
504
|
if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
505
|
505
|
if (isset($ais_data['timestamp'])) { |
|
506
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
|
506
|
+ $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
507
|
507
|
if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
|
508
|
508
|
$last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
509
|
509
|
$add = true; |
|
@@ -526,21 +526,21 @@ discard block |
|
|
block discarded – undo |
|
526
|
526
|
$w = $e = null; |
|
527
|
527
|
|
|
528
|
528
|
if (isset($arr[$id])) { |
|
529
|
|
- $nn = stream_select($arr,$w,$e,$timeout); |
|
|
529
|
+ $nn = stream_select($arr, $w, $e, $timeout); |
|
530
|
530
|
if ($nn > 0) { |
|
531
|
531
|
foreach ($httpfeeds as $feed) { |
|
532
|
|
- $buffer = stream_get_line($feed,2000,"\n"); |
|
|
532
|
+ $buffer = stream_get_line($feed, 2000, "\n"); |
|
533
|
533
|
if ($buffer === FALSE) { |
|
534
|
534
|
connect_all($globalSources); |
|
535
|
535
|
} |
|
536
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
537
|
|
- $buffer = explode('\n',$buffer); |
|
|
536
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
537
|
+ $buffer = explode('\n', $buffer); |
|
538
|
538
|
foreach ($buffer as $line) { |
|
539
|
539
|
if ($line != '') { |
|
540
|
540
|
$ais_data = $AIS->parse_line(trim($line)); |
|
541
|
541
|
$data = array(); |
|
542
|
542
|
if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
543
|
|
- if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
|
543
|
+ if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
544
|
544
|
if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
545
|
545
|
if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
546
|
546
|
if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
@@ -552,9 +552,9 @@ discard block |
|
|
block discarded – undo |
|
552
|
552
|
if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
553
|
553
|
if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
554
|
554
|
if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
555
|
|
- if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
|
555
|
+ if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
556
|
556
|
if (isset($ais_data['timestamp'])) { |
|
557
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
|
557
|
+ $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
558
|
558
|
} else { |
|
559
|
559
|
$data['datetime'] = date('Y-m-d H:i:s'); |
|
560
|
560
|
} |
|
@@ -586,10 +586,10 @@ discard block |
|
|
block discarded – undo |
|
586
|
586
|
(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
|
587
|
587
|
) |
|
588
|
588
|
) { |
|
589
|
|
- $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
|
589
|
+ $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
590
|
590
|
if ($buffer != '') { |
|
591
|
591
|
//echo $buffer; |
|
592
|
|
- $all_data = json_decode($buffer,true); |
|
|
592
|
+ $all_data = json_decode($buffer, true); |
|
593
|
593
|
//print_r($all_data); |
|
594
|
594
|
if (isset($all_data[0]['DATA'])) { |
|
595
|
595
|
foreach ($all_data[0]['DATA'] as $line) { |
|
@@ -598,7 +598,7 @@ discard block |
|
|
block discarded – undo |
|
598
|
598
|
$data['ident'] = $line['NAME']; |
|
599
|
599
|
$data['mmsi'] = $line['MMSI']; |
|
600
|
600
|
if (strlen($data['mmsi']) > 9) { |
|
601
|
|
- $data['mmsi'] = substr($data['mmsi'],-9); |
|
|
601
|
+ $data['mmsi'] = substr($data['mmsi'], -9); |
|
602
|
602
|
} |
|
603
|
603
|
$data['speed'] = $line['SOG']; |
|
604
|
604
|
$data['heading'] = $line['COG']; |
|
@@ -608,8 +608,8 @@ discard block |
|
|
block discarded – undo |
|
608
|
608
|
//$data['type_id'] = $line['TYPE']; |
|
609
|
609
|
$data['imo'] = $line['IMO']; |
|
610
|
610
|
if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
611
|
|
- if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
612
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
|
611
|
+ if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV'])); |
|
|
612
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
613
|
613
|
$data['format_source'] = 'myshiptracking'; |
|
614
|
614
|
$data['id_source'] = $id_source; |
|
615
|
615
|
if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
@@ -626,16 +626,16 @@ discard block |
|
|
block discarded – undo |
|
626
|
626
|
(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
|
627
|
627
|
) |
|
628
|
628
|
) { |
|
629
|
|
- $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
|
629
|
+ $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
630
|
630
|
if ($buffer != '') { |
|
631
|
|
- $all_data = json_decode($buffer,true); |
|
|
631
|
+ $all_data = json_decode($buffer, true); |
|
632
|
632
|
if (isset($all_data[0]['mmsi'])) { |
|
633
|
633
|
foreach ($all_data as $line) { |
|
634
|
634
|
if ($line != '') { |
|
635
|
635
|
$data = array(); |
|
636
|
636
|
$data['ident'] = $line['shipname']; |
|
637
|
637
|
$data['callsign'] = $line['callsign']; |
|
638
|
|
- $data['mmsi'] = substr($line['mmsi'],-9); |
|
|
638
|
+ $data['mmsi'] = substr($line['mmsi'], -9); |
|
639
|
639
|
$data['speed'] = $line['sog']; |
|
640
|
640
|
if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
641
|
641
|
$data['latitude'] = $line['latitude']; |
|
@@ -662,14 +662,14 @@ discard block |
|
|
block discarded – undo |
|
662
|
662
|
) { |
|
663
|
663
|
$buffer = $Common->getData($value['host']); |
|
664
|
664
|
if ($buffer != '') { |
|
665
|
|
- $all_data = json_decode($buffer,true); |
|
|
665
|
+ $all_data = json_decode($buffer, true); |
|
666
|
666
|
if (isset($all_data['features'][0]['id'])) { |
|
667
|
667
|
foreach ($all_data['features'] as $line) { |
|
668
|
668
|
print_r($line); |
|
669
|
669
|
$data = array(); |
|
670
|
670
|
if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
671
|
671
|
if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
672
|
|
- if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
|
672
|
+ if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9); |
|
673
|
673
|
if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
674
|
674
|
if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
675
|
675
|
if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
@@ -696,31 +696,31 @@ discard block |
|
|
block discarded – undo |
|
696
|
696
|
) |
|
697
|
697
|
) { |
|
698
|
698
|
if ($globalDebug) echo 'download...'; |
|
699
|
|
- $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
|
699
|
+ $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
700
|
700
|
if ($globalDebug) echo 'done !'."\n"; |
|
701
|
701
|
// FIXME: Need more work |
|
702
|
702
|
if ($buffer != '') $reset = 0; |
|
703
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
704
|
|
- $buffer = explode('\n',$buffer); |
|
|
703
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
704
|
+ $buffer = explode('\n', $buffer); |
|
705
|
705
|
foreach ($buffer as $line) { |
|
706
|
706
|
if ($line != '') { |
|
707
|
707
|
$data = array(); |
|
708
|
708
|
//echo $line."\n"; |
|
709
|
|
- $data['mmsi'] = (int)substr($line,0,9); |
|
710
|
|
- $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
711
|
|
- $data['status_id'] = substr($line,21,2); |
|
712
|
|
- $data['type_id'] = substr($line,24,3); |
|
713
|
|
- $data['latitude'] = substr($line,29,9); |
|
714
|
|
- $data['longitude'] = substr($line,41,9); |
|
715
|
|
- $data['speed'] = round(substr($line,51,5)); |
|
|
709
|
+ $data['mmsi'] = (int) substr($line, 0, 9); |
|
|
710
|
+ $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
|
711
|
+ $data['status_id'] = substr($line, 21, 2); |
|
|
712
|
+ $data['type_id'] = substr($line, 24, 3); |
|
|
713
|
+ $data['latitude'] = substr($line, 29, 9); |
|
|
714
|
+ $data['longitude'] = substr($line, 41, 9); |
|
|
715
|
+ $data['speed'] = round(substr($line, 51, 5)); |
|
716
|
716
|
//$data['course'] = substr($line,57,5); |
|
717
|
|
- $data['heading'] = round(substr($line,63,3)); |
|
|
717
|
+ $data['heading'] = round(substr($line, 63, 3)); |
|
718
|
718
|
//$data['draft'] = substr($line,67,4); |
|
719
|
719
|
//$data['length'] = substr($line,72,3); |
|
720
|
720
|
//$data['beam'] = substr($line,76,2); |
|
721
|
|
- $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
|
721
|
+ $data['ident'] = trim(utf8_encode(substr($line, 78, 20))); |
|
722
|
722
|
//$data['callsign'] = trim(substr($line,100,7); |
|
723
|
|
- $data['arrival_code'] = substr($line,108,20); |
|
|
723
|
+ $data['arrival_code'] = substr($line, 108, 20); |
|
724
|
724
|
//$data['etaDate'] = substr($line,129,5); |
|
725
|
725
|
//$data['etaTime'] = substr($line,135,5); |
|
726
|
726
|
$data['format_source'] = 'shipplotter'; |
|
@@ -740,21 +740,21 @@ discard block |
|
|
block discarded – undo |
|
740
|
740
|
) |
|
741
|
741
|
) { |
|
742
|
742
|
if ($globalDebug) echo '! Download... '; |
|
743
|
|
- for ($i =0; $i <= 1; $i++) { |
|
|
743
|
+ for ($i = 0; $i <= 1; $i++) { |
|
744
|
744
|
if ($globalDebug) echo 'Racetype: '.$i."\n"; |
|
745
|
745
|
$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
|
746
|
746
|
if ($globalDebug) echo 'done'."\n"; |
|
747
|
747
|
if ($buffer != '') { |
|
748
|
|
- $all_data = json_decode($buffer,true); |
|
|
748
|
+ $all_data = json_decode($buffer, true); |
|
749
|
749
|
if (isset($all_data['missions'])) { |
|
750
|
750
|
foreach ($all_data['missions'] as $mission) { |
|
751
|
751
|
$mission_user = $mission['usrname']; |
|
752
|
|
- $mission_name = iconv("utf-8", "utf-8//ignore",$mission['mistitle']); |
|
753
|
|
- if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
|
|
752
|
+ $mission_name = iconv("utf-8", "utf-8//ignore", $mission['mistitle']); |
|
|
753
|
+ if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) { |
|
754
|
754
|
$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
|
755
|
755
|
} else $bufferm = ''; |
|
756
|
756
|
if ($bufferm != '') { |
|
757
|
|
- $mission_data = json_decode($bufferm,true); |
|
|
757
|
+ $mission_data = json_decode($bufferm, true); |
|
758
|
758
|
if (isset($mission_data['leaderboard'][0]['results'])) { |
|
759
|
759
|
foreach ($mission_data['leaderboard'][0]['results'] as $sail) { |
|
760
|
760
|
//print_r($bufferm); |
|
@@ -771,10 +771,10 @@ discard block |
|
|
block discarded – undo |
|
771
|
771
|
$pos = $Common->convertDecLatLong($sail['pos']); |
|
772
|
772
|
$data['latitude'] = $pos['latitude']; |
|
773
|
773
|
$data['longitude'] = $pos['longitude']; |
|
774
|
|
- $resultdescr = explode(',',$sail['resultdescr']); |
|
775
|
|
- $data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*0.539957,2); |
|
776
|
|
- $data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1])); |
|
777
|
|
- $data['ident'] = trim( preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$sail['ubtname'])); |
|
|
774
|
+ $resultdescr = explode(',', $sail['resultdescr']); |
|
|
775
|
+ $data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*0.539957, 2); |
|
|
776
|
+ $data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1])); |
|
|
777
|
+ $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $sail['ubtname'])); |
|
778
|
778
|
$data['captain_id'] = $sail['usrnr']; |
|
779
|
779
|
$data['captain_name'] = $sail['usrname']; |
|
780
|
780
|
$data['race_id'] = $sail['misnr']; |
|
@@ -815,8 +815,8 @@ discard block |
|
|
block discarded – undo |
|
815
|
815
|
) { |
|
816
|
816
|
//$buffer = $Common->getData($hosts[$id]); |
|
817
|
817
|
$buffer = $Common->getData($value['host']); |
|
818
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
819
|
|
- $buffer = explode('\n',$buffer); |
|
|
818
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
819
|
+ $buffer = explode('\n', $buffer); |
|
820
|
820
|
$reset = 0; |
|
821
|
821
|
foreach ($buffer as $line) { |
|
822
|
822
|
if ($line != '') { |
|
@@ -827,7 +827,7 @@ discard block |
|
|
block discarded – undo |
|
827
|
827
|
else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
828
|
828
|
$data['pilot_id'] = $line[1]; |
|
829
|
829
|
$data['pilot_name'] = $line[2]; |
|
830
|
|
- $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
|
830
|
+ $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
831
|
831
|
$data['ident'] = $line[0]; // ident |
|
832
|
832
|
if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
833
|
833
|
$data['speed'] = $line[8]; // speed |
|
@@ -843,7 +843,7 @@ discard block |
|
|
block discarded – undo |
|
843
|
843
|
//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
|
844
|
844
|
//if (isset($line[37])) $data['last_update'] = $line[37]; |
|
845
|
845
|
$data['departure_airport_icao'] = $line[11]; |
|
846
|
|
- $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
|
846
|
+ $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
847
|
847
|
$data['arrival_airport_icao'] = $line[13]; |
|
848
|
848
|
$data['frequency'] = $line[4]; |
|
849
|
849
|
$data['type'] = $line[18]; |
|
@@ -852,7 +852,7 @@ discard block |
|
|
block discarded – undo |
|
852
|
852
|
$data['id_source'] = $id_source; |
|
853
|
853
|
//$data['arrival_airport_time'] = ; |
|
854
|
854
|
if ($line[9] != '') { |
|
855
|
|
- $aircraft_data = explode('/',$line[9]); |
|
|
855
|
+ $aircraft_data = explode('/', $line[9]); |
|
856
|
856
|
if (isset($aircraft_data[1])) { |
|
857
|
857
|
$data['aircraft_icao'] = $aircraft_data[1]; |
|
858
|
858
|
} |
|
@@ -867,9 +867,9 @@ discard block |
|
|
block discarded – undo |
|
867
|
867
|
if ($line[3] === 'PILOT') $SI->add($data); |
|
868
|
868
|
elseif ($line[3] === 'ATC') { |
|
869
|
869
|
//print_r($data); |
|
870
|
|
- $data['info'] = str_replace('^§','<br />',$data['info']); |
|
871
|
|
- $data['info'] = str_replace('&sect;','',$data['info']); |
|
872
|
|
- $typec = substr($data['ident'],-3); |
|
|
870
|
+ $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
|
871
|
+ $data['info'] = str_replace('&sect;', '', $data['info']); |
|
|
872
|
+ $typec = substr($data['ident'], -3); |
|
873
|
873
|
if ($typec === 'APP') $data['type'] = 'Approach'; |
|
874
|
874
|
elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
875
|
875
|
elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
@@ -881,8 +881,8 @@ discard block |
|
|
block discarded – undo |
|
881
|
881
|
elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
882
|
882
|
if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
883
|
883
|
if (isset($ATC)) { |
|
884
|
|
- 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']); |
|
885
|
|
- 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']); |
|
|
884
|
+ 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']); |
|
|
885
|
+ 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']); |
|
886
|
886
|
} |
|
887
|
887
|
} |
|
888
|
888
|
unset($data); |
|
@@ -898,24 +898,24 @@ discard block |
|
|
block discarded – undo |
|
898
|
898
|
(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
899
|
899
|
) |
|
900
|
900
|
) { |
|
901
|
|
- $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
|
901
|
+ $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
902
|
902
|
if ($buffer != '') { |
|
903
|
903
|
$all_data = simplexml_load_string($buffer); |
|
904
|
|
- foreach($all_data->children() as $childdata) { |
|
|
904
|
+ foreach ($all_data->children() as $childdata) { |
|
905
|
905
|
$data = array(); |
|
906
|
906
|
$line = $childdata; |
|
907
|
907
|
//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
|
908
|
|
- $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
909
|
|
- $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
910
|
|
- $data['latitude'] = (float)$line['pktLatitude']; |
|
911
|
|
- $data['longitude'] = (float)$line['pktLongitude']; |
|
912
|
|
- if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
913
|
|
- if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
914
|
|
- $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
|
908
|
+ $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
|
909
|
+ $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
|
910
|
+ $data['latitude'] = (float) $line['pktLatitude']; |
|
|
911
|
+ $data['longitude'] = (float) $line['pktLongitude']; |
|
|
912
|
+ if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
|
913
|
+ if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
|
914
|
+ $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
915
|
915
|
$data['altitude_relative'] = 'AMSL'; |
|
916
|
|
- $data['pilot_id'] = (int)$line['pktPilotID']; |
|
|
916
|
+ $data['pilot_id'] = (int) $line['pktPilotID']; |
|
917
|
917
|
$data['aircraft_icao'] = 'PARAGLIDER'; |
|
918
|
|
- $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
|
918
|
+ $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
919
|
919
|
if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
920
|
920
|
$data['format_source'] = $value['format']; |
|
921
|
921
|
$SI->add($data); |
|
@@ -923,22 +923,22 @@ discard block |
|
|
block discarded – undo |
|
923
|
923
|
} |
|
924
|
924
|
} |
|
925
|
925
|
$Source->deleteOldLocationByType('gs'); |
|
926
|
|
- $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
|
926
|
+ $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
927
|
927
|
if ($buffer != '') { |
|
928
|
928
|
$all_data = simplexml_load_string($buffer); |
|
929
|
|
- foreach($all_data->children() as $childdata) { |
|
|
929
|
+ foreach ($all_data->children() as $childdata) { |
|
930
|
930
|
$data = array(); |
|
931
|
931
|
$line = $childdata; |
|
932
|
|
- $data['id'] = (int)$line['gsID']; |
|
933
|
|
- $data['latitude'] = (float)$line['gsLatitude']; |
|
934
|
|
- $data['longitude'] = (float)$line['gsLongitude']; |
|
935
|
|
- $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
|
932
|
+ $data['id'] = (int) $line['gsID']; |
|
|
933
|
+ $data['latitude'] = (float) $line['gsLatitude']; |
|
|
934
|
+ $data['longitude'] = (float) $line['gsLongitude']; |
|
|
935
|
+ $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
936
|
936
|
$data['altitude_relative'] = 'AMSL'; |
|
937
|
|
- $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
|
937
|
+ $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
938
|
938
|
if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
|
939
|
|
- $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
|
939
|
+ $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
940
|
940
|
} else { |
|
941
|
|
- $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
|
941
|
+ $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
942
|
942
|
} |
|
943
|
943
|
unset($data); |
|
944
|
944
|
} |
|
@@ -956,9 +956,9 @@ discard block |
|
|
block discarded – undo |
|
956
|
956
|
(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
957
|
957
|
) |
|
958
|
958
|
) { |
|
959
|
|
- $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
|
959
|
+ $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
960
|
960
|
if ($buffer != '') { |
|
961
|
|
- $all_data = json_decode($buffer,true); |
|
|
961
|
+ $all_data = json_decode($buffer, true); |
|
962
|
962
|
if (isset($all_data['acList'])) { |
|
963
|
963
|
$reset = 0; |
|
964
|
964
|
foreach ($all_data['acList'] as $line) { |
|
@@ -974,7 +974,7 @@ discard block |
|
|
block discarded – undo |
|
974
|
974
|
if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
975
|
975
|
$data['emergency'] = ''; // emergency |
|
976
|
976
|
if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
977
|
|
- if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
|
977
|
+ if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
978
|
978
|
else $data['datetime'] = date('Y-m-d H:i:s'); |
|
979
|
979
|
//$data['datetime'] = date('Y-m-d H:i:s'); |
|
980
|
980
|
if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
@@ -999,7 +999,7 @@ discard block |
|
|
block discarded – undo |
|
999
|
999
|
$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1000
|
1000
|
$data['squawk'] = $line['squawk']; // squawk |
|
1001
|
1001
|
$data['emergency'] = ''; // emergency |
|
1002
|
|
- if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
|
1002
|
+ if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
1003
|
1003
|
else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1004
|
1004
|
$data['format_source'] = 'aircraftlistjson'; |
|
1005
|
1005
|
$data['id_source'] = $id_source; |
|
@@ -1020,7 +1020,7 @@ discard block |
|
|
block discarded – undo |
|
1020
|
1020
|
) |
|
1021
|
1021
|
) { |
|
1022
|
1022
|
$buffer = $Common->getData($value['host']); |
|
1023
|
|
- $all_data = json_decode($buffer,true); |
|
|
1023
|
+ $all_data = json_decode($buffer, true); |
|
1024
|
1024
|
if (isset($all_data['planes'])) { |
|
1025
|
1025
|
$reset = 0; |
|
1026
|
1026
|
foreach ($all_data['planes'] as $key => $line) { |
|
@@ -1037,12 +1037,12 @@ discard block |
|
|
block discarded – undo |
|
1037
|
1037
|
$data['emergency'] = ''; // emergency |
|
1038
|
1038
|
$data['registration'] = $line[2]; |
|
1039
|
1039
|
$data['aircraft_icao'] = $line[0]; |
|
1040
|
|
- $deparr = explode('-',$line[1]); |
|
|
1040
|
+ $deparr = explode('-', $line[1]); |
|
1041
|
1041
|
if (count($deparr) === 2) { |
|
1042
|
1042
|
$data['departure_airport_icao'] = $deparr[0]; |
|
1043
|
1043
|
$data['arrival_airport_icao'] = $deparr[1]; |
|
1044
|
1044
|
} |
|
1045
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
|
1045
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
1046
|
1046
|
$data['format_source'] = 'planeupdatefaa'; |
|
1047
|
1047
|
$data['id_source'] = $id_source; |
|
1048
|
1048
|
if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
@@ -1060,7 +1060,7 @@ discard block |
|
|
block discarded – undo |
|
1060
|
1060
|
) |
|
1061
|
1061
|
) { |
|
1062
|
1062
|
$buffer = $Common->getData($value['host']); |
|
1063
|
|
- $all_data = json_decode($buffer,true); |
|
|
1063
|
+ $all_data = json_decode($buffer, true); |
|
1064
|
1064
|
if (isset($all_data['states'])) { |
|
1065
|
1065
|
$reset = 0; |
|
1066
|
1066
|
foreach ($all_data['states'] as $key => $line) { |
|
@@ -1077,7 +1077,7 @@ discard block |
|
|
block discarded – undo |
|
1077
|
1077
|
//$data['emergency'] = ''; // emergency |
|
1078
|
1078
|
//$data['registration'] = $line[2]; |
|
1079
|
1079
|
//$data['aircraft_icao'] = $line[0]; |
|
1080
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
|
1080
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
1081
|
1081
|
$data['format_source'] = 'opensky'; |
|
1082
|
1082
|
$data['id_source'] = $id_source; |
|
1083
|
1083
|
if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
@@ -1094,8 +1094,8 @@ discard block |
|
|
block discarded – undo |
|
1094
|
1094
|
) |
|
1095
|
1095
|
) { |
|
1096
|
1096
|
$buffer = $Common->getData($value['host']); |
|
1097
|
|
- $all_data = json_decode($buffer,true); |
|
1098
|
|
- if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
|
1097
|
+ $all_data = json_decode($buffer, true); |
|
|
1098
|
+ if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) { |
|
1099
|
1099
|
$reset = 0; |
|
1100
|
1100
|
foreach ($all_data['aircraft'] as $key => $line) { |
|
1101
|
1101
|
$data = array(); |
|
@@ -1133,7 +1133,7 @@ discard block |
|
|
block discarded – undo |
|
1133
|
1133
|
) |
|
1134
|
1134
|
) { |
|
1135
|
1135
|
$buffer = $Common->getData($value['host']); |
|
1136
|
|
- $all_data = json_decode($buffer,true); |
|
|
1136
|
+ $all_data = json_decode($buffer, true); |
|
1137
|
1137
|
if (isset($all_data['aircraft'])) { |
|
1138
|
1138
|
$reset = 0; |
|
1139
|
1139
|
foreach ($all_data['aircraft'] as $key => $line) { |
|
@@ -1150,7 +1150,7 @@ discard block |
|
|
block discarded – undo |
|
1150
|
1150
|
//$data['emergency'] = ''; // emergency |
|
1151
|
1151
|
if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1152
|
1152
|
if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1153
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
|
1153
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']); |
|
1154
|
1154
|
$data['format_source'] = 'planefinderclient'; |
|
1155
|
1155
|
$data['id_source'] = $id_source; |
|
1156
|
1156
|
if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
@@ -1169,7 +1169,7 @@ discard block |
|
|
block discarded – undo |
|
1169
|
1169
|
) { |
|
1170
|
1170
|
//$buffer = $Common->getData($hosts[$id]); |
|
1171
|
1171
|
$buffer = $Common->getData($value['host']); |
|
1172
|
|
- $all_data = json_decode($buffer,true); |
|
|
1172
|
+ $all_data = json_decode($buffer, true); |
|
1173
|
1173
|
if (!empty($all_data)) $reset = 0; |
|
1174
|
1174
|
foreach ($all_data as $key => $line) { |
|
1175
|
1175
|
if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
|
@@ -1207,11 +1207,11 @@ discard block |
|
|
block discarded – undo |
|
1207
|
1207
|
) |
|
1208
|
1208
|
) { |
|
1209
|
1209
|
//$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1210
|
|
- $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
|
1210
|
+ $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1211
|
1211
|
//echo $buffer; |
|
1212
|
|
- $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1213
|
|
- $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1214
|
|
- $all_data = json_decode($buffer,true); |
|
|
1212
|
+ $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
|
1213
|
+ $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
|
1214
|
+ $all_data = json_decode($buffer, true); |
|
1215
|
1215
|
if (json_last_error() != JSON_ERROR_NONE) { |
|
1216
|
1216
|
die(json_last_error_msg()); |
|
1217
|
1217
|
} |
|
@@ -1234,7 +1234,7 @@ discard block |
|
|
block discarded – undo |
|
1234
|
1234
|
//$data['departure_airport_iata'] = $line[11]; |
|
1235
|
1235
|
//$data['arrival_airport_iata'] = $line[12]; |
|
1236
|
1236
|
//$data['emergency'] = ''; // emergency |
|
1237
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
|
1237
|
+ $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1238
|
1238
|
$data['format_source'] = 'radarvirtueljson'; |
|
1239
|
1239
|
$data['id_source'] = $id_source; |
|
1240
|
1240
|
if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
@@ -1255,14 +1255,14 @@ discard block |
|
|
block discarded – undo |
|
1255
|
1255
|
) { |
|
1256
|
1256
|
//$buffer = $Common->getData($hosts[$id]); |
|
1257
|
1257
|
$buffer = $Common->getData($value['host'].'?'.time()); |
|
1258
|
|
- $all_data = json_decode(utf8_encode($buffer),true); |
|
|
1258
|
+ $all_data = json_decode(utf8_encode($buffer), true); |
|
1259
|
1259
|
|
|
1260
|
1260
|
if (isset($all_data['pireps'])) { |
|
1261
|
1261
|
$reset = 0; |
|
1262
|
1262
|
foreach ($all_data['pireps'] as $line) { |
|
1263
|
1263
|
$data = array(); |
|
1264
|
1264
|
$data['id'] = $line['id']; |
|
1265
|
|
- $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
|
1265
|
+ $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1266
|
1266
|
$data['ident'] = $line['callsign']; // ident |
|
1267
|
1267
|
if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1268
|
1268
|
if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
@@ -1292,9 +1292,9 @@ discard block |
|
|
block discarded – undo |
|
1292
|
1292
|
$SI->add($data); |
|
1293
|
1293
|
// print_r($data); |
|
1294
|
1294
|
} elseif ($line['icon'] === 'ct') { |
|
1295
|
|
- $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1296
|
|
- $data['info'] = str_replace('&sect;','',$data['info']); |
|
1297
|
|
- $typec = substr($data['ident'],-3); |
|
|
1295
|
+ $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
|
1296
|
+ $data['info'] = str_replace('&sect;', '', $data['info']); |
|
|
1297
|
+ $typec = substr($data['ident'], -3); |
|
1298
|
1298
|
$data['type'] = ''; |
|
1299
|
1299
|
if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1300
|
1300
|
elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
@@ -1305,7 +1305,7 @@ discard block |
|
|
block discarded – undo |
|
1305
|
1305
|
elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1306
|
1306
|
elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1307
|
1307
|
else $data['type'] = 'Observer'; |
|
1308
|
|
- 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']); |
|
|
1308
|
+ 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']); |
|
1309
|
1309
|
} |
|
1310
|
1310
|
unset($data); |
|
1311
|
1311
|
} |
|
@@ -1322,14 +1322,14 @@ discard block |
|
|
block discarded – undo |
|
1322
|
1322
|
//$buffer = $Common->getData($hosts[$id]); |
|
1323
|
1323
|
if ($globalDebug) echo 'Get Data...'."\n"; |
|
1324
|
1324
|
$buffer = $Common->getData($value['host']); |
|
1325
|
|
- $all_data = json_decode($buffer,true); |
|
|
1325
|
+ $all_data = json_decode($buffer, true); |
|
1326
|
1326
|
if ($buffer != '' && is_array($all_data)) { |
|
1327
|
1327
|
$reset = 0; |
|
1328
|
1328
|
foreach ($all_data as $line) { |
|
1329
|
1329
|
$data = array(); |
|
1330
|
1330
|
//$data['id'] = $line['id']; // id not usable |
|
1331
|
1331
|
if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1332
|
|
- $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
|
1332
|
+ $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1333
|
1333
|
if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1334
|
1334
|
if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1335
|
1335
|
$data['ident'] = $line['flightnum']; // ident |
|
@@ -1344,7 +1344,7 @@ discard block |
|
|
block discarded – undo |
|
1344
|
1344
|
//$data['datetime'] = $line['lastupdate']; |
|
1345
|
1345
|
//$data['last_update'] = $line['lastupdate']; |
|
1346
|
1346
|
if (isset($value['timezone'])) { |
|
1347
|
|
- $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
|
1347
|
+ $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1348
|
1348
|
$datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1349
|
1349
|
$data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1350
|
1350
|
} else $data['datetime'] = date('Y-m-d H:i:s'); |
|
@@ -1360,14 +1360,14 @@ discard block |
|
|
block discarded – undo |
|
1360
|
1360
|
if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1361
|
1361
|
if (isset($line['aircraftname'])) { |
|
1362
|
1362
|
$line['aircraftname'] = strtoupper($line['aircraftname']); |
|
1363
|
|
- $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1364
|
|
- $aircraft_data = explode('-',$line['aircraftname']); |
|
|
1363
|
+ $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
|
1364
|
+ $aircraft_data = explode('-', $line['aircraftname']); |
|
1365
|
1365
|
if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1366
|
1366
|
elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1367
|
1367
|
else { |
|
1368
|
|
- $aircraft_data = explode(' ',$line['aircraftname']); |
|
1369
|
|
- if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1370
|
|
- else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
|
1368
|
+ $aircraft_data = explode(' ', $line['aircraftname']); |
|
|
1369
|
+ if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
|
1370
|
+ else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1371
|
1371
|
} |
|
1372
|
1372
|
} |
|
1373
|
1373
|
if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
@@ -1392,7 +1392,7 @@ discard block |
|
|
block discarded – undo |
|
1392
|
1392
|
//$buffer = $Common->getData($hosts[$id]); |
|
1393
|
1393
|
if ($globalDebug) echo 'Get Data...'."\n"; |
|
1394
|
1394
|
$buffer = $Common->getData($value['host']); |
|
1395
|
|
- $all_data = json_decode($buffer,true); |
|
|
1395
|
+ $all_data = json_decode($buffer, true); |
|
1396
|
1396
|
if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1397
|
1397
|
$reset = 0; |
|
1398
|
1398
|
foreach ($all_data['ACARSData'] as $line) { |
|
@@ -1403,7 +1403,7 @@ discard block |
|
|
block discarded – undo |
|
1403
|
1403
|
//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1404
|
1404
|
if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1405
|
1405
|
if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1406
|
|
- $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
|
1406
|
+ $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
1407
|
1407
|
if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1408
|
1408
|
$data['altitude'] = $line['altitude']; // altitude |
|
1409
|
1409
|
$data['speed'] = $line['groundspeed']; // speed |
|
@@ -1414,7 +1414,7 @@ discard block |
|
|
block discarded – undo |
|
1414
|
1414
|
//$data['squawk'] = ''; // squawk |
|
1415
|
1415
|
//$data['emergency'] = ''; // emergency |
|
1416
|
1416
|
if (isset($value['timezone'])) { |
|
1417
|
|
- $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
|
1417
|
+ $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
1418
|
1418
|
$datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1419
|
1419
|
$data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1420
|
1420
|
} else $data['datetime'] = date('Y-m-d H:i:s'); |
|
@@ -1450,14 +1450,14 @@ discard block |
|
|
block discarded – undo |
|
1450
|
1450
|
//$buffer = $Common->getData($hosts[$id]); |
|
1451
|
1451
|
if ($globalDebug) echo 'Get Data...'."\n"; |
|
1452
|
1452
|
$buffer = $Common->getData($value['host']); |
|
1453
|
|
- $all_data = json_decode($buffer,true); |
|
|
1453
|
+ $all_data = json_decode($buffer, true); |
|
1454
|
1454
|
if ($buffer != '' && is_array($all_data)) { |
|
1455
|
1455
|
$reset = 0; |
|
1456
|
1456
|
foreach ($all_data as $line) { |
|
1457
|
1457
|
$data = array(); |
|
1458
|
1458
|
//$data['id'] = $line['id']; // id not usable |
|
1459
|
1459
|
$data['id'] = trim($line['flight_id']); |
|
1460
|
|
- $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
|
1460
|
+ $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1461
|
1461
|
$data['pilot_name'] = $line['pilot_name']; |
|
1462
|
1462
|
$data['pilot_id'] = $line['pilot_id']; |
|
1463
|
1463
|
$data['ident'] = trim($line['callsign']); // ident |
|
@@ -1501,24 +1501,24 @@ 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 != '') { |
|
1506
|
1506
|
$Source->deleteLocationBySource('blitzortung'); |
|
1507
|
|
- $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1508
|
|
- $buffer = explode('\n',$buffer); |
|
|
1507
|
+ $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
|
1508
|
+ $buffer = explode('\n', $buffer); |
|
1509
|
1509
|
foreach ($buffer as $buffer_line) { |
|
1510
|
|
- $line = json_decode($buffer_line,true); |
|
|
1510
|
+ $line = json_decode($buffer_line, true); |
|
1511
|
1511
|
if (isset($line['time'])) { |
|
1512
|
1512
|
$data = array(); |
|
1513
|
1513
|
$data['altitude'] = $line['alt']; // altitude |
|
1514
|
1514
|
$data['latitude'] = $line['lat']; // lat |
|
1515
|
1515
|
$data['longitude'] = $line['lon']; // long |
|
1516
|
|
- $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
|
1516
|
+ $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1517
|
1517
|
$data['id_source'] = $id_source; |
|
1518
|
1518
|
$data['format_source'] = 'blitzortung'; |
|
1519
|
1519
|
$SI->add($data); |
|
1520
|
1520
|
if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1521
|
|
- $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
|
1521
|
+ $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1522
|
1522
|
unset($data); |
|
1523
|
1523
|
} |
|
1524
|
1524
|
} |
|
@@ -1541,11 +1541,11 @@ discard block |
|
|
block discarded – undo |
|
1541
|
1541
|
//$value = $formats[$nb]; |
|
1542
|
1542
|
$format = $globalSources[$nb]['format']; |
|
1543
|
1543
|
if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1544
|
|
- $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
|
1544
|
+ $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1545
|
1545
|
} elseif ($format === 'vrstcp') { |
|
1546
|
1546
|
$buffer = @socket_read($r, 6000); |
|
1547
|
1547
|
} else { |
|
1548
|
|
- $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
|
1548
|
+ $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1549
|
1549
|
} |
|
1550
|
1550
|
//$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1551
|
1551
|
//echo $buffer."\n"; |
|
@@ -1555,8 +1555,8 @@ discard block |
|
|
block discarded – undo |
|
1555
|
1555
|
//$SI::del(); |
|
1556
|
1556
|
if ($buffer !== FALSE) { |
|
1557
|
1557
|
if ($format === 'vrstcp') { |
|
1558
|
|
- $buffer = explode('},{',$buffer); |
|
1559
|
|
- } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
|
1558
|
+ $buffer = explode('},{', $buffer); |
|
|
1559
|
+ } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1560
|
1560
|
} |
|
1561
|
1561
|
// SBS format is CSV format |
|
1562
|
1562
|
if ($buffer !== FALSE && $buffer !== '') { |
|
@@ -1580,7 +1580,7 @@ discard block |
|
|
block discarded – undo |
|
1580
|
1580
|
$ais_data = $AIS->parse_line(trim($buffer)); |
|
1581
|
1581
|
$data = array(); |
|
1582
|
1582
|
if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1583
|
|
- if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
|
1583
|
+ if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
1584
|
1584
|
if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1585
|
1585
|
if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1586
|
1586
|
if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
@@ -1591,13 +1591,13 @@ discard block |
|
|
block discarded – undo |
|
1591
|
1591
|
if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1592
|
1592
|
if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1593
|
1593
|
if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1594
|
|
- if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
|
1594
|
+ if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1595
|
1595
|
if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1596
|
1596
|
if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1597
|
1597
|
if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1598
|
1598
|
|
|
1599
|
1599
|
if (isset($ais_data['timestamp'])) { |
|
1600
|
|
- $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
|
1600
|
+ $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1601
|
1601
|
} else { |
|
1602
|
1602
|
$data['datetime'] = date('Y-m-d H:i:s'); |
|
1603
|
1603
|
} |
|
@@ -1608,10 +1608,10 @@ discard block |
|
|
block discarded – undo |
|
1608
|
1608
|
} elseif ($format === 'flightgearsp') { |
|
1609
|
1609
|
//echo $buffer."\n"; |
|
1610
|
1610
|
if (strlen($buffer) > 5) { |
|
1611
|
|
- $line = explode(',',$buffer); |
|
|
1611
|
+ $line = explode(',', $buffer); |
|
1612
|
1612
|
$data = array(); |
|
1613
|
1613
|
//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
|
1614
|
|
- $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
|
1614
|
+ $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1615
|
1615
|
$data['ident'] = $line[6]; |
|
1616
|
1616
|
$data['aircraft_name'] = $line[7]; |
|
1617
|
1617
|
$data['longitude'] = $line[1]; |
|
@@ -1628,16 +1628,16 @@ discard block |
|
|
block discarded – undo |
|
1628
|
1628
|
} elseif ($format === 'acars') { |
|
1629
|
1629
|
if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1630
|
1630
|
$ACARS->add(trim($buffer)); |
|
1631
|
|
- socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
|
1631
|
+ socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1632
|
1632
|
$ACARS->deleteLiveAcarsData(); |
|
1633
|
1633
|
} elseif ($format === 'flightgearmp') { |
|
1634
|
|
- if (substr($buffer,0,1) != '#') { |
|
|
1634
|
+ if (substr($buffer, 0, 1) != '#') { |
|
1635
|
1635
|
$data = array(); |
|
1636
|
1636
|
//echo $buffer."\n"; |
|
1637
|
|
- $line = explode(' ',$buffer); |
|
|
1637
|
+ $line = explode(' ', $buffer); |
|
1638
|
1638
|
if (count($line) === 11) { |
|
1639
|
|
- $userserver = explode('@',$line[0]); |
|
1640
|
|
- $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
|
1639
|
+ $userserver = explode('@', $line[0]); |
|
|
1640
|
+ $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1641
|
1641
|
$data['ident'] = $userserver[0]; |
|
1642
|
1642
|
$data['registration'] = $userserver[0]; |
|
1643
|
1643
|
$data['latitude'] = $line[4]; |
|
@@ -1645,8 +1645,8 @@ discard block |
|
|
block discarded – undo |
|
1645
|
1645
|
$data['altitude'] = $line[6]; |
|
1646
|
1646
|
$data['datetime'] = date('Y-m-d H:i:s'); |
|
1647
|
1647
|
$aircraft_type = $line[10]; |
|
1648
|
|
- $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1649
|
|
- $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
|
1648
|
+ $aircraft_type = preg_split(':/:', $aircraft_type); |
|
|
1649
|
+ $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1650
|
1650
|
if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1651
|
1651
|
if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1652
|
1652
|
} |
|
@@ -1655,8 +1655,8 @@ discard block |
|
|
block discarded – undo |
|
1655
|
1655
|
echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1656
|
1656
|
die; |
|
1657
|
1657
|
} elseif ($format === 'vrstcp') { |
|
1658
|
|
- foreach($buffer as $all_data) { |
|
1659
|
|
- $line = json_decode('{'.$all_data.'}',true); |
|
|
1658
|
+ foreach ($buffer as $all_data) { |
|
|
1659
|
+ $line = json_decode('{'.$all_data.'}', true); |
|
1660
|
1660
|
$data = array(); |
|
1661
|
1661
|
if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1662
|
1662
|
if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
@@ -1682,16 +1682,16 @@ discard block |
|
|
block discarded – undo |
|
1682
|
1682
|
if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1683
|
1683
|
unset($data); |
|
1684
|
1684
|
} |
|
1685
|
|
- } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
|
|
1685
|
+ } elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') { |
|
1686
|
1686
|
$line = explode("\t", $buffer); |
|
1687
|
|
- for($k = 0; $k < count($line); $k=$k+2) { |
|
|
1687
|
+ for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1688
|
1688
|
$key = $line[$k]; |
|
1689
|
|
- $lined[$key] = $line[$k+1]; |
|
|
1689
|
+ $lined[$key] = $line[$k + 1]; |
|
1690
|
1690
|
} |
|
1691
|
1691
|
if (count($lined) > 3) { |
|
1692
|
1692
|
$data['hex'] = $lined['hexid']; |
|
1693
|
1693
|
//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1694
|
|
- $data['datetime'] = date('Y-m-d H:i:s');; |
|
|
1694
|
+ $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1695
|
1695
|
if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1696
|
1696
|
if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1697
|
1697
|
if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
@@ -1710,23 +1710,23 @@ discard block |
|
|
block discarded – undo |
|
1710
|
1710
|
} else $error = true; |
|
1711
|
1711
|
} elseif ($format === 'aprs' && $use_aprs) { |
|
1712
|
1712
|
if ($aprs_connect === 0) { |
|
1713
|
|
- $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
|
1713
|
+ $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1714
|
1714
|
$aprs_connect = 1; |
|
1715
|
1715
|
} |
|
1716
|
1716
|
|
|
1717
|
|
- if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
|
1717
|
+ if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1718
|
1718
|
$aprs_last_tx = time(); |
|
1719
|
1719
|
$data_aprs = "# Keep alive"; |
|
1720
|
|
- $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
|
1720
|
+ $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1721
|
1721
|
} |
|
1722
|
1722
|
|
|
1723
|
1723
|
//echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1724
|
1724
|
//echo 'APRS data : '.$buffer."\n"; |
|
1725
|
|
- $buffer = str_replace('APRS <- ','',$buffer); |
|
1726
|
|
- $buffer = str_replace('APRS -> ','',$buffer); |
|
|
1725
|
+ $buffer = str_replace('APRS <- ', '', $buffer); |
|
|
1726
|
+ $buffer = str_replace('APRS -> ', '', $buffer); |
|
1727
|
1727
|
//echo $buffer."\n"; |
|
1728
|
1728
|
date_default_timezone_set('UTC'); |
|
1729
|
|
- if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
|
1729
|
+ if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1730
|
1730
|
$line = $APRS->parse($buffer); |
|
1731
|
1731
|
//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
|
1732
|
1732
|
if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
|
@@ -1741,7 +1741,7 @@ discard block |
|
|
block discarded – undo |
|
1741
|
1741
|
if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1742
|
1742
|
if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1743
|
1743
|
if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1744
|
|
- if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
|
1744
|
+ if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1745
|
1745
|
else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1746
|
1746
|
//$data['datetime'] = date('Y-m-d H:i:s'); |
|
1747
|
1747
|
if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
@@ -1829,29 +1829,29 @@ discard block |
|
|
block discarded – undo |
|
1829
|
1829
|
} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1830
|
1830
|
if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
1831
|
1831
|
$Source->deleteOldLocationByType('gs'); |
|
1832
|
|
- if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1833
|
|
- $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
|
1832
|
+ if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
|
1833
|
+ $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1834
|
1834
|
} else { |
|
1835
|
|
- $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
|
1835
|
+ $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1836
|
1836
|
} |
|
1837
|
1837
|
} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1838
|
1838
|
//if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
|
1839
|
1839
|
if ($globalDebug) echo '# Weather Station added'."\n"; |
|
1840
|
1840
|
$Source->deleteOldLocationByType('wx'); |
|
1841
|
1841
|
$weather_data = json_encode($line); |
|
1842
|
|
- if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1843
|
|
- $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
|
1842
|
+ if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
|
1843
|
+ $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1844
|
1844
|
} else { |
|
1845
|
|
- $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
|
1845
|
+ $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1846
|
1846
|
} |
|
1847
|
1847
|
} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1848
|
1848
|
//if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
|
1849
|
1849
|
if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1850
|
1850
|
$Source->deleteOldLocationByType('lightning'); |
|
1851
|
|
- if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
1852
|
|
- $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
|
1851
|
+ if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
|
1852
|
+ $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1853
|
1853
|
} else { |
|
1854
|
|
- $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
|
1854
|
+ $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1855
|
1855
|
} |
|
1856
|
1856
|
} elseif ($globalDebug) { |
|
1857
|
1857
|
echo '/!\ Not added: '.$buffer."\n"; |
|
@@ -1860,7 +1860,7 @@ discard block |
|
|
block discarded – undo |
|
1860
|
1860
|
unset($data); |
|
1861
|
1861
|
} |
|
1862
|
1862
|
elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1863
|
|
- $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
|
1863
|
+ $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1864
|
1864
|
} |
|
1865
|
1865
|
/* |
|
1866
|
1866
|
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')) { |
|
@@ -1869,7 +1869,7 @@ discard block |
|
|
block discarded – undo |
|
1869
|
1869
|
*/ |
|
1870
|
1870
|
//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
|
1871
|
1871
|
elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
1872
|
|
- if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
|
1872
|
+ if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1873
|
1873
|
$Source->deleteOldLocationByType('lightning'); |
|
1874
|
1874
|
$Source->deleteOldLocationByType('wx'); |
|
1875
|
1875
|
$globalSources[$nb]['last_weather_clean'] = time(); |
|
@@ -1955,7 +1955,7 @@ discard block |
|
|
block discarded – undo |
|
1955
|
1955
|
connect_all($sourceee); |
|
1956
|
1956
|
$sourceee = array(); |
|
1957
|
1957
|
//connect_all($globalSources); |
|
1958
|
|
- $tt[$format]=0; |
|
|
1958
|
+ $tt[$format] = 0; |
|
1959
|
1959
|
break; |
|
1960
|
1960
|
} |
|
1961
|
1961
|
//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
@@ -1965,14 +1965,14 @@ discard block |
|
|
block discarded – undo |
|
1965
|
1965
|
} else { |
|
1966
|
1966
|
$error = socket_strerror(socket_last_error()); |
|
1967
|
1967
|
if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
|
1968
|
|
- if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
|
1968
|
+ if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1969
|
1969
|
if (isset($globalDebug)) echo "Restarting...\n"; |
|
1970
|
1970
|
// Restart the script if possible |
|
1971
|
1971
|
if (is_array($sockets)) { |
|
1972
|
1972
|
if ($globalDebug) echo "Shutdown all sockets..."; |
|
1973
|
1973
|
|
|
1974
|
1974
|
foreach ($sockets as $sock) { |
|
1975
|
|
- @socket_shutdown($sock,2); |
|
|
1975
|
+ @socket_shutdown($sock, 2); |
|
1976
|
1976
|
@socket_close($sock); |
|
1977
|
1977
|
} |
|
1978
|
1978
|
|