示例#1
0
        //public static bool NeedAudit(Int32 fid, Int32 modnewposts, int useradminid, int userid, UserGroup userGroup)
        //{
        //    return useradminid != 1 && !Moderators.IsModer(useradminid, userid, fid) && (Scoresets.BetweenTime(GeneralConfigInfo.Current.Postmodperiods) || modnewposts == 1 || userGroup != null && userGroup.ModNewTopics == 1);

        //    if (useradminid == 1) return false;
        //    if (Moderators.IsModer(useradminid, userid, fid)) return false;

        //    if (Scoresets.BetweenTime(GeneralConfigInfo.Current.Postmodperiods)) return true;
        //    if (modnewposts == 1) return true;
        //    if (userGroup != null && userGroup.ModNewPosts == 1) return true;

        //    return false;
        //}

        //public static bool PostReply(String permuserlist, String replyperm, int userid, UserGroup usergroupinfo, TopicInfo topic)
        //{
        //    bool result = usergroupinfo.Is管理团队;
        //    if (topic.Closed == 0)
        //    {
        //        if (userid > -1 && Forums.AllowReplyByUserID(permuserlist, userid)) return true;

        //        if (replyperm.IsNullOrEmpty())
        //        {
        //            if (usergroupinfo.AllowReply) return true;
        //        }
        //        else
        //        {
        //            if (Forums.AllowReply(replyperm, usergroupinfo.ID)) return true;
        //        }
        //    }
        //    return result;
        //}

        public static bool PostReply(IXForum fi, int userid, UserGroup usergroupinfo, Topic topic)
        {
            bool result = usergroupinfo.Is管理团队;

            if (topic.Closed == 0)
            {
                if (userid > -1 && Forums.AllowReplyByUserID(fi.Permuserlist, userid))
                {
                    return(true);
                }

                if (fi.ReplyPerm.IsNullOrEmpty())
                {
                    if (usergroupinfo.AllowReply)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (fi.Field.AllowReply(usergroupinfo.ID))
                    {
                        return(true);
                    }
                }
            }
            return(result);
        }
示例#2
0
文件: Focuses.cs 项目: xiongeee/BBX
        //public static EntityList<Topic> GetDigestTopicList(int count)
        //{
        //	return Focuses.GetTopicList(count, -1, 0, "", TopicTimeType.All, TopicOrderType.ID, true, 20, false, "");
        //}
        //public static EntityList<Topic> GetDigestTopicList(int count, int fid, TopicTimeType timetype, TopicOrderType ordertype)
        //{
        //	return Focuses.GetTopicList(count, -1, fid, "", timetype, ordertype, true, 20, false, "");
        //}
        //public static EntityList<Topic> GetHotTopicList(int count, int views)
        //{
        //	return Focuses.GetTopicList(count, views, 0, "", TopicTimeType.All, TopicOrderType.ID, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetHotTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype)
        //{
        //	return Focuses.GetTopicList(count, views, fid, "", timetype, ordertype, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetRecentTopicList(int count)
        //{
        //	return Focuses.GetTopicList(count, -1, 0, "", TopicTimeType.All, TopicOrderType.ID, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetTopicList(int count, int views, int fid, string typeIdList, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, int cachetime, bool onlyimg)
        //{
        //	return Focuses.GetTopicList(count, views, fid, typeIdList, timetype, ordertype, isdigest, cachetime, onlyimg, "");
        //}

        public static EntityList <Topic> GetTopicList(int count, int views, int fid, string typeIdList, TopicTimeType timetype, Int32 ordertype, bool isdigest, int cachetime, bool onlyimg, string fidlist)
        {
            if (cachetime == 0)
            {
                cachetime = 1;
            }
            if (count > 50)
            {
                count = 50;
            }
            if (count < 1)
            {
                count = 1;
            }
            var order = Topic._FocusOrder[ordertype];

            string xpath        = string.Format("/Forum/TopicList-{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}", count, views, fid, timetype, order, isdigest, onlyimg, typeIdList.Replace(',', 'd'));
            var    cacheService = XCache.Current;

            var dataTable = cacheService.RetrieveObject(xpath) as EntityList <Topic>;

            if (dataTable == null)
            {
                if (String.IsNullOrEmpty(fidlist))
                {
                    fidlist = Forums.GetVisibleForum();
                }

                dataTable = Topic.GetFocusTopicList(count, views, fid, typeIdList, Focuses.GetStartDate(timetype), order, fidlist, isdigest, onlyimg);
                XCache.Add(xpath, dataTable, cachetime * 60);
            }
            return(dataTable);
        }
