Example #1
0
        public List <long> GetUserIds(UserAuthority authority)
        {
            var context     = Context;
            var userService = new UserService(context);

            return(userService.GetUserIds(it => it.Authority == authority));
        }
Example #2
0
 public bool ValidateAuthority()
 {
     if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
     {
         base.AddErrLine(this.msg);
         if (this.userid == -1)
         {
             this.needlogin = true;
         }
         return(false);
     }
     this.canreply = (this.ismoder == 1 || UserAuthority.PostReply(forum, this.userid, this.usergroupinfo, this.topic));
     if (this.userid > -1)
     {
         this.canposttopic = UserAuthority.PostAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg);
         if (!this.canposttopic && !this.pagename.StartsWith("showtopic") && !this.pagename.StartsWith("showtree"))
         {
             base.AddErrLine(this.msg);
             return(false);
         }
     }
     if (this.useradminid != 1 && !this.usergroupinfo.DisablePeriodctrl)
     {
         string text = "";
         if (Scoresets.BetweenTime(this.config.Postbanperiods, out text))
         {
             this.canposttopic = false;
         }
         this.isnewbie = UserAuthority.CheckNewbieSpan(this.userid);
     }
     return(true);
 }
    private void SetUserAuthority(DataTable dtUser, UserAuthority objParentAuthority)
    {
        foreach (DataRow drUser in dtUser.Rows)
        {
            int?UsersId         = drUser[CS.UsersId].zToInt();
            var lstUserAutority = new UserAuthority()
            {
                eAuthority = objParentAuthority.eAuthority,
                UsersId    = UsersId
            }.SelectList <UserAuthority>();

            var objUserAuthority = new UserAuthority()
            {
                UsersId        = UsersId,
                eAuthority     = objParentAuthority.eAuthority,
                IsAllowView    = objParentAuthority.IsAllowView.Value,
                IsAllowAddEdit = objParentAuthority.IsAllowAddEdit.Value,
                IsAllowDelete  = objParentAuthority.IsAllowDelete.Value,
            };

            if (lstUserAutority.Count > 0)
            {
                objUserAuthority.UserAuthorityId = lstUserAutority[0].UserAuthorityId;
                objUserAuthority.Update();
            }
            else
            {
                objUserAuthority.Insert();
            }
        }
    }
Example #4
0
        /// <summary>
        /// 验证用户是否具有指定功能的权限
        /// </summary>
        /// <param name="moduleCode">模块编码</param>
        /// <param name="functionMark">功能标识</param>
        /// <returns>执行结果</returns>
        public static bool VerifyModule(string moduleCode, int functionMark)
        {
            if (string.IsNullOrEmpty(UserAuthority) || UserAuthority.Length == 1)
            {
                return(false);
            }
            bool result = false;
            int  mi     = UserAuthority.IndexOf(";" + moduleCode + "|");

            if (mi >= 0)
            {
                int ml = UserAuthority.IndexOf(";", mi + 1);
                if (ml < 0)
                {
                    ml = UserAuthority.Length;
                }
                string authString = UserAuthority.Substring(mi + moduleCode.Length + 2, ml - mi - moduleCode.Length - 2);
                if (authString.Length >= functionMark)
                {
                    if (authString.Substring(functionMark - 1, 1) == "1")
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }
Example #5
0
        //private string condition = "";

        protected override void ShowPage()
        {
            //type = DNTRequest.GetString("type", true);
            if (userid > 0 && useradminid > 0)
            {
                admingroupinfo = AdminGroup.FindByID(usergroupid);
            }
            if (config.Rssstatus == 1)
            {
                base.AddLinkRss("tools/rss.aspx", "最新主题");
            }

            if (forumid == -1)
            {
                var vs = Request["fidlist"];
                if (vs.IsNullOrWhiteSpace())
                {
                    vs = (Request["forums"] + "").ToLower();
                }
                if (vs.IsNullOrWhiteSpace() || vs.EqualIgnoreCase("all"))
                {
                    vs = GetForums();
                }
                vs     = GetAllowviewForums(vs);
                forums = vs;
            }
            navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);
            if (forumid > 0)
            {
                forum = Forums.GetForumInfo(forumid);
                if (forum == null)
                {
                    base.AddErrLine("不存在的版块ID");
                    return;
                }
                pagetitle      = Utils.RemoveHtml(forum.Name);
                forumnav       = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
                showforumlogin = ShowForumLogin();
                if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
                {
                    base.AddErrLine(msg);
                    return;
                }
                subforumlist = Forums.GetSubForumCollection(forumid, forum.ColCount, config.Hideprivate, usergroupid, config.Moddisplay);
            }
            var condition = GetCondition();

            if (base.IsErr())
            {
                return;
            }

            pagetitle = ((type == "digest") ? "查看精华" : "查看新帖");
            SetPageIdAndNumber(condition);
            topiclist = Topics.GetTopicListByCondition(tpp, pageid, 0, 10, config.Hottopic, forum == null ? 0 : forum.AutoClose, forum == null ? 0 : forum.Topictypeprefix, condition, GetOrder(), direct);
            Online.UpdateAction(olid, UserAction.ShowForum, forumid, config.Onlinetimeout);
            ForumUtils.UpdateVisitedForumsOptions(forumid);
        }
Example #6
0
 public RequestProcessMethodAttribute(UserAuthority requiredAuthority, bool requestUserId = false, bool requestObjectId = false, bool requestSession = false)
 {
     NumberOfExtraParameters  = 0;
     RequiredAuthority        = requiredAuthority;
     RequestUserId            = requestUserId;
     NumberOfExtraParameters += (requestUserId ? 1 : 0);
     RequestObjectId          = requestObjectId;
     NumberOfExtraParameters += (requestObjectId ? 1 : 0);
     RequestSession           = requestSession;
     NumberOfExtraParameters += (requestSession ? 1 : 0);
 }
Example #7
0
        public async ValueTask <string> GenerateInvitationCode(long senderId, UserAuthority authority)
        {
            var context     = Context;
            var userService = new UserService(context);
            var user        = await userService.GetSingleAsync(it => it.Id == senderId);

            if (user == null || user.Authority >= authority)
            {
                return(null);
            }
            return(await GenerateInvitationCode(context, senderId, authority));
        }
Example #8
0
        /// <summary>
        /// 创建主题帖信息
        /// </summary>
        /// <param name="topicinfo"></param>
        /// <returns></returns>
        public PostInfo CreatePost(TopicInfo topicinfo)
        {
            PostInfo postinfo = new PostInfo();

            postinfo.Fid      = forumid;
            postinfo.Tid      = topicinfo.Tid;
            postinfo.Poster   = username;
            postinfo.Posterid = userid;
            postinfo.Title    = useradminid == 1 ? Utils.HtmlEncode(posttitle) :
                                postinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(posttitle));
            postinfo.Postdatetime              = curdatetime;
            postinfo.Message     = message;
            postinfo.Ip          = DNTRequest.GetIP();
            postinfo.Invisible   = UserAuthority.GetTopicPostInvisible(forum, useradminid, userid, usergroupinfo, postinfo);
            postinfo.Usesig      = TypeConverter.StrToInt(DNTRequest.GetString("usesig"));
            postinfo.Htmlon      = (usergroupinfo.Allowhtml == 1 && (TypeConverter.StrToInt(DNTRequest.GetString("htmlon")) == 1)) ? 1 : 0;
            postinfo.Smileyoff   = (smileyoff == 0 && forum.Allowsmilies == 1) ? TypeConverter.StrToInt(DNTRequest.GetString("smileyoff")) : smileyoff;
            postinfo.Bbcodeoff   = (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) ? postinfo.Bbcodeoff = TypeConverter.StrToInt(DNTRequest.GetString("bbcodeoff")) : 1;
            postinfo.Parseurloff = TypeConverter.StrToInt(DNTRequest.GetString("parseurloff"));
            postinfo.Topictitle  = topicinfo.Title;

            //if (Utils.GetCookie("lasttopictitle") == Utils.MD5(postinfo.Title) || Utils.GetCookie("lasttopicmessage") == Utils.MD5(postinfo.Message))
            //{
            //    AddErrLine("请勿重复发帖");
            //    return postinfo;
            //}

            try
            {
                postinfo.Pid = Posts.CreatePost(postinfo);
                Utils.WriteCookie("lasttopictitle", Utils.MD5(postinfo.Title));
                Utils.WriteCookie("lasttopicmessage", Utils.MD5(postinfo.Message));
            }
            catch
            {
                TopicAdmins.DeleteTopics(topicinfo.Tid.ToString(), false);
                AddErrLine("帖子保存出现异常");
            }

            //创建投票
            if (createpoll)
            {
                msg = Polls.CreatePoll(DNTRequest.GetFormString("PollItemname"), DNTRequest.GetString("multiple") == "on" ? 1 : 0,
                                       DNTRequest.GetInt("maxchoices", 1), DNTRequest.GetString("visiblepoll") == "on" ? 1 : 0, DNTRequest.GetString("allowview") == "on" ? 1 : 0,
                                       enddatetime, topicinfo.Tid, pollitem, userid);
            }
            return(postinfo);
        }
Example #9
0
 private void SyncUserAuthority()
 {
     using (var context = new XINEntities())
     {
         string EmployeeNo, ProgramID;
         try
         {
             //找出所有的程式代碼記錄
             var qryPrograms = from P in context.Programs
                               select P.ProgramID;
             //找出所有的使用者代碼記錄
             var qrysUsers = from E in context.XINUsers
                             select E.EmployeeNo;
             foreach (var P in qryPrograms)
             {
                 ProgramID = (string)P;
                 foreach (var U in qrysUsers)
                 {
                     EmployeeNo = (string)U;
                     var qry = (from A in context.UserAuthority
                                where A.EmployeeNo == EmployeeNo &&
                                A.ProgramID == ProgramID
                                select A).FirstOrDefault();
                     if (qry == null)
                     {
                         //新增使用權限記錄
                         UserAuthority NewAuthority = new UserAuthority();
                         NewAuthority.EmployeeNo = EmployeeNo;
                         NewAuthority.ProgramID  = ProgramID;
                         NewAuthority.Run        = true;
                         NewAuthority.Append     = true;
                         NewAuthority.Edit       = true;
                         NewAuthority.Report     = true;
                         context.AddObject("UserAuthority", NewAuthority);
                     }
                 }
             }
             context.SaveChanges();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "啟動錯誤", MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
     }
 }
Example #10
0
        public Post CreatePost(Topic topicinfo)
        {
            var pi = new Post();

            pi.Fid      = this.forumid;
            pi.Tid      = topicinfo.ID;
            pi.Poster   = this.username;
            pi.PosterID = this.userid;
            pi.Title    = ((this.useradminid == 1) ? Utils.HtmlEncode(this.posttitle) : Utils.HtmlEncode(ForumUtils.BanWordFilter(this.posttitle)));
            //pi.Postdatetime = DateTime.Now.ToFullString();
            //pi.Title = topicinfo.Title;
            pi.Message = this.message;
            //pi.Ip = WebHelper.UserHost;
            pi.Invisible   = UserAuthority.GetTopicPostInvisible(this.forum, this.useradminid, this.userid, this.usergroupinfo, pi);
            pi.UseSig      = DNTRequest.GetInt("usesig");
            pi.HtmlOn      = ((this.usergroupinfo.AllowHtml && DNTRequest.GetInt("htmlon") == 1) ? 1 : 0);
            pi.SmileyOff   = (smileyoff == 0 && forum.AllowSmilies) ? DNTRequest.GetInt("smileyoff") : this.smileyoff;
            pi.BBCodeOff   = (this.usergroupinfo.AllowCusbbCode && this.forum.Allowbbcode == 1) ? DNTRequest.GetInt("bbcodeoff") : 1;
            pi.ParseUrlOff = DNTRequest.GetInt("parseurloff");
            //pi.Topictitle = topicinfo.Title;
            //try
            //{
            //pi.Pid = Posts.CreatePost(pi);
            //pi.Insert();
            Utils.WriteCookie("lasttopictitle", Utils.MD5(pi.Title));
            Utils.WriteCookie("lasttopicmessage", Utils.MD5(pi.Message));
            //}
            //catch
            //{
            //	TopicAdmins.DeleteTopics(topicinfo.ID.ToString(), false);
            //	base.AddErrLine("帖子保存出现异常");
            //}
            if (this.createpoll)
            {
                this.msg = Poll.CreatePoll(
                    DNTRequest.GetFormString("PollItemname"),
                    (DNTRequest.GetString("multiple") == "on") ? 1 : 0,
                    DNTRequest.GetInt("maxchoices", 1),
                    (DNTRequest.GetString("visiblepoll") == "on") ? 1 : 0,
                    (DNTRequest.GetString("allowview") == "on") ? true : false,
                    Utility.ToDateTime(this.enddatetime), topicinfo.ID, this.pollitem, this.userid);
            }
            return(pi);
        }
Example #11
0
        /// <summary>
        /// 权限认证,包括回复,下载附件,发主题等
        /// </summary>
        /// <returns></returns>
        public bool ValidateAuthority()
        {
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                if (userid == -1)
                {
                    needlogin = true;
                }

                return(false);
            }

            //是否有回复权限
            canreply = (ismoder == 1 ? true : UserAuthority.PostReply(forum, userid, usergroupinfo, topic));

            //判断是否有发主题权限
            if (userid > -1)
            {
                canposttopic = UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg);
                if (!canposttopic)
                {
                    if (!pagename.StartsWith("showtopic") && !pagename.StartsWith("showtree"))
                    {
                        AddErrLine(msg);
                        return(false);
                    }
                }
            }

            //如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖
            if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1)
            {
                string visittime = "";
                if (Scoresets.BetweenTime(config.Postbanperiods, out visittime))
                {
                    canposttopic = false;
                }

                isnewbie = UserAuthority.CheckNewbieSpan(userid);
            }

            return(true);
        }
