Beispiel #1
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            UserInfo user = UserBLL.Read(base.UserId);

            if (StringHelper.AddSafe(RequestHelper.GetForm <string>("file_code")) == "1")
            {
                string userPhoto = UploadUserPhoto();
                if (userPhoto != string.Empty)
                {
                    user.Photo = userPhoto;
                    CookiesHelper.AddCookie("UserPhoto", userPhoto);
                }
            }
            else
            {
                user.Email     = StringHelper.AddSafe(RequestHelper.GetForm <string>("Email"));
                user.Sex       = RequestHelper.GetForm <int>("Sex");
                user.Birthday  = StringHelper.AddSafe(RequestHelper.GetForm <string>("Birthday"));
                user.MSN       = StringHelper.AddSafe(RequestHelper.GetForm <string>("MSN"));
                user.QQ        = StringHelper.AddSafe(RequestHelper.GetForm <string>("QQ"));
                user.Tel       = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel"));
                user.Mobile    = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile"));
                user.RegionId  = singleUnlimitClass.ClassID;
                user.Address   = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address"));
                user.Introduce = StringHelper.AddSafe(RequestHelper.GetForm <string>("Introduce"));
                CookiesHelper.AddCookie("UserEmail", user.Email);
            }
            UserBLL.Update(user);
            ScriptHelper.AlertFront("修改成功", RequestHelper.RawUrl);
        }
Beispiel #2
0
        /// <summary>
        /// 投票
        /// </summary>
        /// <param name="voteID"></param>
        protected void Vote(int voteID)
        {
            string result = "ok";

            if (ShopConfig.ReadConfigInfo().AllowAnonymousVote == (int)BoolType.False && base.UserID == 0)
            {
                result = "还未登录";
            }
            else
            {
                string voteCookies = CookiesHelper.ReadCookieValue("VoteCookies" + voteID.ToString());
                if (ShopConfig.ReadConfigInfo().VoteRestrictTime > 0 && voteCookies != string.Empty)
                {
                    result = "请不要频繁提交";
                }
                else
                {
                    VoteRecordInfo voteRecord = new VoteRecordInfo();
                    voteRecord.VoteID   = voteID;
                    voteRecord.ItemID   = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("ItemID"));
                    voteRecord.AddDate  = RequestHelper.DateNow;
                    voteRecord.UserIP   = ClientHelper.IP;
                    voteRecord.UserID   = base.UserID;
                    voteRecord.UserName = base.UserName;
                    VoteRecordBLL.AddVoteRecord(voteRecord);
                    if (ShopConfig.ReadConfigInfo().VoteRestrictTime > 0)
                    {
                        CookiesHelper.AddCookie("VoteCookies" + voteID.ToString(), "VoteCookies" + voteID.ToString(), ShopConfig.ReadConfigInfo().VoteRestrictTime, TimeType.Second);
                    }
                }
            }
            ResponseHelper.Write(result);
            ResponseHelper.End();
        }
Beispiel #3
0
        public void AgainstComment()
        {
            string content = string.Empty;

            if ((ShopConfig.ReadConfigInfo().AllowAnonymousCommentOperate == 0) && (base.UserID == 0))
            {
                content = "»¹Î´µÇ¼";
            }
            else
            {
                int    queryString = RequestHelper.GetQueryString <int>("CommentID");
                string str2        = CookiesHelper.ReadCookieValue("CommentOperateCookies" + queryString.ToString());
                if ((ShopConfig.ReadConfigInfo().CommentOperateRestrictTime > 0) && (str2 != string.Empty))
                {
                    content = "Ç벻ҪƵ·±Ìá½»";
                }
                else
                {
                    ProductCommentBLL.ChangeProductCommentAgainstCount(queryString.ToString(), ChangeAction.Plus);
                    if (ShopConfig.ReadConfigInfo().CommentOperateRestrictTime > 0)
                    {
                        CookiesHelper.AddCookie("CommentOperateCookies" + queryString.ToString(), "CommentOperateCookies" + queryString.ToString(), ShopConfig.ReadConfigInfo().CommentOperateRestrictTime, TimeType.Second);
                    }
                    content = "ok";
                }
            }
            ResponseHelper.Write(content);
            ResponseHelper.End();
        }
