protected void BtnRegister_Click(object sender, EventArgs e) { IEncourageStrategy <int> strategy2; if (!this.userSiteConfig.EnableUserReg) { return; } if (!this.Page.IsValid) { return; } this.CheckUserName(); this.CheckEmail(); UserInfo usersInfo = new UserInfo(); usersInfo.Email = this.TxtEmail.Text; usersInfo.FaceWidth = 0; usersInfo.FaceHeight = 0; usersInfo.PrivacySetting = 0; ContacterInfo contacterInfo = new ContacterInfo(); contacterInfo.Sex = (UserSexType)Enum.Parse(typeof(UserSexType), "0"); contacterInfo.Marriage = (UserMarriageType)Enum.Parse(typeof(UserMarriageType), "0"); contacterInfo.Income = -1; contacterInfo.Education = -1; contacterInfo.ClientId = 0; contacterInfo.ParentId = 0; contacterInfo.CreateTime = DateTime.Now; contacterInfo.Owner = ""; contacterInfo.UserType = ContacterType.EnterpriceMainContacter; contacterInfo.UpdateTime = DateTime.Now; contacterInfo.UserName = Users.UserNamefilter(this.TxtRegUserName.Text); contacterInfo.Birthday = null; usersInfo.UserName = Users.UserNamefilter(this.TxtRegUserName.Text); usersInfo.UserPassword = StringHelper.MD5(this.TxtRegPassword.Text); usersInfo.GroupId = this.userSiteConfig.GroupId; usersInfo.JoinTime = DateTime.Now; usersInfo.RegTime = DateTime.Now; usersInfo.UserExp = (int)this.userSiteConfig.PresentExp; usersInfo.UserPoint = 0; usersInfo.IsInheritGroupRole = true; usersInfo.Status = UserStatus.None; string str = DataSecurity.MakeRandomString(10); usersInfo.LastPassword = str; if (this.userSiteConfig.EmailCheckReg) { usersInfo.Status = UserStatus.WaitValidateByEmail; usersInfo.CheckNum = DataSecurity.MakeRandomString("abcdefghijklmnopqrstuvwxyz0123456789_", 10); } if (this.userSiteConfig.AdminCheckReg) { usersInfo.Status = UserStatus.WaitValidateByAdmin; } if (this.userSiteConfig.EmailCheckReg && this.userSiteConfig.AdminCheckReg) { usersInfo.Status = UserStatus.WaitValidateByAdmin | UserStatus.WaitValidateByEmail; } usersInfo.EndTime = new DateTime?(DateTime.Now); usersInfo.Balance = 0M; string str2 = ""; if (ApiData.IsAPiEnable()) { str2 = ApiFunction.RegUser(usersInfo.UserName, this.TxtRegPassword.Text, usersInfo.Question, usersInfo.Answer, usersInfo.Email, contacterInfo.TrueName, contacterInfo.Sex.ToString(), contacterInfo.Birthday.ToString(), contacterInfo.QQ, contacterInfo.Msn, contacterInfo.Mobile, contacterInfo.OfficePhone, contacterInfo.Province, contacterInfo.City, contacterInfo.Address, contacterInfo.ZipCode, contacterInfo.Homepage); if (str2 != "true") { DynamicPage.WriteErrMsg(str2 + "<br><li>注册失败!</li>"); } str2 = ApiFunction.RegLogOn(usersInfo.UserName, this.TxtRegPassword.Text, "1"); } if (!Users.Add(usersInfo, contacterInfo)) { DynamicPage.WriteErrMsg("<li>注册失败!</li>"); return; } if (this.userSiteConfig.PresentMoney != 0.0) { IEncourageStrategy <decimal> strategy = new UserMoney(); strategy.IncreaseForUsers(usersInfo.UserId.ToString(), (decimal)this.userSiteConfig.PresentMoney, "注册时赠送的金钱", true, "注册时赠送的金钱"); } if (this.userSiteConfig.PresentValidNum == 0) { goto Label_03EF; } int howMany = 0; if (this.userSiteConfig.PresentValidNum == -1) { howMany = 0x270f; } else { switch (this.userSiteConfig.PresentValidUnit) { case 1: howMany = this.userSiteConfig.PresentValidNum; goto Label_03C4; case 2: howMany = this.userSiteConfig.PresentValidNum * 30; goto Label_03C4; case 3: howMany = this.userSiteConfig.PresentValidNum * 0x16d; goto Label_03C4; } howMany = this.userSiteConfig.PresentValidNum; } Label_03C4: strategy2 = new UserDate(); strategy2.IncreaseForUsers(usersInfo.UserId.ToString(), howMany, "注册时赠送有效期", true, "注册时赠送有效期"); Label_03EF: if (this.userSiteConfig.PresentPoint != 0) { IEncourageStrategy <int> strategy3 = new UserPoint(); strategy3.IncreaseForUsers(usersInfo.UserId.ToString(), this.userSiteConfig.PresentPoint, "注册时赠送点券", true, "注册时赠送点券"); } if (this.userSiteConfig.EmailCheckReg) { MailInfo mailInfo = new MailInfo(); mailInfo.IsBodyHtml = true; mailInfo.FromName = SiteConfig.SiteInfo.SiteName; List <MailAddress> list = new List <MailAddress>(); list.Add(new MailAddress(usersInfo.Email)); mailInfo.MailToAddressList = list; mailInfo.MailBody = this.userSiteConfig.EmailOfRegCheck.Replace("{$CheckNum}", usersInfo.CheckNum).Replace("{$CheckUrl}", base.Request.Url.GetLeftPart(UriPartial.Authority) + base.BasePath + "User/RegisterCheck.aspx?UserName="******"&CheckNum=" + usersInfo.CheckNum); mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码"; if (SendMail.Send(mailInfo) == MailState.Ok) { DynamicPage.WriteSuccessMsg("<li>注册验证码已成功发送到你的注册邮箱,请到邮箱查收并验证!</li>" + str2, "../Default.aspx"); } else { DynamicPage.WriteSuccessMsg("<li>注册成功,但发送验证邮件失败,请检查邮件地址是否正确,或与网站管理员联系!</li>" + str2, "../Default.aspx"); } } string str3 = ""; if (this.userSiteConfig.EnableRegCompany) { str3 = "<li><a href='/Company/RegCompany.aspx'>继续注册企业?</a></li>"; } if (usersInfo.Status == UserStatus.None) { bool isPersistent = false; DateTime now = DateTime.Now; DateTime expiration = DateTime.Now; isPersistent = false; expiration = now.AddDays(1.0); UserPrincipal principal = new UserPrincipal(); principal.UserName = usersInfo.UserName; principal.LastPassword = usersInfo.LastPassword; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usersInfo.UserName, now, expiration, isPersistent, principal.SerializeToString()); string str4 = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str4); if (isPersistent) { cookie.Expires = expiration; } cookie.HttpOnly = true; cookie.Path = FormsAuthentication.FormsCookiePath; cookie.Secure = FormsAuthentication.RequireSSL; base.Response.Cookies.Add(cookie); this.Session["UserName"] = usersInfo.UserName; } if (SiteConfig.ShopConfig.IsPayPassword) { BasePage.ResponseRedirect("../User/RegisterPayPassword.aspx?Url=FastRegister"); } else { DynamicPage.WriteSuccessMsg("<li>注册成功!" + str3 + "</li>" + str2, "../Shop/Payment.aspx"); } }
protected void IbtnEnter_Click(object sender, ImageClickEventArgs e) { string str2; UserPrincipal principal; UserInfo userInfo = new UserInfo(); userInfo.UserName = this.TxtUserName.Text.Trim(); userInfo.UserPassword = this.TxtPassword.Text.Trim(); if (SiteConfig.UserConfig.EnableCheckCodeOfLogOn && (string.Compare(this.TxtValidateCode.Text.Trim(), this.VcodeLogOn.ValidateCodeValue, StringComparison.OrdinalIgnoreCase) != 0)) { DynamicPage.WriteErrMsg("<li>您输入的验证码和系统产生的不一致,请重新输入。</li>"); } UserStatus status = Users.ValidateUser(userInfo); if ((int)status >= 100) { DynamicPage.WriteErrMsg("<li>用户登录名称或用户密码不对!</li>"); } if (status != UserStatus.None) { switch (status) { case UserStatus.Locked: DynamicPage.WriteErrMsg("<li>用户帐户被锁定!</li>"); return; case UserStatus.WaitValidateByEmail: DynamicPage.WriteErrMsg("<li>用户帐户等待邮件验证!</li>"); return; case (UserStatus.WaitValidateByEmail | UserStatus.Locked): goto Label_0344; case UserStatus.WaitValidateByAdmin: DynamicPage.WriteErrMsg("<li>用户帐户等待管理员验证!</li>"); return; case UserStatus.WaitValidateByMobile: DynamicPage.WriteErrMsg("<li>用户帐户等待手机验证!</li>"); return; } goto Label_0344; } bool isPersistent = false; DateTime now = DateTime.Now; DateTime expiration = DateTime.Now; string selectedValue = this.DropExpiration.SelectedValue; if (selectedValue != null) { if (!(selectedValue == "None")) { if (selectedValue == "Day") { isPersistent = true; expiration = now.AddDays(1.0); goto Label_013F; } if (selectedValue == "Month") { isPersistent = true; expiration = now.AddMonths(1); goto Label_013F; } if (selectedValue == "Year") { isPersistent = true; expiration = now.AddYears(1); goto Label_013F; } } else { isPersistent = false; expiration = now.AddDays(1.0); goto Label_013F; } } isPersistent = false; expiration = now.AddMinutes(20.0); Label_013F: if (!ApiData.IsAPiEnable()) { goto Label_0230; } string savecookie = ""; string str5 = this.DropExpiration.SelectedValue; if (str5 != null) { if (!(str5 == "None")) { if (str5 == "Day") { savecookie = "1"; goto Label_01C5; } if (str5 == "Month") { savecookie = "30"; goto Label_01C5; } if (str5 == "Year") { savecookie = "365"; goto Label_01C5; } } else { savecookie = "-1"; goto Label_01C5; } } savecookie = "-1"; Label_01C5: str2 = ApiFunction.LogOn(this.TxtUserName.Text, this.TxtPassword.Text, savecookie); if (str2 != "true") { DynamicPage.WriteErrMsg(str2 + "<br><li>用户登录名称或用户密码不对或用户帐号处于非正常状态!</li>"); return; } str2 = ApiFunction.RegLogOn(this.TxtUserName.Text, this.TxtPassword.Text, savecookie); base.Response.Write(str2); Label_0230: principal = new UserPrincipal(); principal.UserName = userInfo.UserName; principal.LastPassword = userInfo.LastPassword; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userInfo.UserName, now, expiration, isPersistent, principal.SerializeToString()); string str3 = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str3); if (isPersistent) { cookie.Expires = expiration; } cookie.HttpOnly = true; cookie.Path = FormsAuthentication.FormsCookiePath; cookie.Secure = FormsAuthentication.RequireSSL; base.Response.Cookies.Add(cookie); this.Session["UserName"] = userInfo.UserName; base.Response.Write("<script language=\"JavaScript\">window.location='" + GetRedirectUrl() + "';</script>"); return; Label_0344: DynamicPage.WriteErrMsg("<li>用户登录名称或用户密码不对!</li>"); }
protected void BtnRegStep2_Click(object sender, EventArgs e) { IEncourageStrategy <int> strategy2; if (!this.userSiteConfig.EnableUserReg) { return; } if (!this.Page.IsValid) { return; } this.CheckUserName(); this.CheckEmail(); this.CheckCode(); this.CheckQAofReg(); UserInfo usersInfo = new UserInfo(); usersInfo.Question = this.TxtQuestion.Text; usersInfo.Answer = StringHelper.MD5(this.TxtAnswer.Text); usersInfo.Email = this.TxtEmail.Text; usersInfo.UserFace = this.TxtUserFace.Text; usersInfo.FaceWidth = DataConverter.CLng(this.TxtFaceWidth.Text); usersInfo.FaceHeight = DataConverter.CLng(this.TxtFaceHeight.Text); usersInfo.Sign = this.TxtSign.Text; usersInfo.PrivacySetting = DataConverter.CLng(this.DropPrivacy.SelectedValue); string str = DataSecurity.MakeRandomString(10); usersInfo.LastPassword = str; ContacterInfo contacterInfo = new ContacterInfo(); contacterInfo.TrueName = this.TxtTrueName.Text; contacterInfo.Country = this.Region.Country; contacterInfo.Province = this.Region.Province; contacterInfo.City = this.Region.City; contacterInfo.Address = this.TxtAddress.Text; contacterInfo.ZipCode = this.TxtZipCode.Text; contacterInfo.OfficePhone = this.TxtOfficePhone.Text; contacterInfo.HomePhone = this.TxtHomePhone.Text; contacterInfo.Mobile = this.TxtMobile.Text; contacterInfo.Fax = this.TxtFax.Text; contacterInfo.Homepage = this.TxtHomepage.Text; contacterInfo.Email = this.TxtEmail.Text; contacterInfo.QQ = this.TxtQQ.Text; contacterInfo.Msn = this.TxtMSN.Text; contacterInfo.Icq = this.TxtICQ.Text; contacterInfo.Yahoo = this.TxtYahoo.Text; contacterInfo.UC = this.TxtUC.Text; contacterInfo.Aim = this.TxtAim.Text; contacterInfo.IdCard = this.TxtIDCard.Text; contacterInfo.Sex = (UserSexType)Enum.Parse(typeof(UserSexType), this.DropSex.SelectedValue); contacterInfo.Marriage = (UserMarriageType)Enum.Parse(typeof(UserMarriageType), DataConverter.CLng(this.DropMarriage.SelectedValue).ToString()); if (this.GetDisplayStyle("Income") != "none") { contacterInfo.Income = DataConverter.CLng(this.DropIncome.SelectedValue); } else { contacterInfo.Income = -1; } contacterInfo.Education = -1; contacterInfo.Company = this.TxtCompany.Text; contacterInfo.Department = this.TxtDepartment.Text; contacterInfo.ClientId = 0; contacterInfo.ParentId = 0; contacterInfo.CreateTime = DateTime.Now; contacterInfo.Owner = ""; contacterInfo.UserType = ContacterType.EnterpriceMainContacter; contacterInfo.UpdateTime = DateTime.Now; contacterInfo.UserName = Users.UserNamefilter(this.TxtUserName.Text); contacterInfo.Phs = this.TxtPHS.Text; contacterInfo.Birthday = string.IsNullOrEmpty(this.TxtBirthday.Text) ? null : new DateTime?(this.TxtBirthday.Date); contacterInfo.Position = this.TxtPosTitle.Text; usersInfo.UserName = Users.UserNamefilter(this.TxtUserName.Text); usersInfo.UserPassword = StringHelper.MD5(this.TxtPassword.Text); usersInfo.GroupId = this.userSiteConfig.GroupId; usersInfo.JoinTime = DateTime.Now; usersInfo.RegTime = DateTime.Now; usersInfo.UserExp = (int)this.userSiteConfig.PresentExp; usersInfo.UserPoint = 0; usersInfo.IsInheritGroupRole = true; usersInfo.Status = UserStatus.None; if (this.userSiteConfig.EmailCheckReg) { usersInfo.Status = UserStatus.WaitValidateByEmail; usersInfo.CheckNum = DataSecurity.MakeRandomString("abcdefghijklmnopqrstuvwxyz0123456789_", 10); } if (this.userSiteConfig.AdminCheckReg) { usersInfo.Status = UserStatus.WaitValidateByAdmin; } if (this.userSiteConfig.EmailCheckReg && this.userSiteConfig.AdminCheckReg) { usersInfo.Status = UserStatus.WaitValidateByAdmin | UserStatus.WaitValidateByEmail; } usersInfo.EndTime = new DateTime?(DateTime.Now); usersInfo.Balance = 0M; string str2 = ""; if (ApiData.IsAPiEnable()) { str2 = ApiFunction.RegUser(usersInfo.UserName, this.TxtPassword.Text, usersInfo.Question, usersInfo.Answer, usersInfo.Email, contacterInfo.TrueName, contacterInfo.Sex.ToString(), contacterInfo.Birthday.ToString(), contacterInfo.QQ, contacterInfo.Msn, contacterInfo.Mobile, contacterInfo.OfficePhone, contacterInfo.Province, contacterInfo.City, contacterInfo.Address, contacterInfo.ZipCode, contacterInfo.Homepage); if (str2 != "true") { DynamicPage.WriteErrMsg(str2 + "<br><li>注册失败!</li>"); } str2 = ApiFunction.RegLogOn(usersInfo.UserName, this.TxtPassword.Text, "1"); } if (!Users.Add(usersInfo, contacterInfo)) { DynamicPage.WriteErrMsg("<li>注册失败!</li>"); return; } if (this.userSiteConfig.PresentMoney != 0.0) { IEncourageStrategy <decimal> strategy = new UserMoney(); strategy.IncreaseForUsers(usersInfo.UserId.ToString(), (decimal)this.userSiteConfig.PresentMoney, "注册时赠送的金钱", true, "注册时赠送的金钱"); } if (this.userSiteConfig.PresentValidNum == 0) { goto Label_0665; } int howMany = 0; if (this.userSiteConfig.PresentValidNum == -1) { howMany = 0x270f; } else { switch (this.userSiteConfig.PresentValidUnit) { case 1: howMany = this.userSiteConfig.PresentValidNum; goto Label_063A; case 2: howMany = this.userSiteConfig.PresentValidNum * 30; goto Label_063A; case 3: howMany = this.userSiteConfig.PresentValidNum * 0x16d; goto Label_063A; } howMany = this.userSiteConfig.PresentValidNum; } Label_063A: strategy2 = new UserDate(); strategy2.IncreaseForUsers(usersInfo.UserId.ToString(), howMany, "注册时赠送有效期", true, "注册时赠送有效期"); Label_0665: if (this.userSiteConfig.PresentPoint != 0) { IEncourageStrategy <int> strategy3 = new UserPoint(); strategy3.IncreaseForUsers(usersInfo.UserId.ToString(), this.userSiteConfig.PresentPoint, "注册时赠送点券", true, "注册时赠送点券"); } if (this.userSiteConfig.EmailCheckReg) { MailInfo mailInfo = new MailInfo(); mailInfo.IsBodyHtml = true; mailInfo.FromName = SiteConfig.SiteInfo.SiteName; List <MailAddress> list = new List <MailAddress>(); list.Add(new MailAddress(usersInfo.Email)); mailInfo.MailToAddressList = list; mailInfo.MailBody = this.userSiteConfig.EmailOfRegCheck.Replace("{$CheckNum}", usersInfo.CheckNum).Replace("{$CheckUrl}", base.Request.Url.GetLeftPart(UriPartial.Authority) + base.BasePath + "User/RegisterCheck.aspx?UserName="******"&CheckNum=" + usersInfo.CheckNum); mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码"; if (SendMail.Send(mailInfo) == MailState.Ok) { DynamicPage.WriteSuccessMsg("<li>注册验证码已成功发送到你的注册邮箱,请到邮箱查收并验证!</li>" + str2, "../Default.aspx"); } else { DynamicPage.WriteSuccessMsg("<li>注册成功,但发送验证邮件失败,请检查邮件地址是否正确,或与网站管理员联系!</li>" + str2, "../Default.aspx"); } } string str3 = ""; if (this.userSiteConfig.EnableRegCompany) { str3 = "<li><a href='Company/RegCompany.aspx'>继续注册企业?</a></li>"; } if (usersInfo.Status == UserStatus.None) { UserPrincipal principal = new UserPrincipal(); principal.UserName = usersInfo.UserName; principal.LastPassword = usersInfo.LastPassword; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usersInfo.UserName, DateTime.Now, DateTime.Now.AddMinutes(60.0), false, principal.SerializeToString()); string str4 = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str4); cookie.HttpOnly = true; cookie.Path = FormsAuthentication.FormsCookiePath; cookie.Secure = FormsAuthentication.RequireSSL; base.Response.Cookies.Add(cookie); } if (SiteConfig.ShopConfig.IsPayPassword) { BasePage.ResponseRedirect("RegisterPayPassword.aspx?Url=Register"); } else { DynamicPage.WriteSuccessMsg("<li>注册成功!" + str3 + "</li>" + str2, "Default.aspx"); } }