Example #12
0
        public UserAuthority Create(UserAuthority userAuthority)
        {
            if (string.IsNullOrEmpty(userAuthority.Authority))
            {
                throw new ArgumentException("user Authority should not be empty ");
            }
            if (string.IsNullOrEmpty(userAuthority.JGCITCode))
            {
                throw new ArgumentException("user Authority JGCITCode should not be empty ");
            }
            if (_context.UserAuthorities.Any(x => x.Authority == userAuthority.Authority))
            {
                throw new AppException("user Authority is already Exists");
            }
            _context.UserAuthorities.Add(userAuthority);
            _context.SaveChanges();

            return(userAuthority);
        }
Example #13
0
        private void TreetoList(AuthorityTreeModel root)
        {
            var num = root.ButtonAuthorityList.Where(m => m.IsChecked).Sum(g => g.ButtonID);

            if (num > 0)
            {
                UserAuthority.Add(new UserCustomerAuthority
                {
                    StructureID         = root.StructureID,
                    UserButtonAuthority = num
                });
            }
            if (root.children != null && root.children.Count > 0)
            {
                foreach (var child in root.children)
                {
                    TreetoList(child);
                }
            }
        }
Example #14
0
        public UserAuthority Update(UserAuthority userAuthority, int id)
        {
            var authority = (from x in _context.UserAuthorities
                             where x.ID == userAuthority.ID
                             select x).FirstOrDefault();

            if (authority.ID == id)
            {
                authority.Authority = userAuthority.Authority;
                authority.JGCITCode = userAuthority.JGCITCode;
            }

            if (_context.UserAuthorities.Any(x => x.Authority == userAuthority.Authority))
            {
                throw new AppException("User Authority is already Exists");
            }
            _context.UserAuthorities.Update(authority);
            _context.SaveChanges();

            return(authority);
        }
Example #15
0
        private void MessageReceived(object sender, OnMessageReceivedArgs message)
        {
            try
            {
                if (message.ChatMessage.Username == "kumakaini")
                {
                    return;
                }

                bool isAdmin     = message.ChatMessage.Username == "rekyuus";
                bool isModerator = message.ChatMessage.IsModerator;

                UserAuthority authority = UserAuthority.User;
                if (isAdmin)
                {
                    authority = UserAuthority.Admin;
                }
                else if (isModerator)
                {
                    authority = UserAuthority.Moderator;
                }

                Request request = new Request()
                {
                    Message          = message.ChatMessage.Message,
                    MessageId        = 0,
                    Username         = message.ChatMessage.Username,
                    Authority        = authority,
                    Protocol         = RequestProtocol.Twitch,
                    ChannelId        = 0,
                    ChannelIsPrivate = false,
                    ChannelIsNsfw    = false,
                };
                Response response = _kuma.GetResponse(request);

                if (response.Message != "")
                {
                    if (response.Message[0] == '/')
                    {
                        response.Message = response.Message[1..];
Example #16
0
        public virtual async ValueTask <Tuple <ResponseStatus, object> > GenerateInvitation(UserAuthority authority, long userId)
        {
            var invitation = await UserManager.GenerateInvitationCode(userId, authority);

            return(new Tuple <ResponseStatus, object>(
                       invitation != null
                    ? ResponseStatus.Success
                    : ResponseStatus.BadRequest,
                       invitation != null));
        }
Example #17
0
        private async ValueTask <string> GenerateInvitationCode(SqlSugarClient context, long senderId, UserAuthority authority)
        {
            try
            {
                context.BeginTran();
                var invitationService = new InvitationService(context);
                var invitation        = new Invitation()
                {
                    ObjectId       = IdGenerator.CreateId(),
                    Authority      = authority,
                    CreateTime     = DateTime.UtcNow,
                    InvitationCode = EncryptUtils.GenerateRandomString(32),
                    ReceiverId     = -1,
                    SenderId       = senderId,
                    UsedTime       = DateTime.MinValue
                };
                var success = await invitationService.InsertAsync(invitation);

                context.CommitTran();
                return(success ? invitation.InvitationCode : null);
            }
            catch (Exception e)
            {
                context.RollbackTran();
                throw;
            }
        }
Example #18
0
        protected override void ShowPage()
        {
            if (!SetTopicInfo())
            {
                topic = new TopicInfo();
                forum = new ForumInfo();
                return;
            }

            pagetitle = topic.Title.Trim();

            if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forum.Fid + "password"))
            {
                AddErrLine("本版块被管理员设置了密码");
                Response.Redirect(string.Format("{0}showforum-{1}{2}", BaseConfigs.GetForumPath, forum.Fid, config.Extname), true);
                return;
            }
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                return;
            }

            postinfo = Posts.GetTopicPostInfo(topicid);
            if (postinfo.Message.ToLower().Contains("[free]") || postinfo.Message.ToLower().Contains("[/free]"))
            {
                for (Match m = r.Match(postinfo.Message); m.Success; m = m.NextMatch())
                {
                    postmessage += "<br /><div class=\"msgheader\">免费内容:</div><div class=\"msgborder\">" + m.Groups[1] + "</div><br />";
                }
            }

            #region 获取主题售价等相关信息
            topicprice = topic.Price;
            //判断是否为回复可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买
            if (topic.Price > 0)
            {
                price = topic.Price;
                //判断当前用户是否已经购买
                if (PaymentLogs.IsBuyer(topicid, userid) || (Utils.StrDateDiffHours(topic.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 && Scoresets.GetMaxChargeSpan() != 0))
                {
                    price = -1;
                }
            }

            netamount = topicprice - topicprice * creditstax / 100;
            if (topicprice > maxincpertopic)
            {
                netamount = maxincpertopic - maxincpertopic * creditstax / 100;
            }

            if (price != -1)
            {
                UserInfo userInfo = Users.GetUserInfo(userid);

                if (buyit == 1 && !CheckUserExtCredit(userInfo))
                {
                    return;
                }

                userlastprice = Users.GetUserExtCredit(userInfo, Scoresets.GetTopicAttachCreditsTrans()) - topic.Price;
            }
            #endregion

            if (useradminid != 0)
            {
                isModer = Moderators.IsModer(useradminid, userid, forum.Fid) ? 1 : 0;
            }

            //如果不是提交...
            if (!ispost)
            {
                buyers = PaymentLogs.GetPaymentLogByTidCount(topic.Tid);
                //显示购买信息列表
                if (showpayments == 1)
                {
                    //获取总页数
                    pagecount = buyers % pageSize == 0 ? buyers / pageSize : buyers / pageSize + 1;
                    pagecount = pagecount == 0 ? 1 : pagecount;
                    //修正请求页数中可能的错误
                    pageid = pageid < 1 ? 1 : pageid;
                    pageid = pageid > pagecount ? pagecount : pageid;

                    //获取收入记录并分页显示
                    paymentloglist = PaymentLogs.GetPaymentLogByTid(pageSize, pageid, topic.Tid);
                }

                //判断是否为回复可见帖, hide=0为非回复可见(正常), hide>0为回复可见, hide=-1为回复可见但当前用户已回复
                int hide = (topic.Hide == 1 ? topic.Hide : 0);

                if (Posts.IsReplier(topicid, userid))
                {
                    hide = -1;
                }

                lastpostlist = Posts.GetLastPostDataTable(GetPostPramsInfo(hide));
            }
            else
            {
                int reval = PaymentLogs.BuyTopic(userid, topic.Tid, topic.Posterid, topic.Price, netamount);
                if (reval > 0)
                {
                    SetUrl(base.ShowTopicAspxRewrite(topic.Tid, 0));
                    SetMetaRefresh();
                    SetShowBackLink(false);
                    MsgForward("buytopic_succeed");
                    AddMsgLine("购买主题成功,返回该主题");
                    return;
                }
                else
                {
                    SetBackLink(base.ShowForumAspxRewrite(topic.Fid, 0));
                    if (reval == -1)
                    {
                        AddErrLine("对不起,您的账户余额少于交易额,无法进行交易");
                    }
                    else if (reval == -2)
                    {
                        AddErrLine("您无权购买本主题");
                    }
                    else
                    {
                        AddErrLine("未知原因,交易无法进行,给您带来的不方便我们很抱歉");
                    }
                    return;
                }
            }
        }
Example #19
0
        protected override void ShowPage()
        {
            GetPostAds(forumid);

            if (userid > 0 && useradminid > 0)
            {
                AdminGroupInfo admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid);
                if (admingroupinfo != null)
                {
                    disablepostctrl = admingroupinfo.Disablepostctrl;
                }
            }

            #region 获取版块信息
            if (forumid == -1)
            {
                AddLinkRss(forumpath + "tools/rss.aspx", "最新主题");
                AddErrLine("无效的版块ID");
                return;
            }
            forum = Forums.GetForumInfo(forumid);
            if (forum == null || forum.Fid < 1)
            {
                if (config.Rssstatus == 1)
                {
                    AddLinkRss(forumpath + "tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新主题");
                }

                AddErrLine("不存在的版块ID");
                return;
            }
            #endregion

            if (config.Rssstatus == 1)
            {
                AddLinkRss(forumpath + "tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新主题");
            }

            if (JumpUrl(forum))
            {
                return;
            }

            needaudit = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo);

            // 检查是否具有版主的身份
            if (useradminid > 0)
            {
                ismoder = Moderators.IsModer(useradminid, userid, forumid);
            }

            //设置搜索和排序条件
            SetSearchCondition();

            showforumlogin = IsShowForumLogin(forum);
            pagetitle      = Utils.RemoveHtml(forum.Name);
            navhomemenu    = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);
            forumnav       = ShowForumAspxRewrite(ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname).Replace("\"showforum", "\"" + forumurl + "showforum"),
                                                  forumid, pageid);
            topicextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans());

            #region 主题分类设置
            if (forum.Applytopictype == 1) //启用主题分类
            {
                topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes);
            }

            if (forum.Viewbytopictype == 1) //允许按类别浏览
            {
                topictypeselectlink = Forums.GetCurrentTopicTypesLink(forum.Fid, forum.Topictypes, forumurl + "showforum.aspx");
            }
            #endregion

            //更新页面Meta中的keyword,description项, 提高SEO友好性
            UpdateMetaInfo(Utils.StrIsNullOrEmpty(forum.Seokeywords) ? config.Seokeywords : forum.Seokeywords,
                           Utils.StrIsNullOrEmpty(forum.Seodescription) ? forum.Description : forum.Seodescription,
                           config.Seohead);

            //设置编辑器状态
            SetEditorState();

            #region 访问和发帖权限校验
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                needlogin = userid == -1;
                return;
            }

            canposttopic = UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg);
            // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖
            if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1)
            {
                string visittime = "";
                if (canposttopic && Scoresets.BetweenTime(config.Postbanperiods, out visittime))
                {
                    canposttopic = false;
                }

                isnewbie = UserAuthority.CheckNewbieSpan(userid);
            }

            //是否显示快速发主题编辑器(全局权限判定,版块权限判定,是否是游客,游客需要显示,登录用户是否允许发主题且已过新手见习期)
            if ((config.Fastpost == 1 || config.Fastpost == 3) && forum.Allowspecialonly <= 0 && (userid < 0 || (canposttopic && !isnewbie)))
            {
                canquickpost = true;
            }
            #endregion

            // 得到子版块列表
            if (forum.Subforumcount > 0)
            {
                subforumlist = Forums.GetSubForumCollection(forumid, forum.Colcount, config.Hideprivate, usergroupid, config.Moddisplay);
            }
            if (!forum.Rules.Equals(""))
            {
                forum.Rules = UBB.ParseSimpleUBB(forum.Rules);//替换版规中的UBB
            }
            //获取主题总数
            topiccount = Topics.GetTopicCount(forumid, true, condition);

            #region 设置分页及主题列表信息
            // 得到Tpp设置
            if (tpp <= 0)
            {
                tpp = config.Tpp;
            }

            // 得到Ppp设置
            if (ppp <= 0)
            {
                ppp = config.Ppp;
            }

            //修正请求页数中可能的错误
            if (pageid < 1)
            {
                pageid = 1;
            }

            int toptopicpagecount = 0;

            if (forum.Layer > 0)
            {
                //获取当前页置顶主题列表
                DataRow dr = Topics.GetTopTopicListID(forumid);
                if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString()))
                {
                    topiccount = topiccount + TypeConverter.ObjectToInt(dr["tid0Count"]);
                }

                //获取总页数
                pagecount = topiccount % tpp == 0 ? topiccount / tpp : topiccount / tpp + 1;
                if (pagecount == 0)
                {
                    pagecount = 1;
                }
                if (pageid > pagecount)
                {
                    pageid = pagecount;
                }

                if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString()))
                {
                    toptopiccount = TypeConverter.ObjectToInt(dr["tidCount"]);
                    if (toptopiccount > tpp * (pageid - 1))
                    {
                        toptopiclist      = Topics.GetTopTopicList(forumid, tpp, pageid, dr["tid"].ToString(), forum.Autoclose, forum.Topictypeprefix);
                        toptopicpagecount = toptopiccount / tpp;
                    }

                    if (toptopicpagecount >= pageid || (pageid == 1 && toptopicpagecount != toptopiccount))
                    {
                        topiclist = GetTopicInfoList(tpp - toptopiccount % tpp, pageid - toptopicpagecount, 0);
                    }
                    else
                    {
                        topiclist = GetTopicInfoList(tpp, pageid - toptopicpagecount, toptopiccount % tpp);
                    }
                }
                else
                {
                    toptopicpagecount = 0;
                    topiclist         = GetTopicInfoList(tpp, pageid, 0);
                }

                //如果topiclist为空则更新当前论坛帖数
                if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount)
                {
                    Forums.SetRealCurrentTopics(forum.Fid);
                }

                SetPageNumber();
                //当版块数大于一个并且当版块数量为一个时不是版块自身时显示下拉菜单
                showvisitedforumsmenu = visitedforums != null && ((visitedforums.Length == 1 && visitedforums[0].Fid != forumid) || visitedforums.Length > 1);
                SetVisitedForumsCookie();
                //保存查看版块的页数
                Utils.WriteCookie("forumpageid", pageid.ToString(), 30);

                //判断是否需要生成游客缓存页面
                IsGuestCachePage();
            }
            #endregion

            #region 替换版规中的UBB
            forum.Description = UBB.ParseSimpleUBB(forum.Description);
            #endregion

            #region 更新在线信息
            OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forum.Name, -1, "");

            if ((forumtotalonline < config.Maxonlinelist && (config.Whosonlinestatus == 2 || config.Whosonlinestatus == 3)) || DNTRequest.GetString("showonline") == "yes")
            {
                showforumonline = true;
                onlineuserlist  = OnlineUsers.GetForumOnlineUserCollection(forumid, out forumtotalonline, out forumtotalonlineguest,
                                                                           out forumtotalonlineuser, out forumtotalonlineinvisibleuser);
            }
            //if (DNTRequest.GetString("showonline") != "no")
            //{
            //     showforumonline = false;
            //}

            if (DNTRequest.GetString("showonline") == "no")
            {
                showforumonline = false;
            }
            #endregion

            //修正版主列表
            if (forum.Moderators.Trim() != "")
            {
                string moderHtml = string.Empty;
                foreach (string m in forum.Moderators.Split(','))
                {
                    moderHtml += string.Format("<a href=\"{0}userinfo.aspx?username={1}\">{2}</a>,", forumpath, Utils.UrlEncode(m), m);
                }

                forum.Moderators = moderHtml.TrimEnd(',');
            }

            ForumUtils.UpdateVisitedForumsOptions(forumid);
        }