Beispiel #4
0
        public LoginInfoModel GetLoginInfo()
        {
            var model       = new LoginInfoModel();
            var loginCookie = CookiesHelper.GetCookie(WebConfigOperation.CookieName);//是否已存在登录的用户cookie

            if (loginCookie != null)
            {
                //2.获取用户信息
                model.UserInfo = new LoginBLL().GetUserInfo(loginCookie.Value);
                if (model.UserInfo == null)
                {
                    return(model);
                }
            }
            var ykCookie = CookiesHelper.GetCookie(WebConfigOperation.YkCookieName);

            if (ykCookie == null)
            {
                var yk = EncryptAndDecrypt.Encrypt(DateTime.Now.ToString());
                CookiesHelper.AddCookie(WebConfigOperation.YkCookieName, yk);
                CookiesHelper.SetCookie(WebConfigOperation.YkCookieName, DateTime.Now.AddMonths(1));
                model.ykCookie = yk;
            }
            else
            {
                model.ykCookie = ykCookie.Value.ToString();
            }

            return(model);
        }
Beispiel #5
0
        public void AddProductComment(ref string result)
        {
            int    queryString = RequestHelper.GetQueryString <int>("ProductID");
            string str         = CookiesHelper.ReadCookieValue("CommentCookies" + queryString.ToString());

            if ((ShopConfig.ReadConfigInfo().CommentRestrictTime > 0) && (str != string.Empty))
            {
                result = "Ç벻ҪƵ·±Ìá½»";
            }
            else
            {
                ProductCommentInfo productComment = new ProductCommentInfo();
                productComment.ProductID         = queryString;
                productComment.Title             = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Title"));
                productComment.Content           = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Content"));
                productComment.UserIP            = ClientHelper.IP;
                productComment.PostDate          = RequestHelper.DateNow;
                productComment.Support           = 0;
                productComment.Against           = 0;
                productComment.Status            = ShopConfig.ReadConfigInfo().CommentDefaultStatus;
                productComment.Rank              = RequestHelper.GetQueryString <int>("Rank");
                productComment.ReplyCount        = 0;
                productComment.AdminReplyContent = string.Empty;
                productComment.AdminReplyDate    = RequestHelper.DateNow;
                productComment.UserID            = base.UserID;
                productComment.UserName          = base.UserName;
                ProductCommentBLL.AddProductComment(productComment);
                if (ShopConfig.ReadConfigInfo().CommentRestrictTime > 0)
                {
                    CookiesHelper.AddCookie("CommentCookies" + queryString.ToString(), "CommentCookies" + queryString.ToString(), ShopConfig.ReadConfigInfo().CommentRestrictTime, TimeType.Second);
                }
            }
        }
Beispiel #6
0
        public void AddTags(ref string result)
        {
            int    queryString = RequestHelper.GetQueryString <int>("ProductID");
            string str         = CookiesHelper.ReadCookieValue("TagsCookies" + queryString.ToString());

            if ((ShopConfig.ReadConfigInfo().AddTagsRestrictTime > 0) && (str != string.Empty))
            {
                result = "Ç벻ҪƵ·±Ìá½»";
            }
            else
            {
                TagsInfo tags = new TagsInfo();
                tags.ProductID = queryString;
                tags.Word      = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Word"));
                tags.Color     = "#4C5A62";
                tags.Size      = 12;
                tags.IsTop     = 0;
                tags.UserID    = base.UserID;
                tags.UserName  = base.UserName;
                TagsBLL.AddTags(tags);
                if (ShopConfig.ReadConfigInfo().AddTagsRestrictTime > 0)
                {
                    CookiesHelper.AddCookie("TagsCookies" + queryString.ToString(), "TagsCookies" + queryString.ToString(), ShopConfig.ReadConfigInfo().AddTagsRestrictTime, TimeType.Second);
                }
            }
        }
