Example #1
0
    private void SecondSave()    //验证问题答案,修改问题
    {
        int meid = new BCW.User.Users().GetUsId();

        if (meid == 0)
        {
            Utils.Login();
        }
        string MyMobile = new BCW.BLL.User().GetMobile(meid);

        string answer  = Utils.GetRequest("Myanswer", "post", 1, @"^[\s\S]{1,20}$", ""); //获取输入的答案
        string Myanser = new BCW.BLL.tb_Question().GetAnswer(meid);
        string code    = Utils.GetRequest("code", "post", 1, @"^[0-9]{4}$", "");         //
        //string code = Utils.GetRequest("code", "post", 0, "", "");  //获取输入的答案
        string mycode = Request.Cookies["validateCookie"].Values["ChkCode"].ToString();
        string ac     = Utils.GetRequest("ac", "all", 1, "", "");

        builder.Append(Out.Tab("<div class=\"title\">", ""));
        builder.Append("<a href=\"" + Utils.getUrl("/default.aspx") + "\">首页</a>-");
        builder.Append("<a href=\"" + Utils.getPage("/bbs/pwd/GetPwd.aspx") + "\">上级</a>");
        builder.Append(Out.Tab("</div>", "<br/>"));

        if (Utils.ToSChinese(ac).Contains("刷新验证码"))    //判断哪一个按键
        {
            #region
            Master.Title = "我的密码保护问题管理";
            string Myquestion = new BCW.BLL.tb_Question().GetQuestion(meid);
            builder.Append(Out.Tab("<div class=\"text\">", ""));
            // builder.Append("<b>验证码错误</b>");
            builder.Append("修改密码保护问题时需要先回答你的问题答案" + "<br />");
            builder.Append("<b>你的问题是:" + Myquestion + "</b>");
            builder.Append(Out.Tab("</div>", ""));
            BCW.Model.tb_Validate getmo = null;
            if (new BCW.BLL.tb_Validate().ExistsPhone(new BCW.BLL.User().GetMobile(meid), 3))//修改密保验证码
            {
                getmo = new BCW.BLL.tb_Validate().Gettb_Validate(new BCW.BLL.User().GetMobile(meid), 3);
                string   Reg     = string.Empty;
                DateTime endtime = getmo.codeTime;
                if (!Utils.Isie() && !Utils.GetUA().ToLower().Contains("opera/8"))
                {
                    Reg = new BCW.JS.somejs().daojishi2("Reg", endtime);
                }
                else
                {
                    Reg = new BCW.JS.somejs().daojishi("Reg", endtime);
                }
                if (endtime > DateTime.Now)
                {
                    builder.Append(Out.Tab("<div class=\"\">", ""));
                    builder.Append("请在<b style=\"color:red\">" + Reg + "</b>秒后再次获取手机验证码<br/>");
                    builder.Append(Out.Tab("</div>", "<br/>"));
                }
            }
            strText = "你的问题答案是:/,*请输入手机验证码:/,输入验证码:/,,";
            strName = "Myanswer,phoneCode,code,hid,act";
            strType = "text,text,text,hidden,hidden";
            strValu = "'''" + 1 + "'secondsave";
            strEmpt = "false,false,false,false,false";
            strIdea = "'<a href=\"" + Utils.getUrl("SetQuestion.aspx?act=secondsave&amp;info=ok&amp;ac=ok") + "\">获取手机验证码</a>'<img src=\"Code.aspx\"/>''|/";
            strOthe = "确定提交|刷新验证码,SetQuestion.aspx,post,0,red|blue";
            builder.Append(Out.wapform(strText, strName, strType, strValu, strEmpt, strIdea, strOthe));
            builder.Append("<br/>" + "<a href=\"" + Utils.getUrl("SetQuestion.aspx?act=formibao") + "\">【忘记密保】</a><br/>");
            #region
            int    SizeNum  = 3;
            string strWhere = "";
            IList <BCW.Model.tb_Help> listHelp = new BCW.BLL.tb_Help().GetHelps(SizeNum, strWhere);
            if (listHelp.Count > 0)
            {
                builder.Append(Out.Div("div", "相关帮助.." + "<br/>"));

                int k = 1;
                foreach (BCW.Model.tb_Help n in listHelp)
                {
                    if (k == 1)
                    {
                        builder.Append(Out.Tab("<div>", ""));
                    }
                    else
                    {
                        builder.Append(Out.Tab("<div>", "<br />"));
                    }
                    builder.Append("<a href=\"" + Utils.getUrl("MoreQuestion.aspx?act=shuoming&amp;id=" + n.ID + "") + "\">" + n.Title + "</a>");

                    builder.Append(Out.Tab("</div>", ""));
                    k++;
                }
            }
            else
            {
                builder.Append(Out.Div("div", "没有相关记录.."));
            }
            #endregion
            builder.Append(Out.Tab("<div class=\"text\">", ""));
            builder.Append("<br/><a href=\"" + Utils.getUrl("MoreQuestion.aspx") + "\">&gt;&gt;更多</a><br />");
            builder.Append("<a href=\"" + Utils.getUrl("/default.aspx?id=7") + "\">客服帮助</a>");
            builder.Append(Out.Tab("</div>", ""));
            #endregion
        }
        else if (Utils.ToSChinese(ac).Contains("获取手机验证码") || ac == "ok" || ac == "ok1")    //判断哪一个按键
        {
            #region 获取手机验证码
            //if (ac == "ok")
            //{
            //    if (!code.Equals(mycode))//验证码相等
            //    {
            //     //   Utils.Error("很抱歉,您输入图形验证按不对,请刷新2页面", "");
            //    }
            //}
            if (new BCW.BLL.tb_Validate().ExistsPhone(new BCW.BLL.User().GetMobile(meid), 3))//存在修改密保验证码
            {
                BCW.Model.tb_Validate getmo = new BCW.BLL.tb_Validate().Gettb_Validate(new BCW.BLL.User().GetMobile(meid), 3);
                if (getmo.codeTime > DateTime.Now)//验证码存在切是新发的
                {
                    string   dateDiff = null;
                    TimeSpan x        = getmo.codeTime - DateTime.Now;
                    dateDiff = x.TotalSeconds.ToString();
                    Utils.Error("很抱歉,请在" + dateDiff.Split('.')[0] + "秒之后再次获取手机验证码", "");
                }
            }
            string mobile    = new BCW.BLL.User().GetMobile(meid);
            char[] character = { '0', '1', '2', '3', '4', '5', '6', '8', '9' };
            string mesCode   = string.Empty; //手机验证码
            Random rnd       = new Random();
            //生成验证码字符串
            for (int i = 0; i < 4; i++)
            {
                mesCode += character[rnd.Next(character.Length)];
            }
            //int tm = 2;//短信过期时间
            //int total = 15;//每天可以发的总短信量
            //int ipCount = 10;
            //int phoneCount = 10;
            int tm         = int.Parse(ub.GetSub("msgTime", "/Controls/guestlist.xml"));
            int total      = int.Parse(ub.GetSub("dayCount", "/Controls/guestlist.xml"));
            int ipCount    = int.Parse(ub.GetSub("IPCount", "/Controls/guestlist.xml"));
            int phoneCount = int.Parse(ub.GetSub("phoneCount", "/Controls/guestlist.xml"));
            int msgremain  = int.Parse(ub.GetSub("msgremain", "/Controls/guestlist.xml"));
            int callID     = int.Parse(ub.GetSub("callID", "/Controls/guestlist.xml"));
            if (new BCW.BLL.tb_Validate().ExistsPhone(mobile))//不是第一次获取短信
            {
                DataSet  data       = new BCW.BLL.tb_Validate().GetList(" Top 1 *", "Phone=" + mobile + " order by time desc");
                DateTime changeTime = Convert.ToDateTime(data.Tables[0].Rows[0]["Time"].ToString());
                int      changeday  = changeTime.DayOfYear;
                if ((DateTime.Now.DayOfYear - changeday) >= 1)//上一条短信不是在当天
                {
                    BCW.Model.tb_Validate validate = new BCW.Model.tb_Validate();
                    validate.Phone    = mobile;
                    validate.IP       = Utils.GetUsIP();
                    validate.Time     = DateTime.Now.AddMinutes(0);
                    validate.Flag     = 1;
                    validate.mesCode  = mesCode;
                    validate.codeTime = DateTime.Now.AddMinutes(tm);
                    validate.type     = 3;
                    string result = "";
                    Mesege.Soap57ProviderService MesExt = new Mesege.Soap57ProviderService();
                    result = MesExt.Submit("000379", "123456", "1069032239089369", "【" + ub.GetSub("SiteName", "/Controls/wap.xml") + "】亲,您的验证码是:" + mesCode, mobile);
                    string[] results = result.Split('#');
                    if (results[8] != "0")
                    {
                        Utils.Error("请确认手机号的正确性,如不能为空号!" + results[8], "");
                    }
                    if ((int.Parse(results[2]) / 80) < msgremain)
                    {
                        new BCW.BLL.Guest().Add(0, callID, "", "剩余短信数量低于" + msgremain + "条了,请注意!");
                    }
                    if (results[8] == "0")
                    {
                        new BCW.BLL.tb_Validate().Add(validate);
                        if (ac == "ok1")
                        {
                            Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("SetQuestion.aspx?act=formibao&amp;mobile=" + mobile), "2");
                        }
                        else
                        {
                            Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("SetQuestion.aspx"), "2");
                        }
                    }
                }
                else//当天时间内
                {
                    DataSet dt2 = new BCW.BLL.tb_Validate().GetList("*", "Phone=" + mobile + " and time>='" + DateTime.Now.ToShortDateString() + "' order by time desc");
                    if (dt2.Tables[0].Rows.Count >= total)//当天时间内超过特定数
                    {
                        Utils.Error("抱歉!当天时间内过于频繁获取短信,请明天再试!", "");
                    }
                    DateTime check = DateTime.Now.AddMinutes(-30);
                    if (check.DayOfYear < DateTime.Now.DayOfYear)
                    {
                        check = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    }
                    else
                    {
                        check = DateTime.Now.AddMinutes(-30);
                    }
                    //Utils.Error("check:"+ check, "");
                    string  str = "Phone=" + mobile + " and time>='" + check + "' and time <='" + DateTime.Now + "' order by time desc";
                    DataSet dt1 = new BCW.BLL.tb_Validate().GetList("*", str);
                    if (data.Tables[0].Rows[0]["Flag"].ToString() == "0")//最新一条显示当天不能发送了
                    {
                        Utils.Error("抱歉!由于之前你存在频繁获取短信,请明天再试!", "");
                    }
                    string IP = Utils.GetUsIP();
                    //查看限制IP
                    string  str1 = "IP= '" + IP + "' and time>='" + check + "' and time <='" + DateTime.Now + "' order by time desc";
                    DataSet dt3  = new BCW.BLL.tb_Validate().GetList("*", str1);
                    if (dt3.Tables[0].Rows.Count >= ipCount)//半小时内超过10条
                    {
                        Utils.Error("当前IP过于频繁获取短信,请明天再试!" + dt3.Tables[0].Rows.Count, "");
                    }
                    if (dt1.Tables[0].Rows.Count >= phoneCount)//半小时内超过10条
                    {
                        //跟新标示
                        int ID = int.Parse(dt1.Tables[0].Rows[0]["ID"].ToString());
                        new BCW.BLL.tb_Validate().UpdateFlag(0, ID);
                        Utils.Error("请勿频繁获取短信,请明天再试!", "");
                    }
                    else
                    {
                        BCW.Model.tb_Validate validate = new BCW.Model.tb_Validate();
                        validate.Phone    = mobile;
                        validate.IP       = Utils.GetUsIP();
                        validate.Time     = DateTime.Now.AddMinutes(0);
                        validate.Flag     = 1;
                        validate.mesCode  = mesCode;
                        validate.codeTime = DateTime.Now.AddMinutes(tm);
                        validate.type     = 3;
                        string result = "";
                        Mesege.Soap57ProviderService MesExt = new Mesege.Soap57ProviderService();
                        result = MesExt.Submit("000379", "123456", "1069032239089369", "【" + ub.GetSub("SiteName", "/Controls/wap.xml") + "】亲,您的验证码是:" + mesCode, mobile);
                        string[] results = result.Split('#');
                        if (results[8] != "0")
                        {
                            Utils.Error("请确认手机号的正确性,如不能为空号!" + results[8], "");
                        }
                        if ((int.Parse(results[2]) / 80) < msgremain)
                        {
                            new BCW.BLL.Guest().Add(0, callID, "", "剩余短信数量低于" + msgremain + "条了,请注意!");
                        }
                        if (results[8] == "0")
                        {
                            new BCW.BLL.tb_Validate().Add(validate);
                            if (ac == "ok1")
                            {
                                Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("SetQuestion.aspx?act=formibao&amp;mobile=" + mobile), "2");
                            }
                            else
                            {
                                Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("SetQuestion.aspx"), "2");
                            }
                        }
                    }
                }
            }
            else
            {
                BCW.Model.tb_Validate validate = new BCW.Model.tb_Validate();
                validate.Phone    = mobile;
                validate.IP       = Utils.GetUsIP();
                validate.Time     = DateTime.Now.AddMinutes(0);
                validate.Flag     = 1;
                validate.mesCode  = mesCode;
                validate.codeTime = DateTime.Now.AddMinutes(tm);
                validate.type     = 3;
                string result = "";
                Mesege.Soap57ProviderService MesExt = new Mesege.Soap57ProviderService();
                result = MesExt.Submit("000379", "123456", "1069032239089369", "【" + ub.GetSub("SiteName", "/Controls/wap.xml") + "】亲,您的验证码是:" + mesCode, mobile);
                string[] results = result.Split('#');
                if (results[8] != "0")
                {
                    Utils.Error("请确认手机号的正确性,如不能为空号!" + results[8], "");
                }
                if ((int.Parse(results[2]) / 80) < msgremain)
                {
                    new BCW.BLL.Guest().Add(0, callID, "", "剩余短信数量低于" + msgremain + "条了,请注意!");
                }
                if (results[8] == "0")
                {
                    new BCW.BLL.tb_Validate().Add(validate);
                    if (ac == "ok1")
                    {
                        Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("SetQuestion.aspx?act=formibao&amp;mobile=" + mobile), "2");
                    }
                    else
                    {
                        Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("SetQuestion.aspx"), "2");
                    }
                }
            }
            #endregion
        }
        else   //确定提交
        {
            #region 确定提交
            if (!code.Equals(mycode))//验证码相等
            {
                Utils.Error("输入的图形验证码错误,请刷新..", "");
            }
            if (Utils.ToSChinese(ac).Contains("确定提交"))
            {
                if (!Myanser.Equals(answer))    //答案相等
                {
                    Utils.Error("输入的问题答案错误,请重新输入.", "");
                }
            }
            string phoneCode            = Utils.GetRequest("phoneCode", "post", 2, @"^[0-9]{4}$", "请输入正确的四位手机验证码");
            BCW.Model.tb_Validate getmo = null;
            string mobile = new BCW.BLL.User().GetMobile(meid);
            if (new BCW.BLL.tb_Validate().ExistsPhone(mobile, 3))//存在修改密保验证码
            {
                getmo = new BCW.BLL.tb_Validate().Gettb_Validate(mobile, 3);
                if (getmo.codeTime > DateTime.Now)        //验证码存在且是新发的
                {
                    if (!phoneCode.Equals(getmo.mesCode)) //验证码不相等
                    {
                        Utils.Error("很抱歉,您输入手机验证码不对222", "");
                    }
                }
                else
                {
                    Utils.Error("手机验证码过期,请重新获取", "");
                }
            }
            else//没发送过修改密保验证码
            {
                Utils.Error("很抱歉,您输入手机验证码不对123", "");
            }

            builder.Append(Out.Tab("<div class=\"text\">", ""));
            builder.Append("<b>★可选问题方式(自定义问题):</b>");
            // builder.Append("<b>★:<a href=\"" + Utils.getUrl("SetQuestion.aspx?act=secondsave&amp;type1=" + 1) + "\">自定义问题</a></b>");
            builder.Append(Out.Tab("</div>", ""));
            // builder.Append(Out.Tab("</div>", ""));
            strText = ",";
            strName = "type1:/,act";
            strType = "hideen,hidden";
            strValu = 1 + "'design2";
            strEmpt = "false,false";
            strIdea = "/";
            strOthe = "自定义问题,SetQuestion.aspx,post,0,red";
            builder.Append(Out.wapform(strText, strName, strType, strValu, strEmpt, strIdea, strOthe));
            //
            strText = "选择问题:/,问题答案/,,";
            strName = "Myquestion,Myanswer,hid,act";
            strType = "select,text,hidden,hidden";
            strValu = "''" + 1 + "'savepageagain";
            strEmpt = "你就读第一所学校的名字?|你就读第一所学校的名字?|你最喜欢的电影名称是什么?|你最喜欢的电影名称是什么?|你最喜欢的书是什么?|你最喜欢的书是什么?|你最喜欢的歌曲名称是什么?|你最喜欢的歌曲名称是什么?|你最喜欢的食物是什么?|你最喜欢的食物是什么?,false,false,false";
            strIdea = "/";
            strOthe = "提交,SetQuestion.aspx,post,0,red";
            builder.Append(Out.wapform(strText, strName, strType, strValu, strEmpt, strIdea, strOthe));
            #endregion
        }

        builder.Append(Out.Tab("<div class=\"title\">", "<br/>"));
        builder.Append("<a href=\"" + Utils.getUrl("/default.aspx") + "\">首页</a>-");
        builder.Append("<a href=\"" + Utils.getPage("/bbs/pwd/GetPwd.aspx") + "\">上级</a>");
        builder.Append(Out.Tab("</div>", ""));
    }
