예제 #1
0
        /// <summary>
        /// 修改手机号码
        /// </summary>
        protected void UpdateUserMobile()
        {
            string msg = string.Empty;

            try
            {
                UserInfo user = UserBLL.Read(base.UserId);
                user.Mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile"));
                string safeCode = RequestHelper.GetForm <string>("phoneVer");
                //手机短信验证码
                if (CookiesHelper.ReadCookie("MobileCode" + StringHelper.AddSafe(user.Mobile)) == null)
                {
                    msg = "error|校验码失效,请重新获取";
                }
                else
                {
                    string mobileCode = CookiesHelper.ReadCookie("MobileCode" + StringHelper.AddSafe(user.Mobile)).Value.ToString();
                    if (safeCode.ToLower() != mobileCode.ToLower())
                    {
                        msg = "error|校验码错误";
                    }
                    else
                    {
                        CookiesHelper.DeleteCookie("MobileCode" + StringHelper.AddSafe(user.Mobile));
                    }
                }
                if (msg == string.Empty)
                {
                    if (string.IsNullOrEmpty(user.Mobile))
                    {
                        msg = "error|请填写手机号码";
                    }
                    if (!ShopCommon.CheckMobile(user.Mobile))
                    {
                        msg = "error|手机号码错误";
                    }
                    if (!UserBLL.CheckMobile(user.Mobile, base.UserId))
                    {
                        msg = "error|手机号码已被其他会员注册";
                    }
                    else
                    {
                        UserBLL.Update(user);
                        msg = "ok|修改成功";
                    }
                }
                Response.Clear();
                Response.Write(msg);
            }
            catch (Exception ex)
            {
                Response.Clear();
                Response.Write("error|系统忙,请稍后重试");
            }
            finally {
                Response.End();
            }
        }