Beispiel #7
0
        protected void SetCommentCookies(int sysno)
        {
            string tmpstr = "";

            if (Request.Cookies["upup1000"] != null && Request.Cookies["upup1000"]["QuestComment"] != null && Request.Cookies["upup1000"]["QuestComment"] != string.Empty)
            {
                tmpstr = CommonTools.Decode(Request.Cookies["upup1000"]["QuestComment"]) + "|" + sysno + "," + DateTime.Now.ToString("yyyy-MM-dd");
            }
            else
            {
                tmpstr = sysno.ToString() + "," + DateTime.Now.ToString("yyyy-MM-dd");
            }

            HttpCookie Cookie = CookiesHelper.GetCookie("upup1000");

            if (Cookie == null || Cookie.Value == null || Cookie.Value == "")
            {
                Cookie = new HttpCookie("upup1000");
                Cookie.Values.Add("QuestComment", CommonTools.Encode(tmpstr));
                //设置Cookie过期时间
                Cookie.Expires = DateTime.Now.AddYears(50);
                CookiesHelper.AddCookie(Cookie);
            }
            else
            {
                CookiesHelper.SetCookie("upup1000", "QuestComment", CommonTools.Encode(tmpstr), DateTime.Now.AddYears(50));
            }
        }
        protected override void PageLoad()
        {
            base.PageLoad();

            string action = RequestHelper.GetQueryString <string>("Action");

            if (action == "SelectShipping")
            {
                this.SelectShipping();
            }

            string idList = CookiesHelper.ReadCookieValue("usr_region");

            if (string.IsNullOrEmpty(idList))
            {
                string city = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("city"));
                if (!string.IsNullOrEmpty(city))
                {
                    idList = RegionBLL.ReadRegionIdList(city);
                    CookiesHelper.AddCookie("usr_region", idList, 1, TimeType.Year);
                }
            }

            singleUnlimitClass.DataSource   = RegionBLL.ReadRegionUnlimitClass();
            singleUnlimitClass.ClassID      = idList;
            singleUnlimitClass.FunctionName = "readShippingMoney()";
        }
Beispiel #9
0
        //执行Action之前操作
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //判断是否登录或是否用权限,如果有那么就进行相应的操作,否则跳转到登录页或者授权页面
            string s_accountId = AES.DecryptStr(CookiesHelper.GetCookieValue("UserID"));

            int i_accountId = 0;

            //判断是否有cookie
            if (int.TryParse(s_accountId, out i_accountId))
            {
                AchieveEntity.UserEntity m_account = new AchieveBLL.UserBLL().GetUserById(i_accountId.ToString());
                if (m_account != null)
                {
                    accountmodelJudgment = m_account;
                    filterContext.Controller.ViewData["Account"]     = m_account;
                    filterContext.Controller.ViewData["AccountName"] = m_account.AccountName;
                    filterContext.Controller.ViewData["RealName"]    = m_account.RealName;

                    //处理Action之前操作内容根据我们提供的规则来定义这部分内容
                    base.OnActionExecuting(filterContext);
                }
                else
                {
                    CookiesHelper.AddCookie("UserID", System.DateTime.Now.AddDays(-1));
                    filterContext.Result = new RedirectResult("/Login/Index");
                }
            }
            else
            {
                filterContext.Result = new RedirectResult("/Login/Index");
            }
        }
Beispiel #10
0
        /// <summary>
        /// 添加回复
        /// </summary>
        /// <param name="result"></param>
        public void AddProductReply(ref string result)
        {
            int    productID     = RequestHelper.GetQueryString <int>("ProductID");
            int    commentID     = RequestHelper.GetQueryString <int>("CommentID");
            string replytCookies = CookiesHelper.ReadCookieValue("ReplytCookies" + commentID.ToString());

            if (ShopConfig.ReadConfigInfo().ReplyRestrictTime > 0 && replytCookies != string.Empty)
            {
                result = "请不要频繁提交";
            }
            else
            {
                ProductReplyInfo productReply = new ProductReplyInfo();
                productReply.ProductID = productID;
                productReply.CommentID = commentID;
                productReply.Content   = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Content"));
                productReply.UserIP    = ClientHelper.IP;
                productReply.PostDate  = RequestHelper.DateNow;
                productReply.UserID    = base.UserID;
                productReply.UserName  = base.UserName;
                ProductReplyBLL.AddProductReply(productReply);
                if (ShopConfig.ReadConfigInfo().ReplyRestrictTime > 0)
                {
                    CookiesHelper.AddCookie("ReplytCookies" + commentID.ToString(), "ReplytCookies" + commentID.ToString(), ShopConfig.ReadConfigInfo().ReplyRestrictTime, TimeType.Second);
                }
            }
        }
