⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 register.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 3 页
字号:
                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 str2 = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str2);
                cookie.HttpOnly = true;
                cookie.Path = FormsAuthentication.FormsCookiePath;
                cookie.Secure = FormsAuthentication.RequireSSL;
                base.Response.Cookies.Add(cookie);
            }
            DynamicPage.WriteSuccessMsg("<li>注册成功!" + str + "</li>", "Default.aspx");
        }

        private void CheckCode()
        {
            if (this.userSiteConfig.EnableCheckCodeOfReg && (string.Compare(this.TxtValidateCode.Text.Trim(), this.VcodeRegister.ValidateCodeValue, true) != 0))
            {
                DynamicPage.WriteErrMsg("<li>您输入的验证码和系统产生的不一致,请重新输入。</li>");
            }
        }

        private void CheckEmail()
        {
            if (!this.userSiteConfig.EnableMultiRegPerEmail && !Users.GetUsersByEmail(this.TxtEmail.Text).IsNull)
            {
                DynamicPage.WriteErrMsg("<li>Email已被他人注册,请输入不同的Email!</li>");
            }
        }

        private void CheckQAofReg()
        {
            if (this.userSiteConfig.EnableQAofReg)
            {
                if (!string.IsNullOrEmpty(this.userSiteConfig.RegQuestion1) && (this.TxtRegAnswer1.Text != this.userSiteConfig.RegAnswer1))
                {
                    DynamicPage.WriteErrMsg("<li>您回答网站注册问题一不正确,请重新输入。</li>");
                }
                if (!string.IsNullOrEmpty(this.userSiteConfig.RegQuestion2) && (this.TxtRegAnswer2.Text != this.userSiteConfig.RegAnswer2))
                {
                    DynamicPage.WriteErrMsg("<li>您回答网站注册问题二不正确,请重新输入。</li>");
                }
                if (!string.IsNullOrEmpty(this.userSiteConfig.RegQuestion3) && (this.TxtRegAnswer3.Text != this.userSiteConfig.RegAnswer3))
                {
                    DynamicPage.WriteErrMsg("<li>您回答网站注册问题三不正确,请重新输入。</li>");
                }
            }
        }

        private void CheckUserName()
        {
            if (StringHelper.FoundInArr(this.userSiteConfig.UserNameRegDisabled, this.TxtUserName.Text, "|"))
            {
                DynamicPage.WriteErrMsg("<li>该用户名禁止注册,请输入不同的用户名!</li>");
            }
            if (Users.Exists(Users.UserNamefilter(this.TxtUserName.Text)))
            {
                DynamicPage.WriteErrMsg("<li>该用户名已被他人占用,请输入不同的用户名!</li>");
            }
        }

        public string GetCallbackResult()
        {
            return this.result;
        }

        protected string GetDisplayStyle(string field)
        {
            if (StringHelper.FoundCharInArr(this.userSiteConfig.RegFieldsMustFill, field, ","))
            {
                return "";
            }
            if (StringHelper.FoundCharInArr(this.userSiteConfig.RegFieldsSelectFill, field, ","))
            {
                return "";
            }
            return "none";
        }

        protected bool GetEnableValid(string field)
        {
            return StringHelper.FoundCharInArr(this.userSiteConfig.RegFieldsMustFill, field, ",");
        }

        private void InitProtocol()
        {
            try
            {
                this.LitProtocol.Text = FileSystemObject.ReadFile(base.Request.MapPath("~/User/Protocol.txt"));
            }
            catch (FileNotFoundException)
            {
                DynamicPage.WriteErrMsg("<li>Protocol.txt文件未找到</li>", "../Default.aspx");
            }
            catch (UnauthorizedAccessException)
            {
                DynamicPage.WriteErrMsg("<li>检查您的服务器是否给文件或文件夹写入权限。</li>", "../Default.aspx");
            }
        }

        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            this.userSiteConfig = SiteConfig.UserConfig;
            if (this.Page.IsPostBack)
            {
                string str = base.Request.Form["ControlTreeInfo"];
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strArray = str.Split(new string[] { "$$$$$" }, StringSplitOptions.None);
                    if ((strArray[0] != this.userSiteConfig.RegFieldsMustFill) || (strArray[1] != this.userSiteConfig.RegFieldsSelectFill))
                    {
                        base.Response.Redirect(base.Request.RawUrl);
                    }
                }
            }
            string[] strArray2 = string.IsNullOrEmpty(this.userSiteConfig.RegFieldsMustFill) ? new string[0] : this.userSiteConfig.RegFieldsMustFill.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            string[] strArray3 = string.IsNullOrEmpty(this.userSiteConfig.RegFieldsSelectFill) ? new string[0] : this.userSiteConfig.RegFieldsSelectFill.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string str2 in strArray2)
            {
                HtmlTableRow row = this.FindControl("TR" + str2) as HtmlTableRow;
                if (row != null)
                {
                    this.TableRegister.Rows.Remove(row);
                    this.TableRegisterMust.Rows.Add(row);
                }
            }
            foreach (string str3 in strArray3)
            {
                HtmlTableRow row2 = this.FindControl("TR" + str3) as HtmlTableRow;
                if (row2 != null)
                {
                    this.TableRegister.Rows.Remove(row2);
                    this.TableRegisterSelect.Rows.Add(row2);
                }
            }
            if (this.userSiteConfig.EnableQAofReg)
            {
                if (!string.IsNullOrEmpty(this.userSiteConfig.RegQuestion1))
                {
                    this.TableRegister.Rows.Remove(this.TrRegQuestion1);
                    this.TableRegisterMust.Rows.Add(this.TrRegQuestion1);
                }
                if (!string.IsNullOrEmpty(this.userSiteConfig.RegQuestion2))
                {
                    this.TableRegister.Rows.Remove(this.TrRegQuestion2);
                    this.TableRegisterMust.Rows.Add(this.TrRegQuestion2);
                }
                if (!string.IsNullOrEmpty(this.userSiteConfig.RegQuestion3))
                {
                    this.TableRegister.Rows.Remove(this.TrRegQuestion3);
                    this.TableRegisterMust.Rows.Add(this.TrRegQuestion3);
                }
            }
            if (this.userSiteConfig.EnableCheckCodeOfReg)
            {
                this.TableRegister.Rows.Remove(this.TrVcodeRegister);
                this.TableRegisterMust.Rows.Add(this.TrVcodeRegister);
            }
            if (strArray3.Length > 0)
            {
                this.TableRegister.Rows.Remove(this.TRSwicthSelectFill);
                this.TableRegisterMust.Rows.Add(this.TRSwicthSelectFill);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.TxtBirthday.ImageStyle.Add("float", "left");
            this.TxtBirthday.Style.Add("float", "left");
            if (!this.userSiteConfig.EnableUserReg)
            {
                this.PnlRegStep0.Visible = true;
                this.PnlRegStep1.Visible = false;
                this.PnlRegStep2.Visible = false;
            }
            else
            {
                this.callBackReference = this.Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
                int userNameLimit = 1;
                int userNameMax = 20;
                if (this.userSiteConfig.UserNameLimit > 0)
                {
                    userNameLimit = this.userSiteConfig.UserNameLimit;
                }
                if (this.userSiteConfig.UserNameMax >= userNameLimit)
                {
                    userNameMax = this.userSiteConfig.UserNameMax;
                }
                this.ValgTextMaxLength.ValidationExpression = @"^[a-zA-Z0-9_\u4e00-\u9fa5]{" + userNameLimit.ToString() + "," + userNameMax.ToString() + "}$";
                this.InterMessageUserName.Text = "请输入用户名。不能少于" + userNameLimit.ToString() + "个字符,不能超过" + userNameMax.ToString() + "个字符";
                this.ValgTextMaxLength.ErrorMessage = "用户名必须大于" + userNameLimit.ToString() + "个字符并且不能超过" + userNameMax.ToString() + "个字符";
                if (!base.IsPostBack)
                {
                    this.LitControlTreeInfo.Text = "<input name='ControlTreeInfo' type='hidden' value='" + this.userSiteConfig.RegFieldsMustFill + "$$$$$" + this.userSiteConfig.RegFieldsSelectFill + "'/>";
                    this.InitProtocol();
                    if (this.GetDisplayStyle("Income") != "none")
                    {
                        Choiceset.DropDownListDataBind("PE_Contacter", "Income", this.DropIncome);
                    }
                    this.PnlRegStep1.Visible = true;
                }
            }
        }

        public void RaiseCallbackEvent(string eventArgument)
        {
            if (string.IsNullOrEmpty(eventArgument))
            {
                this.result = "empty";
            }
            else if (StringHelper.FoundInArr(this.userSiteConfig.UserNameRegDisabled, eventArgument, "|"))
            {
                this.result = "disabled";
            }
            else if (Users.Exists(Users.UserNamefilter(eventArgument)))
            {
                this.result = "true";
            }
            else
            {
                this.result = "false";
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -