欢迎注册
微信
  • 微信注册
  • 邮箱注册
nt(*) from " . $GLOBALS['yp']->table('users') . " where user_name = '$username'"; $count = $GLOBALS['db']->getOne($sql); if($count > 0) { return generate_username_by_mobile(); } return $username; } /** * 根据邮箱地址生成用户名 * * @param number $length * @return number */ function generate_username () { $username = 'u'.rand_number(3); $charts = "ABCDEFGHJKLMNPQRSTUVWXYZ"; $max = strlen($charts); for($i = 0; $i < 4; $i ++) { $username .= $charts[mt_rand(0, $max)]; } $username .= rand_number(4); $sql = "select count(*) from " . $GLOBALS['yp']->table('users') . " where user_name = '$username'"; $count = $GLOBALS['db']->getOne($sql); if($count > 0) { return generate_username(); } return $username; } ?>