Beispiel #11
0
        public void AddProductReply(ref string result)
        {
            int    queryString = RequestHelper.GetQueryString <int>("ProductID");
            int    num2        = RequestHelper.GetQueryString <int>("CommentID");
            string str         = CookiesHelper.ReadCookieValue("ReplytCookies" + num2.ToString());

            if ((ShopConfig.ReadConfigInfo().ReplyRestrictTime > 0) && (str != string.Empty))
            {
                result = "Ç벻ҪƵ·±Ìá½»";
            }
            else
            {
                ProductReplyInfo productReply = new ProductReplyInfo();
                productReply.ProductID = queryString;
                productReply.CommentID = num2;
                productReply.Content   = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Content"));
                productReply.UserIP    = ClientHelper.IP;
                productReply.PostDate  = RequestHelper.DateNow;
                productReply.UserID    = base.UserID;
                productReply.UserName  = base.UserName;
                ProductReplyBLL.AddProductReply(productReply);
                if (ShopConfig.ReadConfigInfo().ReplyRestrictTime > 0)
                {
                    CookiesHelper.AddCookie("ReplytCookies" + num2.ToString(), "ReplytCookies" + num2.ToString(), ShopConfig.ReadConfigInfo().ReplyRestrictTime, TimeType.Second);
                }
            }
        }
Beispiel #12
0
 public ActionResult UserLoginOut()
 {
     //清空cookie
     CookiesHelper.AddCookie("UserID", System.DateTime.Now.AddDays(-1));
     Session.Clear();
     return(OperationReturn(true, "退出成功!"));
 }
Beispiel #13
0
        /// <summary>
        /// 获取短信验证码
        /// </summary>
        private void GetVerifyCode()
        {
            string mobile    = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("mobile"));
            bool   isSuccess = false;
            string msg       = "";

            if (string.IsNullOrEmpty(mobile))
            {
                ResponseHelper.Write("error|请输入手机号码");
                ResponseHelper.End();
            }

            isSuccess = true;
            //isSuccess = WebService.GetHttp.PostSms(mobile, out msg);
            if (isSuccess)
            {
                CookiesHelper.AddCookie("verify_send", DateTime.Now.ToString(), 1, TimeType.Minute);
                ResponseHelper.Write("ok|");
                ResponseHelper.End();
            }
            else
            {
                ResponseHelper.Write("error|" + msg);
                ResponseHelper.End();
            }
        }
Beispiel #14
0
 public ActionResult UserLoginOut()
 {
     //清空cookie
     CookiesHelper.AddCookie("UserID", System.DateTime.Now.AddDays(-1));
     log(Request["user_AN"].ToString(), "退出账号", "true", "退出成功");
     return(OperationReturn(true, "退出成功!"));
 }
