public static bool PageValidateEmail(string email, bool checkVerifyRegister, out string errorMessage) { if (string.IsNullOrEmpty(email)) { errorMessage = "Email不能为空"; return(false); } if (!Utils.IsValidEmail(email)) { errorMessage = "Email格式不正确"; return(false); } if (!Users.ValidateEmail(email)) { errorMessage = "Email: \"" + email + "\" 已经被其它用户注册使用"; return(false); } if (checkVerifyRegister) { //var vi = Users.GetVerifyRegisterInfoByEmail(email); var vi = VerifyReg.FindByEmail(email); if (vi != null && vi.CreateTime > DateTime.Now.AddMinutes(-5.0)) { errorMessage = "Email:\"" + email + "\" 在五分钟内已经发送过一次注册请求,请耐心等待"; return(false); } } var config = GeneralConfigInfo.Current; string emailHostName = Utils.GetEmailHostName(email); if (!config.Accessemail.IsNullOrEmpty() && !Utils.InArray(emailHostName, config.Accessemail.Replace("\r\n", "\n"), "\n")) { errorMessage = "Email: \"" + email + "\" 不在本论坛允许范围之类, 本论坛只允许用户使用这些Email地址注册: " + config.Accessemail.Replace("\n", ",").Replace("\r", ""); return(false); } if (!config.Censoremail.IsNullOrEmpty() && Utils.InArray(emailHostName, config.Censoremail.Replace("\r\n", "\n"), "\n")) { errorMessage = "Email: \"" + email + "\" 不允许在本论坛使用, 本论坛不允许用户使用的Email地址包括: " + config.Censoremail.Replace("\n", ",").Replace("\r", ""); return(false); } errorMessage = ""; return(true); }
public static VerifyReg CreateVerifyRegisterInfo(string email, string inviteCode) { if (!Utils.IsValidEmail(email)) { return(null); } var vi = new VerifyReg(); vi.IP = WebHelper.UserHost; vi.Email = email; vi.CreateTime = DateTime.Now; vi.ExpireTime = DateTime.Now.AddDays(GeneralConfigInfo.Current.Verifyregisterexpired); vi.InviteCode = inviteCode; vi.VerifyCode = ForumUtils.CreateAuthStr(16); //if (BBX.Data.Users.CreateVerifyRegisterInfo(vi) <= 0) //{ // return null; //} return(vi); }
protected override void ShowPage() { this.pagetitle = "用户注册"; if (this.userid > 0) { base.SetUrl(BaseConfigs.GetForumPath); base.SetMetaRefresh(); base.SetShowBackLink(false); base.AddMsgLine("不能重复注册用户"); this.ispost = true; return; } if (this.config.Regstatus < 1) { base.AddErrLine("论坛当前禁止新用户注册"); return; } if (string.IsNullOrEmpty(this.action)) { this.action = ((this.config.Rules == 1 && this.infloat == 0) ? "rules" : ((this.config.Regverify == 1) ? "verify" : "reg")); } else { if (!Utils.InArray(this.action, "rules,verify,reg")) { base.AddErrLine("参数错误"); return; } if (this.action == "rules" && (this.config.Rules == 0 || this.infloat == 1)) { this.action = ((this.config.Regverify == 1) ? "verify" : "reg"); } } string text = Users.CheckRegisterDateDiff(WebHelper.UserHost); if (text != null) { base.AddErrLine(text); return; } if (this.action == "verify" && this.config.Regverify == 1 && this.config.Regctrl > 0) { //var vi = Users.GetVerifyRegisterInfoByIp(WebHelper.UserHost); var vi = VerifyReg.FindByIP(WebHelper.UserHost); if (vi != null) { var ts = vi.CreateTime.AddHours(config.Regctrl) - DateTime.Now; //int num = Utils.StrDateDiffHours(vi.CreateTime, this.config.Regctrl); var num = ts.TotalHours; if (num == 0) { base.AddErrLine("抱歉, 系统设置了IP注册间隔限制, 您必须在 " + ts.TotalMinutes + " 分钟后才可以提交请求"); return; } if (num < 0) { base.AddErrLine("抱歉, 系统设置了IP注册间隔限制, 您必须在 " + num * -1 + " 小时后才可以提交请求"); return; } } } if (this.action == "reg" && this.config.Regverify == 1) { //this.verifyinfo = Users.GetVerifyRegisterInfo(this.verifycode); this.verifyinfo = VerifyReg.FindByVerifyCode(this.verifycode); if (verifyinfo == null || (verifyinfo.CreateTime != verifyinfo.ExpireTime && verifyinfo.ExpireTime < DateTime.Now)) { base.AddErrLine("该注册链接不存在或已过期,请点击注册重新获取链接"); return; } this.invitecode = this.verifyinfo.InviteCode; } this.allowinvite = Utils.InArray(this.config.Regstatus.ToString(), "2,3"); string a; if (this.ispost && (a = this.action) != null) { if (a == "rules") { this.action = (string.IsNullOrEmpty(this.agree) ? this.action : ((this.config.Regverify == 1) ? "verify" : "reg")); this.ispost = false; return; } if (a == "verify") { this.SendRegisterVerifyLink(); return; } if (!(a == "reg")) { return; } if (this.createuser == 1) { this.Register(); } } }