Example #2
0
    /// <summary>
    /// 获取手机码
    /// </summary>
    private void vacode()
    {
        builder.Append(Out.Tab("<div class=\"title\">", "<br/>"));
        builder.Append("<a href=\"" + Utils.getUrl("/default.aspx") + "\">首页</a>-");
        builder.Append("<a href=\"" + Utils.getPage("/bbs/pwd/GetPwd.aspx") + "\">上级</a>");
        builder.Append(Out.Tab("</div>", ""));
        string info = Utils.GetRequest("info", "all", 1, "", "");
        //string mobile = Utils.GetRequest("mobile21", "post", 2, @"^(?:13|14|15|18)\d{9}$", "请正确输入十一位数的手机号码");
        string account = Utils.GetRequest("account", "post", 2, @"^\d+$", "请正确输入号码");
        {
            #region  msg
            //string mycode = "";
            //try
            //{
            //    mycode = Request.Cookies["validateCookie"].Values["ChkCode"].ToString();// 图形验证码
            //}
            //catch { }
            //string code = Utils.GetRequest("code", "post", 2, @"^[0-9]{4}$", "请输入验证码!");  //界面图形验证码
            //if (!code.Equals(mycode))//验证码相等
            //{
            //    Utils.Error("很抱歉,您输入图形验证按不对,请刷新页面", "");
            //}
            //if (!new BCW.BLL.User().Exists(new BCW.BLL.User().GetID(mobile)))
            //{
            //    Utils.Error("不存在该手机号码账号", "");
            //}
            if (!new BCW.BLL.User().Exists(int.Parse(account)))
            {
                Utils.Error("不存在该账号", "");
            }
            string mobile = new BCW.BLL.User().GetMobile(int.Parse(account));
            if (new BCW.BLL.tb_Validate().ExistsPhone(mobile, 5))//存在忘记密码验证码
            {
                BCW.Model.tb_Validate getmo = new BCW.BLL.tb_Validate().Gettb_Validate(mobile, 5);
                if (getmo.codeTime > DateTime.Now)//验证码存在切是新发的
                {
                    string   dateDiff = null;
                    TimeSpan x        = getmo.codeTime - DateTime.Now;
                    dateDiff = x.TotalSeconds.ToString();
                    Utils.Error("很抱歉,请在" + dateDiff.Split('.')[0] + "秒之后再次获取手机验证码", Utils.getUrl("GetPwd.aspx?act=forvalidate&amp;account=" + (account) + ""));
                }
            }
            char[] character = { '0', '1', '2', '3', '4', '5', '6', '8', '9' };
            string mesCode   = string.Empty; //手机验证码
            Random rnd       = new Random();
            //生成验证码字符串
            for (int i = 0; i < 4; i++)
            {
                mesCode += character[rnd.Next(character.Length)];
            }
            //int tm = 2;//短信过期时间
            //int total = 15;//每天可以发的总短信量
            //int ipCount = 10;//没IP最大发送量
            //int phoneCount = 10;//每号码最大发送量
            int tm         = int.Parse(ub.GetSub("msgTime", "/Controls/guestlist.xml"));
            int total      = int.Parse(ub.GetSub("dayCount", "/Controls/guestlist.xml"));
            int ipCount    = int.Parse(ub.GetSub("IPCount", "/Controls/guestlist.xml"));
            int phoneCount = int.Parse(ub.GetSub("phoneCount", "/Controls/guestlist.xml"));
            int msgremain  = int.Parse(ub.GetSub("msgremain", "/Controls/guestlist.xml"));
            int callID     = int.Parse(ub.GetSub("callID", "/Controls/guestlist.xml"));
            if (new BCW.BLL.tb_Validate().ExistsPhone(mobile))//不是第一次获取短信
            {
                DataSet  data       = new BCW.BLL.tb_Validate().GetList(" Top 1 *", "Phone=" + mobile + " order by time desc");
                DateTime changeTime = Convert.ToDateTime(data.Tables[0].Rows[0]["Time"].ToString());
                int      changeday  = changeTime.DayOfYear;
                if ((DateTime.Now.DayOfYear - changeday) >= 1)//上一条短信不是在当天
                {
                    BCW.Model.tb_Validate validate = new BCW.Model.tb_Validate();
                    validate.Phone    = mobile;
                    validate.IP       = Utils.GetUsIP();
                    validate.Time     = DateTime.Now.AddMinutes(0);
                    validate.Flag     = 1;
                    validate.mesCode  = mesCode;
                    validate.codeTime = DateTime.Now.AddMinutes(tm);
                    validate.type     = 5;
                    string result = "";
                    Mesege.Soap57ProviderService MesExt = new Mesege.Soap57ProviderService();

                    result = MesExt.Submit("000379", "123456", "1069032239089369", "【" + ub.GetSub("SiteName", "/Controls/wap.xml") + "】亲,您的验证码是:" + mesCode, mobile);
                    string[] results = result.Split('#');
                    if (results[8] != "0")
                    {
                        Utils.Error("请确认手机号的正确性,如不能为空号!" + results[8], "");
                    }
                    if ((int.Parse(results[2]) / 80) < msgremain)
                    {
                        new BCW.BLL.Guest().Add(0, callID, "", "剩余短信数量低于" + msgremain + "条了,请注意!");
                    }
                    if (results[8] == "0")
                    {
                        new BCW.BLL.tb_Validate().Add(validate);
                        Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("GetPwd.aspx?act=forvalidate&amp;account=" + (account) + ""), "2");
                    }
                }
                else//当天时间内
                {
                    DataSet dt2 = new BCW.BLL.tb_Validate().GetList("*", "Phone=" + mobile + " and time>='" + DateTime.Now.ToShortDateString() + "' order by time desc");
                    if (dt2.Tables[0].Rows.Count >= total)//当天时间内超过特定数
                    {
                        Utils.Error("抱歉!当天时间内过于频繁获取短信,请明天再试!", "");
                    }
                    DateTime check = DateTime.Now.AddMinutes(-30);
                    if (check.DayOfYear < DateTime.Now.DayOfYear)
                    {
                        check = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    }
                    else
                    {
                        check = DateTime.Now.AddMinutes(-30);
                    }
                    //Utils.Error("check:"+ check, "");
                    string  str = "Phone=" + mobile + " and time>='" + check + "' and time <='" + DateTime.Now + "' order by time desc";
                    DataSet dt1 = new BCW.BLL.tb_Validate().GetList("*", str);
                    if (data.Tables[0].Rows[0]["Flag"].ToString() == "0")//最新一条显示当天不能发送了
                    {
                        Utils.Error("抱歉!由于之前你存在频繁获取短信,请明天再试!", "");
                    }
                    string IP = Utils.GetUsIP();
                    //查看限制IP
                    string  str1 = "IP= '" + IP + "' and time>='" + check + "' and time <='" + DateTime.Now + "' order by time desc";
                    DataSet dt3  = new BCW.BLL.tb_Validate().GetList("*", str1);
                    if (dt3.Tables[0].Rows.Count >= ipCount)//半小时内超过10条
                    {
                        Utils.Error("当前IP过于频繁获取短信,请明天再试!" + dt3.Tables[0].Rows.Count, "");
                    }
                    if (dt1.Tables[0].Rows.Count >= phoneCount)//半小时内超过10条
                    {
                        //跟新标示
                        int ID = int.Parse(dt1.Tables[0].Rows[0]["ID"].ToString());
                        new BCW.BLL.tb_Validate().UpdateFlag(0, ID);
                        Utils.Error("请勿频繁获取短信,请明天再试!", "");
                    }
                    else
                    {
                        BCW.Model.tb_Validate validate = new BCW.Model.tb_Validate();
                        validate.Phone    = mobile;
                        validate.IP       = Utils.GetUsIP();
                        validate.Time     = DateTime.Now.AddMinutes(0);
                        validate.Flag     = 1;
                        validate.mesCode  = mesCode;
                        validate.codeTime = DateTime.Now.AddMinutes(tm);
                        validate.type     = 5;
                        string result = "";
                        Mesege.Soap57ProviderService MesExt = new Mesege.Soap57ProviderService();
                        result = MesExt.Submit("000379", "123456", "1069032239089369", "【" + ub.GetSub("SiteName", "/Controls/wap.xml") + "】亲,您的验证码是:" + mesCode, mobile);
                        string[] results = result.Split('#');
                        if (results[8] != "0")
                        {
                            Utils.Error("请确认手机号的正确性,如不能为空号!" + results[8], "");
                        }
                        if ((int.Parse(results[2]) / 80) < msgremain)
                        {
                            new BCW.BLL.Guest().Add(0, callID, "", "剩余短信数量低于" + msgremain + "条了,请注意!");
                        }
                        if (results[8] == "0")
                        {
                            new BCW.BLL.tb_Validate().Add(validate);
                            Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("GetPwd.aspx?act=forvalidate&amp;account=" + (account) + ""), "2");
                        }
                    }
                }
            }
            else
            {
                BCW.Model.tb_Validate validate = new BCW.Model.tb_Validate();
                validate.Phone    = mobile;
                validate.IP       = Utils.GetUsIP();
                validate.Time     = DateTime.Now.AddMinutes(0);
                validate.Flag     = 1;
                validate.mesCode  = mesCode;
                validate.codeTime = DateTime.Now.AddMinutes(tm);
                validate.type     = 5;
                string result = "";
                Mesege.Soap57ProviderService MesExt = new Mesege.Soap57ProviderService();
                result = MesExt.Submit("000379", "123456", "1069032239089369", "【" + ub.GetSub("SiteName", "/Controls/wap.xml") + "】亲,您的验证码是:" + mesCode, mobile);
                string[] results = result.Split('#');
                if (results[8] != "0")
                {
                    Utils.Error("请确认手机号的正确性,如不能为空号!" + results[8], "");
                }
                if ((int.Parse(results[2]) / 80) < msgremain)
                {
                    new BCW.BLL.Guest().Add(0, callID, "", "剩余短信数量低于" + msgremain + "条了,请注意!");
                }
                if (results[8] == "0")
                {
                    new BCW.BLL.tb_Validate().Add(validate);
                    Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("GetPwd.aspx?act=forvalidate&amp;account=" + (account) + ""), "2");
                }
            }
            #endregion
        }

        builder.Append(Out.Tab("<div class=\"title\">", "<br/>"));
        builder.Append("<a href=\"" + Utils.getUrl("/default.aspx") + "\">首页</a>-");
        builder.Append("<a href=\"" + Utils.getPage("/bbs/pwd/GetPwd.aspx") + "\">上级</a>");
        builder.Append(Out.Tab("</div>", ""));
    }