示例#3
0
文件: Stats.cs 项目: xiongeee/BBX
        //public static int GetForumCount()
        //{
        //    return BBX.Data.Stats.GetForumCount();
        //}
        //public static int GetTopicCount() { return Statistic.Current.TotalTopic; }
        //public static int GetPostCount() { return Statistic.Current.TotalPost; }
        //public static int GetMemberCount() { return Statistic.Current.TotalUsers; }
        //public static int GetTodayPostCount()
        //{
        //    return BBX.Data.Stats.GetTodayPostCount(TableList.GetPostTableId());
        //}
        //public static int GetTodayNewMemberCount()
        //{
        //    return BBX.Data.Stats.GetTodayNewMemberCount();
        //}
        //public static int GetAdminCount()
        //{
        //    return BBX.Data.Stats.GetAdminCount();
        //}
        //public static int GetNonPostMemCount()
        //{
        //    return BBX.Data.Stats.GetNonPostMemCount();
        //}
        public static IXForum GetHotForum()
        {
            IXForum result = null;
            int     num    = 0;

            foreach (var item in Forums.GetForumList())
            {
                if (item.Layer > 0 && item.Visible && item.Posts > num)
                {
                    num    = item.Posts;
                    result = item;
                }
            }
            if (num > 0)
            {
                return(result);
            }

            foreach (var item in Forums.GetForumList())
            {
                if (item.Layer > 0 && item.Visible)
                {
                    return(item);
                }
            }
            return(null);
        }
示例#4
0
        public static bool DownloadAttachment(IXForum forum, int userid, UserGroup usergroupinfo)
        {
            bool result = false;

            if (Forums.AllowGetAttachByUserID(forum.Permuserlist, userid))
            {
                return(true);
            }

            if (forum.Getattachperm.IsNullOrEmpty())
            {
                if (usergroupinfo.AllowGetattach)
                {
                    return(true);
                }
            }
            else
            {
                if (forum.Field.AllowGetAttach(usergroupinfo.ID))
                {
                    return(true);
                }
            }

            return(result);
        }
示例#5
0
文件: Feeds.cs 项目: xiongeee/BBX
        public static string GetForumRssXml(int ttl, int fid)
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject("/Forum/RSS/Forum" + fid) as string;

            if (text == null)
            {
                var forumInfo = Forums.GetForumInfo(fid);
                if (forumInfo == null)
                {
                    return("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Rss>Specified forum not found</Rss>\r\n");
                }
                if (!forumInfo.AllowView(7))
                {
                    return("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Rss>Guest Denied</Rss>\r\n");
                }
                if (!UserGroup.Guest.AllowVisit)
                {
                    return("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Rss>Guest Denied</Rss>\r\n");
                }
                text = BuildRssOutput(ttl, new Int32[] { fid }, forumInfo.Name);
                XCache.Add("/Forum/RSS/Forum" + fid, text, ttl * 60);
            }
            return(text);
        }
示例#6
0
文件: ForumHots.cs 项目: xiongeee/BBX
        /// <summary>获取帖子列表,带缓存</summary>
        /// <param name="inf"></param>
        /// <returns></returns>
        public static EntityList <Topic> GetTopicList(ForumHotItemInfo inf)
        {
            if (inf.Cachetimeout < 60)
            {
                inf.Cachetimeout = 60;
            }
            if (inf.Dataitemcount > 50)
            {
                inf.Dataitemcount = 50;
            }
            else if (inf.Dataitemcount < 1)
            {
                inf.Dataitemcount = 1;
            }

            var list = XCache.Current.RetrieveObject("/Forum/ForumHostList-" + inf.Id) as EntityList <Topic>;

            if (list == null)
            {
                string visibleFidList = string.IsNullOrEmpty(inf.Forumlist) ? Forums.GetVisibleForum() : inf.Forumlist;
                //string fieldName = Focuses.GetFieldName((TopicOrderType)Enum.Parse(typeof(TopicOrderType), inf.Sorttype));
                var type = Focuses.GetStartDate((TopicTimeType)Enum.Parse(typeof(TopicTimeType), inf.Datatimetype));
                list = Topic.GetFocusTopicList(inf.Dataitemcount, -1, 0, "", type, inf.Sorttype, visibleFidList, inf.Sorttype == "digest", false);
                if (inf.Cachetimeout > 0)
                {
                    XCache.Add("/Forum/ForumHostList-" + inf.Id, list, inf.Cachetimeout);
                }
            }
            return(list);
        }
示例#7
0
        public static string GetFidListByModerator(string moderatorUserName)
        {
            string text = "";

            foreach (var current in Forums.GetForumList())
            {
                if (("," + current.Moderators + ",").Contains("," + moderatorUserName + ","))
                {
                    text = text + current.Fid + ",";
                }
            }
            return(text.TrimEnd(','));
        }
