Ejemplo n.º 1
0
        /// <summary>
        /// 检查登录
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        private ActionResult checkUserPasword(string username, string password, int expires = 0)
        {
            using (var manage = new bitcms.Data.CMSManage())
            {
                var userInfo = manage.checkLogin(username, password, Entity.passwordType.user);

                if (userInfo == null)
                {
                    this.userOnlineInfo.UnsafeVisitsNum++;
                    return(this.getResult(Entity.Error.错误, "验证失败!", new { loginVerifykey = this.userOnlineInfo.LoginVerifykey }));
                }
                else
                {
                    this.userOnlineInfo.UnsafeVisitsNum = 0;
                    if (this.userOnlineInfo.IsOAuth)//更新授权登陆会员
                    {
                        this.userOnlineInfo.UserBindInfo.UserId = userInfo.UserId;
                        manage.updateUserBind(this.userOnlineInfo.UserBindInfo);
                    }

                    //设置会员在线
                    Config.UserConfig.setUserOnline(userInfo, expires);
                    //更改积分
                    manage.insertScoreLog(userInfo.UserId, "land");

                    return(this.getResult(Entity.Error.请求成功, "登录成功!"));
                }
            }
        }
Ejemplo n.º 2
0
        public ActionResult updateAccount(string oldaccount, string account, string accounttype, string verifykey)
        {
            var code = Config.UserConfig.getVerifyCode(account);

            if (code != null && code.Code.Equals(verifykey.ToLower()))
            {
                using (var manage = new bitcms.Data.CMSManage())
                {
                    var userBindInfo = manage.getUserBindInfo(accounttype, account);
                    if (userBindInfo != null)
                    {
                        return(this.getResult(Entity.Error.错误, "该账号已经绑定"));
                    }
                    else
                    {
                        manage.updateUserCode(this.userOnlineInfo.UserId, accounttype, oldaccount, account);
                        return(this.getResult(manage.Error, manage.Message));
                    }
                }
            }
            else
            {
                return(this.getResult(Entity.Error.错误, "验证码错误或已经过期"));
            }
        }
Ejemplo n.º 3
0
        public JsonResult getpassword(string account, string accounttype, string password, string verifycode)
        {
            string message = string.Empty;

            Entity.Error error = Entity.Error.请求成功;

            var mobilecode = Config.UserConfig.getVerifyCode(account);

            if (mobilecode != null && mobilecode.Code == verifycode && mobilecode.Deadline >= Config.SiteConfig.getLocalTime())
            {
                if (mobilecode.Account == account)
                {
                    using (var manage = new bitcms.Data.CMSManage())
                    {
                        var userBindInfo = manage.getUserBindInfo(accounttype, account);
                        if (userBindInfo != null && userBindInfo.UserId > 0)
                        {
                            manage.updatePassword(userBindInfo.UserId, Entity.passwordType.user, password);
                        }
                    }
                }
                else
                {
                    error   = Entity.Error.错误;
                    message = "验证账号和原账号不一致!";
                }
            }
            else
            {
                error   = Entity.Error.错误;
                message = "验证码错误或已经过期!";
            }
            return(this.getResult(error, message));
        }
Ejemplo n.º 4
0
 public JsonResult updateReviewHitsNum(int id)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         var num = manage.updateReviewHitsNum(id);
         return(this.getResult(manage.Error, manage.Message, new { num = num }));
     }
 }
Ejemplo n.º 5
0
 public ActionResult setUserScore(string eventcode)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         var result = manage.insertScoreLog(this.userOnlineInfo.UserId, eventcode);
         return(this.getResult(Entity.Error.请求成功, "请求成功!", result ? 1 : 0));
     }
 }
Ejemplo n.º 6
0
 public JsonResult checkUserFollow(int userid, int followUserId)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         var result = manage.checkFollow(userid, followUserId);
         return(this.getResult(manage.Error, manage.Message, result));
     }
 }
Ejemplo n.º 7
0
 public JsonResult checkfavorties(string code, int targetid)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         var result = manage.checkFavorites(code, targetid);
         return(this.getResult(manage.Error, manage.Message, result));
     }
 }
