protected override void ShowPage() { pagetitle = "用户注册"; if (userid > 0) { SetUrl(BaseConfigs.GetForumPath); SetMetaRefresh(); SetShowBackLink(false); AddMsgLine("不能重复注册用户"); ispost = true; return; } if (config.Regstatus < 1) { AddErrLine("论坛当前禁止新用户注册"); return; } #region action set if (string.IsNullOrEmpty(action)) { action = config.Rules == 1 && infloat == 0 ? "rules" : (config.Regverify == 1 ? "verify" : "reg"); } else if (Utils.InArray(action, "rules,verify,reg")) { if (action == "rules" && (config.Rules == 0 || infloat == 1)) action = config.Regverify == 1 ? "verify" : "reg"; } else { AddErrLine("参数错误"); return; } #endregion #region IP check string msg = Users.CheckRegisterDateDiff(DNTRequest.GetIP()); if (msg != null) { AddErrLine(msg); return; } if (action == "verify" && config.Regverify == 1 && config.Regctrl > 0) { VerifyRegisterInfo tmpVerifyInfo = Users.GetVerifyRegisterInfoByIp(DNTRequest.GetIP()); if (tmpVerifyInfo != null) { int interval = Utils.StrDateDiffHours(tmpVerifyInfo.CreateTime, config.Regctrl); if (interval == 0) { AddErrLine("抱歉, 系统设置了IP注册间隔限制, 您必须在 " + (Utils.StrDateDiffMinutes(tmpVerifyInfo.CreateTime, config.Regctrl * 60) * -1) + " 分钟后才可以提交请求"); return; } else if (interval < 0) { AddErrLine("抱歉, 系统设置了IP注册间隔限制, 您必须在 " + (interval * -1) + " 小时后才可以提交请求"); return; } } } #endregion //如果开启了Email验证注册且action是注册(通过注册链接进入) if (action == "reg" && config.Regverify == 1) { verifyinfo = Users.GetVerifyRegisterInfo(verifycode); if (verifyinfo == null || (verifyinfo.CreateTime != verifyinfo.ExpireTime && TypeConverter.StrToDateTime(verifyinfo.ExpireTime) < DateTime.Now)) { AddErrLine("该注册链接不存在或已过期,请点击注册重新获取链接"); return; } invitecode = verifyinfo.InviteCode; } allowinvite = Utils.InArray(config.Regstatus.ToString(), "2,3");//注册状态是否是开启了邀请功能config.Regstatus=2或者=3 //如果是POST提交 if (ispost) { switch (action) { case "rules"://通过注册协议 action = string.IsNullOrEmpty(agree) ? action : (config.Regverify == 1 ? "verify" : "reg"); ispost = false; break; case "verify"://发送验证注册请求邮件 SendRegisterVerifyLink(); break; case "reg"://注册用户 if (createuser == 1) Register(); break; } } }
/// <summary> /// 创建邮箱验证注册请求信息 /// </summary> /// <param name="verifyInfo"></param> /// <returns></returns> public int CreateVerifyRegisterInfo(VerifyRegisterInfo verifyInfo) { DbParameter[] parms = { DbHelper.MakeInParam("@ip",(DbType)SqlDbType.Char,15,verifyInfo.IP), DbHelper.MakeInParam("@email",(DbType)SqlDbType.Char,50,verifyInfo.Email), DbHelper.MakeInParam("@createtime",(DbType)SqlDbType.SmallDateTime,4,verifyInfo.CreateTime), DbHelper.MakeInParam("@expiretime",(DbType)SqlDbType.SmallDateTime,4,verifyInfo.ExpireTime), DbHelper.MakeInParam("@invitecode",(DbType)SqlDbType.NChar,7,verifyInfo.InviteCode), DbHelper.MakeInParam("@verifycode",(DbType)SqlDbType.NChar,16,verifyInfo.VerifyCode) }; return DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, string.Format("{0}createverifyreg", BaseConfigs.GetTablePrefix), parms); }
private static VerifyRegisterInfo LoadVerifyRegisterInfoExtra(IDataReader reader) { VerifyRegisterInfo verifyInfo = new VerifyRegisterInfo(); verifyInfo.RegId = TypeConverter.ObjectToInt(reader["regid"]); verifyInfo.Email = reader["email"].ToString(); verifyInfo.IP = reader["ip"].ToString(); verifyInfo.CreateTime = reader["createtime"].ToString(); verifyInfo.ExpireTime = reader["expiretime"].ToString(); verifyInfo.InviteCode = reader["invitecode"].ToString(); verifyInfo.VerifyCode = reader["verifycode"].ToString(); return verifyInfo; }
/// <summary> /// 创建邮箱验证注册请求信息 /// </summary> /// <param name="authInfo"></param> /// <param name="inviteCode"></param> /// <returns></returns> public static VerifyRegisterInfo CreateVerifyRegisterInfo(string email, string inviteCode) { if (!Utils.IsValidEmail(email)) return null; VerifyRegisterInfo verifyInfo = new VerifyRegisterInfo(); verifyInfo.IP = DNTRequest.GetIP(); verifyInfo.Email = email; verifyInfo.CreateTime = Utils.GetDateTime(); verifyInfo.ExpireTime = Utils.GetDateTime(GeneralConfigs.GetConfig().Verifyregisterexpired); verifyInfo.InviteCode = inviteCode; verifyInfo.VerifyCode = ForumUtils.CreateAuthStr(16); return Data.Users.CreateVerifyRegisterInfo(verifyInfo) > 0 ? verifyInfo : null; }
/// <summary> /// 创建邮箱验证注册请求信息 /// </summary> /// <param name="verifyInfo"></param> /// <returns></returns> public static int CreateVerifyRegisterInfo(VerifyRegisterInfo verifyInfo) { return DatabaseProvider.GetInstance().CreateVerifyRegisterInfo(verifyInfo); }