示例#8
0
文件: ForumHots.cs 项目: xiongeee/BBX
        public static string HotImagesArray(ForumHotItemInfo fi)
        {
            //string format = "<li><a href=\"{0}\" target=\"_blank\"><img src=\"{1}\" alt=\"{2}\"/></a></li>";
            //string format2 = "<a href=\"#\" rel=\"{0}\">{0}</a>";
            var sb   = new StringBuilder();
            var sb2  = new StringBuilder();
            var thum = (BaseConfigs.GetForumPath + "cache/rotatethumbnail/").EnsureDirectory();

            //string fidlist = string.IsNullOrEmpty(fi.Forumlist) ? Forums.GetVisibleForum() : fi.Forumlist;
            var fidlist = fi.Forumlist;

            if (fidlist.IsNullOrWhiteSpace())
            {
                fidlist = Forums.GetVisibleForum();
            }
            int num = 1;
            // 热点图片
            var list = ForumHots.HotImages(fi.Dataitemcount, fi.Cachetimeout, fi.Sorttype, fi.Id, fidlist, fi.Enabled);

            foreach (var att in list)
            {
                //int topicid = att["tid"].ToInt();
                string filename = (att.FileName + "").Trim();
                string title    = (att.Title + "").Trim();
                title = Utils.JsonCharFilter(title).Replace("'", "\\'");

                string format = "<li><a href=\"{0}\" target=\"_blank\"><img src=\"{1}\" alt=\"{2}\"/></a></li>";
                if (!att.IsLocal)
                {
                    ForumHots.DeleteCacheImageFile();
                    var file = Path.GetFileName(filename);
                    Thumbnail.MakeRemoteThumbnailImage(filename, thum.CombinePath("r_" + file), 360, 240);
                    sb.AppendFormat(format, Urls.ShowTopicAspxRewrite(att.Tid, 0), "cache/rotatethumbnail/r_" + file, title);
                }
                else
                {
                    string file    = att.FullFileName.Replace('\\', '/').Trim();
                    string str     = "cache/rotatethumbnail/r_" + Utils.GetFilename(file);
                    var    newFile = Utils.GetMapPath(BaseConfigs.GetForumPath + str);
                    if (!File.Exists(newFile) && File.Exists(file))
                    {
                        ForumHots.DeleteCacheImageFile();
                        Thumbnail.MakeThumbnailImage(file, newFile, 360, 240);
                    }
                    sb.AppendFormat(format, Urls.ShowTopicAspxRewrite(att.Tid, 0), str, title);
                }
                sb2.AppendFormat("<a href=\"#\" rel=\"{0}\">{0}</a>", num);
                num++;
            }
            return("<div class=\"image_reel\"><ul>" + sb.ToString() + "</ul></div><div class=\"paging\"><span></span>" + sb2.ToString() + "</div>");
        }
示例#9
0
 public static bool PostAuthority(IXForum forum, UserGroup userGroupInfo, int userId, ref string msg)
 {
     if (!Forums.AllowPostByUserID(forum.Permuserlist, userId))
     {
         if (string.IsNullOrEmpty(forum.PostPerm))
         {
             if (!userGroupInfo.AllowPost)
             {
                 msg = "您当前的身份 \"" + userGroupInfo.GroupTitle + "\" 没有发表主题的权限";
                 return(false);
             }
         }
         else
         {
             if (!forum.Field.AllowPost(userGroupInfo.ID))
             {
                 msg = "您没有在该版块发表主题的权限";
                 return(false);
             }
         }
     }
     if (!forum.AllowSpecialOnly)
     {
         return(true);
     }
     if (forum.AllowPostSpecial <= 0)
     {
         msg = "您没有在该版块发表特殊主题的权限";
         return(false);
     }
     if ((forum.Allowpostspecial & 1) != 1 || userGroupInfo.AllowPostpoll)
     {
         return(true);
     }
     msg = "您当前的身份 \"" + userGroupInfo.GroupTitle + "\" 没有发布投票的权限";
     if ((forum.Allowpostspecial & 4) != 4 || userGroupInfo.AllowBonus)
     {
         return(true);
     }
     msg = "您当前的身份 \"" + userGroupInfo.GroupTitle + "\" 没有发布悬赏的权限";
     if ((forum.Allowpostspecial & 16) == 16 && !userGroupInfo.AllowDebate)
     {
         msg = "您当前的身份 \"" + userGroupInfo.GroupTitle + "\" 没有发起辩论的权限";
         return(false);
     }
     return(true);
 }
示例#10
0
 public static bool CheckUsertAttachAuthority(IXForum forum, UserGroup userGroupInfo, int userId, ref string msg)
 {
     if (!Forums.AllowGetAttachByUserID(forum.Permuserlist, userId))
     {
         if (forum.GetattachPerm.IsNullOrEmpty() && !userGroupInfo.AllowGetattach)
         {
             msg = string.Format("您当前的身份 \"{0}\" 没有下载或查看附件的权限", userGroupInfo.GroupTitle);
         }
         else
         {
             if (!forum.Field.AllowGetAttach(userGroupInfo.ID))
             {
                 msg = "您没有在该版块下载附件的权限";
                 return(false);
             }
         }
     }
     return(true);
 }