Ejemplo n.º 8
0
 public JsonResult getUserReviewList(Entity.PageInfo page, string code, int detailid, int replyid = 0, int userid = 0)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         var list = manage.getReviewList(page, code, detailid, replyid, userid, 1);
         return(this.getResult(manage.Error, manage.Message, list));
     }
 }
Ejemplo n.º 9
0
 public JsonResult updateDetailHitsNum(int id)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         var num = manage.insertDetailHits(this.userOnlineInfo.UserOnlineId, this.userOnlineInfo.UserId, id);
         return(this.getResult(manage.Error, manage.Message, new { num = num }));
     }
 }
Ejemplo n.º 10
0
 public JsonResult getViewPointList(string dids, string rids)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         var list = manage.getViewPointList(this.userOnlineInfo.UserId, dids, rids);
         return(this.getResult(manage.Error, manage.Message, list));
     }
 }
Ejemplo n.º 11
0
 public JsonResult setViewPoint(int detailid = 0, int reviewid = 0, int agree = -1, int against = -1)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         var num = manage.setViewPoint(this.userOnlineInfo.UserId, detailid, reviewid, agree, against);
         return(this.getResult(manage.Error, manage.Message, new { num }));
     }
 }
Ejemplo n.º 12
0
 public ActionResult updateUserPassword(string oldpassword, string password)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         manage.updatePassword(this.userOnlineInfo.UserId, Entity.passwordType.user, oldpassword, password);
         return(this.getResult(manage.Error, manage.Message));
     }
 }
Ejemplo n.º 13
0
 public ActionResult checkUserName(string username)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         var count = manage.checkUserName(username, this.userOnlineInfo.UserId);
         return(this.getResult(manage.Error, manage.Message, new { Count = count }));
     }
 }
Ejemplo n.º 14
0
        public ActionResult updateAvatar(string avatar)
        {
            using (var manage = new bitcms.Data.CMSManage())
            {
                manage.updateUserAvatar(this.userOnlineInfo.UserId, avatar);
                this.userOnlineInfo.UserInfo.Avatar = avatar;

                //更改积分
                manage.insertScoreLog(this.userOnlineInfo.UserId, "updateavatar");
                return(this.getResult(manage.Error, manage.Message));
            }
        }
Ejemplo n.º 15
0
 public JsonResult cancelFollow(int userid, int followUserId)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         if (!manage.deleteFollowInfo(userid, followUserId))
         {
             manage.Error   = Entity.Error.错误;
             manage.Message = "取消失败";
         }
         return(this.getResult(manage.Error, manage.Message));
     }
 }
Ejemplo n.º 16
0
        public ActionResult updateUser(Entity.UserInfo userinfo)
        {
            using (var manage = new bitcms.Data.CMSManage())
            {
                userinfo.UserId = this.userOnlineInfo.UserId;
                if (string.IsNullOrEmpty(userinfo.UserName))
                {
                    userinfo.UserName = this.userOnlineInfo.UserName;
                }
                manage.updateBasicUser(userinfo);
                Config.UserConfig.setUserOnline(userinfo);

                return(this.getResult(manage.Error, manage.Message));
            }
        }
Ejemplo n.º 17
0
 public ActionResult checkAccount(string account, string accounttype, string verifykey = null)
 {
     //验证码
     if (!string.IsNullOrEmpty(verifykey))
     {
         var code = Config.UserConfig.getVerifyCode(account);
         if (code == null || !code.Code.Equals(verifykey.ToLower()))
         {
             return(this.getResult(Entity.Error.错误, "验证码错误或已经过期"));
         }
     }
     using (var manage = new bitcms.Data.CMSManage())
     {
         var userid = manage.checkUserBindCode(accounttype, account);
         return(this.getResult(manage.Error, manage.Message, new { UserId = userid }));
     }
 }