예제 #2
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            string userName      = StringHelper.SearchSafe(StringHelper.AddSafe(RequestHelper.GetForm <string>("UserName")));
            string email         = StringHelper.SearchSafe(StringHelper.AddSafe(RequestHelper.GetForm <string>("Email")));
            string userPassword1 = RequestHelper.GetForm <string>("UserPassword1");
            string userPassword2 = RequestHelper.GetForm <string>("UserPassword2");
            string safeCode      = RequestHelper.GetForm <string>("SafeCode");
            string Phone         = StringHelper.SearchSafe(StringHelper.AddSafe(RequestHelper.GetForm <string>("Phone")));
            string phoneCode     = RequestHelper.GetForm <string>("PhoneCode");

            //检查用户名
            if (userName == string.Empty)
            {
                errorMessage = "用户名不能为空";
            }
            if (errorMessage == string.Empty)
            {
                string forbiddinName = ShopConfig.ReadConfigInfo().ForbiddenName;
                if (forbiddinName != string.Empty)
                {
                    foreach (string TempName in forbiddinName.Split('|'))
                    {
                        if (userName.IndexOf(TempName.Trim()) != -1)
                        {
                            errorMessage = "用户名含有非法字符";
                            break;
                        }
                    }
                }
            }
            if (errorMessage == string.Empty)
            {
                if (!UserBLL.UniqueUser(userName))
                {
                    errorMessage = "用户名已经被占用";
                }
            }
            if (errorMessage == string.Empty)
            {
                Regex rg = new Regex("^([a-zA-Z0-9_\u4E00-\u9FA5])+$");
                if (!rg.IsMatch(userName))
                {
                    errorMessage = "用户名只能包含字母、数字、下划线、中文";
                }
            }
            //检查密码
            if (errorMessage == string.Empty)
            {
                if (userPassword1 == string.Empty || userPassword2 == string.Empty)
                {
                    errorMessage = "密码不能为空";
                }
            }
            if (errorMessage == string.Empty)
            {
                if (userPassword1 != userPassword2)
                {
                    errorMessage = "两次密码不一致";
                }
            }

            //检查手机 邮箱 验证码
            if (ShopConfig.ReadConfigInfo().RegisterCheck == 1)
            {//短信验证
                if (errorMessage == string.Empty)
                {
                    if (!ShopCommon.CheckMobile(Phone))
                    {
                        errorMessage = "手机号码错误";
                    }
                }
                if (errorMessage == string.Empty)
                {
                    if (!UserBLL.CheckMobile(Phone, 0))
                    {
                        errorMessage = "手机号码已经被注册";
                    }
                }
                if (errorMessage == string.Empty)
                {
                    if (CookiesHelper.ReadCookie("MobileCode" + StringHelper.AddSafe(Phone)) == null)
                    {
                        errorMessage = "验证码失效,请重新获取验证码";
                    }
                    else
                    {
                        string mobileCode = CookiesHelper.ReadCookie("MobileCode" + StringHelper.AddSafe(Phone)).Value.ToString();
                        if (phoneCode.ToLower() != mobileCode.ToLower())
                        {
                            errorMessage = "验证码错误";
                        }
                        else
                        {
                            CookiesHelper.DeleteCookie("MobileCode" + StringHelper.AddSafe(Phone));
                        }
                    }
                }
            }
            else
            {//邮件验证
                if (errorMessage == string.Empty)
                {
                    if (errorMessage == string.Empty)
                    {
                        if (!UserBLL.CheckEmail(email))
                        {
                            errorMessage = "Email已被注册";
                        }
                    }
                    if (safeCode.ToLower() != Cookies.Common.CheckCode.ToLower())
                    {
                        errorMessage = "验证码错误";
                    }
                }
            }
            //注册用户
            if (errorMessage == string.Empty)
            {
                UserInfo user = new UserInfo();
                user.UserName      = userName;
                user.UserPassword  = StringHelper.Password(userPassword1, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
                user.Mobile        = Phone;
                user.Email         = email;
                user.RegisterIP    = ClientHelper.IP;
                user.RegisterDate  = RequestHelper.DateNow;
                user.LastLoginIP   = ClientHelper.IP;
                user.LastLoginDate = RequestHelper.DateNow;
                user.FindDate      = RequestHelper.DateNow;
                user.Sex           = (int)SexType.Secret;
                if (ShopConfig.ReadConfigInfo().RegisterCheck == 1)
                {//短信验证,用户状态为已验证,可直接登录
                    user.Status = (int)UserStatus.Normal;
                }
                else
                {//邮件验证,用户状态为未验证,需登录邮件手动激活后再登录
                    user.Status = (int)UserStatus.NoCheck;
                }
                int userID = UserBLL.Add(user);
                if (ShopConfig.ReadConfigInfo().RegisterCheck == 1)
                {
                    //短信验证,直接登录
                    HttpCookie cookie = new HttpCookie(ShopConfig.ReadConfigInfo().UserCookies);
                    cookie["User"]     = StringHelper.Encode(userName, ShopConfig.ReadConfigInfo().SecureKey);
                    cookie["Password"] = StringHelper.Encode(userPassword1, ShopConfig.ReadConfigInfo().SecureKey);
                    cookie["Key"]      = StringHelper.Encode(ClientHelper.Agent, ShopConfig.ReadConfigInfo().SecureKey);
                    HttpContext.Current.Response.Cookies.Add(cookie);

                    user = UserBLL.Read(userID);
                    UserBLL.UserLoginInit(user);
                    ResponseHelper.Redirect("/Mobile/User/Index.html");
                }
                else if (ShopConfig.ReadConfigInfo().RegisterCheck == 2)
                {
                    try
                    {
                        //邮件验证
                        string              url             = "http://" + Request.ServerVariables["HTTP_HOST"] + "/Mobile/User/ActiveUser.html?CheckCode=" + StringHelper.Encode(userID + "|" + email + "|" + userName, ShopConfig.ReadConfigInfo().SecureKey);
                        EmailContentInfo    emailContent    = EmailContentHelper.ReadSystemEmailContent("Register");
                        EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo();
                        emailSendRecord.Title     = emailContent.EmailTitle;
                        emailSendRecord.Content   = emailContent.EmailContent.Replace("$UserName$", user.UserName).Replace("$Url$", url);
                        emailSendRecord.IsSystem  = (int)BoolType.True;
                        emailSendRecord.EmailList = email;
                        emailSendRecord.IsStatisticsOpendEmail = (int)BoolType.False;
                        emailSendRecord.SendStatus             = (int)SendStatus.No;
                        emailSendRecord.AddDate  = RequestHelper.DateNow;
                        emailSendRecord.SendDate = RequestHelper.DateNow;
                        emailSendRecord.ID       = EmailSendRecordBLL.AddEmailSendRecord(emailSendRecord);
                        EmailSendRecordBLL.SendEmail(emailSendRecord);
                        result = "恭喜您,注册成功,请登录邮箱激活!<a href=\"http://mail." + email.Substring(email.IndexOf("@") + 1) + "\"  target=\"_blank\">马上激活</a>";
                    }
                    catch (Exception ex)
                    {
                        ScriptHelper.AlertFront("激活邮件发送失败,请联系网站客服");
                    }
                }
                else
                {
                    //人工审核
                    result = "恭喜您,注册成功,请等待我们的审核!";
                }
                ResponseHelper.Redirect("/Mobile/User/Register.html?Result=" + Server.UrlEncode(result));
            }
            else
            {
                ScriptHelper.AlertFront(errorMessage);
                //ResponseHelper.Redirect("/Mobile/User/Register.html?ErrorMessage=" + Server.UrlEncode(errorMessage));
            }
        }
