From 8702d87819f1d7c0b812fb23f148845d5f744734 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 29 Sep 2019 11:31:51 +0800 Subject: [PATCH] sdk chinaChar --- Application/Admin/Model/UserModel.class.php | 2 +- Application/Sdk/Common/function.php | 33 ++++++++++++++++++++ Application/Sdk/SecretKey/Data/chinaChar.txt | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Application/Sdk/SecretKey/Data/chinaChar.txt diff --git a/Application/Admin/Model/UserModel.class.php b/Application/Admin/Model/UserModel.class.php index 27b11617a..30b29906f 100644 --- a/Application/Admin/Model/UserModel.class.php +++ b/Application/Admin/Model/UserModel.class.php @@ -374,7 +374,7 @@ class UserModel extends Model{ $data = array( 'account' => $account, 'password' => $password, - 'nickname' => $account, + 'nickname' => getChinaChar(rand(2,4)), 'phone' => $phone, 'head_img' =>'', 'promote_id' => $promote_id, diff --git a/Application/Sdk/Common/function.php b/Application/Sdk/Common/function.php index 66fd23858..f1931af0f 100644 --- a/Application/Sdk/Common/function.php +++ b/Application/Sdk/Common/function.php @@ -191,3 +191,36 @@ function get_game_param($game_id,$field="",$type=''){ } return $find; } +/** + * 生成随机汉字字符串 + * @param $num 数量 + * @return [type] [description] + */ + +function getChinaChar($num) +{ + // $string = ''; + // for ($i=0; $i<$num; $i++) { + // // 使用chr()函数拼接双字节汉字,前一个chr()为高位字节,后一个为低位字节 + // $a = chr(mt_rand(0xB0,0xD0)).chr(mt_rand(0xA1, 0xF0)); + // // 转码 + // $string .= iconv('GB2312', 'UTF-8', $a); + // } + // return $string; + $char = file_get_contents(APP_PATH.'Sdk/SecretKey/Data/chinaChar.txt'); + $str = ''; + $length = strlen($char); + for($i = 0;$i < $num;$i++) + { + $rand = rand(0,$length); + for(;$rand >= 0;$rand--) + { + if($rand == 0 || $rand %3 ==0) + { + break; + } + } + $str = $str . substr($char,$rand,3); + } + return $str; +} diff --git a/Application/Sdk/SecretKey/Data/chinaChar.txt b/Application/Sdk/SecretKey/Data/chinaChar.txt new file mode 100644 index 000000000..cad57c0bf --- /dev/null +++ b/Application/Sdk/SecretKey/Data/chinaChar.txt @@ -0,0 +1 @@ +的一了是我不在人们有来他这上着个地到大里说去子得也和那要下看天时过出小么起你都把好还多没为又可家学只以主会样年想能生同老中从自面前头到它后然走很像见两用她国动进成回什边作对开而已些现山民候经发工向事命给长水几义三声于高正妈手知理眼志点心战二问但身方实吃做叫当住听革打呢真党全才四已所敌之最光产情路分总条白话东席次亲如被花口放儿常西气五第使写军吧文运在果怎定许快明行因别飞外树物活部门无往船望新带队先力完间却站代员机更九您每风级跟笑啊孩万少直意夜比阶连车重便斗马哪化太指变社似士者干石满决百原拿群究各六本思解立河爸村八难早论吗根共让相研今其书坐接应关信觉死步反处记将千找争领或师结块跑谁草越字加脚紧爱等习阵怕月青半火法题建赶位唱海七女任件感准张团屋爷离色脸片科倒睛利世病刚且由送切星晚表够整认响雪流未场该并底深刻平伟忙提确近亮轻讲农古黑告界拉名呀土清阳照办史改历转画造嘴此治北必服雨穿父内识验传业菜爬睡兴 \ No newline at end of file