Ejemplo n.º 18
0
        public JsonResult updateReview(Entity.ReviewInfo info, string key, string verifykey)
        {
            if (this.config.EnabledReviewVerifykey)
            {
                if (string.IsNullOrEmpty(key))
                {
                    key = "verifycode";
                }
                var code = Config.UserConfig.getVerifyCode(key);
                if (string.IsNullOrEmpty(verifykey) || code == null || !code.Code.Equals(verifykey.ToLower()))
                {
                    return(this.getResult(Entity.Error.错误, "验证码错误!"));
                }
            }
            if (info != null && !string.IsNullOrEmpty(info.Content))
            {
                using (var manage = new bitcms.Data.CMSManage())
                {
                    if (this.config.VerifyReview)
                    {
                        info.Verify = 0;
                    }
                    else
                    {
                        info.Verify = 1;
                    }
                    info.UserId = this.userOnlineInfo.UserId;
                    manage.addReview(info);
                    if (info.Verify != 1)
                    {
                        manage.Message = "评论成功,系统审核后再进行展示!";
                    }
                    else
                    {
                        manage.Message = "评论成功";
                    }

                    return(this.getResult(manage.Error, manage.Message));
                }
            }
            else
            {
                return(this.getResult(Entity.Error.错误, "内容为空!"));
            }
        }
Ejemplo n.º 19
0
 public JsonResult addfavorties(string code, int targetid, string title, string link, string pic = null, string describe = null)
 {
     using (var manage = new bitcms.Data.CMSManage())
     {
         var num = manage.insertFavoritesInfo(new Entity.FavoritesInfo()
         {
             FavoritesCode = code,
             TargetId      = targetid,
             Title         = title,
             Link          = link,
             Pic           = pic,
             Describe      = describe,
             InDate        = Config.SiteConfig.getLocalTime(),
             UserId        = this.userOnlineInfo.UserId
         });
         return(this.getResult(manage.Error, manage.Message, num));
     }
 }
Ejemplo n.º 20
0
 public JsonResult deleteDetail(int id)
 {
     if (id > 0)
     {
         using (var manage = new bitcms.Data.CMSManage())
         {
             var detailInfo = manage.getDetailInfo(id);
             if (detailInfo != null)
             {
                 if (detailInfo.UserId == this.userOnlineInfo.UserId)
                 {
                     manage.deleteDetail(id);
                     return(this.getResult(manage.Error, manage.Message));
                 }
                 else
                 {
                     return(this.getResult(Entity.Error.错误, "非法操作"));
                 }
             }
         }
     }
     return(this.getResult(Entity.Error.错误, "参数错误"));
 }
Ejemplo n.º 21
0
        public JsonResult updateReply(int replyid, string content, int detailid = 0, string key = null, string verifykey = null)
        {
            if (this.config.EnabledReviewVerifykey)
            {
                if (string.IsNullOrEmpty(key))
                {
                    key = "verifycode";
                }
                var code = Config.UserConfig.getVerifyCode(key);
                if (string.IsNullOrEmpty(verifykey) || code == null || !code.Code.Equals(verifykey.ToLower()))
                {
                    return(this.getResult(Entity.Error.错误, "验证码错误!"));
                }
            }
            if (replyid > 0 && !string.IsNullOrEmpty(content))
            {
                using (var manage = new bitcms.Data.CMSManage())
                {
                    manage.addReply(replyid, content, this.userOnlineInfo.UserId, this.config.VerifyReview ? 0 : 1);
                    if (!this.config.VerifyReview)
                    {
                        manage.Message = "回复成功";
                    }
                    else
                    {
                        manage.Message = "回复成功,系统审核后再进行展示!";
                    }

                    return(this.getResult(manage.Error, manage.Message));
                }
            }
            else
            {
                return(this.getResult(Entity.Error.错误, "内容为空!"));
            }
        }