Beispiel #15
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);
        }
        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="result"></param>
        public void AddProductComment(ref string result)
        {
            int    productID      = RequestHelper.GetQueryString <int>("ProductID");
            int    orderID        = RequestHelper.GetQueryString <int>("OrderID");
            string commentCookies = CookiesHelper.ReadCookieValue("CommentCookies" + productID.ToString());

            if (ShopConfig.ReadConfigInfo().CommentRestrictTime > 0 && commentCookies != string.Empty)
            {
                result = "请不要频繁提交";
            }
            else
            {
                ProductCommentInfo productComment = new ProductCommentInfo();
                productComment.ProductId         = productID;
                productComment.Title             = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Title"));
                productComment.Content           = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Content"));
                productComment.UserIP            = ClientHelper.IP;
                productComment.PostDate          = RequestHelper.DateNow;
                productComment.Support           = 0;
                productComment.Against           = 0;
                productComment.Status            = ShopConfig.ReadConfigInfo().CommentDefaultStatus;
                productComment.Rank              = RequestHelper.GetQueryString <int>("Rank");
                productComment.ReplyCount        = 0;
                productComment.AdminReplyContent = string.Empty;
                productComment.AdminReplyDate    = RequestHelper.DateNow;
                productComment.UserId            = base.UserId;
                productComment.UserName          = base.UserName;
                productComment.OrderId           = orderID;
                ProductCommentBLL.Add(productComment);
                if (ShopConfig.ReadConfigInfo().CommentRestrictTime > 0)
                {
                    CookiesHelper.AddCookie("CommentCookies" + productID.ToString(), "CommentCookies" + productID.ToString(), ShopConfig.ReadConfigInfo().CommentRestrictTime, TimeType.Second);
                }
            }
        }
Beispiel #17
0
        protected void Vote(int voteID)
        {
            string content = "ok";

            if ((ShopConfig.ReadConfigInfo().AllowAnonymousVote == 0) && (base.UserID == 0))
            {
                content = "»¹Î´µÇ¼";
            }
            else
            {
                string str2 = CookiesHelper.ReadCookieValue("VoteCookies" + voteID.ToString());
                if ((ShopConfig.ReadConfigInfo().VoteRestrictTime > 0) && (str2 != string.Empty))
                {
                    content = "Ç벻ҪƵ·±Ìá½»";
                }
                else
                {
                    VoteRecordInfo voteRecord = new VoteRecordInfo();
                    voteRecord.VoteID   = voteID;
                    voteRecord.ItemID   = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("ItemID"));
                    voteRecord.AddDate  = RequestHelper.DateNow;
                    voteRecord.UserIP   = ClientHelper.IP;
                    voteRecord.UserID   = base.UserID;
                    voteRecord.UserName = base.UserName;
                    VoteRecordBLL.AddVoteRecord(voteRecord);
                    if (ShopConfig.ReadConfigInfo().VoteRestrictTime > 0)
                    {
                        CookiesHelper.AddCookie("VoteCookies" + voteID.ToString(), "VoteCookies" + voteID.ToString(), ShopConfig.ReadConfigInfo().VoteRestrictTime, TimeType.Second);
                    }
                }
            }
            ResponseHelper.Write(content);
            ResponseHelper.End();
        }
Beispiel #18
0
        /// <summary>
        /// 设置登陆cookie
        /// </summary>
        /// <param name="user"></param>
        public void SetLoginCookie(UserInfo user)
        {
            var userInfo  = JsonConvert.SerializeObject(new { user.UserID, user.CreateTime });
            var cookieStr = EncryptAndDecrypt.Encrypt(userInfo);

            CookiesHelper.AddCookie(WebConfigOperation.CookieName, cookieStr);
            CookiesHelper.SetCookie(WebConfigOperation.CookieName, DateTime.Now.AddMonths(1));
        }
 /// <summary>
 /// 退出系统
 /// </summary>
 /// <returns></returns>
 public ActionResult LogOut()
 {
     CookiesHelper.AddCookie("UserID", DateTime.Now.AddDays(-1));
     return(Json(new Result {
         Success = true,
         Msg = "成功!"
     }));
 }