Example #20
0
        protected override void ShowPage()
        {
            pagetitle = "搜索";

            GetSearchType();

            //判断当前操作是否是用户打开的页面
            if (searchsubmit == 0 && !ispost)
            {
                //用户权限校验
                if (!UserAuthority.Search(usergroupinfo, ref msg))
                {
                    AddErrLine(msg);
                    return;
                }

                //读取分表信息
                if (searchid <= 0)
                {
                    tablelist = Posts.GetAllPostTableName();
                }
                else
                {
                    if (searchType == SearchType.Error)
                    {
                        AddErrLine("非法的参数信息");
                        return;
                    }

                    switch (searchType)
                    {
                    case SearchType.SpacePostTitle:
                        spacepostlist = Searches.GetSearchCacheList(posttableid, searchid, 16, pageid, out topiccount, searchType);
                        break;

                    case SearchType.AlbumTitle:
                        albumlist = Searches.GetSearchCacheList(posttableid, searchid, 16, pageid, out topiccount, searchType);
                        break;

                    case SearchType.ByPoster:
                        topiclist   = Searches.GetSearchCacheList(posttableid, searchid, 16, topicpageid, out topiccount, SearchType.TopicTitle);
                        topicpageid = CalculateCurrentPage(topiccount, topicpageid, out topicpagecount);

                        topicpagenumbers = topicpagecount > 1 ? Utils.GetPageNumbers(topicpageid, topicpagecount, "search.aspx?type=" + type + "&searchid=" + searchid.ToString() + "&keyword=" + keyword + "&poster=" + poster, 8, "topicpage", "#1") : "";
                        return;

                    case SearchType.PostContent:
                    default:
                        topiclist = Searches.GetSearchCacheList(posttableid, searchid, 16, pageid, out topiccount, searchType);
                        break;
                    }

                    if (topiccount == 0)
                    {
                        AddErrLine("不存在的searchid");
                        return;
                    }
                    CalculateCurrentPage();
                    //得到页码链接
                    pagenumbers = pagecount > 1 ? Utils.GetPageNumbers(pageid, pagecount, "search.aspx?type=" + type + "&searchid=" + searchid.ToString() + "&keyword=" + keyword + "&poster=" + poster, 8) : "";
                }
            }
            else
            {
                //检查用户的搜索权限,包括搜索时间间隔的限制
                if (!UserAuthority.Search(userid, lastsearchtime, useradminid, usergroupinfo, ref msg))
                {
                    AddErrLine(msg);
                    return;
                }

                if (searchType == SearchType.Error)
                {
                    AddErrLine("非法的参数信息");
                    return;
                }

                searchpost = true;
                string searchforumid = DNTRequest.GetString("searchforumid").Trim();
                int    posterid      = CheckSearchInfo(searchforumid);
                if (IsErr())
                {
                    return;
                }

                //if (Utils.StrIsNullOrEmpty(keyword) && posterid > 0 && Utils.StrIsNullOrEmpty(type))
                //{
                //    type = "author";
                //    searchType = SearchType.ByPoster;
                //}

                searchid = Searches.Search(posttableid, userid, usergroupid, keyword, posterid, searchType, searchforumid, DNTRequest.GetInt("searchtime", 0), DNTRequest.GetInt("searchtimetype", 0), DNTRequest.GetInt("resultorder", 0), DNTRequest.GetInt("resultordertype", 0));
                if (searchid > 0)
                {
                    System.Web.HttpContext.Current.Response.Redirect(forumpath + "search.aspx?type=" + type + "&searchid=" + searchid + "&keyword=" + keyword + "&poster=" + poster + "&posttableid=" + posttableid, false);
                }
                else
                {
                    AddErrLine("抱歉, 没有搜索到符合要求的记录");
                    return;
                }
            }
        }
