public ActionResult Upload(UploadModel model) { if (ModelState.IsValid) { MallConfigInfo mallConfigInfo = BMAConfig.MallConfig; mallConfigInfo.UploadImgType = model.UploadImgType; mallConfigInfo.UploadImgSize = model.UploadImgSize * 1000; mallConfigInfo.WatermarkType = model.WatermarkType; mallConfigInfo.WatermarkQuality = model.WatermarkQuality; mallConfigInfo.WatermarkPosition = model.WatermarkPosition; mallConfigInfo.WatermarkImg = model.WatermarkImg == null ? "" : model.WatermarkImg; mallConfigInfo.WatermarkImgOpacity = model.WatermarkImgOpacity; mallConfigInfo.WatermarkText = model.WatermarkText == null ? "" : model.WatermarkText; mallConfigInfo.WatermarkTextFont = model.WatermarkTextFont; mallConfigInfo.WatermarkTextSize = model.WatermarkTextSize; mallConfigInfo.BrandThumbSize = model.BrandThumbSize; mallConfigInfo.ProductShowThumbSize = model.ProductShowThumbSize; mallConfigInfo.UserAvatarThumbSize = model.UserAvatarThumbSize; mallConfigInfo.UserRankAvatarThumbSize = model.UserRankAvatarThumbSize; mallConfigInfo.StoreRankAvatarThumbSize = model.StoreRankAvatarThumbSize; mallConfigInfo.StoreLogoThumbSize = model.StoreLogoThumbSize; BMAConfig.SaveMallConfig(mallConfigInfo); Emails.ResetMall(); SMSes.ResetMall(); AddMallAdminLog("修改上传设置"); return(PromptView(Url.Action("upload"), "修改上传设置成功")); } LoadFont(); return(View(model)); }
public ActionResult Upload(UploadModel model) { if (ModelState.IsValid) { ShopConfigInfo shopConfigInfo = BSPConfig.ShopConfig; shopConfigInfo.UploadImgType = model.UploadImgType; shopConfigInfo.UploadImgSize = model.UploadImgSize * 1000; shopConfigInfo.WatermarkType = model.WatermarkType; shopConfigInfo.WatermarkQuality = model.WatermarkQuality; shopConfigInfo.WatermarkPosition = model.WatermarkPosition; shopConfigInfo.WatermarkImg = model.WatermarkImg == null ? "" : model.WatermarkImg; shopConfigInfo.WatermarkImgOpacity = model.WatermarkImgOpacity; shopConfigInfo.WatermarkText = model.WatermarkText == null ? "" : model.WatermarkText; shopConfigInfo.WatermarkTextFont = model.WatermarkTextFont; shopConfigInfo.WatermarkTextSize = model.WatermarkTextSize; shopConfigInfo.BrandThumbSize = model.BrandThumbSize; shopConfigInfo.ProductShowThumbSize = model.ProductShowThumbSize; shopConfigInfo.UserAvatarThumbSize = model.UserAvatarThumbSize; shopConfigInfo.UserRankAvatarThumbSize = model.UserRankAvatarThumbSize; BSPConfig.SaveShopConfig(shopConfigInfo); Emails.ResetShop(); SMSes.ResetShop(); AddAdminOperateLog("修改上传设置"); return(PromptView(Url.Action("upload"), "修改上传设置成功")); } LoadFont(); return(View(model)); }
public ActionResult Mall(MallModel model) { if (ModelState.IsValid) { MallConfigInfo mallConfigInfo = BMAConfig.MallConfig; mallConfigInfo.IsGuestSC = model.IsGuestSC; mallConfigInfo.SCSubmitType = model.SCSubmitType; mallConfigInfo.GuestSCCount = model.GuestSCCount; mallConfigInfo.MemberSCCount = model.MemberSCCount; mallConfigInfo.SCExpire = model.SCExpire; mallConfigInfo.OSNFormat = model.OSNFormat; mallConfigInfo.OnlinePayExpire = model.OnlinePayExpire; mallConfigInfo.ReceiveExpire = model.ReceiveExpire; mallConfigInfo.BroHisCount = model.BroHisCount; mallConfigInfo.MaxShipAddress = model.MaxShipAddress; mallConfigInfo.FavoriteProductCount = model.FavoriteProductCount; mallConfigInfo.FavoriteStoreCount = model.FavoriteStoreCount; BMAConfig.SaveMallConfig(mallConfigInfo); Emails.ResetMall(); SMSes.ResetMall(); AddMallAdminLog("修改商城设置"); return(PromptView(Url.Action("mall"), "修改商城设置成功")); } return(View(model)); }
public ActionResult Access(AccessModel model) { if (ModelState.IsValid) { ShopConfigInfo shopConfigInfo = BSPConfig.ShopConfig; shopConfigInfo.IsClosed = model.IsClosed; shopConfigInfo.CloseReason = model.CloseReason == null ? "" : model.CloseReason; shopConfigInfo.BanAccessTime = model.BanAccessTime == null ? "" : model.BanAccessTime; shopConfigInfo.BanAccessIP = model.BanAccessIP == null ? "" : model.BanAccessIP; shopConfigInfo.AllowAccessIP = model.AllowAccessIP == null ? "" : model.AllowAccessIP; shopConfigInfo.AdminAllowAccessIP = model.AdminAllowAccessIP == null ? "" : model.AdminAllowAccessIP; shopConfigInfo.SecretKey = model.SecretKey; shopConfigInfo.CookieDomain = model.CookieDomain == null ? "" : model.CookieDomain.Trim('.'); shopConfigInfo.RandomLibrary = model.RandomLibrary == null ? "" : model.RandomLibrary; shopConfigInfo.VerifyPages = CommonHelper.StringArrayToString(model.VerifyPages); shopConfigInfo.IgnoreWords = model.IgnoreWords == null ? "" : model.IgnoreWords; shopConfigInfo.AllowEmailProvider = model.AllowEmailProvider == null ? "" : model.AllowEmailProvider; shopConfigInfo.BanEmailProvider = model.BanEmailProvider == null ? "" : model.BanEmailProvider; BSPConfig.SaveShopConfig(shopConfigInfo); Emails.ResetShop(); SMSes.ResetShop(); Randoms.ResetRandomLibrary(); FilterWords.ResetIgnoreWordsRegex(); AddAdminOperateLog("修改访问控制"); return(PromptView(Url.Action("access"), "修改访问控制成功")); } ViewData["verifyPages"] = CommonHelper.StringArrayToString(model.VerifyPages); return(View(model)); }
public ActionResult Shop(ShopModel model) { if (ModelState.IsValid) { ShopConfigInfo shopConfigInfo = BSPConfig.ShopConfig; shopConfigInfo.IsGuestSC = model.IsGuestSC; shopConfigInfo.SCSubmitType = model.SCSubmitType; shopConfigInfo.GuestSCCount = model.GuestSCCount; shopConfigInfo.MemberSCCount = model.MemberSCCount; shopConfigInfo.SCExpire = model.SCExpire; shopConfigInfo.OSNFormat = model.OSNFormat; shopConfigInfo.OnlinePayExpire = model.OnlinePayExpire; shopConfigInfo.OfflinePayExpire = model.OfflinePayExpire; shopConfigInfo.BroHisCount = model.BroHisCount; shopConfigInfo.MaxShipAddress = model.MaxShipAddress; shopConfigInfo.FavoriteCount = model.FavoriteCount; BSPConfig.SaveShopConfig(shopConfigInfo); Emails.ResetShop(); SMSes.ResetShop(); AddAdminOperateLog("修改商城设置"); return(PromptView(Url.Action("shop"), "修改商城设置成功")); } return(View(model)); }
public ActionResult Performance(PerformanceModel model) { if (ModelState.IsValid) { MallConfigInfo mallConfigInfo = BMAConfig.MallConfig; mallConfigInfo.ImageCDN = model.ImageCDN == null ? "" : model.ImageCDN; mallConfigInfo.CSSCDN = model.CSSCDN == null ? "" : model.CSSCDN; mallConfigInfo.ScriptCDN = model.ScriptCDN == null ? "" : model.ScriptCDN; mallConfigInfo.OnlineUserExpire = model.OnlineUserExpire; mallConfigInfo.UpdateOnlineTimeSpan = model.UpdateOnlineTimeSpan; mallConfigInfo.MaxOnlineCount = model.MaxOnlineCount; mallConfigInfo.OnlineCountExpire = model.OnlineCountExpire; mallConfigInfo.IsStatBrowser = model.IsStatBrowser; mallConfigInfo.IsStatOS = model.IsStatOS; mallConfigInfo.IsStatRegion = model.IsStatRegion; BMAConfig.SaveMallConfig(mallConfigInfo); Emails.ResetMall(); SMSes.ResetMall(); AddMallAdminLog("修改性能设置"); return(PromptView(Url.Action("performance"), "修改性能设置成功")); } return(View(model)); }
/// <summary> /// 发送验证手机短信(注册认证) /// </summary> public ActionResult SendVerifyMobileForAuth() { string mobile = WebHelper.GetFormString("mobile"); if (string.IsNullOrEmpty(mobile)) { return(AjaxResult("verifycode", "手机号不能为空")); } if (!ValidateHelper.IsMobile(mobile)) { return(AjaxResult("verifycode", "手机号格式不正确")); } if (Users.IsExistMobile(mobile)) { return(AjaxResult("verifycode", "手机号已存在")); } //if (WorkContext.PartUserInfo.VerifyMobile == 0) // return AjaxResult("unverifymobile", "手机号没有通过验证,所以不能发送验证短信"); string moibleCode = Randoms.CreateRandomValue(6); //发送验证手机短信 SMSes.SendSCVerifySMS(mobile, moibleCode); //将验证值保存在session中 Sessions.SetItem(WorkContext.Sid, "authMoibleCode", mobile + moibleCode); return(AjaxResult("success", "短信已经发送,请查收")); }
public ActionResult Performance(PerformanceModel model) { if (ModelState.IsValid) { ShopConfigInfo shopConfigInfo = BSPConfig.ShopConfig; shopConfigInfo.ImageCDN = model.ImageCDN == null ? "" : model.ImageCDN; shopConfigInfo.CSSCDN = model.CSSCDN == null ? "" : model.CSSCDN; shopConfigInfo.ScriptCDN = model.ScriptCDN == null ? "" : model.ScriptCDN; shopConfigInfo.OnlineUserExpire = model.OnlineUserExpire; shopConfigInfo.UpdateOnlineTimeSpan = model.UpdateOnlineTimeSpan; shopConfigInfo.MaxOnlineCount = model.MaxOnlineCount; shopConfigInfo.OnlineCountExpire = model.OnlineCountExpire; shopConfigInfo.UpdatePVStatTimespan = model.UpdatePVStatTimespan; shopConfigInfo.IsStatBrowser = model.IsStatBrowser; shopConfigInfo.IsStatOS = model.IsStatOS; shopConfigInfo.IsStatRegion = model.IsStatRegion; BSPConfig.SaveShopConfig(shopConfigInfo); Emails.ResetShop(); SMSes.ResetShop(); AddAdminOperateLog("修改性能设置"); return(PromptView(Url.Action("performance"), "修改性能设置成功")); } return(View(model)); }
/// <summary> /// 发送更新手机确认短信 /// </summary> public ActionResult SendUpdateMobile() { string v = WebHelper.GetQueryString("v"); //解密字符串 string realV = ShopUtils.AESDecrypt(v); //数组第一项为uid,第二项为动作,第三项为验证时间,第四项为随机值 string[] result = StringHelper.SplitString(realV); if (result.Length != 4) { return(AjaxResult("noauth", "您的权限不足")); } int uid = TypeHelper.StringToInt(result[0]); string action = result[1]; DateTime time = TypeHelper.StringToDateTime(result[2]); //判断当前用户是否为验证用户 if (uid != WorkContext.Uid) { return(AjaxResult("noauth", "您的权限不足")); } //判断验证时间是否过时 if (DateTime.Now.AddMinutes(-30) > time) { return(AjaxResult("expired", "密钥已过期,请重新验证")); } string mobile = WebHelper.GetFormString("mobile"); //检查手机号 if (string.IsNullOrWhiteSpace(mobile)) { return(AjaxResult("mobile", "手机号不能为空")); } if (!ValidateHelper.IsMobile(mobile)) { return(AjaxResult("mobile", "手机号格式不正确")); } int tempUid = Users.GetUidByMobile(mobile); if (tempUid > 0 && tempUid != WorkContext.Uid) { return(AjaxResult("mobile", "手机号已经存在")); } string mobileCode = Randoms.CreateRandomValue(6); //发送短信 SMSes.SendSCUpdateSMS(mobile, mobileCode); //将验证值保存在session中 Sessions.SetItem(WorkContext.Sid, "ucsuMobile", mobile); Sessions.SetItem(WorkContext.Sid, "ucsuMobileCode", mobileCode); return(AjaxResult("success", "短信已发送,请查收")); }
/// <summary> /// 发送找回密码短信 /// </summary> public ActionResult SendMSGMobile() { //发送找回密码短信 string moibleCode = Randoms.CreateRandomValue(6); try { string mobile = WebHelper.GetFormString("mobile"); if (string.IsNullOrEmpty(mobile)) { return(AjaxResult("nouser", "请输入正确的手机号")); } var smsmodel = NewUser.GetSMSCodeList(1, 1, " where account='" + mobile + "'").FirstOrDefault(); if (smsmodel != null) { moibleCode = smsmodel.Code; string body = "【PC蛋蛋】您正在注册,验证码" + moibleCode + ",若非本人操作,请勿泄露。"; bool smsres = SMSes.SendSY(mobile, HttpUtility.UrlEncode(body, Encoding.UTF8)); if (!smsres) { return(AjaxResult("error", "发送失败")); } return(AjaxResult("success", "发送成功")); } else { string body = "【PC蛋蛋】您正在注册,验证码" + moibleCode + ",若非本人操作,请勿泄露。"; MD_SMSCode smscode = new MD_SMSCode { Account = mobile, Code = moibleCode, Expiretime = DateTime.Now.AddMinutes(10) }; bool sms = NewUser.AddSMSCode(smscode); if (sms) { //发送短信 bool smsres = SMSes.SendSY(mobile, HttpUtility.UrlEncode(body, Encoding.UTF8)); if (!smsres) { return(AjaxResult("error", "发送失败")); } return(AjaxResult("success", "发送成功")); } else { return(AjaxResult("error", "发送失败")); } } } catch (Exception ex) { return(AjaxResult("error", "发送失败")); } }
/// <summary> /// 发送验证手机短信 /// </summary> public ActionResult SendVerifyMobile() { if (WorkContext.PartUserInfo.VerifyMobile == 0) { return(AjaxResult("unverifymobile", "手机号没有通过验证,所以不能发送验证短信")); } string moibleCode = Randoms.CreateRandomValue(6); //发送验证手机短信 SMSes.SendSCVerifySMS(WorkContext.UserMobile, moibleCode); //将验证值保存在session中 Sessions.SetItem(WorkContext.Sid, "ucsvMoibleCode", moibleCode); return(AjaxResult("success", "短信已经发送,请查收")); }
/// <summary> /// 发送短信验证码 /// </summary> /// <returns></returns> public ActionResult SendSMS() { try { NameValueCollection parmas = WorkContext.postparms; if (parmas.Keys.Count != 4) { return(APIResult("error", "缺少请求参数")); } string account = parmas["account"].Trim().ToLower(); //手机 string code = parmas["code"]; //验证码 string type = parmas["type"]; string body = "【PC蛋蛋】您正在" + type + ",验证码" + code + ",若非本人操作,请勿泄露。"; MD_SMSCode smscode = new MD_SMSCode { Account = account, Code = code, Expiretime = DateTime.Now.AddMinutes(10) }; bool sms = NewUser.AddSMSCode(smscode); if (sms) { //发送短信 bool smsres = SMSes.SendSY(account, HttpUtility.UrlEncode(body, Encoding.UTF8)); if (!smsres) { return(APIResult("error", "发送失败")); } return(APIResult("success", "发送成功")); } else { return(APIResult("error", "发送失败")); } } catch (Exception ex) { return(APIResult("error", "发送失败")); } }
public ActionResult SMS(SMSModel model) { if (ModelState.IsValid) { SMSConfigInfo smsConfigInfo = BSPConfig.SMSConfig; smsConfigInfo.Url = model.Url; smsConfigInfo.UserName = model.UserName; smsConfigInfo.Password = model.Password; smsConfigInfo.FindPwdBody = model.FindPwdBody; smsConfigInfo.SCVerifyBody = model.SCVerifyBody; smsConfigInfo.SCUpdateBody = model.SCUpdateBody; smsConfigInfo.WebcomeBody = model.WebcomeBody; BSPConfig.SaveSMSConfig(smsConfigInfo); SMSes.ResetSMS(); AddAdminOperateLog("修改短信设置"); return(PromptView(Url.Action("sms"), "修改短信设置成功")); } return(View(model)); }
/// <summary> /// 发送找回密码短信 /// </summary> public ActionResult SendFindPwdMobile() { int uid = WebHelper.GetQueryInt("uid"); PartUserInfo partUserInfo = Users.GetPartUserById(uid); if (partUserInfo == null) { return(AjaxResult("nouser", "用户不存在")); } if (partUserInfo.Mobile.Length == 0) { return(AjaxResult("nocanfind", "由于您没有设置手机,所以不能通过手机找回此账号的密码")); } //发送找回密码短信 string moibleCode = Randoms.CreateRandomValue(6); Sessions.SetItem(WorkContext.Sid, "findPwdMoibleCode", moibleCode); SMSes.SendFindPwdMobile(partUserInfo.Mobile, moibleCode); return(AjaxResult("success", "验证码已发送,请查收")); }
public ActionResult Site(SiteModel model) { if (ModelState.IsValid) { MallConfigInfo mallConfigInfo = BMAConfig.MallConfig; mallConfigInfo.MallName = model.MallName == null ? "" : model.MallName; mallConfigInfo.SiteUrl = model.SiteUrl == null ? "" : model.SiteUrl; mallConfigInfo.SiteTitle = model.SiteTitle == null ? "" : model.SiteTitle; mallConfigInfo.SEOKeyword = model.SEOKeyword == null ? "" : model.SEOKeyword; mallConfigInfo.SEODescription = model.SEODescription == null ? "" : model.SEODescription; mallConfigInfo.ICP = model.ICP == null ? "" : model.ICP; mallConfigInfo.Script = model.Script == null ? "" : model.Script; mallConfigInfo.IsLicensed = model.IsLicensed; BMAConfig.SaveMallConfig(mallConfigInfo); Emails.ResetMall(); SMSes.ResetMall(); AddMallAdminLog("修改站点信息"); return(PromptView(Url.Action("site"), "修改站点信息成功")); } return(View(model)); }
public ActionResult Site(SiteModel model) { if (ModelState.IsValid) { ShopConfigInfo shopConfigInfo = BSPConfig.ShopConfig; shopConfigInfo.WebName = model.ShopName == null ? "" : model.ShopName; shopConfigInfo.SiteUrl = model.SiteUrl == null ? "" : model.SiteUrl; shopConfigInfo.SiteTitle = model.SiteTitle == null ? "" : model.SiteTitle; shopConfigInfo.SEOKeyword = model.SEOKeyword == null ? "" : model.SEOKeyword; shopConfigInfo.SEODescription = model.SEODescription == null ? "" : model.SEODescription; shopConfigInfo.ICP = model.ICP == null ? "" : model.ICP; shopConfigInfo.Script = model.Script == null ? "" : model.Script; shopConfigInfo.IsLicensed = model.IsLicensed; BSPConfig.SaveShopConfig(shopConfigInfo); Emails.ResetShop(); SMSes.ResetShop(); AddAdminOperateLog("修改站点信息"); return(PromptView(Url.Action("site"), "修改站点信息成功")); } return(View(model)); }
public ActionResult Account(AccountModel model) { if (ModelState.IsValid) { ShopConfigInfo shopConfigInfo = BSPConfig.ShopConfig; shopConfigInfo.RegType = model.RegType == null ? "" : CommonHelper.IntArrayToString(model.RegType, ""); shopConfigInfo.ReservedName = model.ReservedName ?? ""; shopConfigInfo.RegTimeSpan = model.RegTimeSpan; shopConfigInfo.IsWebcomeMsg = model.IsWebcomeMsg; shopConfigInfo.WebcomeMsg = model.WebcomeMsg ?? ""; shopConfigInfo.LoginType = model.LoginType == null ? "" : CommonHelper.IntArrayToString(model.LoginType, ""); shopConfigInfo.ShadowName = model.ShadowName ?? ""; shopConfigInfo.IsRemember = model.IsRemember; shopConfigInfo.LoginFailTimes = model.LoginFailTimes; BSPConfig.SaveShopConfig(shopConfigInfo); Emails.ResetShop(); SMSes.ResetShop(); AddAdminOperateLog("修改账号设置"); return(PromptView(Url.Action("account"), "修改账号设置成功")); } return(View(model)); }
/// <summary> /// 注册 /// </summary> public ActionResult Register() { string returnUrl = WebHelper.GetQueryString("returnUrl"); if (returnUrl.Length == 0) { returnUrl = Url.Action("index", "home"); } if (WorkContext.MallConfig.RegType.Length == 0) { return(PromptView(returnUrl, "商城目前已经关闭注册功能!")); } if (WorkContext.Uid > 0) { return(PromptView(returnUrl, "你已经是本商城的注册用户,无需再注册!")); } if (WorkContext.MallConfig.RegTimeSpan > 0) { DateTime registerTime = Users.GetRegisterTimeByRegisterIP(WorkContext.IP); if ((DateTime.Now - registerTime).Minutes <= WorkContext.MallConfig.RegTimeSpan) { return(PromptView(returnUrl, "你注册太频繁,请间隔一定时间后再注册!")); } } //get请求 if (WebHelper.IsGet()) { RegisterModel model = new RegisterModel(); model.ReturnUrl = returnUrl; model.ShadowName = WorkContext.MallConfig.ShadowName; model.IsVerifyCode = CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.MallConfig.VerifyPages); return(View(model)); } //ajax请求 string accountName = WebHelper.GetFormString(WorkContext.MallConfig.ShadowName).Trim().ToLower(); string password = WebHelper.GetFormString("password"); string confirmPwd = WebHelper.GetFormString("confirmPwd"); string verifyCode = WebHelper.GetFormString("verifyCode"); StringBuilder errorList = new StringBuilder("["); #region 验证 //账号验证 if (string.IsNullOrWhiteSpace(accountName)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名不能为空", "}"); } else if (accountName.Length < 4 || accountName.Length > 50) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名必须大于3且不大于50个字符", "}"); } else if (accountName.Contains(" ")) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名中不允许包含空格", "}"); } else if (accountName.Contains(":")) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名中不允许包含冒号", "}"); } else if (accountName.Contains("<")) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名中不允许包含'<'符号", "}"); } else if (accountName.Contains(">")) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名中不允许包含'>'符号", "}"); } else if ((!SecureHelper.IsSafeSqlString(accountName, false))) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名不符合系统要求", "}"); } else if (CommonHelper.IsInArray(accountName, WorkContext.MallConfig.ReservedName, "\n")) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "此账户名不允许被注册", "}"); } else if (FilterWords.IsContainWords(accountName)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "账户名包含禁止单词", "}"); } //密码验证 if (string.IsNullOrWhiteSpace(password)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码不能为空", "}"); } else if (password.Length < 4 || password.Length > 32) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码必须大于3且不大于32个字符", "}"); } else if (password != confirmPwd) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "两次输入的密码不一样", "}"); } //验证码验证 if (CommonHelper.IsInArray(WorkContext.PageKey, WorkContext.MallConfig.VerifyPages)) { if (string.IsNullOrWhiteSpace(verifyCode)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "verifyCode", "验证码不能为空", "}"); } else if (verifyCode.ToLower() != Sessions.GetValueString(WorkContext.Sid, "verifyCode")) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "verifyCode", "验证码不正确", "}"); } } //其它验证 int gender = WebHelper.GetFormInt("gender"); if (gender < 0 || gender > 2) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "gender", "请选择正确的性别", "}"); } string nickName = WebHelper.GetFormString("nickName"); if (nickName.Length > 10) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "nickName", "昵称的长度不能大于10", "}"); } else if (FilterWords.IsContainWords(nickName)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "nickName", "昵称中包含禁止单词", "}"); } if (WebHelper.GetFormString("realName").Length > 5) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "realName", "真实姓名的长度不能大于5", "}"); } string bday = WebHelper.GetFormString("bday"); if (bday.Length == 0) { string bdayY = WebHelper.GetFormString("bdayY"); string bdayM = WebHelper.GetFormString("bdayM"); string bdayD = WebHelper.GetFormString("bdayD"); bday = string.Format("{0}-{1}-{2}", bdayY, bdayM, bdayD); } if (bday.Length > 0 && bday != "--" && !ValidateHelper.IsDate(bday)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "bday", "请选择正确的日期", "}"); } string idCard = WebHelper.GetFormString("idCard"); if (idCard.Length > 0 && !ValidateHelper.IsIdCard(idCard)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "idCard", "请输入正确的身份证号", "}"); } int regionId = WebHelper.GetFormInt("regionId"); if (regionId > 0) { if (Regions.GetRegionById(regionId) == null) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "regionId", "请选择正确的地址", "}"); } if (WebHelper.GetFormString("address").Length > 75) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "address", "详细地址的长度不能大于75", "}"); } } if (WebHelper.GetFormString("bio").Length > 150) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "bio", "简介的长度不能大于150", "}"); } //当以上验证都通过时 UserInfo userInfo = null; if (errorList.Length == 1) { if (WorkContext.MallConfig.RegType.Contains("2") && ValidateHelper.IsEmail(accountName))//验证邮箱 { string emailProvider = CommonHelper.GetEmailProvider(accountName); if (WorkContext.MallConfig.AllowEmailProvider.Length != 0 && (!CommonHelper.IsInArray(emailProvider, WorkContext.MallConfig.AllowEmailProvider, "\n"))) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "不能使用'" + emailProvider + "'类型的邮箱", "}"); } else if (CommonHelper.IsInArray(emailProvider, WorkContext.MallConfig.BanEmailProvider, "\n")) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "不能使用'" + emailProvider + "'类型的邮箱", "}"); } else if (Users.IsExistEmail(accountName)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "邮箱已经存在", "}"); } else { userInfo = new UserInfo(); userInfo.UserName = string.Empty; userInfo.Email = accountName; userInfo.Mobile = string.Empty; } } else if (WorkContext.MallConfig.RegType.Contains("3") && ValidateHelper.IsMobile(accountName))//验证手机 { if (Users.IsExistMobile(accountName)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "手机号已经存在", "}"); } else { userInfo = new UserInfo(); userInfo.UserName = string.Empty; userInfo.Email = string.Empty; userInfo.Mobile = accountName; } } else if (WorkContext.MallConfig.RegType.Contains("1"))//验证用户名 { if (accountName.Length > 20) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "用户名长度不能超过20个字符", "}"); } else if (BrnMall.Services.Users.IsExistUserName(accountName)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "accountName", "用户名已经存在", "}"); } else { userInfo = new UserInfo(); userInfo.UserName = accountName; userInfo.Email = string.Empty; userInfo.Mobile = string.Empty; } } } #endregion if (errorList.Length > 1)//验证失败 { return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true)); } else//验证成功 { #region 绑定用户信息 userInfo.Salt = Randoms.CreateRandomValue(6); userInfo.Password = Users.CreateUserPassword(password, userInfo.Salt); userInfo.UserRid = UserRanks.GetLowestUserRank().UserRid; userInfo.StoreId = 0; userInfo.MallAGid = 1;//非管理员组 if (nickName.Length > 0) { userInfo.NickName = WebHelper.HtmlEncode(nickName); } else { userInfo.NickName = "bma" + Randoms.CreateRandomValue(7); } userInfo.Avatar = ""; userInfo.PayCredits = 0; userInfo.RankCredits = 0; userInfo.VerifyEmail = 0; userInfo.VerifyMobile = 0; userInfo.LastVisitIP = WorkContext.IP; userInfo.LastVisitRgId = WorkContext.RegionId; userInfo.LastVisitTime = DateTime.Now; userInfo.RegisterIP = WorkContext.IP; userInfo.RegisterRgId = WorkContext.RegionId; userInfo.RegisterTime = DateTime.Now; userInfo.Gender = WebHelper.GetFormInt("gender"); userInfo.RealName = WebHelper.HtmlEncode(WebHelper.GetFormString("realName")); userInfo.Bday = bday.Length > 0 ? TypeHelper.StringToDateTime(bday) : new DateTime(1900, 1, 1); userInfo.IdCard = WebHelper.GetFormString("idCard"); userInfo.RegionId = WebHelper.GetFormInt("regionId"); userInfo.Address = WebHelper.HtmlEncode(WebHelper.GetFormString("address")); userInfo.Bio = WebHelper.HtmlEncode(WebHelper.GetFormString("bio")); #endregion //创建用户 userInfo.Uid = Users.CreateUser(userInfo); //添加用户失败 if (userInfo.Uid < 1) { return(AjaxResult("exception", "创建用户失败,请联系管理员")); } //发放注册积分 Credits.SendRegisterCredits(ref userInfo, DateTime.Now); //更新购物车中用户id Carts.UpdateCartUidBySid(userInfo.Uid, WorkContext.Sid); //将用户信息写入cookie MallUtils.SetUserCookie(userInfo, 0); //发送注册欢迎信息 if (WorkContext.MallConfig.IsWebcomeMsg == 1) { if (userInfo.Email.Length > 0) { Emails.SendWebcomeEmail(userInfo.Email); } if (userInfo.Mobile.Length > 0) { SMSes.SendWebcomeSMS(userInfo.Mobile); } } //同步上下文 WorkContext.Uid = userInfo.Uid; WorkContext.UserName = userInfo.UserName; WorkContext.UserEmail = userInfo.Email; WorkContext.UserMobile = userInfo.Mobile; WorkContext.NickName = userInfo.NickName; return(AjaxResult("success", "注册成功")); } }
/// <summary> /// 验证手机号 /// </summary> /// <param name="account"></param> /// <param name="paccount"></param> /// <returns></returns> public ActionResult Validate(string account, string paccount) { if (account == string.Empty) { return(AjaxResult("error", "请输入手机号!")); } else if (account.Length != 11) { return(AjaxResult("error", "请输入有效手机号!")); } else if (paccount == string.Empty || paccount.Trim().Length != 11) { return(AjaxResult("error", "访问的分享地址无效!")); } else if (paccount == account) { return(AjaxResult("error", "推广功能只能推荐好友注册呦!")); } else { //bool result = ValidateHelper.IsGZYDModbile(account); //if (!result) //{ // return AjaxResult("error", "主人!请使用您的广州移动号码申请《黑米壳通行证》有更多惊喜等着你哟!!"); //} //else { //验证手机号是否已经领过 DataTable dt = Users.ValidateUser(account); if (dt.Rows.Count > 0) { //return AjaxResult("error", "您已经领取过,每个手机号只能领取一次奥!"); return(AjaxResult("error", "99")); } //发送短信验证码,将验证码记录到数据库 string code = Randoms.CreateRandomValue(6); PartUserInfo puser = Users.GetPartUserByMobile(paccount); if (puser == null) { return(AjaxResult("error", "访问的分享地址无效!")); } //记录数据库 bool addcode = Users.AddInviteInfo(paccount, account, code); if (addcode) { //发送短信 try { bool smsres = SMSes.SendAliSMS(account, "register", code); if (!smsres) { Users.DelInviteInfo(account); return(AjaxResult("error", "短信验证码发送失败,请稍后再试")); } else { return(AjaxResult("success", "发送成功")); } } catch (Exception ex) { Users.DelInviteInfo(account); return(AjaxResult("error", "短信验证码发送失败,请稍后再试")); } } else { return(AjaxResult("error", "发送失败")); } } } }