Beispiel #20
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected override void PageLoad()
        {
            base.PageLoad();
            string checkCode = RequestHelper.GetQueryString <string>("CheckCode");

            if (checkCode != string.Empty)
            {
                string decode = StringHelper.Decode(checkCode, ShopConfig.ReadConfigInfo().SecureKey);
                if (decode.IndexOf('|') > 0)
                {
                    int    userID = Convert.ToInt32(decode.Split('|')[0]);
                    string email  = decode.Split('|')[1];

                    string   safeCode = decode.Split('|')[2];
                    UserInfo user     = UserBLL.ReadUserMore(userID);
                    if (user.Id > 0 && safeCode == user.SafeCode)
                    {
                        if (ShopConfig.ReadConfigInfo().BindEmailTime > 0 && user.FindDate.AddHours(ShopConfig.ReadConfigInfo().BindEmailTime) < RequestHelper.DateNow)
                        {
                            result = "信息过时,<a href=\"/user/UpdateEmail.html\">请重新申请验证邮箱</a>";
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(email))
                            {
                                result = "错误的信息";
                            }
                            else if (!new Regex("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,3}){1,2})$").IsMatch(email))
                            {
                                result = "错误的信息";
                            }
                            else
                            {
                                if (!UserBLL.CheckEmail(email, user.Id))
                                {
                                    result = "此邮箱已被其他会员绑定";
                                }
                                else
                                {
                                    user.Email = email;
                                    UserBLL.Update(user);
                                    CookiesHelper.AddCookie("UserEmail", user.Email);
                                    result = "恭喜您,邮箱验证成功!您可进入<a href=\"/user/useradd.html\">个人信息</a>查看刚才绑定的邮箱";
                                }
                            }
                        }
                    }
                    else
                    {
                        result = "错误的信息";
                    }
                }
                else
                {
                    result = "错误的信息";
                }
            }
        }
Beispiel #21
0
        //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("异常错误!");
            }
        }
Beispiel #22
0
 public ActionResult UserLoginOut()
 {
     //清空cookie
     CookiesHelper.AddCookie("UserID", System.DateTime.Now.AddDays(-1));
     Session.Abandon();
     Session.Clear();
     ViewData["Account"] = null;
     return(RedirectToAction("Index", "Login"));
 }
Beispiel #23
0
        /// <summary>
        /// 设置一周的过期时间
        /// </summary>
        /// <param name="usr"></param>
        public static void AddUserCookieWeekly(UserInfo usr)
        {
            int    gradeID = UserGradeBLL.ReadByMoney(usr.MoneyUsed).Id;
            string sign    = FormsAuthentication.HashPasswordForStoringInConfigFile(usr.Id.ToString() + HttpContext.Current.Server.UrlEncode(usr.UserName) + gradeID.ToString() + ShopConfig.ReadConfigInfo().SecureKey + ClientHelper.Agent, "MD5");
            string value   = sign + "|" + usr.Id.ToString() + "|" + HttpContext.Current.Server.UrlEncode(usr.UserName) + "|" + gradeID;

            CookiesHelper.AddCookie(ShopConfig.ReadConfigInfo().UserCookies, value, 7, TimeType.Day);
            CookiesHelper.AddCookie("UserPhoto", usr.Photo, 7, TimeType.Day);
            CookiesHelper.AddCookie("UserEmail", usr.Email, 7, TimeType.Day);
        }
Beispiel #24
0
        public static ArrayList ReadPostCourseArrayList(int PostId, int PageSize)
        {
            string CookiesKey = "PostCourseArray_" + PostId.ToString();

            if (string.IsNullOrEmpty(CookiesHelper.ReadCookieValue(CookiesKey)))
            {
                CookiesHelper.AddCookie(CookiesKey, JsonConvert.SerializeObject(CreatePostCoursePage(PostId, PageSize)));
            }
            return((ArrayList)JsonConvert.DeserializeObject(CookiesHelper.ReadCookieValue(CookiesKey), typeof(ArrayList)));
        }
