/// <summary> /// 语音通知短信接口 /// </summary> /// <returns></returns> public ActionResult vsmscode() { string json = ""; string mobile = Utils.CheckSQLHtml(DNTRequest.GetString("mobile")); string vvcode = Utils.CheckSQLHtml(DNTRequest.GetString("vcode")); string ipc = Utils.GetRealIP(); M_td_SMS_record p = new M_td_SMS_record(); B_td_SMS_record o = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.语音短信验证码.ToString()); int smstype1 = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.短信验证码.ToString()); string sql = "select sms_record_id,smscontext,phone_number,vcode,sendtime,hits from hx_td_SMS_record where (smstype=" + smstype + " or smstype=" + smstype1 + " ) and phone_number='" + mobile + "' and DATEDIFF(MINUTE,sendtime,getDate())<3 order by sms_record_id desc"; if (vvcode.Length >= 4) { string strIdentify = "ValidateCode"; //随机字串存储键值,以便存储到Session中 if (Session[strIdentify] != null) { if (Session[strIdentify].ToString() != vvcode) { json = @" {""rs"": ""n"", ""info"": ""验证码不对!""}"; return(Content(json)); } } else { json = @" {""rs"": ""n"", ""info"": ""验证码已过期!""}"; return(Content(json)); } } else { json = @" {""rs"": ""n"", ""info"": ""v""}"; return(Content(json)); } if (ck.checkmobile(mobile) != "y") { json = @" {""rs"": ""n"", ""info"": ""手机号已经被注册!""}"; return(Content(json)); } //短信防刷 if (Session["checkmobile"] == null) { Session["checkmobile"] = DateTime.Now.ToString(); } else { DateTime dte = DateTime.Parse(Session["checkmobile"].ToString()); long sec = Utils.DateDiff("Second", dte, DateTime.Now); if (sec > 60) { Session["checkmobile"] = null; } else { json = @" {""rs"": ""n"", ""info"": ""短信发送太频繁!请稍后再试""}"; return(Content(json)); } } if (ck.checkipsess(ipc, smstype, smstype1) == false) { json = @" {""rs"": ""n"", ""info"": ""短信发送太频繁!发送异常""}"; return(Content(json)); } //限制ip访问发送次数验证码最多发送4次 if (ck.checkipnum(Utils.GetRealIP(), smstype, smstype1) >= 8) { json = @" {""rs"": ""n"", ""info"": ""短信发送太频繁!请与客服联系""}"; return(Content(json)); } else { DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { //以前存在,直接发送验证码 // decimal dd = SendSMS.Send_SMS(dt.Rows[0]["phone_number"].ToString(), dt.Rows[0]["smscontext"].ToString()); if (int.Parse(dt.Rows[0]["hits"].ToString()) < 8) { //string vstr = "您的验证码是 " + Utils.strJoin(dt.Rows[0]["vcode"].ToString()); string vstr = dt.Rows[0]["vcode"].ToString(); decimal dd = SendSMS.Send_Audio(dt.Rows[0]["phone_number"].ToString(), vstr); if (dd > 0) { sql = "update hx_td_SMS_record set orderid=" + dd.ToString() + ",hits=hits+1 where sms_record_id=" + dt.Rows[0]["sms_record_id"].ToString(); DbHelperSQL.RunSql(sql); } } else { json = @" {""rs"": ""n"", ""info"": ""短信发送异常,请与客报联系""}"; return(Content(json)); } } else { //不存在生成新的验证码 string vcode = Utils.RndNum(6); //string vstr = "您的验证码是 " + Utils.strJoin(vcode); string vstr = vcode; string smscontxt = Utils.GetMSMEmailContext(8, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(smscontxt); sbsms = sbsms.Replace("#CODE#", vcode); p.phone_number = mobile; p.sendtime = DateTime.Now; p.senduserid = 0; p.smstype = smstype; p.smscontext = sbsms.ToString(); // p.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); p.orderid = SendSMS.Send_Audio(mobile, vstr); p.vcode = vcode; o.Add(p); } json = @" {""rs"": ""y"", ""info"": ""语音短信发送成功! 请留意接听电话 ""}"; } return(Content(json)); }
public ActionResult Changepass() { string json = ""; string tel1 = Utils.CheckSQLHtml(DNTRequest.GetString("t")); string rid1 = Utils.CheckSQLHtml(DNTRequest.GetString("key")); string vcode1 = Utils.CheckSQLHtml(DNTRequest.GetString("c")); string pcode1 = Utils.CheckSQLHtml(DNTRequest.GetString("p")); string rid = ""; if (rid1 != "") { rid = DESEncrypt.Decrypt(rid1, ConfigurationManager.AppSettings["webp"].ToString()); } string tel = ""; if (tel1 != "") { tel = DESEncrypt.Decrypt(tel1, ConfigurationManager.AppSettings["webp"].ToString()); } string vcode = ""; if (vcode1 != "") { vcode = DESEncrypt.Decrypt(vcode1, ConfigurationManager.AppSettings["webp"].ToString()); } string pcode = ""; if (pcode1 != "") { pcode = DESEncrypt.Decrypt(pcode1, ConfigurationManager.AppSettings["webp"].ToString()); } string pass = ""; string sql = ""; if (pcode == "gettel") { sql = "select top 1 smscontext,phone_number from hx_td_SMS_record where ( smstype=8 or smstype=7) and phone_number='" + tel + "' and vcode='" + vcode + "' and DATEDIFF(MINUTE,sendtime,getDate())<3 order by sms_record_id desc"; DataTable dtc = DbHelperSQL.GET_DataTable_List(sql); var ts = true; if (Settings.Instance.SiteDomain.IndexOf(PublicURL.NewPCUrl) >= 0) { ts = false; } if (dtc.Rows.Count > 0 || ts) { sql = "select registerid,mobile from hx_member_table where registerid=" + rid + " and mobile='" + tel + "' "; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { pass = DESEncrypt.Encrypt(Utils.CheckSQLHtml(DNTRequest.GetString("userpassword")), ConfigurationManager.AppSettings["webp"].ToString()); sql = "update hx_member_table set password='******' where registerid=" + rid; if (DbHelperSQL.ExecuteSql(sql) > 0) { DateTime dti = DateTime.Now; M_td_System_message p = new M_td_System_message(); p.MReg = int.Parse(dt.Rows[0]["registerid"].ToString()); p.Mstate = 0; p.MTitle = "安全提示"; p.MContext = "您在" + dti.ToString("yyyy-MM-dd HH:mm:ss") + "使用手机进行了密码找回操作,如非本人操作请联系客服"; p.PubTime = dti; B_usercenter.AddMessage(p); M_td_SMS_record pm = new M_td_SMS_record(); B_td_SMS_record om = new B_td_SMS_record(); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.修改密码.ToString()); string smscontxt = Utils.GetMSMEmailContext(17, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(smscontxt); string mobile = tel; sbsms = sbsms.Replace("#DATATIME#", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); pm.phone_number = mobile; pm.sendtime = DateTime.Now; pm.senduserid = int.Parse(dt.Rows[0]["registerid"].ToString()); pm.smstype = smstype; pm.smscontext = sbsms.ToString(); // p.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); pm.orderid = SendSMS.Send_Audio(mobile, smscontxt); pm.vcode = ""; om.Add(pm); json = @" {""rs"": ""y"", ""info"": ""新密码设置成功!"",""url"":""/""}"; return(Content(json)); } else { json = @" {""rs"": ""n"", ""info"": ""新密码设置失败!""}"; return(Content(json)); } } else { json = @" {""rs"": ""n"", ""info"": ""数据异常!""}"; return(Content(json)); } } else { json = @" {""rs"": ""n"", ""info"": ""验证码无效,或已经过期,请重新获取!""}"; return(Content(json)); } } return(Content(json)); }