update: standard

This commit is contained in:
v2board
2023-01-28 22:42:05 +08:00
parent 7c4f206819
commit 2c9f45a193

View File

@ -18,21 +18,21 @@ class ServerService
public function getAvailableV2ray(User $user):array public function getAvailableV2ray(User $user):array
{ {
$servers = []; $servers = [];
$model = ServerV2ray::orderBy('sort', 'ASC') $model = ServerV2ray::orderBy('sort', 'ASC');
->where('show', 1);
$v2ray = $model->get(); $v2ray = $model->get();
for ($i = 0; $i < count($v2ray); $i++) { foreach ($v2ray as $key => $v) {
$v2ray[$i]['type'] = 'v2ray'; if (!$v['show']) continue;
if (!in_array($user->group_id, $v2ray[$i]['group_id'])) continue; $v2ray[$key]['type'] = 'v2ray';
if (strpos($v2ray[$i]['port'], '-') !== false) { if (!in_array($user->group_id, $v2ray[$key]['group_id'])) continue;
$v2ray[$i]['port'] = Helper::randomPort($v2ray[$i]['port']); if (strpos($v2ray[$key]['port'], '-') !== false) {
$v2ray[$key]['port'] = Helper::randomPort($v2ray[$key]['port']);
} }
if ($v2ray[$i]['parent_id']) { if ($v2ray[$key]['parent_id']) {
$v2ray[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$i]['parent_id'])); $v2ray[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$key]['parent_id']));
} else { } else {
$v2ray[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$i]['id'])); $v2ray[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$key]['id']));
} }
$servers[] = $v2ray[$i]->toArray(); $servers[] = $v2ray[$key]->toArray();
} }
@ -42,21 +42,21 @@ class ServerService
public function getAvailableTrojan(User $user):array public function getAvailableTrojan(User $user):array
{ {
$servers = []; $servers = [];
$model = ServerTrojan::orderBy('sort', 'ASC') $model = ServerTrojan::orderBy('sort', 'ASC');
->where('show', 1);
$trojan = $model->get(); $trojan = $model->get();
for ($i = 0; $i < count($trojan); $i++) { foreach ($trojan as $key => $v) {
$trojan[$i]['type'] = 'trojan'; if (!$v['show']) continue;
if (!in_array($user->group_id, $trojan[$i]['group_id'])) continue; $trojan[$key]['type'] = 'trojan';
if (strpos($trojan[$i]['port'], '-') !== false) { if (!in_array($user->group_id, $trojan[$key]['group_id'])) continue;
$trojan[$i]['port'] = Helper::randomPort($trojan[$i]['port']); if (strpos($trojan[$key]['port'], '-') !== false) {
$trojan[$key]['port'] = Helper::randomPort($trojan[$key]['port']);
} }
if ($trojan[$i]['parent_id']) { if ($trojan[$key]['parent_id']) {
$trojan[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $trojan[$i]['parent_id'])); $trojan[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $trojan[$key]['parent_id']));
} else { } else {
$trojan[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $trojan[$i]['id'])); $trojan[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $trojan[$key]['id']));
} }
$servers[] = $trojan[$i]->toArray(); $servers[] = $trojan[$key]->toArray();
} }
return $servers; return $servers;
} }
@ -64,10 +64,10 @@ class ServerService
public function getAvailableShadowsocks(User $user) public function getAvailableShadowsocks(User $user)
{ {
$servers = []; $servers = [];
$model = ServerShadowsocks::orderBy('sort', 'ASC') $model = ServerShadowsocks::orderBy('sort', 'ASC');
->where('show', 1);
$shadowsocks = $model->get()->keyBy('id'); $shadowsocks = $model->get()->keyBy('id');
foreach ($shadowsocks as $key => $v) { foreach ($shadowsocks as $key => $v) {
if (!$v['show']) continue;
$shadowsocks[$key]['type'] = 'shadowsocks'; $shadowsocks[$key]['type'] = 'shadowsocks';
$shadowsocks[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $v['id'])); $shadowsocks[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $v['id']));
if (!in_array($user->group_id, $v['group_id'])) continue; if (!in_array($user->group_id, $v['group_id'])) continue;