private void MemberLogin(string userName, string passWord) { if (txtPhone.Text == "" || txtPassword.Text.Trim() == "") { MojoCube.Api.UI.Script.ScriptMessage(this, "请填写手机号和密码"); return; } //判断是否存在用户名及验证码是否正确 if (Session["SiteCheckCode"] == null) { MojoCube.Api.UI.Script.ScriptMessage(this, "请填写验证码"); return; } if (Session["SiteCheckCode"] != null && Session["SiteCheckCode"].ToString().ToLower() != txtCode.Text.Trim().ToLower()) { MojoCube.Api.UI.Script.ScriptMessage(this, "验证码错误"); return; } if (userName != "" && passWord != "") { MojoCube.Web.Member.List user = new MojoCube.Web.Member.List(); passWord = FormsAuthentication.HashPasswordForStoringInConfigFile(passWord, "MD5").ToLower().Trim(); if (user.IsUser(userName, passWord) && !user.IsLock) { //更新用户数据 user.SetLoginSession(); user.LastLoginIP = MojoCube.Web.IP.Get(); user.UpdateLastLogin(user.pk_Member); //记住登录信息 MojoCube.Web.Member.List.SetLogin(); //加入在线用户 MojoCube.Web.Member.Online online = new MojoCube.Web.Member.Online(); online.fk_Member = user.pk_Member; online.SessionID = Session.SessionID; online.IPAddress = MojoCube.Web.IP.Get(); online.Browser = MojoCube.Web.String.GetBrowser(); online.TypeID = 0; online.LoginTime = DateTime.Now.ToString(); online.InsertData(); if (Request.QueryString["url"] != null && Request.QueryString["url"] != "") { Response.Redirect(Request.QueryString["url"]); } else { Response.Redirect(MojoCube.Api.File.Function.GetRelativePath(MojoCube.Web.Site.Cache.GetUrlExtension("Member", MojoCube.Api.UI.Language.GetLanguage()))); } Response.End(); } else { MojoCube.Api.UI.Script.ScriptMessage(this, "错误的手机号或密码"); } } else { MojoCube.Api.UI.Script.ScriptMessage(this, "错误的手机号或密码"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (txtPhone.Text == "" || txtName.Text == "" || txtEmail.Text == "" || txtPassword.Text.Trim() == "") { MojoCube.Api.UI.Script.ScriptMessage(this, "请填写完整"); return; } if (!RegexPhone(txtPhone.Text.Trim())) { MojoCube.Api.UI.Script.ScriptMessage(this, "请输入正确的手机号"); return; } if (txtPassword1.Text.Trim() != "" && txtPassword1.Text.Trim().Length < 6) { MojoCube.Api.UI.Script.ScriptMessage(this, "请输入至少6位密码"); return; } if (txtPassword1.Text.Trim() != txtPassword2.Text.Trim()) { MojoCube.Api.UI.Script.ScriptMessage(this, "两次密码不一致"); return; } MojoCube.Web.Member.List list = new MojoCube.Web.Member.List(); list.GetData(int.Parse(Session["Member_UserID"].ToString())); if (list.ChkUserName(txtPhone.Text.Trim()) && list.Phone1 != txtPhone.Text.Trim()) { MojoCube.Api.UI.Script.ScriptMessage(this, "手机号已存在!"); return; } if (list.ChkUserEmail(txtEmail.Text.Trim()) && list.Email != txtEmail.Text.Trim()) { MojoCube.Api.UI.Script.ScriptMessage(this, "邮件已存在!"); return; } if (list.IsUser(txtPhone.Text.Trim(), FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.Trim(), "MD5").ToLower().Trim()) && !list.IsLock) { list.UserName = txtPhone.Text.Trim(); list.Address = txtAddress.Text.Trim(); list.FirstName = MojoCube.Web.String.GetChineseName(txtName.Text.Trim(), false); list.LastName = MojoCube.Web.String.GetChineseName(txtName.Text.Trim(), true); list.Phone1 = txtPhone.Text.Trim(); list.Email = txtEmail.Text.Trim(); if (txtPassword1.Text.Trim() != "") { list.UserPass = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword1.Text.Trim(), "MD5").ToLower(); } MojoCube.Api.File.Upload upload = new MojoCube.Api.File.Upload(); upload.FilePath = "Member/" + list.pk_Member; upload.FileName = MojoCube.Api.Text.Function.DateTimeString(true); upload.DoFileUpload(fuPortrait); if (upload.IsUpload) { list.ImagePath = upload.OldFilePath; Session["Member_UserImagePath"] = list.ImagePath; imgPortrait.ImageUrl = "Files.aspx?image=" + MojoCube.Api.Text.Security.EncryptString(Session["Member_UserImagePath"].ToString()); } list.UpdateData(list.pk_Member); MojoCube.Api.UI.Script.ScriptMessage(this, "修改成功!"); } else { MojoCube.Api.UI.Script.ScriptMessage(this, "密码错误!"); } }