Example #21
0
        public AttachUploadPage()
        {
            if (!DNTRequest.GetRawUrl().Contains("action=swfupload") && ForumUtils.IsCrossSitePost(DNTRequest.GetUrlReferrer(), DNTRequest.GetHost())) //如果是跨站提交...
            {
                return;
            }

            //处理flash批量上传无法获取userid的问题
            bool canpostattach = true;

            if (DNTRequest.GetString("operation") == "upload")
            {
                string uploadUserid = DNTRequest.GetString("uid");
                int    olid         = Discuz.Forum.OnlineUsers.GetOlidByUid(TypeConverter.StrToInt(uploadUserid));
                if (olid > 0)
                {
                    OnlineUserInfo oluserinfo = Discuz.Forum.OnlineUsers.GetOnlineUser(olid);
                    string         hash       = Discuz.Common.DES.Encode(oluserinfo.Olid.ToString() + "," + oluserinfo.Username.ToString(), oluserinfo.Password.Substring(0, 10)).Replace("+", "[");
                    if (DNTRequest.GetString("hash") == hash)
                    {
                        userid        = oluserinfo.Userid;
                        usergroupinfo = UserGroups.GetUserGroupInfo(oluserinfo.Groupid);
                    }
                    else
                    {
                        canpostattach = false;
                    }
                }
                else
                {
                    canpostattach = false;
                }
            }

            UserInfo  userinfo     = Users.GetUserInfo(userid);
            ForumInfo forum        = Forums.GetForumInfo(forumid);
            int       MaxTodaySize = (userid > 0 ? Attachments.GetUploadFileSizeByuserid(userid) : 0);
            //今天可上传得大小
            int attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;
            //得到用户可以上传的文件类型
            string attachmentTypeSelect   = Attachments.GetAllowAttachmentType(usergroupinfo, forum);
            string attachextensions       = Attachments.GetAttachmentTypeArray(attachmentTypeSelect);
            string attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect);

            if (DNTRequest.GetString("action") == "swfupload" && DNTRequest.GetString("operation") == "config")
            {
                GetConfig(userid, attachextensionsnosize, attachsize, DNTRequest.GetString("type").Trim() == "image");
            }
            else
            {
                //处理附件
                string        msg = "";
                StringBuilder sb  = new StringBuilder();
                canpostattach &= UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg);
                if (!canpostattach)
                {
                    ResponseXML(sb.Append("DISCUZUPLOAD|11|0|-1").ToString());//11,上传权限
                    return;
                }
                if (attachsize <= 0)
                {
                    ResponseXML(sb.Append("DISCUZUPLOAD|3|0|-1").ToString());//3,附件大小超限
                    return;
                }

                //得到今天允许用户上传的附件总大小(字节)
                AttachmentInfo[] attachmentinfoarray = ForumUtils.SaveRequestFiles(forumid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize,
                                                                                   attachextensions, forum.Disablewatermark == 1 ? 0 : config.Watermarkstatus, config, "Filedata", DNTRequest.GetString("type") == "image");
                if (attachmentinfoarray.Length > 0)//已有上传文件
                {
                    int    aId      = DNTRequest.GetInt("aid", 0);
                    string noUpload = "";

                    foreach (AttachmentInfo attachmentinfo in attachmentinfoarray)
                    {
                        noUpload           = string.IsNullOrEmpty(attachmentinfo.Sys_noupload) ? noUpload : attachmentinfo.Sys_noupload;
                        attachmentinfo.Uid = userid;
                    }

                    if (aId <= 0)
                    {
                        Attachments.CreateAttachments(attachmentinfoarray);
                    }
                    else if (string.IsNullOrEmpty(noUpload))
                    {
                        AttachmentInfo attchmentInfo = Attachments.GetAttachmentInfo(aId);
                        //判断当前用户是否为附件所有者
                        if (attchmentInfo == null || (userinfo.Adminid <= 0 && attchmentInfo.Uid != userid))
                        {
                            return;
                        }
                        attchmentInfo.Postdatetime = attachmentinfoarray[0].Postdatetime;
                        attchmentInfo.Filename     = attachmentinfoarray[0].Filename;
                        attchmentInfo.Description  = attachmentinfoarray[0].Description;
                        attchmentInfo.Filetype     = attachmentinfoarray[0].Filetype;
                        attchmentInfo.Filesize     = attachmentinfoarray[0].Filesize;
                        attchmentInfo.Attachment   = attachmentinfoarray[0].Attachment;
                        attchmentInfo.Width        = attachmentinfoarray[0].Width;
                        attchmentInfo.Height       = attachmentinfoarray[0].Height;
                        attchmentInfo.Isimage      = attachmentinfoarray[0].Isimage;
                        Attachments.UpdateAttachment(attchmentInfo);
                    }
                    StringBuilder text = new StringBuilder();
                    int           type = attachmentinfoarray[0].Filetype.StartsWith("image") ? 0 : -1;

                    int resultCode = GetNoUploadCode(noUpload);

                    if (aId <= 0)
                    {
                        if (DNTRequest.GetString("action") != "swfupload")
                        {
                            text.AppendFormat("DISCUZUPLOAD|{0}|{1}|{2}", resultCode, attachmentinfoarray[0].Aid, type);
                        }
                        else
                        {
                            text.AppendFormat(resultCode != 0 ? "error" : attachmentinfoarray[0].Aid.ToString());
                        }
                    }
                    else
                    {
                        text.AppendFormat("DISCUZUPDATE|{0}|{1}|{2}|{3}", resultCode, attachmentinfoarray[0].Attachment, aId, type);
                    }
                    ResponseXML(text.ToString());
                }
            }
        }
Example #22
0
        protected override void ShowPage()
        {
            pagetitle = "附件下载";

            if (attachmentid == -1)
            {
                AddErrLine("无效的附件ID");
                return;
            }

            // 如果当前用户非管理员并且论坛设定了禁止下载附件时间段,当前时间如果在其中的一个时间段内,则不允许用户下载附件
            if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1)
            {
                string visitTime = "";
                if (Scoresets.BetweenTime(config.Attachbanperiods, out visitTime))
                {
                    AddErrLine("在此时间段( " + visitTime + " )内用户不可以下载附件");
                    return;
                }
            }

            if (DNTRequest.GetString("goodsattach").ToLower() == "yes")
                GetGoodsAttachInfo(attachmentid);
            else
            {
                // 获取该附件的信息
                attachmentinfo = Attachments.GetAttachmentInfo(attachmentid);
                if (attachmentinfo == null)
                {
                    AddErrLine("不存在的附件ID");
                    return;
                }
                //当前用户已上传但是还没有绑定到帖子的附件需要特殊处理,直接输出图片
                if ((userid > 0 || userid == -1) && userid == attachmentinfo.Uid && attachmentinfo.Tid == 0 && attachmentinfo.Filetype.StartsWith("image/"))
                {
                    HttpContext.Current.Response.Clear();
                    if(attachmentinfo.Filename.IndexOf("http") < 0 )
                       HttpContext.Current.Response.TransmitFile(BaseConfigs.GetForumPath + "upload/" + attachmentinfo.Filename.Trim());
                    else
                       HttpContext.Current.Response.Redirect(attachmentinfo.Filename.Trim());
                    
                    HttpContext.Current.Response.End();
                    return;
                }
                // 获取该主题的信息
                topic = Topics.GetTopicInfo(attachmentinfo.Tid);
                if (topic == null)
                {
                    AddErrLine("不存在的主题ID");
                    return;
                }

                ForumInfo forum = Forums.GetForumInfo(topic.Fid);
                pagetitle = Utils.RemoveHtml(forum.Name);
                if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
                {
                    AddErrLine(msg);
                    if (userid == -1)
                        needlogin = true;
                    return;
                }

                //添加判断特殊用户的代码
                if (!UserAuthority.CheckUsertAttachAuthority(forum, usergroupinfo, userid, ref msg))
                {
                    AddErrLine(msg);
                    if (userid == -1)
                        needlogin = true;
                    return;
                }

                ismoder = Moderators.IsModer(useradminid, userid, forum.Fid);
                // 检查用户是否拥有足够的阅读权限
                if ((attachmentinfo.Readperm > usergroupinfo.Readaccess) && (attachmentinfo.Uid != userid) && (!ismoder))
                {
                    AddErrLine("您的阅读权限不够");
                    if (userid == -1)
                        needlogin = true;
                    return;
                }

                //检查附件是否存在
                if (attachmentinfo.Filename.IndexOf("http") < 0 && !File.Exists(Utils.GetMapPath(string.Format(@"{0}upload/{1}", BaseConfigs.GetForumPath, attachmentinfo.Filename))))
                {
                    AddErrLine("该附件文件不存在或已被删除");
                    return;
                }

                //(!Utils.IsImgFilename(attachmentinfo.Filename.Trim()) || config.Showimages != 1):判断文件是否是图片和图片是否允许在帖子中直接显示
                //userid != attachmentinfo.Uid && !ismoder:判断当前下载用户是否是该附件的发布者和当前用户是否具有管理权限
                //Utils.StrIsNullOrEmpty(Utils.GetCookie("dnt_attachment_" + attachmentid))当前用户是否已经下载过该附件
                if ((!Utils.IsImgFilename(attachmentinfo.Filename.Trim()) || config.Showimages != 1) &&
                    (userid != attachmentinfo.Uid && !ismoder && Utils.StrIsNullOrEmpty(Utils.GetCookie("dnt_attachment_" + attachmentid))))
                {
                    if (Scoresets.IsSetDownLoadAttachScore() && UserCredits.UpdateUserExtCreditsByDownloadAttachment(userid, 1) == -1)
                    {
                        string addExtCreditsTip = "";
                        if (EPayments.IsOpenEPayments())
                            addExtCreditsTip = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>";
                        AddErrLine("您的积分不足" + addExtCreditsTip);
                        return;
                    }
                    //设置该附件已经下载的cookie
                    Utils.WriteCookie("dnt_attachment_" + attachmentid, "true", 5);
                }

                //检查附件是否存在
                if (AttachPaymentLogs.HasBoughtAttach(userid, usergroupinfo.Radminid, attachmentinfo))
                {
                    AddErrLine("该附件为交易附件, 请先行购买!");
                    return;
                }
                //如果是图片就不更新下载次数
                if (!Utils.IsImgFilename(attachmentinfo.Filename.Trim()))
                {
                    Attachments.UpdateAttachmentDownloads(attachmentid);
                }

                EntLibConfigInfo entLibConfigInfo = EntLibConfigs.GetConfig();
                //当使用企业版squid静态文件加速时
                if (attachmentinfo.Filename.IndexOf("http") < 0 && entLibConfigInfo != null && !Utils.StrIsNullOrEmpty(entLibConfigInfo.Attachmentdir))
                    attachmentinfo.Filename = EntLibConfigs.GetConfig().Attachmentdir.TrimEnd('/') + "/" + attachmentinfo.Filename;

                if (attachmentinfo.Filename.IndexOf("http") < 0)
                {   //当使用mongodb数据库存储附件及相关信息时
                    if (entLibConfigInfo != null && entLibConfigInfo.Cacheattachfiles.Enable && entLibConfigInfo.Cacheattachfiles.Attachpostid > 0 && entLibConfigInfo.Cacheattachfiles.Attachpostid < attachmentinfo.Pid)
                        Discuz.Cache.Data.DBCacheService.GetAttachFilesService().ResponseFile(attachmentinfo.Filename, Path.GetFileName(attachmentinfo.Attachment), attachmentinfo.Filetype);
                    else
                        Utils.ResponseFile(Utils.GetMapPath(BaseConfigs.GetForumPath + @"upload/" + attachmentinfo.Filename), Path.GetFileName(attachmentinfo.Attachment), attachmentinfo.Filetype);
                }
                else
                {
                    try //添加try语法, 以防止在并发访问情况下, 服务器端远程链接被关闭后出现应用程序 '警告'(事件查看器)
                    {
                        HttpContext.Current.Response.Clear();
                        HttpContext.Current.Response.Redirect(attachmentinfo.Filename.Trim());
                        HttpContext.Current.Response.End();
                    }
                    catch { }
                }
            }
        }
    private void SaveAuthority(bool ChangeUserAuthority)
    {
        if (IsDesignation())
        {
            dtAuthority = new DesignationAuthority()
            {
                DesignationId = lblDesignationId.zToInt(),
            }.Select();
        }

        var dtUser = new DataTable();

        if (ChangeUserAuthority || IsUser())
        {
            if (IsUser())
            {
                dtAuthority = new UserAuthority()
                {
                    UsersId = lblUsersId.zToInt()
                }.Select();
            }

            dtUser = new Query()
            {
                UsersId       = IsUser() ? lblUsersId.zToInt() : (int?)null,
                DesignationId = IsUser() ? (int?)null : lblDesignationId.zToInt(),
                eStatusNot    = (int)eStatus.Delete,
            }.Select(eSP.qry_User);
        }

        foreach (RepeaterItem item in rptAuthority.Items)
        {
            var lblAuthorityId = item.FindControl("lblAuthorityId") as Label;

            var chkView    = item.FindControl("chkView") as CheckBox;
            var chkAddEdit = item.FindControl("chkAddEdit") as CheckBox;
            var chkDelete  = item.FindControl("chkDelete") as CheckBox;

            if (!lblAuthorityId.zIsNullOrEmpty() && lblAuthorityId.zToInt() != 0)
            {
                if (dtAuthority.Select(CS.eAuthority + " = " + lblAuthorityId.zToInt()
                                       + " AND " + CS.IsAllowView + " = " + chkView.Checked
                                       + " AND " + CS.IsAllowAddEdit + " = " + chkAddEdit.Checked
                                       + " AND " + CS.IsAllowDelete + " = " + chkDelete.Checked).Length == 0)
                {
                    if (IsDesignation())
                    {
                        #region Designation Authority

                        var objAuthority = new DesignationAuthority()
                        {
                            eAuthority     = lblAuthorityId.zToInt(),
                            DesignationId  = lblDesignationId.zToInt(),
                            IsAllowView    = chkView.Checked,
                            IsAllowAddEdit = chkAddEdit.Checked,
                            IsAllowDelete  = chkDelete.Checked,
                        };

                        SetDesignationAuthority(objAuthority);

                        #endregion
                    }

                    if (ChangeUserAuthority || IsUser())
                    {
                        var objUserAuthority = new UserAuthority()
                        {
                            eAuthority     = lblAuthorityId.zToInt(),
                            IsAllowView    = chkView.Checked,
                            IsAllowAddEdit = chkAddEdit.Checked,
                            IsAllowDelete  = chkDelete.Checked,
                        };

                        SetUserAuthority(dtUser, objUserAuthority);
                    }
                }
            }
        }

        CU.ZMessage(eMsgType.Success, string.Empty, "Authority Updated Successfully.");
    }
