From 4b285af104bccc99053642a29827279364540804 Mon Sep 17 00:00:00 2001 From: zhanggucheng Date: Thu, 13 Jan 2022 09:41:34 +0800 Subject: [PATCH] * --- .../TestingResourceRepository.class.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Application/Base/Repository/TestingResourceRepository.class.php b/Application/Base/Repository/TestingResourceRepository.class.php index d0cb05e44..98b2f45cc 100644 --- a/Application/Base/Repository/TestingResourceRepository.class.php +++ b/Application/Base/Repository/TestingResourceRepository.class.php @@ -482,6 +482,22 @@ class TestingResourceRepository ]; } + private function encodeStr($str) + { + # 判断字符串长度 + $length = strlen($str); + if ($length == 1) { + # 长度为 1 前后拼接 * 号 + $newStr = $str.'*'.rand(1,6); + }else{ + # 长度超过1随机插入 * 号 + $newStr = substr_replace($str,str_repeat('*',$length/2),ceil($length/2),$length).mb_substr($str,$length-2,$length,"utf-8"); + // str_repeat('*',$length/2) 星号重复字符长度的一半长度 + // ceil($length/2) 算出从第几个字符开始 + } + return $newStr; + } + public function makeTestingRoleRecords($roles) { $result = $this->statByRoles($roles); @@ -553,11 +569,11 @@ class TestingResourceRepository 'server_name' => $role['server_name'], 'server_id' => $role['server_id'], 'role_id' => $role['role_id'], - 'user_account' => $role['user_account'], + 'user_account' => $this->encodeStr($role['user_account']), 'user_phone' => $user ? $user['phone'] : '', 'role_name' => $role['role_name'], 'binding_id' => $binding ? $binding['id'] : 0, - 'bind_user_account' => $bindingRole ? $bindingRole['user_account'] : '', + 'bind_user_account' => $bindingRole ? $this->encodeStr($bindingRole['user_account']) : '', 'bind_role_name' => $bindingRole ? $bindingRole['role_name'] : '', 'base_quota' => $gameSetting ? $gameSetting['base_quota'] : 0, 'other_quota' => intval($role['testing_other_quota']),