private bool CheckSMSCode(string Mobile, string CheckCode, int TimeOutSeconds) { bool IsOK = false; //从Cookies中读取验证码并解密 string SrcCheckCode = StringHelper.Decode(CookiesHelper.ReadCookieValue("SMSCheckCode"), "SMS"); //如果验证码值不为空(cookies的有效期只有几分钟) if (!string.IsNullOrEmpty(SrcCheckCode)) { if (SrcCheckCode == CheckCode) { IsOK = true; } CookiesHelper.AddCookie("SMSIsChecked", StringHelper.Encode("true", "SMS"), SMSConfig.CodeTimeOut, TimeType.Minute); } else { SMSRecordInfo SMSRecordModel = SMSRecordBLL.ReadSMSRecord(Mobile, CheckCode); if (SMSRecordModel != null) { if ((DateTime.Now - SMSRecordModel.DataCreateDate).TotalSeconds <= TimeOutSeconds) { if (SMSRecordModel.VerCode == CheckCode) { IsOK = true; } CookiesHelper.AddCookie("SMSCheckCode", StringHelper.Encode(CheckCode, "SMS"), (SMSConfig.CodeTimeOut - (int)(DateTime.Now - SMSRecordModel.DataCreateDate).TotalMinutes), TimeType.Minute); CookiesHelper.AddCookie("SMSIsChecked", StringHelper.Encode("true", "SMS"), (SMSConfig.CodeTimeOut - (int)(DateTime.Now - SMSRecordModel.DataCreateDate).TotalMinutes), TimeType.Minute); } } } return(IsOK); }
public int AddSMSRecord(SMSRecordInfo Model) { StringBuilder sql = new StringBuilder(); sql.Append("insert into [" + ShopMssqlHelper.TablePrefix + "SMSRecord]([Mobile],[VerCode],[DataCreateDate]) values(@Mobile,@VerCode,@DataCreateDate)"); SqlParameter[] par = (SqlParameter[])this.ValueParas(Model); return(DbSQLHelper.ExecuteSql(sql.ToString(), par)); }
//private void VerSMS() //{ // string Mobile = RequestHelper.GetQueryString<string>("Mobile"); // string CheckCode = RequestHelper.GetQueryString<string>("CheckCode"); // int productID = RequestHelper.GetQueryString<int>("CateId"); // int Part = RequestHelper.GetQueryString<int>("Part"); // int UserId = RequestHelper.GetQueryString<int>("UserId"); // bool IsSend = false; // try // { // ProductInfo product = ProductBLL.ReadProduct(productID); // //从Cookies中读取验证码并解密 // string SrcCheckCode = StringHelper.Decode(CookiesHelper.ReadCookieValue("SMSCheckCode"), "SMS"); // //如果验证码值不为空(cookies的有效期只有几分钟) // if (!string.IsNullOrEmpty(SrcCheckCode)) // { // if (SrcCheckCode == CheckCode) IsSend = true; // } // else // { // int TimeOutSeconds = SMSConfig.CodeTimeOut * 60; // //if (TestCateModel.CateCode.Contains("|")) // //{ // // //多个视频,验证有效期延长至五个小时 // // TimeOutSeconds = 5 * 3600; // //} // SMSRecordInfo SMSRecordModel = SMSRecordBLL.ReadSMSRecord(Mobile, CheckCode); // if (SMSRecordModel != null) // { // if ((DateTime.Now - SMSRecordModel.DataCreateDate).TotalSeconds <= TimeOutSeconds) // { // if (SMSRecordModel.VerCode == CheckCode) IsSend = true; // } // } // } // if (IsSend) // { // //添加已验证的cookies标志 // CookiesHelper.AddCookie("SMSIsChecked", StringHelper.Encode("true", "SMS"), SMSConfig.CodeTimeOut, TimeType.Minute); // if (UserId == int.MinValue) UserId = base.UserID; // if (Part < 0) Part = 0; // product.ProductNumber = "a5b7f39294fe8738289db2ae88ccc896_a|a5b7f39294ccd4aa12c69403ad6287ec_a"; // string[] CateCodeArray = product.ProductNumber.Split('|'); // for (int i = 0; i < CateCodeArray.Length; i++) // { // if (Part == i) // ResponseHelper.Write("<li class=\"current\"><a href=\"javascript:compareMoveCode(" + productID.ToString() + "," + i.ToString() + ",'" + Mobile + "','" + CheckCode + "');\">第 " + (i + 1).ToString() + " 集</a></li>"); // else // ResponseHelper.Write("<li><a href=\"javascript:compareMoveCode(" + productID.ToString() + "," + i.ToString() + ",'" + Mobile + "','" + CheckCode + "');\">第 " + (i + 1).ToString() + " 集</a></li>"); // } // ResponseHelper.Write("|http://player.polyv.net/videos/player.swf?vid=" + CateCodeArray[Part] + "&code=" + UserId.ToString() + "_" + CheckCode); // //ResponseHelper.Write("|http://yuntv.letv.com/bcloud.html?uu=debb2235d3&vu=" + CateCodeArray[Part] + "&auto_play=1&gpcflag=1&width=800&height=475&payer_name=" + Mobile + "&check_code=" + UserId.ToString() + "_" + CheckCode + "_" + productID.ToString() + "&extend=0&share=0"); // } // else // { // ResponseHelper.Write("验证码不正确"); // } // } // catch // { // ResponseHelper.Write("异常错误!"); // } //} private void VerSMS() { string Mobile = RequestHelper.GetQueryString <string>("Mobile"); string CheckCode = RequestHelper.GetQueryString <string>("CheckCode"); int productID = RequestHelper.GetQueryString <int>("CateId"); int Part = RequestHelper.GetQueryString <int>("Part"); int UserId = RequestHelper.GetQueryString <int>("UserId"); bool IsSend = false; try { //从Cookies中读取验证码并解密 string SrcCheckCode = StringHelper.Decode(CookiesHelper.ReadCookieValue("SMSCheckCode"), "SMS"); //如果验证码值不为空(cookies的有效期只有几分钟) if (!string.IsNullOrEmpty(SrcCheckCode)) { if (SrcCheckCode == CheckCode) { IsSend = true; } CookiesHelper.AddCookie("SMSIsChecked", StringHelper.Encode("true", "SMS"), SMSConfig.CodeTimeOut, TimeType.Minute); } else { int TimeOutSeconds = SMSConfig.CodeTimeOut * 60; SMSRecordInfo SMSRecordModel = SMSRecordBLL.ReadSMSRecord(Mobile, CheckCode); if (SMSRecordModel != null) { if ((DateTime.Now - SMSRecordModel.DataCreateDate).TotalSeconds <= TimeOutSeconds) { if (SMSRecordModel.VerCode == CheckCode) { IsSend = true; } CookiesHelper.AddCookie("SMSCheckCode", StringHelper.Encode(CheckCode, "SMS"), (SMSConfig.CodeTimeOut - (int)(DateTime.Now - SMSRecordModel.DataCreateDate).TotalMinutes), TimeType.Minute); CookiesHelper.AddCookie("SMSIsChecked", StringHelper.Encode("true", "SMS"), (SMSConfig.CodeTimeOut - (int)(DateTime.Now - SMSRecordModel.DataCreateDate).TotalMinutes), TimeType.Minute); } } } if (IsSend) { //添加已验证的cookies标志 //CookiesHelper.AddCookie("SMSIsChecked", StringHelper.Encode("true", "SMS"), SMSConfig.CodeTimeOut, TimeType.Minute); ResponseHelper.Write("true"); } else { ResponseHelper.Write("验证码不正确"); } } catch { ResponseHelper.Write("异常错误!"); } }
/// <summary> /// 返回数据 /// </summary> /// <returns></returns> public SMSRecordInfo GetModel(SqlDataReader dr) { SMSRecordInfo Model = new SMSRecordInfo(); if (dr.Read()) { Model.Mobile = dr["Mobile"].ToString(); Model.VerCode = dr["VerCode"].ToString(); Model.DataCreateDate = Convert.ToDateTime(dr["DataCreateDate"]); } return(Model); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/json"; string vid = context.Request.QueryString["vid"]; string code = context.Request.QueryString["code"]; string t = context.Request.QueryString["t"]; string callback = context.Request.QueryString["callback"]; int status = 2; string result = string.Empty; try { //判断来源,如果是铃木中国的就放行 string referer = context.Request.ServerVariables["Http_Referer"]; if (referer.ToLower().Contains("suzuki") || referer.ToLower().Contains("player.polyv.net")) { status = 1; string sign = BuildRequestMysign("vid=" + vid + "&secretkey=6NrHe1WPPO&username=suzuki&code=" + code + "&status=" + status + "&t=" + t); result = "{\"status\":" + status + ",\"username\":\"suzuki\",\"sign\":\"" + sign + "\"}"; } else { string[] codeArray = code.Split('_'); UserInfo user = UserBLL.ReadUser(int.Parse(codeArray[0])); if ((user.Status == (int)UserState.Normal || user.Status == (int)UserState.Free || user.Status == (int)UserState.Other) && CompanyBLL.ReadCompany(user.CompanyID).State == 0) { int TimeOutSeconds = SMSConfig.CodeTimeOut * 60; SMSRecordInfo SMSRecordModel = SMSRecordBLL.ReadSMSRecord(user.Mobile, codeArray[1]); if (SMSRecordModel != null) { if ((DateTime.Now - SMSRecordModel.DataCreateDate).TotalSeconds <= TimeOutSeconds) { status = 1; } } } string sign = BuildRequestMysign("vid=" + vid + "&secretkey=6NrHe1WPPO&username="******"&code=" + code + "&status=" + status + "&t=" + t); result = "{\"status\":" + status + ",\"username\":\"" + user.UserName + "\",\"sign\":\"" + sign + "\"}"; } if (!string.IsNullOrEmpty(callback)) { result = string.Format("{0}({1})", callback, result); } } catch { } context.Response.Write(result); }
/// <summary> /// 该数据访问对象的属性值装载到数据库更新参数数组 /// </summary> /// <remarks></remarks> protected IDbDataParameter[] ValueParas(SMSRecordInfo Model) { SqlParameter[] par = { new SqlParameter("@Mobile", SqlDbType.VarChar), new SqlParameter("@VerCode", SqlDbType.VarChar), new SqlParameter("@DataCreateDate", SqlDbType.DateTime) }; par[0].Value = Model.Mobile; par[1].Value = Model.VerCode; par[2].Value = Model.DataCreateDate; return(par); }
private void VerFindSMS() { string Mobile = RequestHelper.GetQueryString <string>("Mobile"); string CheckCode = RequestHelper.GetQueryString <string>("CheckCode"); bool IsSend = false; try { //从Cookies中读取验证码并解密 string SrcCheckCode = StringHelper.Decode(CookiesHelper.ReadCookieValue("SMSCheckCode"), "SMS"); //如果验证码值不为空(cookies的有效期只有几分钟) if (!string.IsNullOrEmpty(SrcCheckCode)) { if (SrcCheckCode == CheckCode) { IsSend = true; } } else { int TimeOutSeconds = 2 * 60; SMSRecordInfo SMSRecordModel = SMSRecordBLL.ReadSMSRecord(Mobile, CheckCode); if (SMSRecordModel != null) { if ((DateTime.Now - SMSRecordModel.DataCreateDate).TotalSeconds <= TimeOutSeconds) { if (SMSRecordModel.VerCode == CheckCode) { IsSend = true; } } } } if (IsSend) { ResponseHelper.Write("0"); } else { ResponseHelper.Write("验证码不正确"); } } catch { ResponseHelper.Write("异常错误!"); } }
private void SendCode() { string Mobile = RequestHelper.GetQueryString <string>("Mobile"); if (!string.IsNullOrEmpty(Mobile)) { UserSearchInfo userSearch = new UserSearchInfo(); userSearch.Mobile = Mobile; List <UserInfo> userList = UserBLL.SearchUserList(userSearch); if (userList.Count > 0) { YXTSMS.YXTSMS api = new YXTSMS.YXTSMS(); string CheckCode = api.MakeCode(); SMSInfo SMSModel = new SMSInfo(); SMSModel.Mobile = Mobile; SMSModel.Content = new string[] { "找回密码", CheckCode, "2" }; if (api.SendSMS(SMSModel)) { SMSRecordInfo SMSRecordModel = new SMSRecordInfo(); SMSRecordModel.Mobile = SMSModel.Mobile; SMSRecordModel.VerCode = CheckCode; SMSRecordModel.DataCreateDate = DateTime.Now; SMSRecordBLL.AddSMSRecord(SMSRecordModel); //验证码加密后写入Cookies中 CookiesHelper.AddCookie("SMSCheckCode", StringHelper.Encode(CheckCode, "SMS"), 2, TimeType.Minute); ResponseHelper.Write("0|发送成功!"); } else { ResponseHelper.Write("1|发送失败!"); } } else { ResponseHelper.Write("2|手机号码不存在!"); } } else { ResponseHelper.Write("1|号码获取失败!"); } }
private void SMSSend(string Mobile, string Content, string TempleId) { YXTSMS.YXTSMS api = new YXTSMS.YXTSMS(); string CheckCode = api.MakeCode(); SMSInfo SMSModel = new SMSInfo(); SMSModel.TempleId = TempleId; SMSModel.Mobile = Mobile; switch (TempleId) { case "17101": SMSModel.Content = new string[] { Content, CheckCode, SMSConfig.CodeTimeOut.ToString() }; break; case "210196": SMSModel.Content = new string[] { CheckCode, SMSConfig.CodeTimeOut.ToString() }; break; } //SMSModel.Content = new string[] { Content, CheckCode, SMSConfig.CodeTimeOut.ToString() }; if (api.SendSMS(SMSModel)) { SMSRecordInfo SMSRecordModel = new SMSRecordInfo(); SMSRecordModel.Mobile = SMSModel.Mobile; SMSRecordModel.VerCode = CheckCode; SMSRecordModel.DataCreateDate = DateTime.Now; SMSRecordBLL.AddSMSRecord(SMSRecordModel); //验证码加密后写入Cookies中 CookiesHelper.AddCookie("SMSCheckCode", StringHelper.Encode(CheckCode, "SMS"), SMSConfig.CodeTimeOut, TimeType.Minute); ResponseHelper.Write("0|发送成功!"); } else { ResponseHelper.Write("1|发送失败!"); } }
private void SendCheckCode() { string mobile = RequestHelper.GetQueryString <string>("Mobile"); int productID = RequestHelper.GetQueryString <int>("CateId"); int userID = RequestHelper.GetQueryString <int>("UserId"); if (!string.IsNullOrEmpty(mobile)) { //try { //if (string.IsNullOrEmpty(CookiesHelper.ReadCookieValue("SMSCheckCode"))) { UserInfo user = new UserInfo(); if (userID == int.MinValue) { userID = base.UserID; } if (UserID > 0) { user = UserBLL.ReadUser(userID); } else { user = UserBLL.ReadUserByMobile(mobile); } if ((user.Status == (int)UserState.Normal || user.Status == (int)UserState.Free || user.Status == (int)UserState.Other) && CompanyBLL.ReadCompany(user.CompanyID).State == 0) { if (mobile == user.Mobile) { YXTSMS.YXTSMS api = new YXTSMS.YXTSMS(); string CheckCode = api.MakeCode(); SMSInfo SMSModel = new SMSInfo(); SMSModel.Mobile = mobile; //SMSModel.Content = new string[] { ProductBLL.ReadProduct(productID).Name, CheckCode, SMSConfig.CodeTimeOut.ToString() }; SMSModel.Content = new string[] { CheckCode, SMSConfig.CodeTimeOut.ToString() }; if (api.SendSMS(SMSModel)) { SMSRecordInfo SMSRecordModel = new SMSRecordInfo(); SMSRecordModel.Mobile = SMSModel.Mobile; SMSRecordModel.VerCode = CheckCode; SMSRecordModel.DataCreateDate = DateTime.Now; SMSRecordBLL.AddSMSRecord(SMSRecordModel); //验证码加密后写入Cookies中 CookiesHelper.AddCookie("SMSCheckCode", StringHelper.Encode(CheckCode, "SMS"), SMSConfig.CodeTimeOut, TimeType.Minute); ResponseHelper.Write("0|发送成功!|" + user.ID); } else { ResponseHelper.Write("1|发送失败!"); } } else { ResponseHelper.Write("2|输入的手机号码与登记的号码不一致!"); } } else { ResponseHelper.Write("2|帐号不能使用!"); } } //else //{ // ResponseHelper.Write("1|请勿频繁操作!"); //} } //catch //{ // ResponseHelper.Write("1|异常错误!"); //} } else { ResponseHelper.Write("1|号码获取失败!"); } }
protected override void PostBack() { string userName = StringHelper.SearchSafe(RequestHelper.GetForm <string>("UserName")); //string email = StringHelper.SearchSafe(RequestHelper.GetForm<string>("Email")); //string form = RequestHelper.GetForm<string>("SafeCode"); string mobile = StringHelper.SearchSafe(RequestHelper.GetForm <string>("phone")); string code = StringHelper.SearchSafe(RequestHelper.GetForm <string>("inputmovecode")); //int id = 0; if (userName == string.Empty) { this.errorMessage = "用户名不能为空"; } if (string.IsNullOrEmpty(mobile)) { this.errorMessage = "手机号码不能为空"; } if (this.errorMessage == string.Empty) { //id = UserBLL.CheckUserName(userName); //if (id == 0) //{ // this.errorMessage = "不存在该用户名"; //} UserSearchInfo userSearch = new UserSearchInfo(); userSearch.Mobile = mobile; userSearch.UserName = UserName; if (UserBLL.SearchUserList(userSearch).Count <= 0) { this.errorMessage = "不存在该用户名"; } } if (this.errorMessage == string.Empty) { bool IsSend = false; //从Cookies中读取验证码并解密 string SrcCheckCode = StringHelper.Decode(CookiesHelper.ReadCookieValue("SMSCheckCode"), "SMS"); //如果验证码值不为空(cookies的有效期只有几分钟) if (!string.IsNullOrEmpty(SrcCheckCode)) { if (SrcCheckCode == code) { IsSend = true; } } else { int TimeOutSeconds = 2 * 60; SMSRecordInfo SMSRecordModel = SMSRecordBLL.ReadSMSRecord(mobile, code); if (SMSRecordModel != null) { if ((DateTime.Now - SMSRecordModel.DataCreateDate).TotalSeconds <= TimeOutSeconds) { if (SMSRecordModel.VerCode == code) { IsSend = true; } } } } if (!IsSend) { this.errorMessage = "手机验证码错误!"; } } //if ((this.errorMessage == string.Empty) && (email == string.Empty)) //{ // this.errorMessage = "Email不能为空"; //} //if ((this.errorMessage == string.Empty) && !UserBLL.CheckEmail(email)) //{ // this.errorMessage = "不存在该Email"; //} //if ((this.errorMessage == string.Empty) && (form.ToLower() != Cookies.Common.checkcode.ToLower())) //{ // this.errorMessage = "验证码错误"; //} //if ((this.errorMessage == string.Empty) && (UserBLL.ReadUser(id).Email != email)) //{ // this.errorMessage = "用户名和Email不匹配"; //} if (this.errorMessage == string.Empty) { //string safeCode = Guid.NewGuid().ToString(); //UserBLL.ChangeUserSafeCode(id, safeCode, RequestHelper.DateNow); //string newValue = "http://" + base.Request.ServerVariables["HTTP_HOST"] + "/User/ResetPassword.aspx?CheckCode=" + StringHelper.Encode(string.Concat(new object[] { id, "|", email, "|", userName, "|", safeCode }), ShopConfig.ReadConfigInfo().SecureKey); //EmailContentInfo info2 = EmailContentHelper.ReadSystemEmailContent("FindPassword"); //EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo(); //emailSendRecord.Title = info2.EmailTitle; //emailSendRecord.Content = info2.EmailContent.Replace("$Url$", newValue); //emailSendRecord.IsSystem = 1; //emailSendRecord.EmailList = email; //emailSendRecord.IsStatisticsOpendEmail = 0; //emailSendRecord.SendStatus = 1; //emailSendRecord.AddDate = RequestHelper.DateNow; //emailSendRecord.SendDate = RequestHelper.DateNow; //emailSendRecord.ID = EmailSendRecordBLL.AddEmailSendRecord(emailSendRecord); //EmailSendRecordBLL.SendEmail(emailSendRecord); //this.result = "您的申请已提交,请登录邮箱重设你的密码!<a href=\"http://mail." + email.Substring(email.IndexOf("@") + 1) + "\" target=\"_blank\">马上登录</a>"; //ResponseHelper.Redirect("/User/FindPassword.aspx?Result=" + base.Server.UrlEncode(this.result)); string userPassword = RequestHelper.GetForm <string>("password"); UserSearchInfo userSearch = new UserSearchInfo(); userSearch.Mobile = mobile; userSearch.UserName = userName; userSearch.StatusNoEqual = (int)UserState.Del; List <UserInfo> userList = UserBLL.SearchUserList(userSearch); if (userList.Count < 5) //限制一下,安全第一,以免条件出错,把所有的都改了 { foreach (UserInfo user in userList) { user.UserPassword = StringHelper.Password(userPassword, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); UserBLL.ChangePassword(user.ID, user.UserPassword); } } ScriptHelper.Alert("修改成功!", "/User/Login.aspx"); } else { ResponseHelper.Redirect("/User/FindPassword.aspx?ErrorMessage=" + base.Server.UrlEncode(this.errorMessage)); } }
public static int AddSMSRecord(SMSRecordInfo Model) { return(dal.AddSMSRecord(Model)); }