private void CheckUserName() { string s = Req.GetQueryString("s"); if (!Fn.IsRegex(s, Fn.EnumRegex.用户名)) { Response.Write('2');//格式不正确 Response.End(); } if (User_InfoL.IsUserName(s)) { Response.Write('1'); } else { Response.Write('0'); } }
private void Reg() { if (Req.GetForm("cCode").Length == 0) { msgAjax.Error("code.input;"); } else { if (!Fn.IsVerifyCode1("cCode", "uverify")) { msgAjax.Error("code.wrong;"); } } string sName = Fn.EncodeHtml(Req.GetForm("cName").Trim()); string sEmail = Fn.EncodeHtml(Req.GetForm("cEmail").Trim()); string sPwd = Req.GetForm("cPwd").Trim(); string sPwdSure = Req.GetForm("cPwdSure").Trim(); string sCard = Fn.EncodeHtml(Req.GetForm("cCard").Trim()); string sPromoter = Req.GetForm("cPromoter").Trim(); //用户名 if (sName.Length == 0) { msgAjax.Error("name.input;");//请输入用户名 } else { if (sName.Length < 5 || sName.Length > 30) { msgAjax.Error("name.above;");//用户名须在5-30个字符之间 } else { if (!Fn.IsRegex(sName, Fn.EnumRegex.用户名)) { msgAjax.Error("name.format;");//用户名格式不正确 } else { if (User_InfoL.IsUserName(sName)) { msgAjax.Error("name.has;");//此用户名已被注册,请重新输入用户名 } } } } //邮箱 if (sEmail.Length == 0) { msgAjax.Error("email.input;");//请输入邮箱 } else { if (sEmail.Length < 5 || sEmail.Length > 30) { msgAjax.Error("email.above;");//邮箱须在5-30个字符之间 } else { if (!Fn.IsRegex(sEmail, Fn.EnumRegex.电子邮件)) { msgAjax.Error("email.format;");//邮箱格式不正确 } else { if (User_InfoL.IsEmail(sEmail)) { msgAjax.Error("email.has;");//此邮箱名已被注册,请重新输入用户名 } } } } //密码 if (sPwd.Length == 0) { msgAjax.Error("pwd.input;");//请输入密码 } else { if (sPwd.Length < 5 || sPwd.Length > 30) { msgAjax.Error("pwd.above;");//密码不能小于5位数 } } //确认密码 if (sPwdSure.Length == 0) { msgAjax.Error("pwd1.input;");//请输入确认密码 } else { if (sPwd != sPwdSure) { msgAjax.Error("pwd1.notEqual;");//两次密码输入不一致 } } //会员卡号 int exp = 0; if (sCard.Length > 0) { if (!Activity_InfoL.IsOpen("user_card")) { msgAjax.Error("card.clo;"); return; } if (!User_CardL.IsUse(sCard, out exp)) { msgAjax.Error("card.wrong;"); return; } if (exp <= 0) { msgAjax.Error("card.wrong;"); return; } } //推广员号码 int UserBTJ = 0; if (sPromoter.Length > 0) { int iPromoter; if (!int.TryParse(sPromoter, out iPromoter)) { msgAjax.Error("promoter.wrong;"); return; } if (!Activity_InfoL.IsOpen("user_promoter")) { msgAjax.Error("promoter.clo;"); return; } if (!User_InfoL.IsUserPromoter(iPromoter)) { msgAjax.Error("promoter.wrong;"); return; } UserBTJ = iPromoter; } if (msgAjax.IsError) { return; } User_InfoM infoMod = new User_InfoM(); infoMod.UserName = sName; infoMod.UserPwd = Fn.MD5(sPwd); infoMod.LastLoginIP = Request.UserHostAddress; infoMod.OpenIdentity = 1;//个人用户 infoMod.FK_User_Level = User_LevelL.GetDefaultLevel(); infoMod.Email = sEmail; infoMod.UserCard = sCard; infoMod.UserBTJ = UserBTJ; User_PersonalM perMod = new User_PersonalM(); User_InfoL.Reg_TransM lsTrans = new User_InfoL.Reg_TransM(); lsTrans.infoMod = infoMod; lsTrans.perMod = perMod; if (exp > 0) { lsTrans.IsUseCard = true; lsTrans.Exp = exp; } DbHelp.ExecuteTrans(new DbHelpParam(), User_InfoL.Reg_Trans, lsTrans); if (lsTrans.returnValue == "1") { User_Info.Login(sName, sPwd); Session.Remove("uverify"); int isSend = 0; try { string url = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "") + "/email/regSuccess.aspx?un=" + sName; string sText = Fn.GetPageHtml(url); User_InfoL.SendEmail(sEmail, sName + " 您好,您在搜菜网已成功注册会员", sText); isSend = 1; } catch { } msgAjax.Success(isSend.ToString()); } else { msgAjax.Error(lsTrans.returnValue); } }
private void Reg() { if (Req.GetForm("cIsAgree") != "1") { msgAjax.Error("必需同意[搜菜网用户注册协议]才能注册;"); return; } if (!Fn.IsVerifyCode1("cCode", "uverify")) { msgAjax.Error("code.wrong;"); return; } string cname = Fn.EncodeHtml(Req.GetForm("cname").Trim()); string email = Fn.EncodeHtml(Req.GetForm("email").Trim()); string pwd = Req.GetForm("pwd").Trim(); string pwd1 = Req.GetForm("pwd1").Trim(); string realname = Fn.EncodeHtml(Req.GetForm("realname").Trim()); string sSex = Req.GetForm("cSex").Trim(); string sArea = Req.GetForm("cArea").Trim(); string address = Fn.EncodeHtml(Req.GetForm("address").Trim()); string tel = Fn.EncodeHtml(Req.GetForm("tel").Trim()); string telfix = Fn.EncodeHtml(Req.GetForm("telfix").Trim()); string sCard = Fn.EncodeHtml(Req.GetForm("card").Trim()); string sPromoter = Req.GetForm("cPromoter").Trim(); //用户名 if (cname.Length == 0) { msgAjax.Error("请输入用户名;"); } else { if (cname.Length < 5 || cname.Length > 30) { msgAjax.Error("用户名需在5-30个字符之间;"); } else { if (!Fn.IsRegex(cname, Fn.EnumRegex.用户名)) { msgAjax.Error("用户名中有非法字条;"); } else { if (User_InfoL.IsUserName(cname)) { msgAjax.Error("此用户名已被注册,请重新输入;"); } } } } if (email.Length == 0) { msgAjax.Error("请输入邮箱;"); } else { if (email.Length < 5 || email.Length > 30) { msgAjax.Error("邮箱需在5-30个字符之间;"); } else { if (!Fn.IsRegex(email, Fn.EnumRegex.电子邮件)) { msgAjax.Error("邮箱格式不正确;"); } else { if (User_InfoL.IsEmail(email)) { msgAjax.Error("此邮箱名已被注册,请重新输入;"); } } } } if (pwd.Length == 0) { msgAjax.Error("请输入密码;"); } else { if (pwd.Length < 5 || pwd.Length > 30) { msgAjax.Error("密码需在5-30位数之间;"); } else { if (pwd1.Length == 0) { msgAjax.Error("请输入确认密码;"); } else { if (pwd != pwd1) { msgAjax.Error("两次密码输入不一致;"); } } } } //会员卡号 int exp = 0; if (sCard.Length > 0) { if (!Activity_InfoL.IsOpen("user_card")) { msgAjax.Error("会员卡活动已关闭;"); return; } if (!User_CardL.IsUse(sCard, out exp)) { msgAjax.Error("会员卡错误或不存在此卡号;"); return; } if (exp <= 0) { msgAjax.Error("会员卡错误或不存在此卡号;"); return; } } //推广员号码 int UserBTJ = 0; if (sPromoter.Length > 0) { int iPromoter; if (!int.TryParse(sPromoter, out iPromoter)) { msgAjax.Error("推广员号码错误或不存在此推广员;"); return; } if (!Activity_InfoL.IsOpen("user_promoter")) { msgAjax.Error("注册推广员活动已关闭;"); return; } if (!User_InfoL.IsUserPromoter(iPromoter)) { msgAjax.Error("推广员号码错误或不存在此推广员;"); return; } UserBTJ = iPromoter; } if (realname.Length > 30) { msgAjax.Error("联系人不超过30个字;"); } if (tel.Length > 25) { msgAjax.Error("手机不超过25字;"); } if (telfix.Length > 25) { msgAjax.Error("固定电话不超过25字;"); } if (address.Length > 300) { msgAjax.Error("地址不超过300字;"); } int iArea = Fn.IsInt(sArea, 0); if (iArea < 0) { msgAjax.Error("非法操作;"); } else if (iArea > 0) { if (ClassData.HasNext("Pub_Area", iArea)) { msgAjax.Error("请选择最后一级分类;"); } } //if (tel.Length == 0 && telfix.Length == 0) //{ // msgAjax.Error("手机和固定电话必填一个;"); //} if (msgAjax.IsError) { return; } //账号信息 User_InfoM infoMod = new User_InfoM(); infoMod.FK_User_Level = User_LevelL.GetDefaultLevel(); infoMod.UserName = cname; infoMod.UserPwd = Fn.MD5(pwd); infoMod.LastLoginIP = Request.UserHostAddress; infoMod.OpenIdentity = 1;//个人用户 infoMod.Email = email; infoMod.UserCard = sCard; infoMod.UserBTJ = UserBTJ; //个人用户信息 User_PersonalM perMod = new User_PersonalM(); perMod.RealName = realname; perMod.Sex = byte.Parse(sSex); perMod.Area = iArea; perMod.Address = address; perMod.FixTel = telfix; perMod.Tel = tel; //收货信息 User_ContactM conMod = new User_ContactM(); conMod.FK_Area = iArea; conMod.Name = realname; conMod.Address = address; conMod.FixTel = telfix; conMod.Tel = tel; //事务类 User_InfoL.Reg1_TransM lsTrans = new User_InfoL.Reg1_TransM(); lsTrans.infoMod = infoMod; lsTrans.perMod = perMod; lsTrans.conMod = conMod; if (exp > 0) { lsTrans.IsUseCard = true; lsTrans.Exp = exp; } DbHelp.ExecuteTrans(new DbHelpParam(), User_InfoL.Reg1_Trans, lsTrans); if (lsTrans.returnValue == "1") { Session.Remove("uverify"); User_Info.Login(cname, pwd); int isSend = 0; try { string url = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "") + "/email/regSuccess.aspx?un=" + cname; string sText = Fn.GetPageHtml(url); User_InfoL.SendEmail(email, cname + " 您好,您在搜菜网已成功注册会员", sText); isSend = 1; } catch { } msgAjax.Success(isSend.ToString()); } else { msgAjax.Error(lsTrans.returnValue); } }