Beispiel #25
0
    private bool SetCookie(string name, string pwd)
    {
        Request.Cookies.Remove("UserInfo");
        HttpCookie Cookie = new HttpCookie("UserInfo");

        Cookie.Values.Add("userName", Server.UrlEncode(name));
        Cookie.Values.Add("usertPwd", Server.UrlEncode(pwd));
        //设置Cookie过期时间
        Cookie.Expires = DateTime.Now.AddMonths(60);//DateTime.Now.AddDays(365);
        CookiesHelper.AddCookie(Cookie);
        return(true);
        ////下次自动登录
        ////if (CheckBox1.Checked == true)
        ////{


        ////if (!Convert.ToBoolean(hfIsEnableCookie.Value))
        ////{
        ////    // Response.Write("<script language='javascript'>alert('提示!您的浏览器不接受cookie,将影响一些功能的正常使用,请将浏览器cookie启用!')</script>");
        ////    msg.InnerHtml = "【友情提示】:您的浏览器不接受cookie,将影响一些功能的正常使用,请将浏览器cookie启用!";
        ////    return false;
        ////}
        ////else
        ////{

        //    HttpCookie Cookie = CookiesHelper.GetCookie("UserInfo");
        //    if (Cookie == null)
        //    {
        //        Cookie = new HttpCookie("UserInfo");
        //        Cookie.Values.Add("userName",Server.UrlEncode(name));
        //        Cookie.Values.Add("usertPwd",Server.UrlEncode(pwd));
        //        //设置Cookie过期时间
        //        Cookie.Expires = DateTime.Now.AddMonths(12);//DateTime.Now.AddDays(365);
        //        CookiesHelper.AddCookie(Cookie);

        //    }
        //    else if (!Cookie.Values["userName"].Equals(name) || !Cookie.Values["usertPwd"].Equals(pwd))
        //    {
        //        CookiesHelper.SetCookie("UserInfo", "userName", Server.UrlEncode(name),DateTime.Now.AddMonths(12));
        //        CookiesHelper.SetCookie("UserInfo", "usertPwd", Server.UrlEncode(pwd), DateTime.Now.AddMonths(12));
        //    }
        //    return true;
        ////}

        ////}
        ////else
        ////{
        ////    CookiesHelper.RemoveCookie("UserInfo");
        ////    HttpCookie Cookie = CookiesHelper.GetCookie("UserInfo");
        ////    int a = Request.Cookies.Count;
        ////    return true;
        ////}
    }
Beispiel #26
0
        /// <summary>
        /// 保存游戏数据
        /// </summary>
        /// <param name="game"></param>
        public void SetGameData(string key, GameInfo game)
        {
            //IIS缓存
            CacheExts <GameInfo> .SetValue(key, game, noSlidingExpiration : false);

            //客户端持久化存储
            var json      = JsonConvert.SerializeObject(game);
            var cookieStr = EncryptAndDecrypt.Encrypt(json);

            CookiesHelper.AddCookie(key, cookieStr);
            CookiesHelper.SetCookie(key, DateTime.Now.AddMonths(1));
        }
Beispiel #27
0
        /// <summary>
        /// 添加留言
        /// </summary>
        protected void AddUserMessage()
        {
            string result             = string.Empty;
            int    messageClass       = RequestHelper.GetQueryString <int>("MessageClass");
            string title              = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Title"));
            string content            = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Content"));
            string userMessageCookies = CookiesHelper.ReadCookieValue("UserMessageCookies" + base.UserId.ToString());

            if (content == string.Empty || content == string.Empty)
            {
                result = "请填写标题和内容";
            }
            else
            {
                if (ShopConfig.ReadConfigInfo().CommentRestrictTime > 0 && !string.IsNullOrEmpty(userMessageCookies))
                {
                    string[] strArray = userMessageCookies.Split(new char[] { '|' });
                    string   _userId  = strArray[0];
                    string   _title   = strArray[1];
                    string   _content = strArray[2];
                    //如果该用户在限制时间内提交过相同title或content的内容,则不能再频繁提交
                    if (_userId == base.UserId.ToString() && (title == Server.UrlDecode(_title) || content == (Server.UrlDecode(_content))))
                    {
                        result = "请不要频繁提交相似留言";
                    }
                }
            }
            if (string.IsNullOrEmpty(result))
            {
                UserMessageInfo userMessage = new UserMessageInfo();
                userMessage.MessageClass      = messageClass;
                userMessage.Title             = title;
                userMessage.Content           = content;
                userMessage.UserIP            = ClientHelper.IP;
                userMessage.PostDate          = RequestHelper.DateNow;
                userMessage.IsHandler         = (int)BoolType.False;
                userMessage.AdminReplyContent = string.Empty;
                userMessage.AdminReplyDate    = RequestHelper.DateNow;
                userMessage.UserId            = base.UserId;
                userMessage.UserName          = base.UserName;
                UserMessageBLL.Add(userMessage);
                if (ShopConfig.ReadConfigInfo().CommentRestrictTime > 0)
                {
                    string cookieValue = base.UserId + "|" + Server.UrlEncode(title) + "|" + Server.UrlEncode(content);
                    CookiesHelper.AddCookie("UserMessageCookies" + base.UserId.ToString(), cookieValue, ShopConfig.ReadConfigInfo().CommentRestrictTime, TimeType.Second);
                }
            }

            ResponseHelper.Write(result);
            ResponseHelper.End();
        }