예제 #3
0
        //提交
        protected void Submit()
        {
            string result = "ok";

            try
            {
                var realnames = RequestHelper.GetForm <string>("realname").Split(',');
                var names     = RequestHelper.GetForm <string>("username").Split(',');
                var mobiles   = RequestHelper.GetForm <string>("mobile").Split(',');
                var birthdays = RequestHelper.GetForm <string>("birthday").Split(',');
                //var emails = RequestHelper.GetForm<string>("email").Split(',');
                //var tels = RequestHelper.GetForm<string>("tel").Split(',');
                //var qqs = RequestHelper.GetForm<string>("qq").Split(',');


                List <object[]> entities = new List <object[]>();
                for (int i = 0; i < names.Length; i++)
                {
                    UserInfo user = new UserInfo();

                    user.RealName = realnames[i];
                    user.UserName = names[i];
                    user.Mobile   = mobiles[i];
                    user.Birthday = birthdays[i];
                    //user.Email = emails[i];
                    //user.Tel = tels[i];
                    //user.QQ = qqs[i];
                    //初始密码123456
                    user.UserPassword      = StringHelper.Password("123456", (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
                    user.RegisterIP        = ClientHelper.IP;
                    user.RegisterDate      = RequestHelper.DateNow;
                    user.LastLoginIP       = ClientHelper.IP;
                    user.LastLoginDate     = RequestHelper.DateNow;
                    user.FindDate          = RequestHelper.DateNow;
                    user.Sex               = (int)SexType.Secret;
                    user.Status            = (int)JWShop.Entity.UserStatus.Normal;
                    user.HasRegisterCoupon = 0;
                    user.HasBirthdayCoupon = 0;
                    //检查姓名是否存在
                    if (string.IsNullOrEmpty(user.RealName))
                    {
                        result = "姓名必填";
                    }

                    //检查用户名/微信昵称是否存在
                    if (string.IsNullOrEmpty(user.UserName))
                    {
                        result = "用户名/微信昵称必填";
                        //Response.Write(result);
                        //Response.End();
                    }
                    string forbiddinName = ShopConfig.ReadConfigInfo().ForbiddenName;
                    if (forbiddinName != string.Empty)
                    {
                        foreach (string TempName in forbiddinName.Split('|'))
                        {
                            if (user.UserName.IndexOf(TempName.Trim()) != -1)
                            {
                                result = "用户名/微信昵称:[" + user.UserName + "]含有非法字符";
                                //Response.Write(result);
                                //Response.End();
                            }
                        }
                    }
                    if (!UserBLL.UniqueUser(user.UserName))
                    {
                        result = "用户名/微信昵称:[" + user.UserName + "]已经注册";
                        //Response.Write(result);
                        //Response.End();
                    }
                    if (string.IsNullOrEmpty(user.Mobile))
                    {
                        result = "手机必填";
                        //Response.Write(result);
                        //Response.End();
                    }
                    if (!ShopCommon.CheckMobile(user.Mobile))
                    {
                        result = "手机号码:[" + user.Mobile + "]错误";
                        //Response.Write(result);
                        //Response.End();
                    }
                    if (!UserBLL.CheckMobile(user.Mobile, 0))
                    {
                        result = "手机号码:[" + user.Mobile + "]已经注册";
                        //Response.Write(result);
                        //Response.End();
                    }
                    DateTime date = DateTime.Now;
                    if (!string.IsNullOrEmpty(user.Birthday) && !DateTime.TryParse(user.Birthday, out date))
                    {
                        result = "生日:[" + user.Birthday + "]格式错误";
                    }
                    //if (string.IsNullOrEmpty(user.Email))
                    //{
                    //    result = "邮箱:"+user.Email+"必填";
                    //    //Response.Write(result);
                    //    //Response.End();
                    //}
                    //if (!UserBLL.CheckEmail(user.Email))
                    //{
                    //    result = "邮箱:[" + user.Email + "]已被注册";
                    //    //Response.Write(result);
                    //    //Response.End();
                    //}
                    else
                    {
                        entities.Add(new object[] { user });
                    }
                }
                if (result == "ok")
                {
                    UserBLL.AddBatch(entities);
                }
            }
            catch (Exception ex)
            {
                result = "error";
            }
            finally
            {
                Response.Clear();
                Response.Write(result);
                Response.End();
            }
        }