Ejemplo n.º 22
0
        public JsonResult updateDetail(Entity.DetailInfo info, string pics, int cid, string content, string key, string verifykey)
        {
            if (this.config.EnabledDetailVerifykey)
            {
                if (string.IsNullOrEmpty(key))
                {
                    key = "verifycode";
                }
                var code = Config.UserConfig.getVerifyCode(key);
                if (string.IsNullOrEmpty(verifykey) || code == null || !code.Code.Equals(verifykey.ToLower()))
                {
                    return(this.getResult(Entity.Error.错误, "验证码错误!"));
                }
            }
            if (info == null || string.IsNullOrEmpty(info.ChannelCode))
            {
                return(this.getResult(Entity.Error.错误, "频道错误!"));
            }
            if (string.IsNullOrEmpty(pics) && string.IsNullOrEmpty(content))
            {
                return(this.getResult(Entity.Error.错误, "内容为空!"));
            }
            using (var manage = new bitcms.Data.CMSManage())
            {
                if (this.config.VerifyUserDetail)
                {
                    info.Display = 0;
                }

                if (info.ItemId > 0)
                {
                    info.Items = info.ItemId.ToString();
                }
                info.UserId = this.userOnlineInfo.UserId;
                info.Author = this.userOnlineInfo.UserName;
                if (string.IsNullOrEmpty(info.Source))
                {
                    info.Source = this.config.SiteName;
                }
                manage.updateDetail(info);
                if (info.DetailId > 0)
                {
                    if (!string.IsNullOrEmpty(content))
                    {
                        var contentInfo = new Entity.DetailContentInfo()
                        {
                            Title       = info.Title,
                            Content     = content,
                            OrderNo     = 0,
                            DetailId    = info.DetailId,
                            ContentId   = cid,
                            ItemId      = info.ItemId,
                            ChannelCode = info.ChannelCode,
                            InDate      = Config.SiteConfig.getLocalTime()
                        };
                        manage.updateDetailContent(contentInfo);
                    }
                    if (!string.IsNullOrEmpty(pics))
                    {
                        //更新图库
                        JavaScriptSerializer jsHelper = new JavaScriptSerializer();
                        var gallerylist = jsHelper.Deserialize <List <Entity.DetailGalleryInfo> >(pics);
                        if (gallerylist != null)
                        {
                            manage.updateDetailGallery(gallerylist, info.DetailId);
                        }
                    }
                }
                if (info.Display != 1 && this.config.VerifyUserDetail)
                {
                    manage.Message = "发表成功,系统审核后将进行展示!";
                }
                else
                {
                    manage.Message = "发表成功";
                }

                return(this.getResult(manage.Error, manage.Message));
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 控制后台访问
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            if (!this.validateAdminPermission())
            {
                ViewBag.Title        = "受限访问";
                ViewBag.Message      = "抱歉, 系统设置了IP访问列表限制, 您无法访问本网站!";
                filterContext.Result = this.Content(this.getSystemTemplate("error.cshtml"));
                return;
            }

            if (!this.userOnlineInfo.AdminOnline)
            {
                string url = Fetch.getRawUrl();
                if (!url.EndsWith("/"))
                {
                    url += "/";
                }
                if (url != "/admin/")
                {
                    filterContext.Result = getResult(Entity.Error.登录超时, "登陆超时!");
                }
                else
                {
                    filterContext.Result = new RedirectResult("/admin/login/");
                }
                return;
            }
            else if (this.userOnlineInfo.AdminUserInfo.UserId != 1)//权限控制
            {
                object area       = null;
                object controller = null;
                if (filterContext.RouteData.Values.TryGetValue("controller", out controller) && filterContext.RouteData.DataTokens.TryGetValue("area", out area))
                {
                    if (controller != null && area != null)
                    {
                        var _controller = controller.ToString().ToLower();
                        var _area       = area.ToString().ToLower();
                        if (!(_area == "admin" && (_controller == "home" || _controller == "changepassword" || _controller == "shortcutmenu")))//排除管理主页和修改密码页
                        {
                            using (var manage = new bitcms.Data.CMSManage())
                            {
                                Entity.AdminMenuInfo meunInfo = null;
                                var menuList = manage.getAdminMenuList(_area, _controller);
                                if (menuList.Count == 1)
                                {
                                    meunInfo = menuList[0];
                                }
                                else if (menuList.Count > 1)
                                {
                                    //参数
                                    var url = Fetch.getRawUrl();
                                    if (url.IndexOf('?') > -1)
                                    {
                                        foreach (var info in menuList)
                                        {
                                            if (!string.IsNullOrEmpty(info.Parm) && url.IndexOf(info.Parm) > -1)
                                            {
                                                meunInfo = info;
                                                break;
                                            }
                                        }
                                    }
                                }
                                Entity.RolePowerInfo power = null;
                                if (meunInfo != null)
                                {
                                    power = manage.getRolePowerInfo(this.userOnlineInfo.AdminUserInfo.RoleId, meunInfo.AdminMenuId);
                                }

                                if (power == null)
                                {
                                    filterContext.Result = getResult(Entity.Error.无查看权限, "无查看权限!");
                                    return;
                                }
                                else if (Fetch.isPost() && power.Edit != 1)//post提交
                                {
                                    filterContext.Result = getResult(Entity.Error.无提交权限, "无提交权限!");
                                    return;
                                }
                                this.ViewBag.Power = power;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 24
0
        public ActionResult loginAccount(string account, string password, string accounttype, string key, string verifykey, int expires = 0)
        {
            if (this.userOnlineInfo.LoginVerifykey)
            {
                if (string.IsNullOrEmpty(key))
                {
                    key = "verifycode";
                }
                var code = Config.UserConfig.getVerifyCode(key);
                if (string.IsNullOrEmpty(verifykey) || code == null || !code.Code.Equals(verifykey.ToLower()))
                {
                    return(this.getResult(Entity.Error.错误, "验证码错误!", new { loginVerifykey = this.userOnlineInfo.LoginVerifykey }));
                }
            }
            using (var manage = new bitcms.Data.CMSManage())
            {
                if (string.IsNullOrEmpty(accounttype))
                {
                    if (Common.Utils.isMobile(account))
                    {
                        accounttype = "mobile";
                    }
                    else if (Common.Utils.isEmail(account))
                    {
                        accounttype = "email";
                    }
                }
                if (!string.IsNullOrEmpty(accounttype))
                {
                    var moduleInfo = manage.getModuleInfo(accounttype);
                    if (moduleInfo != null && moduleInfo.Enabled == 1)
                    {
                        var userBindInfo = manage.getUserBindInfo(accounttype, account);
                        if (userBindInfo != null)
                        {
                            if (manage.checkUserPassword(userBindInfo.UserId, password, Entity.passwordType.user))
                            {
                                this.userOnlineInfo.UnsafeVisitsNum = 0;
                                //设置会员在线
                                var userinfo = manage.getUserInfo(userBindInfo.UserId);
                                manage.updateLastLandDate(userinfo);

                                if (this.userOnlineInfo.IsOAuth)//更新授权登陆会员
                                {
                                    this.userOnlineInfo.UserBindInfo.UserId = userinfo.UserId;
                                    manage.updateUserBind(this.userOnlineInfo.UserBindInfo);
                                }

                                Config.UserConfig.setUserOnline(userinfo, expires);

                                //更改积分
                                manage.insertScoreLog(userinfo.UserId, "land");

                                return(this.getResult(Entity.Error.请求成功, "登录成功!"));
                            }
                            else
                            {
                                this.userOnlineInfo.UnsafeVisitsNum++;
                                return(this.getResult(Entity.Error.错误, "密码错误!", new { loginVerifykey = this.userOnlineInfo.LoginVerifykey }));
                            }
                        }
                        else
                        {
                            this.userOnlineInfo.UnsafeVisitsNum++;
                            return(this.getResult(Entity.Error.错误, "账号不存在!", new { loginVerifykey = this.userOnlineInfo.LoginVerifykey }));
                        }
                    }
                    else
                    {
                        return(this.getResult(Entity.Error.错误, "配置错误,请与网站管理员联系!", new { loginVerifykey = this.userOnlineInfo.LoginVerifykey }));
                    }
                }
                else
                {
                    //账号登录
                    return(checkUserPasword(account, password, expires));
                }
            }
        }