Beispiel #28
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            UserInfo user = UserBLL.Read(base.UserId);

            if (StringHelper.AddSafe(RequestHelper.GetForm <string>("file_code")) == "1")
            {
                //string userPhoto = UploadUserPhoto();
                string userPhoto = StringHelper.AddSafe(RequestHelper.GetForm <string>("postFile"));
                if (userPhoto != string.Empty)
                {
                    user.Photo = userPhoto;
                    CookiesHelper.AddCookie("UserPhoto", userPhoto);
                }
            }
            else
            {
                //user.Email = StringHelper.AddSafe(RequestHelper.GetForm<string>("Email"));
                user.Sex      = RequestHelper.GetForm <int>("Sex");
                user.Birthday = StringHelper.AddSafe(RequestHelper.GetForm <string>("Birthday"));
                user.MSN      = StringHelper.AddSafe(RequestHelper.GetForm <string>("MSN"));
                user.QQ       = StringHelper.AddSafe(RequestHelper.GetForm <string>("QQ"));
                user.Tel      = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel"));
                //user.Mobile = StringHelper.AddSafe(RequestHelper.GetForm<string>("Mobile"));
                user.RegionId  = singleUnlimitClass.ClassID;
                user.Address   = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address"));
                user.Introduce = StringHelper.AddSafe(RequestHelper.GetForm <string>("Introduce"));
                //CookiesHelper.AddCookie("UserEmail", user.Email);
            }
            //if (!UserBLL.CheckEmail(user.Email, base.UserId))
            //{
            //    ScriptHelper.AlertFront("Email已被其他会员注册", RequestHelper.RawUrl);
            //}
            //else
            //{
            Regex reg = new Regex("^[1-9]\\d{4,12}$");

            if (!string.IsNullOrEmpty(user.QQ) && !reg.IsMatch(user.QQ))
            {
                ScriptHelper.AlertFront("QQ号输入错误", RequestHelper.RawUrl);
            }
            else if (!string.IsNullOrEmpty(user.Tel) && !new Regex("^(([\\d]{3,4}-?)?[\\d]{7,8})$").IsMatch(user.Tel))
            {
                ScriptHelper.AlertFront("固定电话输入错误", RequestHelper.RawUrl);
            }
            else
            {
                UserBLL.Update(user);
                ScriptHelper.AlertFront("修改成功", RequestHelper.RawUrl);
            }
            //}
        }
Beispiel #29
0
 public ActionResult Login(string account, string password, string verifcode)
 {
     if (verifcode != "1234")
     {
         return(Json("error"));
     }
     if (account != "admin" || password != "123456")
     {
         return(Json("error"));
     }
     CookiesHelper.AddCookie("ua", account);
     CookiesHelper.AddCookie("up", password);
     return(Json("OK"));
 }
Beispiel #30
0
        public static void SetAuthentication <T>(string username, T user) where T : class, new()
        {
            var token = new AuthenticationToken <T>(user);

            var ticket = new FormsAuthenticationTicket(1,                 // 版本号。
                                                       username,          // 与身份验证票关联的用户名。
                                                       DateTime.Now,      // Cookie 的发出时间。
                                                       DateTime.MaxValue, // Cookie 的到期日期。
                                                       false,             // 如果 Cookie 是持久的,为 true;否则为 false。
                                                       token.ToJson());   // 将存储在 Cookie 中的用户定义数据。  roles是一个角色字符串数组

            string encryptedTicket = FormsAuthentication.Encrypt(ticket); //加密

            CookiesHelper.AddCookie(FormsAuthentication.FormsCookieName, encryptedTicket, FormsAuthentication.CookieDomain);
        }