示例#11
0
 public static void PostTopic(int userId, IXForum forumInfo, bool isNeedAnimation)
 {
     if (userId == -1)
     {
         return;
     }
     float[] values = Forums.GetValues(forumInfo.PostcrEdits);
     if (values != null)
     {
         UpdateUserExtCredits(userId, values, false);
     }
     else
     {
         UpdateUserExtCredits(userId, 1, CreditsOperationType.PostTopic, 1, false);
     }
     if (isNeedAnimation)
     {
         WriteUpdateUserExtCreditsCookies((values != null) ? values : Scoresets.GetUserExtCredits(CreditsOperationType.PostTopic));
     }
 }
示例#12
0
文件: Posts.cs 项目: xiongeee/BBX
 private static int GetAllowGetAttachValue(PostpramsInfo postpramsInfo)
 {
     if (Forums.AllowGetAttachByUserID(Forums.GetForumInfo(postpramsInfo.Fid).Permuserlist, postpramsInfo.CurrentUserid))
     {
         return 1;
     }
     int result = 0;
     if (postpramsInfo.Getattachperm.IsNullOrWhiteSpace() || postpramsInfo.Getattachperm == null)
     {
         result = postpramsInfo.CurrentUserGroup.AllowGetattach ? 1 : 0;
     }
     else
     {
         if (Forums.AllowGetAttach(postpramsInfo.Getattachperm, postpramsInfo.Usergroupid))
         {
             result = 1;
         }
     }
     return result;
 }
示例#13
0
文件: Forums.cs 项目: xiongeee/BBX
        //public static IXForum GetForumInfo(int fid, bool clone)
        //{
        //    if (fid < 1)
        //    {
        //        return null;
        //    }
        //    var forumList = GetForumList();
        //    if (forumList == null) return null;

        //    foreach (var item in forumList)
        //    {
        //        if (item.Fid == fid)
        //        {
        //            item.Pathlist = item.Pathlist.Replace("a><a", "a> &raquo; <a");
        //            return clone ? item.Clone() : item;
        //        }
        //    }
        //    return null;
        //}

        //public static int SetRealCurrentTopics(int fid)
        //{
        //    return BBX.Data.Forums.SetRealCurrentTopics(fid);
        //}

        public static string GetVisibleForum()
        {
            var sb = new StringBuilder();
            var visibleForumList = Forums.GetVisibleForumList();

            if (visibleForumList == null)
            {
                return("");
            }

            foreach (var current in visibleForumList)
            {
                sb.AppendFormat(",{0}", current.Fid);
            }
            if (sb.Length <= 0)
            {
                return("");
            }
            return(sb.Remove(0, 1).ToString());
        }
示例#14
0
        //public static void PostReply(int userId, IXForum forumInfo, bool isNeedAnimation = false)
        public static void PostReply(int userId, String replyCredits, bool isNeedAnimation = false)
        {
            if (userId == -1)
            {
                return;
            }

            float[] values = Forums.GetValues(replyCredits);
            if (values != null)
            {
                UpdateUserExtCredits(userId, values, false);
            }
            else
            {
                UpdateUserExtCredits(userId, 1, CreditsOperationType.PostReply, 1, false);
            }
            if (isNeedAnimation)
            {
                WriteUpdateUserExtCreditsCookies((values != null) ? values : Scoresets.GetUserExtCredits(CreditsOperationType.PostReply));
            }
        }
示例#15
0
文件: Feeds.cs 项目: xiongeee/BBX
        public static string GetBaiduSitemap(int ttl)
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject("/Forum/Sitemap/Baidu") as string;

            if (text == null)
            {
                var guest = UserGroup.Guest;
                var sb    = new StringBuilder();
                foreach (var item in Forums.GetForumList())
                {
                    if (!item.AllowRss)
                    {
                        sb.AppendFormat(",{0}", item.Fid);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(item.ViewPerm))
                        {
                            if (!guest.AllowVisit)
                            {
                                sb.AppendFormat(",{0}", item.Fid);
                            }
                        }
                        else
                        {
                            if (!Utils.InArray("7", item.ViewPerm, ","))
                            {
                                sb.AppendFormat(",{0}", item.Fid);
                            }
                        }
                    }
                }
                sb = ((sb.Length > 0) ? sb.Remove(0, 1) : sb);
                var user = User.FindByID(BaseConfigs.GetFounderUid);
                text = GetBaiduSitemap(sb.ToString(), user);
                XCache.Add("/Forum/Sitemap/Baidu", text, ttl * 60);
            }
            return(text);
        }
示例#16
0
文件: Feeds.cs 项目: xiongeee/BBX
        public static string GetRssXml(int ttl)
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject(CacheKeys.FORUM_RSS_INDEX) as string;

            if (text == null)
            {
                var guest = UserGroup.Guest;
                //var sb = new StringBuilder();
                // 查找支持RSS或者匿名访客浏览的论坛版面
                var fids = new List <Int32>();
                foreach (var item in Forums.GetForumList())
                {
                    if (item.AllowRss)
                    {
                        if (!item.Viewperm.IsNullOrEmpty())
                        {
                            if (Utils.InArray("7", item.Viewperm, ","))
                            {
                                //sb.AppendFormat(",{0}", current.Fid);
                                fids.Add(item.Fid);
                            }
                        }
                        else
                        {
                            if (guest.AllowVisit)
                            {
                                //sb.AppendFormat(",{0}", current.Fid);
                                fids.Add(item.Fid);
                            }
                        }
                    }
                }
                //text = BBX.Data.Feeds.BuildRssOutput(ttl, sb.ToString().Trim(','), "");
                text = BuildRssOutput(ttl, fids.ToArray(), "");
                XCache.Add(CacheKeys.FORUM_RSS_INDEX, text, ttl * 60);
            }
            return(text);
        }
