Example #1
0
        //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);
        }
Example #2
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(','));
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
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);
        }