Example #24
0
        public void ProcessRequest(HttpContext context)
        {
            //Stream reqStream = HttpContext.Current.Request.InputStream;
            //byte[] buffer = new byte[(int)reqStream.Length];
            //reqStream.Read(buffer, 0, (int)reqStream.Length);

            //Request
            StreamReader sr     = new StreamReader(HttpContext.Current.Request.InputStream);
            string       strReq = sr.ReadToEnd();

            //Test
            //JObject Req = new JObject(
            //          new JProperty("loginname", "zxn"),
            //          new JProperty("password", "zxn")
            //new JProperty("userid", "00000000-0000-0000-0000-000000000003")
            //         );
            //string strReq = Req.ToString();


            #region ShowYouSend
            if (HttpContext.Current.Request["method"] == "showyousend")
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write(strReq);
            }
            #endregion ShowYouSend

            #region Login
            if (HttpContext.Current.Request["method"] == "login")
            {
                JObject      o         = JObject.Parse(strReq);
                string       loginname = (string)o["loginname"];
                string       password  = (string)o["password"];
                BLL.UserInfo userInfo;
                userInfo = UserInfo.LoginInfo(loginname, password);
                JObject rss = new JObject();
                if (userInfo.Identity == Guid.Empty)//失败
                {
                    rss = new JObject(
                        new JProperty("Method", "login"),
                        new JProperty("ReturnStatus", "0")
                        );
                }
                else
                {
                    List <string> CurrentUserAuthority = userInfo.Authority;
                    List <string> AllAuthority         = UserAuthority.GetAllAuthority();
                    //Dictionary<string, string> CurrentUserAuthorityDic = new Dictionary<string, string>();
                    //foreach (string s in AllAuthority)
                    //{
                    //    if (CurrentUserAuthority.Contains(s))
                    //    {
                    //        CurrentUserAuthorityDic.Add(s, "1");
                    //    }
                    //    else
                    //    {
                    //        CurrentUserAuthorityDic.Add(s, "0");
                    //    }
                    //}
                    JObject CurrentUserAuthorityDic = new JObject();
                    foreach (string s in AllAuthority)
                    {
                        if (CurrentUserAuthority.Contains(s))
                        {
                            CurrentUserAuthorityDic.Add(s, "1");
                        }
                        else
                        {
                            CurrentUserAuthorityDic.Add(s, "0");
                        }
                    }
                    rss = new JObject(
                        new JProperty("Method", "login"),
                        new JProperty("ReturnStatus", "1"),
                        new JProperty("UserId", userInfo.Identity),
                        new JProperty("UserName", userInfo.RealName),
                        new JProperty("Authority",
                                      new JArray(CurrentUserAuthorityDic)
                                      )
                        );
                }
                context.Response.ContentType = "text/plain";
                context.Response.Write(rss.ToString());
            }
            #endregion Login
            #region MyTask
            else if (HttpContext.Current.Request["method"] == "mytask")
            {
                JObject      o      = JObject.Parse(strReq);
                string       UserId = (string)o["userid"];
                BLL.UserInfo userInfo;
                userInfo = UserInfo.GetUserById(UserId);
                List <string> CurrentUserAuthoritys = userInfo.Authority;
                JObject       rss = new JObject();
                foreach (string CurrentAuthority in CurrentUserAuthoritys)
                {
                    if (CurrentAuthority != "copy" && CurrentAuthority != "PlanManage")//无需处理特定工单
                    {
                        if (CurrentAuthority == "recond")
                        {
                            List <ProjectPlan> Recond  = BLL.ProjectPlan.GetRecondProjectPlan();
                            JObject            JRecond =
                                new JObject(
                                    new JProperty("Recond",
                                                  new JArray(
                                                      from r in Recond
                                                      orderby r.PlanDate
                                                      select new JObject(
                                                          new JProperty("ProjectPlanId", r.ProjectPlanId),
                                                          new JProperty("ProjectPlanNo", r.ProjectPlanNo),
                                                          new JProperty("Title", r.Title),
                                                          new JProperty("ProjectPlanTypeText", r.ProjectPlanTypeText),
                                                          new JProperty("PlanDate", r.PlanDate.ToString("D")),
                                                          new JProperty("ProgressText", r.ProgressText)
                                                          )
                                                      )
                                                  )
                                    );
                            rss.Merge(JRecond, new JsonMergeSettings
                            {
                                MergeArrayHandling = MergeArrayHandling.Concat
                            }
                                      );
                        }
                        else if (CurrentAuthority == "OpenClassReceive")
                        {
                            List <CustomProject> OpenClass = BLL.CustomProject.GetCustomProjectByType(new Guid("00000000-0000-0000-0000-000000000202"), new Guid("00000000-0000-0000-0000-000000000203"));
                            JObject JOpenClass             =
                                new JObject(
                                    new JProperty("OpenClassReceive",
                                                  new JArray(
                                                      from oc in OpenClass
                                                      orderby oc.SendingDate
                                                      select new JObject(
                                                          new JProperty("CustomProjectId", oc.CustomProjectId),
                                                          new JProperty("CustomProjectNo", oc.No),
                                                          new JProperty("Title", oc.Title),
                                                          new JProperty("SendingDate", oc.SendingDate.ToString("D")),
                                                          new JProperty("Lecturer", oc.Lecturer),
                                                          new JProperty("ProgressText", oc.ProgressText)
                                                          )
                                                      )
                                                  )
                                    );
                            rss.Merge(OpenClass, new JsonMergeSettings
                            {
                                MergeArrayHandling = MergeArrayHandling.Concat
                            }
                                      );
                        }
                        else if (CurrentAuthority == "OpenClassOperation")
                        {
                            List <CustomProject> OpenClass = BLL.CustomProject.GetCustomProjectByType(new Guid("00000000-0000-0000-0000-000000000202"), new Guid("00000000-0000-0000-0000-000000000204"));
                            JObject JOpenClass             =
                                new JObject(
                                    new JProperty("OpenClassOperation",
                                                  new JArray(
                                                      from oc in OpenClass
                                                      orderby oc.SendingDate
                                                      select new JObject(
                                                          new JProperty("CustomProjectId", oc.CustomProjectId),
                                                          new JProperty("CustomProjectNo", oc.No),
                                                          new JProperty("Title", oc.Title),
                                                          new JProperty("SendingDate", oc.SendingDate.ToString("D")),
                                                          new JProperty("Lecturer", oc.Lecturer),
                                                          new JProperty("ProgressText", oc.ProgressText)
                                                          )
                                                      )
                                                  )
                                    );
                            rss.Merge(OpenClass, new JsonMergeSettings
                            {
                                MergeArrayHandling = MergeArrayHandling.Concat
                            }
                                      );
                        }
                        else if (CurrentAuthority == "OpenClassPublish")
                        {
                            List <CustomProject> OpenClass = BLL.CustomProject.GetCustomProjectByType(new Guid("00000000-0000-0000-0000-000000000202"), new Guid("00000000-0000-0000-0000-000000000205"));
                            JObject JOpenClass             =
                                new JObject(
                                    new JProperty("OpenClassPublish",
                                                  new JArray(
                                                      from oc in OpenClass
                                                      orderby oc.SendingDate
                                                      select new JObject(
                                                          new JProperty("CustomProjectId", oc.CustomProjectId),
                                                          new JProperty("CustomProjectNo", oc.No),
                                                          new JProperty("Title", oc.Title),
                                                          new JProperty("SendingDate", oc.SendingDate.ToString("D")),
                                                          new JProperty("Lecturer", oc.Lecturer),
                                                          new JProperty("ProgressText", oc.ProgressText)
                                                          )
                                                      )
                                                  )
                                    );
                            rss.Merge(OpenClass, new JsonMergeSettings
                            {
                                MergeArrayHandling = MergeArrayHandling.Concat
                            }
                                      );
                        }
                        else if (CurrentAuthority == "OpenClassCheck")
                        {
                            List <CustomProject> OpenClass = BLL.CustomProject.GetCustomProjectByType(new Guid("00000000-0000-0000-0000-000000000202"), new Guid("00000000-0000-0000-0000-000000000207"));
                            JObject JOpenClass             =
                                new JObject(
                                    new JProperty("OpenClassCheck",
                                                  new JArray(
                                                      from oc in OpenClass
                                                      orderby oc.SendingDate
                                                      select new JObject(
                                                          new JProperty("CustomProjectId", oc.CustomProjectId),
                                                          new JProperty("CustomProjectNo", oc.No),
                                                          new JProperty("Title", oc.Title),
                                                          new JProperty("SendingDate", oc.SendingDate.ToString("D")),
                                                          new JProperty("Lecturer", oc.Lecturer),
                                                          new JProperty("ProgressText", oc.ProgressText)
                                                          )
                                                      )
                                                  )
                                    );
                            rss.Merge(OpenClass, new JsonMergeSettings
                            {
                                MergeArrayHandling = MergeArrayHandling.Concat
                            }
                                      );
                        }
                        else
                        {
                            List <Project> ProjectList = BLL.Project.GetProjectList(CurrentAuthority, UserId);
                            JObject        JProject    =
                                new JObject(
                                    new JProperty(CurrentAuthority,
                                                  new JArray(
                                                      from p in ProjectList
                                                      orderby p.SendingDate
                                                      select new JObject(
                                                          //new JProperty("ProjectId", p.ProjectId),
                                                          //new JProperty("ProjectNo", p.ProjectNo),
                                                          //new JProperty("Title", p.CourseName),
                                                          //new JProperty("SendingDate", p.SendingDate.ToString("D")),
                                                          //new JProperty("Lecturer", p.lecturer),
                                                          //new JProperty("ProgressText", p.ProgressText)
                                                          from System.Reflection.PropertyInfo ProjectProperty in p.GetType().GetProperties()
                                                          select new JProperty(
                                                              ProjectProperty.Name, ProjectProperty.GetValue(p)
                                                              )
                                                          )
                                                      )
                                                  )
                                    );
                            rss.Merge(JProject, new JsonMergeSettings
                            {
                                MergeArrayHandling = MergeArrayHandling.Concat
                            }
                                      );
                        }
                    }
                }
                JObject ResRss = new JObject(
                    new JProperty("method", "mytask"),
                    new JProperty("tasks",
                                  new JObject(rss)
                                  )
                    );
                context.Response.ContentType = "text/plain";
                context.Response.Write(ResRss.ToString());
            }
            #endregion MyTask
            #region PlanList
            else if (HttpContext.Current.Request["method"] == "allplan")
            {
                JObject o         = JObject.Parse(strReq);
                int     PageIndex = Convert.ToInt16((string)o["pageindex"]);
                JObject rss       = new JObject();
                rss = new JObject(
                    new JProperty("method", "allplan")
                    );
                List <ProjectPlan> PlanList = BLL.ProjectPlan.GetAllProjectPlanPage(PageIndex);
                JObject            JPlan    =
                    new JObject(
                        new JProperty("Plan",
                                      new JArray(
                                          from p in PlanList
                                          orderby p.PlanDate
                                          select new JObject(
                                              //new JProperty("ProjectPlanId", p.ProjectPlanId),
                                              //new JProperty("ProjectNo", p.ProjectPlanNo),
                                              //new JProperty("Title", p.Title),
                                              //new JProperty("PlanDate", p.PlanDate.ToString("D")),
                                              //new JProperty("Lecturer", p.Lecturer),
                                              //new JProperty("ProgressText", p.ProgressText),
                                              //new JProperty("ProjectCount", p.ProjectCount),
                                              //new JProperty("ProjectFinishCount", p.ProjectFinishCount),
                                              //new JProperty("ProjectDelayCount", p.ProjectDelayCount),
                                              //new JProperty("ProjectPlanTypeId", p.ProjectPlanTypeId)
                                              from System.Reflection.PropertyInfo PlanProperty in p.GetType().GetProperties()
                                              select new JProperty(
                                                  PlanProperty.Name, PlanProperty.GetValue(p)
                                                  )
                                              )
                                          )
                                      )
                        );
                rss.Merge(JPlan, new JsonMergeSettings
                {
                    MergeArrayHandling = MergeArrayHandling.Concat
                }
                          );
                context.Response.ContentType = "text/plain";
                context.Response.Write(rss.ToString());
            }
            else if (HttpContext.Current.Request["method"] == "finishedplan")
            {
                JObject o         = JObject.Parse(strReq);
                int     PageIndex = Convert.ToInt16((string)o["pageindex"]);
                JObject rss       = new JObject();
                rss = new JObject(
                    new JProperty("method", "finishedplan")
                    );
                List <ProjectPlan> PlanList = BLL.ProjectPlan.GetFinishedProjectPlanPage(PageIndex);
                JObject            JPlan    =
                    new JObject(
                        new JProperty("Plan",
                                      new JArray(
                                          from p in PlanList
                                          orderby p.PlanDate
                                          select new JObject(
                                              from System.Reflection.PropertyInfo PlanProperty in p.GetType().GetProperties()
                                              select new JProperty(
                                                  PlanProperty.Name, PlanProperty.GetValue(p)
                                                  )
                                              )
                                          )
                                      )
                        );
                rss.Merge(JPlan, new JsonMergeSettings
                {
                    MergeArrayHandling = MergeArrayHandling.Concat
                }
                          );
                context.Response.ContentType = "text/plain";
                context.Response.Write(rss.ToString());
            }
            else if (HttpContext.Current.Request["method"] == "unfinishplan")
            {
                JObject o         = JObject.Parse(strReq);
                int     PageIndex = Convert.ToInt16((string)o["pageindex"]);
                JObject rss       = new JObject();
                rss = new JObject(
                    new JProperty("method", "unfinishplan")
                    );
                List <ProjectPlan> PlanList = BLL.ProjectPlan.GetUnfinishProjectPlanPage(PageIndex);
                JObject            JPlan    =
                    new JObject(
                        new JProperty("Plan",
                                      new JArray(
                                          from p in PlanList
                                          orderby p.PlanDate
                                          select new JObject(
                                              from System.Reflection.PropertyInfo PlanProperty in p.GetType().GetProperties()
                                              select new JProperty(
                                                  PlanProperty.Name, PlanProperty.GetValue(p)
                                                  )
                                              )
                                          )
                                      )
                        );
                rss.Merge(JPlan, new JsonMergeSettings
                {
                    MergeArrayHandling = MergeArrayHandling.Concat
                }
                          );
                context.Response.ContentType = "text/plain";
                context.Response.Write(rss.ToString());
            }
            #endregion PlanList
            #region ProjectInPlan
            else if (HttpContext.Current.Request["method"] == "projectinplan")
            {
                JObject o      = JObject.Parse(strReq);
                Guid    PlanId = new Guid((string)o["planid"]);
                JObject rss    = new JObject();
                rss = new JObject(
                    new JProperty("method", "projectinplan")
                    );
                List <Project> ProjectList = BLL.Project.GetProjectByPlanId(PlanId);
                JObject        JProject    =
                    new JObject(
                        new JProperty("Project",
                                      new JArray(
                                          from p in ProjectList
                                          orderby p.SendingDate
                                          select new JObject(
                                              from System.Reflection.PropertyInfo ProjectProperty in p.GetType().GetProperties()
                                              select new JProperty(
                                                  ProjectProperty.Name, ProjectProperty.GetValue(p)
                                                  )
                                              )
                                          )
                                      )
                        );
                rss.Merge(JProject, new JsonMergeSettings
                {
                    MergeArrayHandling = MergeArrayHandling.Concat
                }
                          );
                context.Response.ContentType = "text/plain";
                context.Response.Write(rss.ToString());
            }
            #endregion ProjectInPlan
            #region Project
            else if (HttpContext.Current.Request["method"] == "allproject")
            {
                JObject o         = JObject.Parse(strReq);
                int     PageIndex = Convert.ToInt16((string)o["pageindex"]);
                JObject rss       = new JObject();
                rss = new JObject(
                    new JProperty("method", "allproject")
                    );
                List <Project> ProjectList = BLL.Project.GetAllProjectPage(PageIndex);
                JObject        JProject    =
                    new JObject(
                        new JProperty("Project",
                                      new JArray(
                                          from p in ProjectList
                                          orderby p.SendingDate
                                          select new JObject(
                                              from System.Reflection.PropertyInfo ProjectProperty in p.GetType().GetProperties()
                                              select new JProperty(
                                                  ProjectProperty.Name, ProjectProperty.GetValue(p)
                                                  )
                                              )
                                          )
                                      )
                        );
                rss.Merge(JProject, new JsonMergeSettings
                {
                    MergeArrayHandling = MergeArrayHandling.Concat
                }
                          );
                context.Response.ContentType = "text/plain";
                context.Response.Write(rss.ToString());
            }
            else if (HttpContext.Current.Request["method"] == "UpdateContentProgress")
            {
                string id    = HttpContext.Current.Request["id"];
                string value = HttpContext.Current.Request["progress"];
                using (var ProjectModel = new ProjectCollection.WebUI.Models.ProjectCollectionEntities())
                {
                    ProjectCollection.WebUI.Models.Project ThisProject = (from p in ProjectModel.Project
                                                                          where p.ProjectNo == id
                                                                          select p).First();
                    ThisProject.progress            = new Guid(value);
                    ThisProject.ContentProgress     = new Guid(value);
                    ThisProject.ShorthandFinishDate = DateTime.Now;
                    ProjectModel.SaveChanges();
                }
                context.Response.ContentType = "text/plain";
                context.Response.Write("success");
            }
            else if (HttpContext.Current.Request["method"] == "NewProjectWithoutVideo")
            {
                string name        = HttpContext.Current.Request["name"];
                string lecturer    = HttpContext.Current.Request["lecturer"];
                string LecturerJob = HttpContext.Current.Request["lecturerjob"];
                string STTType     = HttpContext.Current.Request["stttype"];
                string user        = HttpContext.Current.Request["user"];
                string projectid   = HttpContext.Current.Request["projectid"];
                using (var ProjectModel = new ProjectCollection.WebUI.Models.ProjectCollectionEntities())
                {
                    ProjectCollection.WebUI.Models.user_info User = (from p in ProjectModel.user_info
                                                                     where p.login_name == user
                                                                     select p).First();
                    ProjectCollection.WebUI.Models.Project project = new Models.Project();

                    project.ProjectId     = Guid.NewGuid();
                    project.ProjectPlanId = new Guid("f48c8eeb-e321-4f6c-9d08-c4fa5703834e");
                    //
                    project.ProjectTypeId = new Guid("00000000-0000-0000-0000-000000000199");
                    project.ProjectNo     = "S-" + DateTime.Now.ToString("yyyyMMdd-HHmmss");
                    project.emergency     = new Guid("00000000-0000-0000-0000-000000000030");
                    project.WorkType      = new Guid("00000000-0000-0000-0000-000000000027");
                    project.CourseName    = name;
                    project.notice        = new Guid("00000000-0000-0000-0000-000000000034");
                    project.headline      = new Guid("00000000-0000-0000-0000-000000000036");
                    project.TextCategory  = "";
                    project.lecturer      = lecturer;
                    project.LecturerJob   = LecturerJob;
                    project.InCharge      = User.user_identity;
                    project.CreateNote    = "自动生成工单,需上传高清视频";
                    project.ExtraNote     = "";
                    project.ContentNeeds  = new Guid("00000000-0000-0000-0000-000000000042");
                    project.PublishNeeds  = new Guid("00000000-0000-0000-0000-000000000042");
                    project.CanBeSold     = new Guid("00000000-0000-0000-0000-000000000043");
                    project.EpisodeCount  = 1;
                    //
                    project.progress = new Guid("00000000-0000-0000-0000-000000000120");
                    project.STTType  = STTType;
                    project.MakeType = "new";
                    ProjectModel.SaveChanges();
                }
            }
            else if (HttpContext.Current.Request["method"] == "NewProjectWithVideo")
            {
                string name        = HttpContext.Current.Request["name"];
                string lecturer    = HttpContext.Current.Request["lecturer"];
                string LecturerJob = HttpContext.Current.Request["lecturerjob"];
                string STTType     = HttpContext.Current.Request["stttype"];
                string user        = HttpContext.Current.Request["user"];
                string projectid   = HttpContext.Current.Request["projectid"];
                string logstr      = HttpContext.Current.Request["str"];
                using (var ProjectModel = new ProjectCollection.WebUI.Models.ProjectCollectionEntities())
                {
                    ProjectCollection.WebUI.Models.user_info User = (from p in ProjectModel.user_info
                                                                     where p.login_name == user
                                                                     select p).First();
                    ProjectCollection.WebUI.Models.Project project = new Models.Project();

                    project.ProjectId     = Guid.NewGuid();
                    project.ProjectPlanId = new Guid("f48c8eeb-e321-4f6c-9d08-c4fa5703834e");
                    //
                    project.ProjectTypeId = new Guid("00000000-0000-0000-0000-000000000199");
                    project.ProjectNo     = "S-" + DateTime.Now.ToString("yyyyMMdd-HHmmss");
                    project.emergency     = new Guid("00000000-0000-0000-0000-000000000030");
                    project.WorkType      = new Guid("00000000-0000-0000-0000-000000000027");
                    project.CourseName    = name;
                    project.notice        = new Guid("00000000-0000-0000-0000-000000000034");
                    project.headline      = new Guid("00000000-0000-0000-0000-000000000036");
                    project.TextCategory  = "";
                    project.lecturer      = lecturer;
                    project.LecturerJob   = LecturerJob;
                    project.InCharge      = User.user_identity;
                    project.CreateNote    = "自动生成工单";
                    project.ExtraNote     = "";
                    project.ContentNeeds  = new Guid("00000000-0000-0000-0000-000000000042");
                    project.PublishNeeds  = new Guid("00000000-0000-0000-0000-000000000042");
                    project.CanBeSold     = new Guid("00000000-0000-0000-0000-000000000043");
                    project.EpisodeCount  = 1;
                    //
                    project.progress = new Guid("00000000-0000-0000-0000-000000000210");
                    project.STTType  = STTType;
                    project.MakeType = "new";
                    ProjectModel.SaveChanges();
                    //
                    string CourseWorkType = "";
                    if (STTType == "low")
                    {
                        CourseWorkType = "OldVideoCopyNoSTT";
                    }
                    else
                    {
                        CourseWorkType = "OldVideoCopy";
                    }
                    string url = @"http://newpms.cei.cn/FTPVideoUpload/?link="
                                 + logstr
                                 + "&type="
                                 + CourseWorkType
                                 + "&title="
                                 + HttpUtility.UrlEncode(project.CourseName)
                                 + "&lecturer="
                                 + HttpUtility.UrlEncode(project.lecturer)
                                 + "&post="
                                 + HttpUtility.UrlEncode(project.LecturerJob)
                                 + "&src="
                                 + HttpUtility.UrlEncode(projectid)
                                 + "&ProjectNo="
                                 + HttpUtility.UrlEncode(project.ProjectNo);
                    //
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    request.Method      = "GET";
                    request.ContentType = "text/html;charset=UTF-8";
                    HttpWebResponse response         = (HttpWebResponse)request.GetResponse();
                    Stream          myResponseStream = response.GetResponseStream();
                    StreamReader    myStreamReader   = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
                    string          retString        = myStreamReader.ReadToEnd();
                    myStreamReader.Close();
                    myResponseStream.Close();
                    //
                    JObject jo = (JObject)JsonConvert.DeserializeObject(retString);
                    if (jo["data"].ToString() == "数据添加成功")
                    {
                    }
                    else
                    {
                        throw new MyException(jo["status"].ToString());
                    }
                }
            }
            #endregion Project
            else
            {
            }
        }
