//检测会员名是否有效 private bool CheckUserName(string uname, ref string err) { if (string.IsNullOrEmpty(uname)) { return(false); } uname = uname.Replace(" ", ""); if (SiteConfig.UserConfig.UserNameLimit > uname.Length || uname.Length > SiteConfig.UserConfig.UserNameMax) { err = "用户名的长度必须小于" + SiteConfig.UserConfig.UserNameMax + ",并大于" + SiteConfig.UserConfig.UserNameLimit + "!"; return(false); } else if (ZoomlaSecurityCenter.CheckData(uname)) { err = "用户名不能包含特殊字段!"; return(false); } else if (!SafeSC.CheckUName(uname)) { err = "用户名不能包含特殊字符!"; return(false); } if (StringHelper.FoundInArr(SiteConfig.UserConfig.UserNameRegDisabled, uname, "|")) { err = "该用户名禁止注册,请输入不同的用户名!"; return(false); } if (buser.IsExistUName(uname)) { err = "该用户名已被他人占用,请输入不同的用户名"; return(false); } string userregrule = SiteConfig.UserConfig.RegRule; if (userregrule != null && userregrule != "") { if (userregrule.IndexOf(',') > -1) { string[] rulearr = userregrule.Split(','); for (int ii = 0; ii < rulearr.Length; ii++) { if (rulearr[ii].ToString() == "1") { string resultString = null; try { resultString = Regex.Match(uname, @"[0-9]*").Value; } catch (ArgumentException) { } if (uname == resultString.Trim()) { err = "用户名不允许纯数字"; return(false); } } if (rulearr[ii].ToString() == "2") { string resultString = null; try { resultString = Regex.Match(uname, @"[a-zA-Z]*").Value; } catch (ArgumentException) { } if (uname == resultString) { err = "用户名不允许纯英文"; return(false); } } if (rulearr[ii].ToString() == "3") { bool foundMatch = false; try { foundMatch = Regex.IsMatch(uname, @"[\u0391-\uFFE5]$"); } catch (ArgumentException) { } if (foundMatch) { err = "用户名不允许带有中文"; return(false); } } } } else { if (userregrule.ToString() == "1") { string resultString = null; try { resultString = Regex.Match(uname, @"[0-9]*").Value; } catch (ArgumentException) { } if (uname == resultString.Trim()) { err = "用户名不允许纯数字"; return(false); } } if (userregrule.ToString() == "2") { string resultString = null; try { resultString = Regex.Match(uname, @"[a-zA-Z]*").Value; } catch (ArgumentException) { } if (uname == resultString) { err = "用户名不允许纯英文"; return(false); } } if (userregrule.ToString() == "3") { bool foundMatch = false; try { foundMatch = Regex.IsMatch(uname, @"[\u0391-\uFFE5]$"); } catch (ArgumentException) { } if (foundMatch) { err = "用户名不允许带有中文"; return(false); } } } } return(true); }