public IActionResult GetPassWord_Email() { B_MailManage mailBll = new B_MailManage(); if (!VerifyHelper.Check(RequestEx["VCode_Hid"])) { return(WriteErr("验证码不正确", "/User/GetPassword")); } M_UserInfo mu = GetUserByName(RequestEx["TxtUserName"]); if (string.IsNullOrEmpty(mu.Email) || mu.Email.Contains("@random")) { return(WriteErr("用户未设置邮箱,无法通过邮箱找回")); } //生成Email验证链接 string seturl = function.GetRandomString(12) + "," + DateTime.Now.ToString(); mu.seturl = EncryptHelper.AESEncrypt(seturl); buser.UpDateUser(mu); //Email发送 string url = SiteConfig.SiteInfo.SiteUrl + "/User/Change/GetPassWord?key=" + mu.seturl + "&uid=" + mu.UserID; string returnurl = "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>"; string content = mailBll.SelByType(B_MailManage.MailType.RetrievePWD); content = new OrderCommon().TlpDeal(content, GetPwdEmailDt(mu.UserName, SiteConfig.SiteInfo.SiteName, returnurl)); MailInfo mailInfo = SendMail.GetMailInfo(mu.Email, SiteConfig.SiteInfo.SiteName, SiteConfig.SiteInfo.SiteName + "_找回密码", content); SendMail.Send(mailInfo); //不需要更新步骤,其从邮箱进入地址栏后再更新 string emailUrl = B_Plat_Common.GetMailSite(mu.Email); return(WriteOK("密码重设请求提交成功,<a href='" + emailUrl + "' target='_blank'>请前往邮箱查收</a>!!")); }
public void GetPassWord_Email() { B_MailManage mailBll = new B_MailManage(); if (!ZoomlaSecurityCenter.VCodeCheck(Request.Form["VCode_hid"], Request.Form["VCode"])) { function.WriteErrMsg("验证码不正确", "/User/GetPassword"); return; } M_UserInfo mu = GetUserByName(Request.Form["TxtUserName"]); if (string.IsNullOrEmpty(mu.Email) || mu.Email.Contains("@random")) { function.WriteErrMsg("用户未设置邮箱,无法通过邮箱找回"); return; } //生成Email验证链接 string seturl = function.GetRandomString(12) + "," + DateTime.Now.ToString(); mu.seturl = seturl; buser.UpDateUser(mu); //Email发送 string url = SiteConfig.SiteInfo.SiteUrl + "/User/GetPassWord?key=" + mu.seturl + "&uid=" + mu.UserID; string returnurl = "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>"; string content = mailBll.SelByType(B_MailManage.MailType.RetrievePWD); content = new OrderCommon().TlpDeal(content, GetPwdEmailDt(mu.UserName, SiteConfig.SiteInfo.SiteName, returnurl)); MailInfo mailInfo = SendMail.GetMailInfo(mu.Email, SiteConfig.SiteInfo.SiteName, SiteConfig.SiteInfo.SiteName + "_找回密码", content); SendMail.Send(mailInfo); //不需要更新步骤,其从邮箱进入地址栏后再更新 function.WriteSuccessMsg("密码重设请求提交成功,<a href='" + B_Plat_Common.GetMailSite(mu.Email) + "' target='_blank'>请前往邮箱查收</a>!!", "", 0); return; }
//发送确认订阅邮件 public string SendSubEmail(string uname, string authcode, string email) { MailAddress adMod = new MailAddress(email); MailInfo mailInfo = new MailInfo() { ToAddress = adMod, IsBodyHtml = true }; mailInfo.FromName = SiteConfig.SiteInfo.SiteName; mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "订阅邮件"; string mailtlp = mailBll.SelByType(B_MailManage.MailType.SubMailVerification); string url = SiteConfig.SiteInfo.SiteUrl + "/common/SubScriptCheck.aspx?authcode=" + authcode; DataTable tempDt = GetDtModel(); DataRow tempDr = tempDt.Rows[0]; tempDr["CDate"] = DateTime.Now.ToString(); tempDr["SiteName"] = SiteConfig.SiteInfo.SiteName; tempDr["url"] = "<a href='" + url + "' target='_blank'>" + url + "</a>"; tempDr["UserName"] = uname; mailtlp = new OrderCommon().TlpDeal(mailtlp, tempDt); mailInfo.MailBody = mailtlp; if (SendMail.Send(mailInfo) == SendMail.MailState.Ok) { return("1"); } else { return("-2"); } }
//创建用户,并发送邮件,email:compid:时间戮 protected void Step1_Btn_Click(object sender, EventArgs e) { int compid = 0; if (!string.IsNullOrEmpty(Request.QueryString["Invite"])) { string invite = Request.QueryString["Invite"]; compid = DataConverter.CLng(EncryptHelper.AESDecrypt(invite).Split(':')[0]); } Email_T.Text = Email_T.Text.Trim(); string code = B_Plat_Common.GetTimeStamp(Email_T.Text + ":" + compid); string url = SiteConfig.SiteInfo.SiteUrl.TrimEnd('/') + "/User/RegPlat.aspx?code=" + code; string emailTlp = mailBll.SelByType(B_MailManage.MailType.PlatReg); //SiteConfig.UserConfig.EmailPlatReg; MailAddress adMod = new MailAddress(Email_T.Text); MailInfo mailInfo = new MailInfo() { ToAddress = adMod, IsBodyHtml = true }; mailInfo.FromName = SiteConfig.SiteInfo.SiteName; mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "注册邮件"; mailInfo.MailBody = new OrderCommon().TlpDeal(emailTlp, GetPlatRegDt(url, Email_T.Text)); if (SendMail.Send(mailInfo) == SendMail.MailState.Ok)//发送成功,生成用户,显示下一步提示 { M_UserInfo mu = new M_UserInfo(); //if (buser.IsExistMail(Email_T.Text)) { function.WriteErrMsg("帐号错误请检查注册选项或联系官方!!"); } mu.Email = Email_T.Text; mu.UserName = Email_T.Text;//OK后再更改用户名 mu.UserPwd = function.GetRandomString(6); mu.Question = "尚未定义问题"; mu.Answer = function.GetRandomString(6); mu.RegTime = DateTime.Now; mu.Status = 1; mu.Remark = code; buser.AddModel(mu); MailSite_A.NavigateUrl = B_Plat_Common.GetMailSite(mu.Email); function.Script(this, "showme();"); } else { function.WriteErrMsg("邮件发送失败,请检测邮箱地址是否正确!!"); } }
protected void Send_Btn_Click(object sender, EventArgs e) { string emailcontent = mailBll.SelByType(B_MailManage.MailType.SubMailContent); emailcontent = common.TlpDeal(emailcontent, GetSubEmailDt(Content_T.Text)); if (DataConverter.CLng(Graph_Drop.SelectedValue) > 0)//邮件签名 { M_MailIdiograph graphMod = graphBll.SelReturnModel(DataConverter.CLng(Graph_Drop.SelectedValue)); emailcontent += graphMod.Context; } if (SubUsers_Radio.SelectedValue.Equals("alluser"))//全部订阅用户发送 { DataTable allUserDT = readBll.SelectAll(1); foreach (DataRow dr in allUserDT.Rows) { SendSubEMail(dr["EMail"].ToString(), emailcontent); } } function.WriteSuccessMsg("发送成功!"); }
protected void SendMail_B_Click(object sender, EventArgs e) { orderinfo = oll.SelReturnModel(Mid); M_UserInfo uinfo = buser.SelReturnModel(orderinfo.Userid); MailAddress address = new MailAddress(uinfo.Email); MailInfo mailInfo = new MailInfo(); mailInfo.IsBodyHtml = true; mailInfo.FromName = SiteConfig.SiteInfo.SiteName; mailInfo.ToAddress = address; mailInfo.MailBody = new OrderCommon().TlpDeal(mailBll.SelByType(B_MailManage.MailType.IDCOrder), GetEmailDt()); mailInfo.Subject = "IDC订单邮件提醒"; if (SendMail.Send(mailInfo) == SendMail.MailState.Ok) { function.Script(this, "alert('邮件发送成功!');"); } else { function.Script(this, "alert('邮件发送失败!');"); } }
public ActionResult Register_Submit() { B_UserBaseField bmf = new B_UserBaseField(); string siteurls = SiteConfig.SiteInfo.SiteUrl.TrimEnd('/'); if (!SiteConfig.UserConfig.EnableUserReg) { function.WriteErrMsg("服务器已关闭用户注册"); return(null); } //----------------------------------- M_UserInfo info = new M_UserInfo(); info.UserBase = new M_Uinfo(); info.UserName = Request.Form["TxtUserName"].Replace(" ", ""); info.UserPwd = Request.Form["TxtPassword"]; info.Question = Request.Form["Question_DP"]; info.Answer = Request.Form["TxtAnswer"]; info.Email = Request.Form["TxtEmail"].Replace(" ", ""); info.CheckNum = function.GetRandomString(10); info.GroupID = DataConverter.CLng(Request.Form["UserGroup"]); info.RegisterIP = EnviorHelper.GetUserIP(); info.LastLoginIP = info.RegisterIP; //info.Purse = SiteConfig.UserConfig.PresentMoney;//注册赠送的余额,积分等 //info.UserPoint = SiteConfig.UserConfig.PresentPoint; //info.UserExp = DataConverter.CLng(SiteConfig.UserConfig.PresentExp); info.TrueName = Request.Form["TxtTrueName"]; info.UserPwd = StringHelper.MD5(info.UserPwd);; //----------------------------------------------------- //会员基本信息 info.UserBase.Address = Request.Form["TxtAddress"]; info.UserBase.BirthDay = Request.Form["TxtBirthday"]; info.UserFace = Request.Form["TxtUserFace"]; info.UserBase.Fax = Request.Form["TxtFax"]; info.UserBase.HomePage = Request.Form["TxtHomepage"]; info.UserBase.HomePhone = Request.Form["TxtHomePhone"]; info.UserBase.IDCard = Request.Form["TxtIDCard"]; info.UserBase.Mobile = Request.Form["TxtMobile"]; info.UserBase.OfficePhone = Request.Form["TxtOfficePhone"]; info.UserBase.Privating = DataConvert.CLng(Request.Form["DropPrivacy"]); info.UserBase.PHS = Request.Form["TxtPHS"]; info.UserBase.QQ = Request.Form["TxtQQ"]; info.UserBase.Sign = Request.Form["TxtSign"]; info.UserBase.UserSex = DataConverter.CBool(Request.Form["DropSex"]); info.UserBase.ZipCode = Request.Form["TxtZipCode"]; info.UserBase.HoneyName = ""; info.UserBase.CardType = ""; info.UserBase.Province = Request["selprovince"]; info.UserBase.City = Request["selcity"]; info.UserBase.County = Request["selcoutry"]; if (!string.IsNullOrEmpty(RegisterMobile)) { info.UserBase.Mobile = RegisterMobile; RegisterMobile = null; } //----------------------------------------------------- #region 信息检测 string err = ""; if (SiteConfig.UserConfig.EnableCheckCodeOfReg) { if (!ZoomlaSecurityCenter.VCodeCheck(Request.Form["VCode_hid"], Request.Form["VCode"])) { function.WriteErrMsg("您输入的验证码和系统产生的不一致,请重新输入", "javascript:history.go(-1);"); return(null); } } if (!CheckUserName(info.UserName, ref err)) { function.WriteErrMsg(err); return(null); } else if (!CheckUserInfo(info.UserBase)) { return(null); } else if (string.IsNullOrEmpty(info.Answer)) { function.WriteErrMsg("问题答案不能为空!"); return(null); } else if (!CheckEmail(info.Email, ref err)) { function.WriteErrMsg(err); return(null); } #endregion //推荐人处理 M_User_InviteCode utMod = null; { //支持使用用户名和用户ID info.ParentUserID = CheckParentUser(Request.Form["TxtParentUser"]).UserID.ToString(); //邀请码推荐用户,高于填写的推荐人 string inviteCode = Request.Form["TxtInvitCode"]; if (!string.IsNullOrEmpty(inviteCode)) { utMod = utBll.Code_SelModel(inviteCode); if (utMod != null) { if (utMod.ZStatus != 0) { function.WriteErrMsg("该邀请码已被使用"); return(null); } info.ParentUserID = utMod.UserID.ToString(); info.GroupID = utMod.JoinGroup; } } //计算深度 if (DataConvert.CLng(info.ParentUserID) > 0)//从1开始 { info.RoomID = (buser.SelParentTree(DataConvert.CLng(info.ParentUserID)).Split(',').Length + 1); } } //用于初始状态 if (SiteConfig.UserConfig.EmailCheckReg) { info.Status = 4; } //邮件认证 else if (SiteConfig.UserConfig.AdminCheckReg) { info.Status = 2; } //管理员认证 else if (SiteConfig.UserConfig.EmailCheckReg && SiteConfig.UserConfig.AdminCheckReg) { info.Status = 3; } //邮件认证及管理员认证 else if (!SiteConfig.UserConfig.UserValidateType) { info.Status = 5; } else { info.Status = 0; } //自定义字段信息 DataTable table; try { table = new Call().GetDTFromMVC(bmf.Select_All(), Request); } catch (Exception e) { function.WriteErrMsg(e.Message); return(Content("")); } string[] strArray2 = string.IsNullOrEmpty(SiteConfig.UserConfig.RegFieldsMustFill) ? new string[0] : SiteConfig.UserConfig.RegFieldsMustFill.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (string str2 in strArray2) { if (Request.Form["txt_" + str2] == null || Request.Form["txt_" + str2] == "") { DataTable tbles = bmf.SelByFieldName(str2); } } //------------添加新用户 info.UserID = buser.AddModel(info); info.UserBase.UserId = info.UserID; buser.AddBase(info.UserBase); if (table != null && table.Rows.Count > 0) { buser.UpdateUserFile(info.UserID, table); } buser.SetLoginState(info); if (info.UserID < 1) { function.WriteErrMsg("注册失败"); return(null); } //邀请码状态变更 if (utMod != null) { utBll.Code_Used(utMod.ID, info); } //---------------------------------------------------------------------------- string ReturnUrl = Request.Form["ReturnUrl_Hid"]; string RegMessage = ""; string RegRUrl = ""; bool isok = false; //关联绑定微信用户 //if (!string.IsNullOrEmpty(WXOpenID)) //{ // B_User_Token tokenBll = new B_User_Token(); // M_User_Token tokenMod = tokenBll.SelModelByUid(info.UserID); // if (tokenMod == null) { tokenMod = new M_User_Token(); } // tokenMod.uid = info.UserID; // tokenMod.WXOpenID = WXOpenID; // tokenBll.Insert(tokenMod); //} #region 自定义模型 int ModelID = DataConverter.CLng(gpBll.GetGroupModel(info.GroupID)); string usertablename = modBll.GetModelById(ModelID).TableName; if (ModelID > 0 && usertablename != "" && usertablename != null) { DataTable groupset = fieldBll.GetModelFieldListall(ModelID); DataTable tablereg = new DataTable(); tablereg.Columns.Add(new DataColumn("FieldName", typeof(string))); tablereg.Columns.Add(new DataColumn("FieldType", typeof(string))); tablereg.Columns.Add(new DataColumn("FieldValue", typeof(string))); if (groupset != null && groupset.Rows.Count > 0) { foreach (DataRow dr in groupset.Rows) { if (dr["FieldType"].ToString() == "FileType") { string[] Sett = dr["Content"].ToString().Split(new char[] { ',' }); bool chksize = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]); string sizefield = Sett[1].Split(new char[] { '=' })[1]; if (chksize && sizefield != "") { DataRow row2 = tablereg.NewRow(); row2[0] = sizefield; row2[1] = "FileSize"; row2[2] = Request.Form["txt_" + sizefield]; tablereg.Rows.Add(row2); } } if (dr["FieldType"].ToString() == "MultiPicType") { string[] Sett = dr["Content"].ToString().Split(new char[] { ',' }); bool chksize = DataConverter.CBool(Sett[0].Split(new char[] { '=' })[1]); string sizefield = Sett[1].Split(new char[] { '=' })[1]; if (chksize && sizefield != "") { if (string.IsNullOrEmpty(Request.Form["txt_" + sizefield])) { function.WriteErrMsg(dr["FieldAlias"].ToString() + "的缩略图不能为空!"); } DataRow row1 = tablereg.NewRow(); row1[0] = sizefield; row1[1] = "ThumbField"; row1[2] = Request.Form["txt_" + sizefield]; tablereg.Rows.Add(row1); } } DataRow row = tablereg.NewRow(); row[0] = dr["FieldName"].ToString(); string ftype = dr["FieldType"].ToString(); row[1] = ftype; string fvalue = Request.Form["txt_" + dr["FieldName"].ToString()]; if (ftype == "TextType" || ftype == "MultipleTextType" || ftype == "MultipleHtmlType") { if (dr["IsNotNull"].Equals("True") && string.IsNullOrEmpty(fvalue)) { function.WriteErrMsg(dr["FieldAlias"] + ":不能为空!"); } } row[2] = fvalue; tablereg.Rows.Add(row); } try { if (tablereg.Select("FieldName='UserID'").Length == 0) { DataRow rowsd1 = tablereg.NewRow(); rowsd1[0] = "UserID"; rowsd1[1] = "int"; rowsd1[2] = info.UserID; tablereg.Rows.Add(rowsd1); } else { tablereg.Rows[0]["UserID"] = info.UserID; } } catch (Exception) { } try { if (tablereg.Select("FieldName='UserName'").Length == 0) { DataRow rowsd2 = tablereg.NewRow(); rowsd2[0] = "UserName"; rowsd2[1] = "TextType"; rowsd2[2] = info.UserName; tablereg.Rows.Add(rowsd2); } else { tablereg.Rows[0]["UserName"] = info.UserName; } } catch (Exception) { } try { if (tablereg.Select("FieldName='Styleid'").Length == 0) { DataRow rowsd3 = tablereg.NewRow(); rowsd3[0] = "Styleid"; rowsd3[1] = "int"; rowsd3[2] = 0; tablereg.Rows.Add(rowsd3); } else { tablereg.Rows[0]["UserName"] = 0; } } catch (Exception) { } try { if (tablereg.Select("FieldName='Recycler'").Length == 0) { DataRow rowsd4 = tablereg.NewRow(); rowsd4[0] = "Recycler"; rowsd4[1] = "int"; rowsd4[2] = 0; tablereg.Rows.Add(rowsd4); } else { tablereg.Rows[0]["Recycler"] = 0; } } catch (Exception) { } try { if (tablereg.Select("FieldName='IsCreate'").Length == 0) { DataRow rowsd5 = tablereg.NewRow(); rowsd5[0] = "IsCreate"; rowsd5[1] = "int"; rowsd5[2] = 0; tablereg.Rows.Add(rowsd5); } else { tablereg.Rows[0]["IsCreate"] = 0; } } catch (Exception) { } try { if (tablereg.Select("FieldName='NewTime'").Length == 0) { DataRow rs6 = tablereg.NewRow(); rs6[0] = "NewTime"; rs6[1] = "DateType"; rs6[2] = DateTime.Now; tablereg.Rows.Add(rs6); } else { tablereg.Rows[0]["NewTime"] = DateTime.Now; } } catch (Exception) { } } if (tablereg != null && tablereg.Rows.Count > 0) { buser.InsertModel(tablereg, usertablename); } } #endregion if (SiteConfig.UserConfig.EmailCheckReg && !string.IsNullOrEmpty(info.Email))//发送认证邮件,当需要邮件认证时 { MailInfo mailInfo = new MailInfo(); mailInfo.IsBodyHtml = true; mailInfo.FromName = SiteConfig.SiteInfo.SiteName; MailAddress address = new MailAddress(info.Email); mailInfo.ToAddress = address; string regurl = siteurls + "/User/RegisterCheck?UserName="******"&CheckNum=" + info.CheckNum; string mailcontent = mailBll.SelByType(B_MailManage.MailType.NewUserReg); mailInfo.MailBody = new OrderCommon().TlpDeal(mailcontent, GetRegEmailDt(info.UserName, info.CheckNum, regurl)); mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码"; if (SendMail.Send(mailInfo) == SendMail.MailState.Ok) { RegMessage = "注册验证码已成功发送到你的注册邮箱,请到邮箱查收并验证!"; RegMessage = RegMessage + "<a href=\"/\">返回首页</a>"; } else { RegMessage = "注册成功,但发送验证邮件失败,请检查邮件地址是否正确,或与网站管理员联系!"; RegMessage = RegMessage + "<a href=\"/\">返回首页</a>"; } } switch (info.Status) { case 0: #region 直接注册成功 if (!string.IsNullOrEmpty(info.Email) && SiteConfig.UserConfig.EmailTell) { MailInfo mailInfo = new MailInfo(); mailInfo.IsBodyHtml = true; mailInfo.FromName = SiteConfig.SiteInfo.SiteName; MailAddress address = new MailAddress(info.Email); mailInfo.ToAddress = address; //SiteConfig.UserConfig.EmailOfRegCheck string regurl = siteurls + "/User/RegisterCheck?UserName="******"&CheckNum=" + info.CheckNum; mailInfo.MailBody = new OrderCommon().TlpDeal(mailBll.SelByType(B_MailManage.MailType.NewUserReg), GetRegEmailDt(info.UserName, info.CheckNum, regurl)); //mailInfo.MailBody = mailInfo.MailBody.Replace("{$UserName}", info.UserName).Replace("{$UserPwd}", TxtPassword.Text); mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "_注册成功提醒"; if (SendMail.Send(mailInfo) == SendMail.MailState.Ok) { RegMessage = "注册基本信息已成功发送到你的注册邮箱!"; RegMessage = RegMessage + "<a href=\"/\">返回首页</a>"; } else { RegMessage = "注册成功,但发送注册基本信息邮件失败,请检查邮件地址是否正确,或与网站管理员联系!"; RegMessage = RegMessage + "<a href=\"/\">返回首页</a>"; } } else { RegMessage = "注册成功!"; if (string.IsNullOrEmpty(ReturnUrl)) { RegMessage = RegMessage + "<a href=\"/\">返回首页</a> <a href=\"/User/Index\">进入会员中心</a>,5秒后系统自动跳转到会员中心!"; RegRUrl = "/User/Index"; } else { RegMessage = RegMessage + "<a href=\"/\">返回首页</a> <a href=\"" + ReturnUrl + "\">进入默认页面</a>,5秒后系统自动跳转到默认页面!"; RegRUrl = ReturnUrl; } isok = true; } #endregion break; case 2: //等待管理员认证 RegMessage = "注册成功!新注册会员需管理员认证才能有效,请耐心等待!"; RegMessage = RegMessage + "若长期没有通过管理员认证,请及时和管理员联系!"; RegMessage = RegMessage + "<a href=\"/\">返回首页</a>"; break; default: //未开启邮箱验证,则可以登录 if (!SiteConfig.UserConfig.EmailCheckReg) { RegMessage = "注册成功!"; } if (string.IsNullOrEmpty(ReturnUrl)) { RegMessage = RegMessage + "<a href=\"/\">返回首页</a> <a href=\"/User/Index\">进入会员中心</a>,5秒后系统自动跳转到会员中心!"; RegRUrl = "default"; } else { RegMessage = RegMessage + "<a href=\"/\">返回首页</a> <a href=\"" + ReturnUrl + "\">进入默认页面</a>,5秒后系统自动跳转到默认页面!"; RegRUrl = ReturnUrl; } isok = true; break; } if (SiteConfig.UserConfig.EmailCheckReg) { RegMessage = "<div class='emptyDiv'><br/>注册成功! <a href='http://mail." + info.Email.Substring(info.Email.LastIndexOf('@') + 1) + "' target='_blank'>立即登录邮箱进行验证>></a><br/></div>"; isok = false; } ViewBag.RegMessage = RegMessage; ViewBag.RegRUrl = RegRUrl; ViewBag.isok = isok;//为true则自动跳转 ViewBag.pwd = Request.Form["TxtPassword"]; return(View("Register_Finish", info)); }