示例#17
0
 public static bool PostAttachAuthority(IXForum forum, UserGroup userGroupInfo, int userId, ref string msg)
 {
     if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userId))
     {
         bool flag = forum.Field.AllowPostAttach(userGroupInfo.ID);
         if (flag && forum.PostattachPerm != "")
         {
             return(true);
         }
         if (!flag)
         {
             msg = "您没有在该版块上传附件的权限";
             return(false);
         }
         if (!userGroupInfo.AllowPostattach)
         {
             msg = string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", userGroupInfo.GroupTitle);
             return(false);
         }
     }
     return(true);
 }
示例#18
0
 public static bool VisitAuthority(IXForum forum, UserGroup userGroupInfo, int userId, ref string msg)
 {
     if (!Forums.AllowViewByUserId(forum.Permuserlist, userId))
     {
         if (string.IsNullOrEmpty(forum.Viewperm))
         {
             if (!userGroupInfo.AllowVisit)
             {
                 msg = "您当前的身份 \"" + userGroupInfo.GroupTitle + "\" 没有浏览该版块的权限";
                 return(false);
             }
         }
         else
         {
             if (!forum.AllowView(userGroupInfo.ID))
             {
                 msg = "您没有浏览该版块的权限";
                 return(false);
             }
         }
     }
     return(true);
 }
示例#19
0
 private static void LoadTopTopicListExtraInfo(Int32 topicTypePrefix, Int32 newMinutes, Int32 hotReplyNumber, List <Topic> list)
 {
     //var topicTypeArray = TopicType.GetTopicTypeArray();
     //var stringBuilder = new StringBuilder();
     foreach (var tp in list)
     {
         var forumInfo = Forums.GetForumInfo(tp.Fid);
         if (tp.Closed == 0 && forumInfo.AutoClose > 0 && tp.PostDateTime.AddHours(forumInfo.AutoClose * 24) < DateTime.Now)
         {
             //stringBuilder.Append(tp.ID.ToString());
             //stringBuilder.Append(",");
             tp.Closed = 1;
             tp.Update();
         }
         LoadTopicFolder(forumInfo.AutoClose, newMinutes, hotReplyNumber, tp);
         //LoadTopicHighlightTitle(tp);
         //LoadTopicType(topicTypePrefix, topicTypeArray, tp);
     }
     //if (stringBuilder.Length > 0)
     //{
     //    TopicAdmins.SetClose(stringBuilder.ToString().TrimEnd(','), 1);
     //}
 }
示例#20
0
        public static void DeletePost(Post pi, bool reserveAttach)
        {
            var config = GeneralConfigInfo.Current;

            if (config.Losslessdel == 0 || pi.PostDateTime.AddHours(config.Losslessdel * 24) > DateTime.Now)
            {
                var     type      = (pi.Layer == 0) ? CreditsOperationType.PostTopic : CreditsOperationType.PostReply;
                var     forumInfo = pi.Forum as IXForum;
                float[] array     = Forums.GetValues((type == CreditsOperationType.PostTopic) ? forumInfo.PostcrEdits : forumInfo.ReplycrEdits);
                if (array == null)
                {
                    array = Scoresets.GetUserExtCredits(type);
                }
                UpdateUserExtCredits(pi.PosterID, array, 1, type, -1, true);
                if (!reserveAttach)
                {
                    int att = Attachment.FindCountByPid(pi.ID);
                    if (att != 0)
                    {
                        DeleteAttachments(pi.PosterID, att);
                    }
                }
            }
        }