Example #25
0
        protected override void ShowPage()
        {
            if (topic.ID == 0)
            {
                return;
            }

            this.pagetitle = this.topic.Title.Trim();
            if (!String.IsNullOrEmpty(forum.Password) && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + this.forum.Fid + "password"))
            {
                base.AddErrLine("本版块被管理员设置了密码");
                base.Response.Redirect(string.Format("{0}showforum-{1}{2}", BaseConfigs.GetForumPath, this.forum.Fid, this.config.Extname), true);
                return;
            }
            if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
            {
                base.AddErrLine(this.msg);
                return;
            }
            this.postinfo = Post.FindByTid(this.topicid);
            var msg = postinfo.Message;

            if (msg.ToLower().Contains("[free]") || msg.ToLower().Contains("[/free]"))
            {
                Match match = buytopic.r.Match(msg);
                while (match.Success)
                {
                    object obj = this.postmessage;
                    this.postmessage = obj + "<br /><div class=\"msgheader\">免费内容:</div><div class=\"msgborder\">" + match.Groups[1] + "</div><br />";
                    match            = match.NextMatch();
                }
            }
            this.topicprice = this.topic.Price;
            if (this.topic.Price > 0)
            {
                this.price       = this.topic.Price;
                this.expirehours = (Int32)(DateTime.Now - topic.PostDateTime.AddHours(maxchargespan)).TotalHours;
                if (PaymentLog.IsBuyer(this.topicid, this.userid) || (this.expirehours > 0 && this.maxchargespan != 0))
                {
                    this.price = -1;
                }
                else
                {
                    this.expirehours = Math.Abs(this.expirehours);
                }
            }
            this.netamount = (float)this.topicprice - (float)this.topicprice * this.creditstax / 100f;
            if (this.topicprice > this.maxincpertopic)
            {
                this.netamount = (float)this.maxincpertopic - (float)this.maxincpertopic * this.creditstax / 100f;
            }
            if (this.price != -1)
            {
                var userInfo = Users.GetUserInfo(this.userid);
                if (this.buyit == 1 && !this.CheckUserExtCredit(userInfo))
                {
                    return;
                }
                this.userlastprice = Users.GetUserExtCredit(userInfo, Scoresets.GetTopicAttachCreditsTrans()) - (float)this.topic.Price;
            }
            if (!this.ispost)
            {
                this.buyers = PaymentLog.GetPaymentLogByTidCount(this.topic.ID);
                if (this.showpayments == 1)
                {
                    this.pagecount      = ((this.buyers % this.pageSize == 0) ? (this.buyers / this.pageSize) : (this.buyers / this.pageSize + 1));
                    this.pagecount      = ((this.pagecount == 0) ? 1 : this.pagecount);
                    this.pageid         = ((this.pageid < 1) ? 1 : this.pageid);
                    this.pageid         = ((this.pageid > this.pagecount) ? this.pagecount : this.pageid);
                    this.paymentloglist = PaymentLog.GetPaymentLogByTid(this.pageSize, this.pageid, this.topic.ID);
                }
                int hide = (this.topic.Hide == 1) ? this.topic.Hide : 0;
                if (Post.IsReplier(this.topicid, this.userid))
                {
                    hide = -1;
                }
                this.lastpostlist = Posts.GetPagedLastPost(this.GetPostPramsInfo(hide));
                return;
            }
            int num = PaymentLog.BuyTopic(this.userid, this.topic.ID, this.topic.PosterID, this.topic.Price, this.netamount);

            if (num > 0)
            {
                base.SetUrl(base.ShowTopicAspxRewrite(this.topic.ID, 0));
                base.SetMetaRefresh();
                base.SetShowBackLink(false);
                base.MsgForward("buytopic_succeed");
                base.AddMsgLine("购买主题成功,返回该主题");
                return;
            }
            base.SetBackLink(base.ShowForumAspxRewrite(this.topic.Fid, 0));
            if (num == -1)
            {
                base.AddErrLine("对不起,您的账户余额少于交易额,无法进行交易");
                return;
            }
            if (num == -2)
            {
                base.AddErrLine("您无权购买本主题");
                return;
            }
            base.AddErrLine("未知原因,交易无法进行,给您带来的不方便我们很抱歉");
        }
