mirror of
https://github.com/v2board/v2board.git
synced 2025-03-13 22:24:46 +08:00
修正统计在线数时导致记录错误日志的BUG
This commit is contained in:
parent
98990f841f
commit
6f85cb0207
@ -90,15 +90,18 @@ class UniProxyController extends Controller
|
|||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($data as $nodeid => $ips) {
|
foreach ($data as $uid => $ips) {
|
||||||
$updateAt = time();
|
$updateAt = time();
|
||||||
$oldips_array = Cache::get('ALIVE_IP_USER_'. $nodeid) ?? [];
|
$oldips_array = Cache::get('ALIVE_IP_USER_'. $uid) ?? [];
|
||||||
|
|
||||||
// 更新节点数据
|
// 更新节点数据
|
||||||
$oldips_array[$this->nodeType . $this->nodeId] = ['aliveips' => $ips, 'lastupdateAt' => $updateAt];
|
$oldips_array[$this->nodeType . $this->nodeId] = ['aliveips' => $ips, 'lastupdateAt' => $updateAt];
|
||||||
// 删除过期节点在线数据
|
// 删除过期节点在线数据
|
||||||
$expired_array = [];
|
$expired_array = [];
|
||||||
foreach($oldips_array as $nodetypeid => $oldips) {
|
foreach($oldips_array as $nodetypeid => $oldips) {
|
||||||
|
if (is_int($oldips)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ($updateAt - $oldips['lastupdateAt'] > 120){
|
if ($updateAt - $oldips['lastupdateAt'] > 120){
|
||||||
$expired_array[$nodetypeid] = '';
|
$expired_array[$nodetypeid] = '';
|
||||||
}
|
}
|
||||||
@ -107,12 +110,15 @@ class UniProxyController extends Controller
|
|||||||
$new_array = array_diff_key($oldips_array, $expired_array);
|
$new_array = array_diff_key($oldips_array, $expired_array);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach($new_array as $nodetypeid => $newdata) {
|
foreach($new_array as $nodetypeid => $newdata) {
|
||||||
|
if (is_int($newdata)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
foreach($newdata['aliveips'] as $newip) {
|
foreach($newdata['aliveips'] as $newip) {
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$new_array['alive_ip'] = $count;
|
$new_array['alive_ip'] = $count;
|
||||||
Cache::put('ALIVE_IP_USER_'. $nodeid, $new_array, 120);
|
Cache::put('ALIVE_IP_USER_'. $uid, $new_array, 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response([
|
return response([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user