示例#21
0
        public Template SelectTemplate(Template tmp, String pagename, String newUrl)
        {
            var pages   = "showforum,showtopic,showdebate,showbonus,posttopic,postreply,showtree,editpost,delpost,topicadmin";
            var forumid = 0;
            var num2    = pagename.LastIndexOf("/") + 1;
            var num3    = pagename.LastIndexOf(".") - num2;

            if (num3 > 0 && Utils.InArray(pagename.Substring(num2, num3), pages))
            {
                var config = GeneralConfigInfo.Current;
                var cookie = Utils.GetCookie(Utils.GetTemplateCookieName());
                var deftid = 0;
                //if (Utils.InArray(cookie, Templates.GetValidTemplateIDList()))
                if (Template.Has(cookie))
                {
                    deftid = cookie.ToInt(config.Templateid);
                }

                var array = newUrl.Split('&');
                for (int i = 0; i < array.Length; i++)
                {
                    var item  = array[i];
                    var value = item.Split('=')[1];
                    if (item.IndexOf("forumid=") >= 0 && value != "")
                    {
                        forumid = value.ToInt(0);
                    }
                    else
                    {
                        if (item.IndexOf("topicid=") >= 0 && value != "")
                        {
                            var topicInfo = Topic.FindByID(value.ToInt(0));
                            if (topicInfo != null)
                            {
                                forumid = topicInfo.Fid;
                            }
                        }
                        else
                        {
                            forumid = DNTRequest.GetInt("forumid", 0);
                        }
                    }
                    if (forumid > 0)
                    {
                        var forumInfo = Forums.GetForumInfo(forumid);
                        var tid       = (forumInfo == null) ? 0 : forumInfo.TemplateID;
                        if (tid <= 0)
                        {
                            tid = deftid;
                            if (tid == 0)
                            {
                                tid = config.Templateid;
                            }
                        }
                        if (tid > 0 && tmp.ID != tid)
                        {
                            tmp = Template.FindByID(tid);
                        }
                        break;
                    }
                }
            }
            return(tmp);
        }
示例#22
0
        private void ReUrl_BeginRequest(object sender, EventArgs e)
        {
            var baseConfigInfo = BaseConfigInfo.Current;

            if (baseConfigInfo == null)
            {
                return;
            }

            var config  = GeneralConfigInfo.Current;
            var context = ((HttpApplication)sender).Context;

            #region Forcewww
            var request = context.Request;
            var url     = request.Url;
            if (config.Forcewww == 1 && url.Host.Contains(".") && !url.Host.StartsWith("www.", StringComparison.OrdinalIgnoreCase))
            {
                context.Response.Redirect(url.Scheme + "://www." + url.Authority + url.PathAndQuery);
            }
            #endregion

            var forumPath = baseConfigInfo.Forumpath.ToLower();
            var myPath    = request.Path.ToLower();
            if (!myPath.StartsWith(forumPath) || !myPath.EndsWith(".aspx") || this.IgnorePathContains(myPath, forumPath))
            {
                return;
            }

            // 获取模版信息
            var templateID = config.Templateid;
            var cookie     = Utils.GetCookie(Utils.GetTemplateCookieName());
            if (Template.Has(cookie))
            {
                templateID = cookie.ToInt();
            }
            var tmp = Template.FindByID(templateID);

            #region 主题列表页 list.aspx
            if ((config.Iisurlrewrite == 1 || config.Aspxrewrite == 1) && myPath.EndsWith("/list.aspx"))
            {
                myPath = (myPath.StartsWith("/") ? myPath : ("/" + myPath));
                var array = myPath.Replace(forumPath, "/").Split('/');
                if (array.Length > 1 && !Utils.StrIsNullOrEmpty(array[1]))
                {
                    var num = 0;
                    foreach (var fi in Forums.GetForumList())
                    {
                        if (array[1].EqualIgnoreCase(fi.RewriteName))
                        {
                            num = fi.Fid;
                            break;
                        }
                    }
                    if (num > 0)
                    {
                        var text4 = "forumid=" + num;
                        if (array.Length > 2 && Utils.IsNumeric(array[2]))
                        {
                            text4 = text4 + "&page=" + array[2];
                        }
                        if (config.Specifytemplate > 0)
                        {
                            tmp = this.SelectTemplate(tmp, "showforum.aspx", text4);
                        }
                        this.CreatePage("showforum.aspx", forumPath, tmp);
                        context.RewritePath(forumPath + "aspx/" + tmp.Name + "/showforum.aspx", String.Empty, text4 + "&selectedtemplateid=" + tmp.ID);
                        return;
                    }
                    context.RewritePath(myPath.Replace("list.aspx", String.Empty), String.Empty, String.Empty);
                    return;
                }
            }
            #endregion

            #region 子目录
            if (myPath.Substring(forumPath.Length).IndexOf("/") != -1)
            {
                if (config.Aspxrewrite == 1)
                {
                    if (myPath.StartsWith(forumPath + "archiver/"))
                    {
                        var input = myPath.Substring(forumPath.Length + 8);
                        foreach (var item in SiteUrls.Current.Urls)
                        {
                            if (Regex.IsMatch(input, item.Pattern, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase))
                            {
                                var queryString = Regex.Replace(input, item.Pattern, item.QueryString, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase);
                                context.RewritePath(forumPath + "archiver" + item.Page, String.Empty, queryString);
                                return;
                            }
                        }
                    }
                    if (myPath.StartsWith(forumPath + "tools/"))
                    {
                        var input2 = myPath.Substring(forumPath.Length + 5);
                        foreach (var item in SiteUrls.Current.Urls)
                        {
                            if (Regex.IsMatch(input2, item.Pattern, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase))
                            {
                                var queryString2 = Regex.Replace(input2, item.Pattern, Utils.UrlDecode(item.QueryString), Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase);
                                context.RewritePath(forumPath + "tools" + item.Page, String.Empty, queryString2);
                                return;
                            }
                        }
                    }
                }
                if (myPath.StartsWith(forumPath + "upload/") || myPath.StartsWith(forumPath + "space/upload/") || myPath.StartsWith(forumPath + "avatars/upload/"))
                {
                    context.RewritePath(forumPath + "index.aspx");
                }
                return;
            }
            #endregion

            if (myPath.EndsWith("/index.aspx") || myPath.EndsWith("/default.aspx"))
            {
                var pageName = (config.Indexpage == 0) ? "forumindex.aspx" : "website.aspx";
                CreatePage(pageName, forumPath, tmp);
                context.RewritePath(forumPath + "aspx/" + tmp.Name + "/" + pageName);
                return;
            }
            var fileAndQuery = myPath.Substring(request.Path.LastIndexOf("/"));
            var query        = request.QueryString.ToString();
            // 根据重写规则进行匹配
            if (config.Aspxrewrite == 1)
            {
                foreach (var item in SiteUrls.Current.Urls)
                {
                    if (Regex.IsMatch(myPath, item.Pattern, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase))
                    {
                        var text7 = Regex.Replace(fileAndQuery, item.Pattern, item.QueryString, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase);
                        CreatePage(item.Page.Replace("/", ""), forumPath, tmp);
                        if (config.Specifytemplate > 0)
                        {
                            tmp = SelectTemplate(tmp, item.Page, text7);
                        }
                        context.RewritePath(forumPath + "aspx/" + tmp.Name + item.Page, String.Empty, text7 + "&selectedtemplateid=" + tmp.ID + (String.IsNullOrEmpty(query) ? "" : ("&" + query)));
                        return;
                    }
                }
            }
            CreatePage(fileAndQuery.Replace("/", ""), forumPath, tmp);
            if (config.Specifytemplate > 0)
            {
                tmp = SelectTemplate(tmp, myPath, query);
            }
            context.RewritePath(forumPath + "aspx/" + tmp.Name + fileAndQuery, String.Empty, query + "&selectedtemplateid=" + tmp.ID);
        }
