コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: SMSAjax.cs プロジェクト: xuefuruanjian/ems
        //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("异常错误!");
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: SMSAjax.cs プロジェクト: xuefuruanjian/ems
        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("异常错误!");
            }
        }
コード例 #5
0
ファイル: FindPassword.cs プロジェクト: xuefuruanjian/ems
        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));
            }
        }