Example #3
0
    /// <summary>
    /// 手机验证
    /// </summary>
    private void validate()
    {
        int meid = new BCW.User.Users().GetUsId();

        if (meid == 0)
        {
            Utils.Login();
        }
        string keys = "";

        BCW.Model.User model = new BCW.BLL.User().GetKey(meid);
        keys = BCW.User.Users.SetUserKeys(meid, model.UsPwd, model.UsKey);
        string info   = Utils.GetRequest("info", "all", 1, "", "");
        string mobile = new BCW.BLL.User().GetMobile(meid);
        string code   = Utils.GetRequest("code", "all", 1, @"^[0-9]{4}$", "请输入验证码!"); //界面图形验证码                                                                      ////   string phoneCode = Utils.GetRequest("phoneCode", "post", 2, @"^[0-9]{4}$", "请输入手机验证码");  //手机验证码
        string mycode = "";

        try
        {
            mycode = Request.Cookies["validateCookie"].Values["ChkCode"].ToString();// 图形验证码
        }
        catch { }

        if (info == "")
        {
            builder.Append(Out.Tab("<div class=\"title\">", Out.Hr()));
            builder.Append("<a href=\"" + Utils.getUrl("default.aspx") + "\">首页</a>-");
            builder.Append("<a href=\"/bbs/uinfo.aspx?ve=" + Utils.getstrVe() + "&amp;u=" + keys + "\">空间</a>");
            //  builder.Append("<a href=\"/bbs/myedit.aspx?act=basic&amp;ve=" + Utils.getstrVe() + "&amp;u=" + keys + "\">-完善资料</a>");
            builder.Append(Out.Tab("</div>", ""));
            BCW.Model.tb_Validate getmo = null;
            DateTime endtime            = DateTime.Now.AddMinutes(-1);
            if (new BCW.BLL.tb_Validate().ExistsPhone(mobile, 1))              //注册验证码
            {
                getmo   = new BCW.BLL.tb_Validate().Gettb_Validate(mobile, 1); //获取注册验证码
                endtime = getmo.codeTime;
                string Reg = string.Empty;
                if (!Utils.Isie() && !Utils.GetUA().ToLower().Contains("opera/8"))
                {
                    Reg = new BCW.JS.somejs().daojishi2("Reg", endtime);
                }
                else
                {
                    Reg = new BCW.JS.somejs().daojishi("Reg", endtime);
                }
                if (endtime > DateTime.Now)
                {
                    builder.Append(Out.Tab("<div class=\"\">", Out.Hr()));
                    builder.Append("请在<b style=\"color:red\">" + Reg + "</b>秒后再次获取手机验证码<br/>");
                    builder.Append(Out.Tab("</div>", ""));
                }
            }
            string strText = "*请输入手机验证码:/,*请输入验证码:/,,,,";
            string strName = "phoneCode,code,info,mobile,act,backurl";
            string strType = "text,text,hidden,hidden,hidden,hidden";
            string strValu = "''ok'" + mobile + "'validate'" + Utils.getPage(0) + "";
            string strEmpt = "false,false,false,false,false,false";
            string strIdea = "<a href=\"" + Utils.getUrl("reg.aspx?act=validate&amp;info=ok&amp;ac=ok") + "\">获取手机验证码</a>'<img src=\"bbs/pwd/Code.aspx\"/>''''|/";
            string strOthe = "马上验证,reg.aspx,post,0,red";
            builder.Append(Out.wapform(strText, strName, strType, strValu, strEmpt, strIdea, strOthe));
            builder.Append(Out.Tab("<div class=\"title\">", Out.Hr()));
            builder.Append("<a href=\"" + Utils.getUrl("default.aspx") + "\">首页</a>-");
            builder.Append("<a href=\"/bbs/uinfo.aspx?ve=" + Utils.getstrVe() + "&amp;u=" + keys + "\">空间</a>");
            //  builder.Append("<a href=\"/bbs/myedit.aspx?act=basic&amp;ve=" + Utils.getstrVe() + "&amp;u=" + keys + "\">-完善资料</a>");
            builder.Append(Out.Tab("</div>", ""));
        }
        else
        {
            string ac = Utils.GetRequest("ac", "all", 1, "", "");
            if (Utils.ToSChinese(ac).Contains("获取手机验证码") || ac == "ok")    //判断哪一个按键
            {
                #region 获取手机验证码
                if (!code.Equals(mycode))//验证码相等
                {
                    //   Utils.Error("很抱歉,您输入图形验证按不对,请刷新页面", "");
                }
                if (new BCW.BLL.tb_Validate().ExistsPhone(mobile, 1))//存在注册验证
                {
                    BCW.Model.tb_Validate getmo = new BCW.BLL.tb_Validate().Gettb_Validate(mobile, 1);
                    if (getmo.codeTime > DateTime.Now)//验证码存在切是新发的
                    {
                        string   dateDiff = null;
                        TimeSpan x        = getmo.codeTime - DateTime.Now;
                        dateDiff = x.TotalSeconds.ToString();
                        Utils.Error("很抱歉,请在" + dateDiff.Split('.')[0] + "秒之后再次获取手机验证码", "");
                    }
                }
                char[] character = { '0', '1', '2', '3', '4', '5', '6', '8', '9' };
                string mesCode   = string.Empty; //手机验证码
                Random rnd       = new Random();
                //生成验证码字符串
                for (int i = 0; i < 4; i++)
                {
                    mesCode += character[rnd.Next(character.Length)];
                }

                //int tm = 2;//短信过期时间分钟
                //int total = 15;//每天可以发的总短信量
                //int ipCount = 10;
                //int phoneCount = 10;
                int tm         = int.Parse(ub.GetSub("msgTime", "/Controls/guestlist.xml"));
                int total      = int.Parse(ub.GetSub("dayCount", "/Controls/guestlist.xml"));
                int ipCount    = int.Parse(ub.GetSub("IPCount", "/Controls/guestlist.xml"));
                int phoneCount = int.Parse(ub.GetSub("phoneCount", "/Controls/guestlist.xml"));
                int msgremain  = int.Parse(ub.GetSub("msgremain", "/Controls/guestlist.xml"));
                int callID     = int.Parse(ub.GetSub("callID", "/Controls/guestlist.xml"));
                if (new BCW.BLL.tb_Validate().ExistsPhone(mobile))//不是第一次获取短信
                {
                    DataSet  data       = new BCW.BLL.tb_Validate().GetList(" Top 1 *", "Phone=" + mobile + " order by time desc");
                    DateTime changeTime = Convert.ToDateTime(data.Tables[0].Rows[0]["Time"].ToString());
                    int      changeday  = changeTime.DayOfYear;
                    if ((DateTime.Now.DayOfYear - changeday) >= 1)//上一条短信不是在当天
                    {
                        BCW.Model.tb_Validate validate = new BCW.Model.tb_Validate();
                        validate.Phone    = mobile;
                        validate.IP       = Utils.GetUsIP();
                        validate.Time     = DateTime.Now.AddMinutes(0);
                        validate.Flag     = 1;
                        validate.mesCode  = mesCode;
                        validate.codeTime = DateTime.Now.AddMinutes(tm);
                        validate.type     = 1;
                        Mesege.Soap57ProviderService MesExt = new Mesege.Soap57ProviderService();
                        string result = "";
                        result = MesExt.Submit("000379", "123456", "1069032239089369", "【" + ub.GetSub("SiteName", "/Controls/wap.xml") + "】亲,您的验证码是:" + mesCode, mobile);
                        string[] results = result.Split('#');
                        if (results[8] != "0")
                        {
                            Utils.Error("请确认手机号的正确性,如不能为空号!", "");
                        }
                        if ((int.Parse(results[2]) / 80) < msgremain)
                        {
                            new BCW.BLL.Guest().Add(0, callID, "", "剩余短信数量低于" + msgremain + "条了,请注意!");
                        }
                        if (results[8] == "0")
                        {
                            new BCW.BLL.tb_Validate().Add(validate);
                            Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("reg.aspx?act=validate"), "2");
                        }
                    }
                    else//当天时间内
                    {
                        //获取当天的短信数量
                        DataSet dt2 = new BCW.BLL.tb_Validate().GetList("*", "Phone=" + mobile + " and time>='" + DateTime.Now.ToShortDateString() + "' order by time desc");
                        if (dt2.Tables[0].Rows.Count >= total)//当天时间内超过特定数
                        {
                            Utils.Error("抱歉!当天时间内过于频繁获取短信,请明天再试!", "");
                        }
                        DateTime check = DateTime.Now.AddMinutes(-30);
                        if (check.DayOfYear < DateTime.Now.DayOfYear)
                        {
                            check = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                        }
                        else
                        {
                            check = DateTime.Now.AddMinutes(-30);
                        }
                        //获取最近半小时的短信量
                        string  str = "Phone=" + mobile + " and time>='" + check + "' and time <='" + DateTime.Now + "' order by time desc";
                        DataSet dt1 = new BCW.BLL.tb_Validate().GetList("*", str);
                        if (data.Tables[0].Rows[0]["Flag"].ToString() == "0")//最新一条显示当天不能发送了
                        {
                            Utils.Error("抱歉!由于之前你存在频繁获取短信,请明天再试!", "");
                        }
                        string IP = Utils.GetUsIP();
                        //查看限制IP
                        string  str1 = "IP= '" + IP + "' and time>='" + check + "' and time <='" + DateTime.Now + "' order by time desc";
                        DataSet dt3  = new BCW.BLL.tb_Validate().GetList("*", str1);
                        if (dt3.Tables[0].Rows.Count >= ipCount)//半小时内超过10条
                        {
                            ////跟新标示
                            //int ID = int.Parse(dt3.Tables[0].Rows[0]["ID"].ToString());
                            //new BCW.BLL.tb_Validate().UpdateFlag(0, ID);
                            Utils.Error("当前IP过于频繁获取短信,请明天再试!" + dt3.Tables[0].Rows.Count, "");
                        }
                        if (dt1.Tables[0].Rows.Count >= phoneCount)//半小时内超过10条
                        {
                            //跟新标示
                            int ID = int.Parse(dt1.Tables[0].Rows[0]["ID"].ToString());
                            new BCW.BLL.tb_Validate().UpdateFlag(0, ID);
                            Utils.Error("请勿频繁获取短信,请明天再试!", "");
                        }
                        else
                        {
                            BCW.Model.tb_Validate validate = new BCW.Model.tb_Validate();
                            validate.Phone    = mobile;
                            validate.IP       = Utils.GetUsIP();
                            validate.Time     = DateTime.Now.AddMinutes(0);
                            validate.Flag     = 1;
                            validate.mesCode  = mesCode;
                            validate.codeTime = DateTime.Now.AddMinutes(tm);
                            validate.type     = 1;
                            Mesege.Soap57ProviderService MesExt = new Mesege.Soap57ProviderService();
                            string result = "";
                            result = MesExt.Submit("000379", "123456", "1069032239089369", "【" + ub.GetSub("SiteName", "/Controls/wap.xml") + "】亲,您的验证码是:" + mesCode, mobile);
                            string[] results = result.Split('#');
                            if (results[8] != "0")
                            {
                                Utils.Error("请确认手机号的正确性,如不能为空号!", "");
                            }
                            if ((int.Parse(results[2]) / 80) < msgremain)
                            {
                                new BCW.BLL.Guest().Add(0, callID, "", "剩余短信数量低于" + msgremain + "条了,请注意!");
                            }
                            if (results[8] == "0")
                            {
                                new BCW.BLL.tb_Validate().Add(validate);
                                Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("reg.aspx?act=validate"), "2");
                            }
                        }
                    }
                }
                else
                {
                    BCW.Model.tb_Validate validate = new BCW.Model.tb_Validate();
                    validate.Phone    = mobile;
                    validate.IP       = Utils.GetUsIP();
                    validate.Time     = DateTime.Now.AddMinutes(0);
                    validate.Flag     = 1;
                    validate.mesCode  = mesCode;
                    validate.codeTime = DateTime.Now.AddMinutes(tm);
                    validate.type     = 1;
                    Mesege.Soap57ProviderService MesExt = new Mesege.Soap57ProviderService();
                    string result = "";
                    result = MesExt.Submit("000379", "123456", "1069032239089369", "【" + ub.GetSub("SiteName", "/Controls/wap.xml") + "】亲,您的验证码是:" + mesCode, mobile);
                    string[] results = result.Split('#');
                    if (results[8] != "0")
                    {
                        Utils.Error("请确认手机号的正确性,如不能为空号!", "");
                    }
                    if ((int.Parse(results[2]) / 80) < msgremain)
                    {
                        new BCW.BLL.Guest().Add(0, callID, "", "剩余短信数量低于" + msgremain + "条了,请注意!");
                    }
                    if (results[8] == "0")
                    {
                        new BCW.BLL.tb_Validate().Add(validate);
                        Utils.Success("获取手机验证码", "正在发送手机验证码,请查收", Utils.getUrl("reg.aspx?act=validate"), "2");
                    }
                }


                #endregion
            }
            else
            {
                //  Utils.Error("come here", "");
                string phoneCode = Utils.GetRequest("phoneCode", "post", 2, @"^[0-9]{4}$", "请输入正确的四位手机验证码"); //手机验证码
                if (!code.Equals(mycode))                                                                    //验证码相等
                {
                    Utils.Error("很抱歉,您输入图形验证按不对,请刷新页面", "");
                }
                BCW.Model.tb_Validate getmo = null;
                if (new BCW.BLL.tb_Validate().ExistsPhone(mobile, 1))//有发送注册过验证码
                {
                    getmo = new BCW.BLL.tb_Validate().Gettb_Validate(mobile, 1);
                    if (getmo.codeTime > DateTime.Now)        //验证码存在且是新发的
                    {
                        if (!phoneCode.Equals(getmo.mesCode)) //验证码不相等
                        {
                            Utils.Error("很抱歉,您输入手机验证码不对222", "");
                        }
                    }
                    else
                    {
                        Utils.Error("手机验证码过期,请重新获取", "");
                    }
                }
                else//没发送过注册验证码
                {
                    Utils.Error("很抱歉,您输入手机验证码不对111", "");
                }
                //积分操作
                new BCW.User.Cent().UpdateCent(BCW.User.Cent.enumRole.Cent_RegUser, meid);
                //if (rd > 0 && model.IsVerify == 1)
                //{
                //    new BCW.User.Cent().UpdateCent(BCW.User.Cent.enumRole.Cent_RecomUser, rd);
                //}
                builder.Append(Out.Tab("<div class=\"title\">", Out.Hr()));
                builder.Append("<a href=\"" + Utils.getUrl("default.aspx") + "\">首页</a>");
                //   builder.Append("<a href=\"/bbs/uinfo.aspx?ve=" + Utils.getstrVe() + "&amp;u=" + keys + "\">空间</a>");
                //  builder.Append("<a href=\"/bbs/myedit.aspx?act=basic&amp;ve=" + Utils.getstrVe() + "&amp;u=" + keys + "\">-完善资料</a>");
                builder.Append(Out.Tab("</div>", ""));
                new BCW.BLL.User().UpdateIsVerify(mobile, 1);
                //string strText = "";
                //string strName = "act";
                //string strType = "hidden";
                //string strValu = "recommended";
                //string strEmpt = "false";
                //string strIdea = "/";
                //string strOthe = "马上填写推荐人ID,reg.aspx,post,0,red";
                //builder.Append(Out.wapform(strText, strName, strType, strValu, strEmpt, strIdea, strOthe));
                Utils.Success("验证成功,请填写推荐人ID", "验证成功,请填写推荐人ID", Utils.getUrl("reg.aspx?act=recommended"), "3");
                builder.Append(Out.Tab("<div class=\"title\">", Out.Hr()));
                builder.Append("<a href=\"" + Utils.getUrl("default.aspx") + "\">首页</a>");
                //   builder.Append("<a href=\"/bbs/uinfo.aspx?ve=" + Utils.getstrVe() + "&amp;u=" + keys + "\">空间</a>");
                //  builder.Append("<a href=\"/bbs/myedit.aspx?act=basic&amp;ve=" + Utils.getstrVe() + "&amp;u=" + keys + "\">-完善资料</a>");
                builder.Append(Out.Tab("</div>", ""));
            }
        }
    }