示例#23
0
文件: Forums.cs 项目: xiongeee/BBX
        public static List <IXForum> GetForumIndexCollection(int hidePrivate, int userGroupId, int moderStyle, out int topicCount, out int postCount, out int todayCount)
        {
            var list = new List <IXForum>();

            topicCount = 0;
            postCount  = 0;
            todayCount = 0;
            //foreach (var current in BBX.Data.Forums.GetForumIndexList())
            foreach (var frm in XForum.GetForumIndexList())
            {
                if (!frm.Viewperm.IsNullOrEmpty() && !Utils.InArray(userGroupId.ToString(), frm.Viewperm))
                {
                    if (hidePrivate != 0)
                    {
                        continue;
                    }

                    //frm.LastTitle = "";
                    //frm.LastPoster = "";
                    //frm.Status = -1;
                }
                if (frm.Layer == 0 && Utils.GetCookie("bbx_collapse").IndexOf("_category_" + frm.Fid + "_") > -1)
                {
                    frm.Collapse = "display: none;";
                }
                //if (frm.Status > 0)
                //{
                //    if (frm.ParentID == 0 && frm.SubforumCount > 0)
                //    {
                //        frm.Status = frm.ColCount + 1;
                //    }
                //    else
                //    {
                //        frm.Status = 1;
                //        //frm.ColCount = 1;
                //    }
                //}
                //current.Moderators = Forums.GetModerators(current, moderStyle);
                if (frm.ModeratorsHtml == null)
                {
                    frm.ModeratorsHtml = frm.GetModerators(moderStyle);
                }
                if (frm.LastPost <= DateTime.MinValue || frm.LastPost.Date != DateTime.Now.Date)
                {
                    frm.TodayPosts = 0;
                }
                //if (!frm.Viewperm.IsNullOrEmpty() && !Utils.InArray(userGroupId.ToString(), frm.Viewperm) && hidePrivate == 0)
                //{
                //    frm.LastTitle = "";
                //    frm.LastPoster = "";
                //    frm.Status = -1;
                //}
                if (frm.Layer > 0)
                {
                    //var forumInfo = Forums.GetForumInfo(frm.Fid, false);
                    //if (forumInfo != null)
                    //{
                    //    forumInfo.Topics = frm.Topics;
                    //    forumInfo.Posts = frm.Posts;
                    //    forumInfo.TodayPosts = frm.TodayPosts;
                    //}
                    topicCount += frm.Topics;
                    postCount  += frm.Posts;
                    todayCount += frm.TodayPosts;
                }
                list.Add(frm);
            }
            return(Forums.GetRealForumIndexCollection(list));
        }
示例#24
0
文件: Forums.cs 项目: xiongeee/BBX
 public static bool AllowPostAttachByUserID(string permUserList, int userId)
 {
     return(Forums.ValidateSpecialUserPerm(permUserList, userId, ForumSpecialUserPower.PostAttachByUser));
 }