Example #26
0
        public void GetGoodsAttachInfo(int attachmentid)
        {
            MallPluginBase mpb = MallPluginProvider.GetInstance();
            if (mpb == null)
            {
                AddErrLine("未安装商城插件");
                return;
            }
            goodsattachmentinfo = mpb.GetGoodsAttachmentsByAid(attachmentid);
            if (goodsattachmentinfo == null)
            {
                AddErrLine("不存在的附件ID");
                return;
            }
            // 获取该商品的信息
            goodsinfo = mpb.GetGoodsInfo(goodsattachmentinfo.Goodsid);
            if (goodsinfo == null)
            {
                AddErrLine("不存在的商品ID");
                return;
            }

            forum = Forums.GetForumInfo(mpb.GetCategoriesFid(goodsinfo.Categoryid));
            pagetitle = Utils.RemoveHtml(forum.Name);

            //添加判断特殊用户的代码
            if (!Forums.AllowViewByUserId(forum.Permuserlist, userid) && !Forums.AllowView(forum.Viewperm, usergroupid))
            {
                AddErrLine("您没有浏览该版块的权限");
                if (userid == -1)
                    needlogin = true;
                return;
            }

            //添加判断特殊用户的代码
            if (!UserAuthority.CheckUsertAttachAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                if (userid == -1)
                    needlogin = true;
                return;
            }
            // 检查用户是否拥有足够的阅读权限
            if (goodsattachmentinfo.Readperm > usergroupinfo.Readaccess && goodsattachmentinfo.Uid != userid && !Moderators.IsModer(useradminid, userid, forum.Fid))
            {
                AddErrLine("您的阅读权限不够");
                if (userid == -1)
                    needlogin = true;
                return;
            }
            if (goodsattachmentinfo.Filename.IndexOf("http") < 0 && !File.Exists(Utils.GetMapPath(string.Format(@"{0}upload/{1}", BaseConfigs.GetForumPath, goodsattachmentinfo.Filename))))
            {
                AddErrLine("该附件文件不存在或已被删除");
                return;
            }

            if (goodsattachmentinfo.Filename.IndexOf("http") < 0)
                Utils.ResponseFile(Utils.GetMapPath(string.Format(@"{0}upload/{1}", BaseConfigs.GetForumPath, goodsattachmentinfo.Filename)), Path.GetFileName(goodsattachmentinfo.Attachment), goodsattachmentinfo.Filetype);
            else
                HttpContext.Current.Response.Redirect(goodsattachmentinfo.Filename.Trim());
        }