示例#25
0
文件: Forums.cs 项目: xiongeee/BBX
 public static bool AllowViewByUserId(string permUserList, int userId)
 {
     return(Forums.ValidateSpecialUserPerm(permUserList, userId, ForumSpecialUserPower.ViewByUser));
 }
示例#26
0
文件: Forums.cs 项目: xiongeee/BBX
 private static bool ValidateSpecialUserPerm(string permUserList, int userId, ForumSpecialUserPower forumSpecialUserPower)
 {
     if (!permUserList.IsNullOrEmpty())
     {
         ForumSpecialUserPower forumSpecialUserPower2 = (ForumSpecialUserPower)Forums.GetForumSpecialUserPower(permUserList, userId);
         if ((forumSpecialUserPower2 & forumSpecialUserPower) > (ForumSpecialUserPower)0)
         {
             return(true);
         }
     }
     return(false);
 }
示例#27
0
文件: Forums.cs 项目: xiongeee/BBX
        //public static List<IXForum> GetArchiverForumIndexList(int hideprivate, int usergroupid)
        //{
        //    //List<ArchiverForumInfo> archiverForumIndexList = BBX.Data.Forums.GetArchiverForumIndexList();
        //    var forumList = GetForumList();
        //    var list = new List<IXForum>();
        //    var list2 = new List<IXForum>();
        //    var list3 = new List<IXForum>();
        //    foreach (IXForum item in XForum.FindAllWithCache())
        //    {
        //        if (item.Visible)
        //        {
        //            //foreach (var current2 in forumList)
        //            //{
        //            //    if (Utils.InArray(current2.Fid.ToString(), item.Parentidlist))
        //            //    {
        //            //        int arg_79_0 = current2.Status;
        //            //    }
        //            //}
        //            if (item.Layer == 0)
        //            {
        //                if (hideprivate == 0 || item.AllowView(usergroupid))
        //                {
        //                    list.Add(item);
        //                }
        //            }
        //            else
        //            {
        //                if (hideprivate == 0 || item.AllowView(usergroupid))
        //                {
        //                    list2.Add(item);
        //                }
        //            }
        //        }
        //    }
        //    foreach (var item in list)
        //    {
        //        list3.Add(item);
        //        foreach (var elm in list2)
        //        {
        //            if (Utils.InArray(item.Fid.ToString().Trim(), elm.Parentidlist))
        //            {
        //                list3.Add(elm);
        //            }
        //        }
        //    }
        //    return list3;
        //}

        //public static DataTable GetForumList(int fid)
        //{
        //    if (fid < 0) return new DataTable();

        //    //return Forums.GetSubForumListTable(fid);
        //    var f = XForum.FindByID(fid);
        //    if (f == null) return null;

        //    return f.AllChilds.ToDataTable(false);
        //}

        //public static DataTable GetSubForumListTable(int fid)
        //{
        //	DataTable subForumTable = BBX.Data.Forums.GetSubForumTable(fid);
        //	if (subForumTable != null)
        //	{
        //		int num = 0;
        //		int num2 = 1;
        //		foreach (DataRow dataRow in subForumTable.Rows)
        //		{
        //			if (TypeConverter.ObjectToInt(dataRow["status"]) > 0)
        //			{
        //				if (num2 > 1)
        //				{
        //					dataRow["status"] = ++num;
        //					dataRow["colcount"] = num2;
        //				}
        //				else
        //				{
        //					if (TypeConverter.ObjectToInt(dataRow["subforumcount"]) > 0 && TypeConverter.ObjectToInt(dataRow["colcount"]) > 0)
        //					{
        //						num2 = dataRow["colcount"].ToString().ToInt(0);
        //						num = num2;
        //						dataRow["status"] = num + 1;
        //					}
        //				}
        //			}
        //		}
        //	}
        //	return subForumTable;
        //}

        //public static List<ForumInfo> GetSubForumList(int fid)
        //{
        //    List<ForumInfo> list = new List<ForumInfo>();
        //    foreach (ForumInfo current in BBX.Data.GetForumList())
        //    {
        //        if (current.Parentid == fid && current.Status == 1)
        //        {
        //            list.Add(current);
        //        }
        //    }
        //    return list;
        //}

        //public static bool AllowView(string viewperm, int usergroupid)
        //{
        //    return Forums.HasPerm(viewperm, usergroupid);
        //}

        //public static bool AllowPost(string postperm, int usergroupid)
        //{
        //    return Forums.HasPerm(postperm, usergroupid);
        //}

        public static bool AllowReply(string replyperm, int usergroupid)
        {
            return(Forums.HasPerm(replyperm, usergroupid));
        }
示例#28
0
文件: Forums.cs 项目: xiongeee/BBX
 public static bool AllowGetAttach(string getattachperm, int usergroupid)
 {
     return(Forums.HasPerm(getattachperm, usergroupid));
 }