Example #27
0
        protected override void ShowPage()
        {
            //pagetitle = "编辑帖子";
            #region 判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            this.disablepostctrl = 0;
            if (admininfo != null)
            {
                disablepostctrl = admininfo.Disablepostctrl;
            }
            #endregion

            if (userid == -1)
            {
                forum    = new ForumInfo();
                topic    = new TopicInfo();
                postinfo = new PostInfo();
                AddErrLine("您尚未登录");
                return;
            }

            #region 获取帖子和主题相关信息
            // 如果帖子ID非数字
            if (postid == -1)
            {
                AddErrLine("无效的帖子ID");
                return;
            }

            postinfo = Posts.GetPostInfo(topicid, postid);
            // 如果帖子不存在
            if (postinfo == null)
            {
                AddErrLine("不存在的帖子ID");
                return;
            }
            pagetitle   = (postinfo.Title == "") ? "编辑帖子" : postinfo.Title;
            htmlon      = postinfo.Htmlon;
            message     = postinfo.Message;
            isfirstpost = postinfo.Layer == 0;

            // 获取主题ID
            if (topicid != postinfo.Tid || postinfo.Tid == -1)
            {
                AddErrLine("无效的主题ID");
                return;
            }

            // 获取该主题的信息
            topic = Topics.GetTopicInfo(postinfo.Tid);
            // 如果该主题不存在
            if (topic == null)
            {
                AddErrLine("不存在的主题ID");
                return;
            }

            if (topic.Special == 1 && postinfo.Layer == 0)
            {
                pollinfo       = Polls.GetPollInfo(topic.Tid);
                polloptionlist = Polls.GetPollOptionList(topic.Tid);
            }

            if (topic.Special == 4 && postinfo.Layer == 0)
            {
                debateinfo = Debates.GetDebateTopic(topic.Tid);
            }

            #endregion

            #region 获取并检查版块信息
            ///得到所在版块信息
            forumid   = topic.Fid;
            forum     = Forums.GetForumInfo(forumid);
            needaudit = UserAuthority.NeedAudit(forum, useradminid, topic, userid, disablepostctrl, usergroupinfo);
            // 如果该版块不存在
            if (forum == null || forum.Layer == 0)
            {
                AddErrLine("版块已不存在");
                forum = new ForumInfo();
                return;
            }

            if (!Utils.StrIsNullOrEmpty(forum.Password) && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password"))
            {
                AddErrLine("本版块被管理员设置了密码");
                SetBackLink(base.ShowForumAspxRewrite(forumid, 0));
                return;
            }

            if (forum.Applytopictype == 1)  //启用主题分类
            {
                topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes);
            }
            customeditbuttons = Caches.GetCustomEditButtonList();
            #endregion

            //是否有编辑帖子的权限
            if (!UserAuthority.CanEditPost(postinfo, userid, useradminid, ref msg))
            {
                AddErrLine(msg);
                return;
            }
            #region  附件信息绑定
            //得到用户可以上传的文件类型
            string attachmentTypeSelect = Attachments.GetAllowAttachmentType(usergroupinfo, forum);
            attachextensions       = Attachments.GetAttachmentTypeArray(attachmentTypeSelect);
            attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect);
            //得到今天允许用户上传的附件总大小(字节)
            int MaxTodaySize = (userid > 0 ? MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid) : 0);
            attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;//今天可上传得大小
            //是否有上传附件的权限
            canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg);

            userinfo = Users.GetShortUserInfo(userid);
            if (canpostattach && (config.Enablealbum == 1) && apb != null &&
                (UserGroups.GetUserGroupInfo(userinfo.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0))
            {
                caninsertalbum = true;
                albumlist      = apb.GetSpaceAlbumByUserId(userid);
            }
            else
            {
                caninsertalbum = false;
            }

            attachmentlist  = Attachments.GetAttachmentListByPid(postinfo.Pid);
            attachmentcount = attachmentlist.Rows.Count;
            //当前用户是否有允许下载附件权限
            allowviewattach = UserAuthority.DownloadAttachment(forum, userid, usergroupinfo);

            #endregion

            smileyoff          = (!DNTRequest.IsPost()) ? postinfo.Smileyoff : 1 - forum.Allowsmilies;
            allowimg           = forum.Allowimgcode;
            parseurloff        = postinfo.Parseurloff;
            bbcodeoff          = (usergroupinfo.Allowcusbbcode == 1) ? postinfo.Bbcodeoff : 1;
            usesig             = postinfo.Usesig;
            userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            if (bonusCreditsTrans > 0 && bonusCreditsTrans < 9)
            {
                bonusextcreditsinfo = Scoresets.GetScoreSet(bonusCreditsTrans);
                mybonustranscredits = Users.GetUserExtCredits(userid, bonusCreditsTrans);
            }

            //是否有访问当前版块的权限
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                return;
            }

            // 判断当前用户是否有修改权限, 检查是否具有版主的身份
            if (!Moderators.IsModer(useradminid, userid, forumid))
            {
                if (postinfo.Posterid != userid)
                {
                    AddErrLine("你并非作者, 且你当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有修改该帖的权限");
                    return;
                }
                else if (config.Edittimelimit > 0 && Utils.StrDateDiffMinutes(postinfo.Postdatetime, config.Edittimelimit) > 0)
                {
                    AddErrLine("抱歉, 系统规定只能在帖子发表" + config.Edittimelimit + "分钟内才可以修改");
                    return;
                }
                else if (config.Edittimelimit == -1)
                {
                    AddErrLine("抱歉,系统不允许修改帖子");
                    return;
                }
            }

            #region htmltitle标题
            if (postinfo.Layer == 0)
            {
                canhtmltitle = usergroupinfo.Allowhtmltitle == 1;
            }

            if (Topics.GetMagicValue(topic.Magic, MagicType.HtmlTitle) == 1)
            {
                htmltitle = Topics.GetHtmlTitle(topic.Tid).Replace("\"", "\\\"").Replace("'", "\\'");
            }
            #endregion

            #region tag信息
            enabletag = (config.Enabletag & forum.Allowtag) == 1;
            if (enabletag && Topics.GetMagicValue(topic.Magic, MagicType.TopicTag) == 1)
            {
                foreach (TagInfo tag in ForumTags.GetTagsListByTopic(topic.Tid))
                {
                    if (tag.Orderid > -1)
                    {
                        topictags += string.Format(" {0}", tag.Tagname);
                    }
                }
                topictags = topictags.Trim();
            }
            #endregion
            userGroupInfoList.Sort(delegate(UserGroupInfo x, UserGroupInfo y) { return((x.Readaccess - y.Readaccess) + (y.Groupid - x.Groupid)); });
            //如果是提交...
            if (ispost)
            {
                SetBackLink("editpost.aspx?topicid=" + postinfo.Tid + "&postid=" + postinfo.Pid);

                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                //设置相关帖子信息
                SetPostInfo(admininfo, userinfo, Utils.StrToInt(DNTRequest.GetString("htmlon"), 0) == 1);

                if (IsErr())
                {
                    return;
                }

                //通过验证的用户可以编辑帖子
                Posts.UpdatePost(postinfo);

                //设置附件相关信息
                System.Text.StringBuilder sb = SetAttachmentInfo();

                if (IsErr())
                {
                    return;
                }

                UserCredits.UpdateUserCredits(userid);

                #region 设置提示信息和跳转链接
                //辩论地址
                if (topic.Special == 4)
                {
                    SetUrl(Urls.ShowDebateAspxRewrite(topic.Tid));
                }
                else if (DNTRequest.GetQueryString("referer") != "")//ajax快速回复将传递referer参数
                {
                    SetUrl(string.Format("showtopic.aspx?page=end&forumpage={2}&topicid={0}#{1}", topic.Tid, postinfo.Pid, forumpageid));
                }
                else if (pageid != "")//如果不是ajax,则应该是带pageid的参数
                {
                    if (config.Aspxrewrite == 1)
                    {
                        SetUrl(string.Format("showtopic-{0}-{2}{1}#{3}", topic.Tid, config.Extname, DNTRequest.GetString("pageid"), postinfo.Pid));
                    }
                    else
                    {
                        SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={3}&page={2}#{1}", topic.Tid, postinfo.Pid, DNTRequest.GetString("pageid"), forumpageid));
                    }
                }
                else//如果都为空.就跳转到第一页(以免意外情况)
                {
                    if (config.Aspxrewrite == 1)
                    {
                        SetUrl(string.Format("showtopic-{0}{1}", topic.Tid, config.Extname));
                    }
                    else
                    {
                        SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={1}", topic.Tid, forumpageid));
                    }
                }

                if (sb.Length > 0)
                {
                    SetMetaRefresh(5);
                    SetShowBackLink(true);
                    if (infloat == 1)
                    {
                        AddErrLine(sb.ToString());
                        return;
                    }
                    else
                    {
                        sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>编辑帖子成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>");
                        sb.Append("</table>");
                        AddMsgLine(sb.ToString());
                    }
                }
                else
                {
                    //编辑主题和回复需要审核
                    if (postinfo.Layer == 0)
                    {
                        SetMetaRefresh(2, base.ShowForumAspxRewrite(forumid, forumpageid));
                    }
                    else
                    {
                        SetMetaRefresh();
                    }
                    SetShowBackLink(false);

                    if (useradminid != 1 && (needaudit || topic.Displayorder == -2 || postinfo.Invisible == 1))
                    {
                        if (postinfo.Layer == 0)
                        {
                            SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid));
                        }
                        else
                        {
                            SetUrl(base.ShowTopicAspxRewrite(topic.Tid, forumpageid));
                        }
                        AddMsgLine("编辑成功, 但需要经过审核才可以显示");
                    }
                    else
                    {
                        MsgForward("editpost_succeed");
                        AddMsgLine("编辑帖子成功, 返回该主题");
                    }
                }
                #endregion

                // 删除主题游客缓存
                if (postinfo.Layer == 0)
                {
                    ForumUtils.DeleteTopicCacheFile(topic.Tid);
                }
            }
            else
            {
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
            }
        }
Example #28
0
 public bool CheckAuthority(string token, UserAuthority authority)
 {
     return(GetAuthority(token) <= authority);
 }
Example #29
0
        private string condition   = ""; //查询条件

        protected override void ShowPage()
        {
            if (userid > 0 && useradminid > 0)
            {
                admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            }

            if (config.Rssstatus == 1)
            {
                AddLinkRss("tools/rss.aspx", "最新主题");
            }

            #region 版块信息设置
            //当所选论坛为多个时或全部时
            if (forumid == -1)
            {
                //用户点选相应的论坛
                forums = (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("fidlist")) ? DNTRequest.GetString("fidlist") : DNTRequest.GetString("forums")).ToLower();
                //如果是选择全部版块

                forums = (forums == string.Empty || forums == "all") ? GetForums() : forums;
                forums = GetAllowviewForums(forums);
            }

            navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);
            if (forumid > 0)
            {
                forum = Forums.GetForumInfo(forumid);
                if (forum == null)
                {
                    AddErrLine("不存在的版块ID");
                    return;
                }

                pagetitle      = Utils.RemoveHtml(forum.Name);
                forumnav       = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
                showforumlogin = ShowForumLogin();

                if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
                {
                    AddErrLine(msg);
                    return;
                }
                // 得到子版块列表
                subforumlist = Forums.GetSubForumCollection(forumid, forum.Colcount, config.Hideprivate, usergroupid, config.Moddisplay);
            }
            #endregion

            //设置查询条件
            SetCondition();

            if (IsErr())
            {
                return;
            }

            pagetitle = (type == "digest" ? "查看精华" : "查看新帖");

            SetPageIdAndNumber();
            topiclist = Topics.GetTopicListByCondition(tpp, pageid, 0, 10, config.Hottopic, forum.Autoclose, forum.Topictypeprefix, condition, GetOrder(), direct);

            OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, config.Onlinetimeout);
            ForumUtils.UpdateVisitedForumsOptions(forumid);
        }
Example #30
0
        protected override void ShowPage()
        {
            this.pagetitle = "搜索";
            this.GetSearchType();
            if (this.searchsubmit == 0 && !this.ispost)
            {
                if (!UserAuthority.Search(this.usergroupinfo, ref this.msg))
                {
                    base.AddErrLine(this.msg);
                    return;
                }
                if (this.searchid <= 0)
                {
                    return;
                }

                if (this.searchType == SearchType.Error)
                {
                    base.AddErrLine("非法的参数信息");
                    return;
                }
                switch (this.searchType)
                {
                case SearchType.ByPoster:
                    this.topiclist        = SearchCache.GetSearchCacheList(this.searchid, 16, this.topicpageid, out this.topiccount, SearchType.TopicTitle);
                    this.topicpageid      = this.CalculateCurrentPage(this.topiccount, this.topicpageid, out this.topicpagecount);
                    this.topicpagenumbers = ((this.topicpagecount > 1) ? Utils.GetPageNumbers(this.topicpageid, this.topicpagecount, "search.aspx?type=" + this.type + "&searchid=" + this.searchid + "&keyword=" + this.keyword + "&poster=" + this.poster, 8, "topicpage", "#1") : "");
                    return;
                }
                this.topiclist = SearchCache.GetSearchCacheList(this.searchid, 16, this.pageid, out this.topiccount, this.searchType);
                if (this.topiccount == 0)
                {
                    base.AddErrLine("不存在的searchid");
                    return;
                }
                this.CalculateCurrentPage();
                this.pagenumbers = ((this.pagecount > 1) ? Utils.GetPageNumbers(this.pageid, this.pagecount, "search.aspx?type=" + this.type + "&searchid=" + this.searchid + "&keyword=" + this.keyword + "&poster=" + this.poster, 8) : "");
                return;
            }
            else
            {
                if (!UserAuthority.Search(this.userid, this.lastsearchtime, this.useradminid, this.usergroupinfo, ref this.msg))
                {
                    base.AddErrLine(this.msg);
                    return;
                }
                if (this.searchType == SearchType.Error)
                {
                    base.AddErrLine("非法的参数信息");
                    return;
                }
                this.searchpost = true;
                string searchforumid = DNTRequest.GetString("searchforumid").Trim();
                int    posterid      = this.CheckSearchInfo(searchforumid);
                if (base.IsErr())
                {
                    return;
                }

                this.searchid = SearchCache.Search(this.userid, this.usergroupid, this.keyword, posterid, this.searchType, searchforumid, DNTRequest.GetInt("searchtime", 0), DNTRequest.GetInt("searchtimetype", 0), DNTRequest.GetInt("resultorder", 0), DNTRequest.GetInt("resultordertype", 0));
                if (this.searchid > 0)
                {
                    Response.Redirect(this.forumpath + "search.aspx?type=" + this.type + "&searchid=" + this.searchid + "&keyword=" + this.keyword + "&poster=" + this.poster, false);
                    return;
                }
                base.AddErrLine("抱歉, 没有搜索到符合要求的记录");
                return;
            }
        }