Ejemplo n.º 1
0
        /// <summary>
        /// 设置论坛字版数和显示顺序
        /// </summary>
        public static void SetForumsSubForumCountAndDispalyorder()
        {
            DataTable dt = Forums.GetForumListForDataTable();

            foreach (DataRow dr in dt.Rows)
            {
                Discuz.Data.Forums.UpdateSubForumCount(int.Parse(dt.Select("parentid=" + dr["fid"].ToString()).Length.ToString()), int.Parse(dr["fid"].ToString()));
            }

            if (dt.Rows.Count == 1)
            {
                return;
            }
            //因为不能拖动论坛分类,所以注释以下代码。sun 2009-1-7

            /*int displayorder = 1;
             * string fidlist;
             * foreach (DataRow dr in dt.Select("parentid=0"))
             * {
             *  if (dr["parentid"].ToString() == "0")
             *  {
             *      ChildNode = "0";
             *      fidlist = ("," + FindChildNode(dr["fid"].ToString())).Replace(",0,", "");
             *
             *      foreach (string fidstr in fidlist.Split(','))
             *      {
             *          DatabaseProvider.GetInstance().UpdateDisplayorderInForumByFid(displayorder, int.Parse(fidstr));
             *          displayorder++;
             *      }
             *
             *  }
             * }*/
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获得帖子列表
        /// </summary>
        /// <param name="count">数量</param>
        /// <param name="views">最小浏览量</param>
        /// <param name="fid">板块ID</param>
        /// <param name="timetype">期限类型,一天、一周、一月、不限制</param>
        /// <param name="ordertype">排序类型,时间倒序、浏览量倒序、最后回复倒序</param>
        /// <param name="isdigest">是否精华</param>
        /// <param name="cachetime">缓存的有效期(单位:分钟)</param>
        /// <returns></returns>
        public static DataTable GetTopicList(int count, int fid, TopicOrderType ordertype, bool digest, int cachetime, bool onlyimg, string fidlist, int tabid, TopicTimeType timetype)
        {
            //防止恶意行为
            cachetime = cachetime == 0 ? 1 : cachetime;
            count     = count > 50 ? 50 : (count < 1 ? 1 : count);

            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            DataTable             dt    = cache.RetrieveObject("/Forum/ForumHostList-" + tabid) as DataTable;

            if (dt == null)
            {
                if (fidlist == "")
                {
                    fidlist = Forums.GetVisibleForum();
                }

                if (Focuses.GetFieldName(ordertype) == "digest")
                {
                    digest = true;
                }

                dt = Discuz.Data.Topics.GetTopicList(count, -1, fid, "", Focuses.GetStartDate(timetype), Focuses.GetFieldName(ordertype), fidlist, digest, onlyimg);

                cache.AddObject("/Forum/ForumHostList-" + tabid, dt, cachetime);
            }
            return(dt);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 移动主题到指定版块
        /// </summary>
        /// <param name="topiclist">要移动的主题列表</param>
        /// <param name="fid">转到的版块ID</param>
        /// <param name="savelink">是否在原版块保留连接</param>
        /// <returns>更新记录数</returns>
        public static int MoveTopics(string topiclist, int fid, int oldfid, bool savelink, int topicType)
        {
            if (!Utils.IsNumericList(topiclist))
            {
                return(-1);
            }

            Discuz.Data.TopicAdmins.DeleteClosedTopics(fid, topiclist);

            //转移帖子
            MoveTopics(topiclist, fid, oldfid, topicType);

            //如果保存链接则复制一条记录到原版块
            if (savelink)
            {
                if (Discuz.Data.TopicAdmins.CopyTopicLink(oldfid, topiclist) <= 0)
                {
                    return(-2);
                }

                AdminForumStats.ReSetFourmTopicAPost(oldfid);
                Forums.SetRealCurrentTopics(oldfid);
            }
            return(1);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到当前指定条件和页数的积分交易日志记录(表)
        /// </summary>
        /// <param name="pagesize">当前分页的尺寸大小</param>
        /// <param name="currentpage">当前页码</param>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>
        public static DataTable LogList(int pagesize, int currentpage, string condition)
        {
            DataTable dt = Discuz.Data.PaymentLogs.GetPaymentLogList(pagesize, currentpage, condition);

            if (dt != null)
            {
                DataColumn dc = new DataColumn();
                dc.ColumnName   = "forumname";
                dc.DataType     = System.Type.GetType("System.String");
                dc.DefaultValue = "";
                dc.AllowDBNull  = false;
                dt.Columns.Add(dc);
                DataTable ForumList = Forums.GetForumListForDataTable();
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr["fid"].ToString().Trim() != "")
                    {
                        foreach (DataRow forumdr in ForumList.Select("fid=" + dr["fid"].ToString()))
                        {
                            dr["forumname"] = forumdr["name"].ToString();
                            break;
                        }
                    }
                }
            }
            return(dt);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 删除主题帖(layer=0)或是回复时更新用户积分
        /// </summary>
        /// <param name="postInfo">帖子信息</param>
        /// <param name="forumInfo">版块信息</param>
        /// <param name="reserveAttach">是否保留附件</param>
        public static void DeletePost(PostInfo postInfo, ForumInfo forumInfo, bool reserveAttach)
        {
            GeneralConfigInfo configInfo = GeneralConfigs.GetConfig();

            if (configInfo.Losslessdel == 0 || Utils.StrDateDiffHours(postInfo.Postdatetime, configInfo.Losslessdel * 24) < 0)
            {
                CreditsOperationType creditsOperationType = postInfo.Layer == 0 ? CreditsOperationType.PostTopic : CreditsOperationType.PostReply;
                //获取版块积分规则
                float[] creditsValue = Forums.GetValues(
                    creditsOperationType == CreditsOperationType.PostTopic ?
                    forumInfo.Postcredits :
                    forumInfo.Replycredits
                    );

                //如果未定义版块积分规则
                if (creditsValue == null)
                {
                    creditsValue = Scoresets.GetUserExtCredits(creditsOperationType);
                }
                UpdateUserExtCredits(postInfo.Posterid, creditsValue, 1, creditsOperationType, -1, true);
                //当不保留附件时,对附件进行相应的减分操作
                if (!reserveAttach)
                {
                    int attCount = Attachments.GetAttachmentCountByPid(postInfo.Pid);
                    if (attCount != 0)
                    {
                        DeleteAttachments(postInfo.Posterid, attCount);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获得最热论坛
        /// </summary>
        /// <returns></returns>
        public static ForumInfo GetHotForum()
        {
            ForumInfo forum = null;
            int       posts = 0;

            foreach (ForumInfo f in Forums.GetForumList())
            {
                if (f.Layer > 0 && f.Status > 0 && f.Posts > posts)
                {
                    posts = f.Posts;
                    forum = f;
                }
            }

            if (posts > 0)
            {
                return(forum);
            }

            foreach (ForumInfo f in Forums.GetForumList())
            {
                if (f.Layer > 0 && f.Status > 0)
                {
                    return(f);
                }
            }
            return(null);
        }
Ejemplo n.º 7
0
        public static bool PostReply(ForumInfo forum, int userid, UserGroupInfo usergroupinfo, TopicInfo topic)
        {
            bool canreply = (usergroupinfo.Radminid == 1);

            //是否有回复的权限
            if (topic.Closed == 0)
            {
                if (userid > -1 && Forums.AllowReplyByUserID(forum.Permuserlist, userid))
                {
                    canreply = true;
                }
                else
                {
                    if (Utils.StrIsNullOrEmpty(forum.Replyperm)) //权限设置为空时,根据用户组权限判断
                    {
                        // 验证用户是否有发表主题的权限
                        if (usergroupinfo.Allowreply == 1)
                        {
                            canreply = true;
                        }
                    }
                    else if (Forums.AllowReply(forum.Replyperm, usergroupinfo.Groupid))
                    {
                        canreply = true;
                    }
                }
            }
            return(canreply);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 设置待验证的主题,包括通过,忽略,删除等操作
        /// </summary>
        /// <param name="postTableId">回复表ID</param>
        /// <param name="ignore">忽略的主题列表</param>
        /// <param name="validate">验证通过的主题列表</param>
        /// <param name="delete">删除的主题列表</param>
        /// <param name="fidlist">版块列表</param>
        public static void PassAuditNewTopic(string postTableId, string ignore, string validate, string delete, string fidlist)
        {
            if (!Utils.IsNumeric(postTableId) ||
                (!string.IsNullOrEmpty(ignore) && !Utils.IsNumericList(ignore)) ||
                (!string.IsNullOrEmpty(validate) && !Utils.IsNumericList(validate)) ||
                (!string.IsNullOrEmpty(delete) && !Utils.IsNumericList(delete)) ||
                (!string.IsNullOrEmpty(fidlist) && !Utils.IsNumericList(fidlist)))
            {
                return;
            }
            Data.Topics.PassAuditNewTopic(postTableId, ignore, validate, delete, fidlist);

            //获取验证通过的主题列表信息,为用户增加发主题的扩展积分
            if (!string.IsNullOrEmpty(validate))
            {
                foreach (DataRow topicInfo in Topics.GetTopicList(validate).Rows)
                {
                    ForumInfo forumInfo = Forums.GetForumInfo(TypeConverter.ObjectToInt(topicInfo["fid"]));//获取主题的版块信息

                    float[] forumPostcredits = Forums.GetValues(forumInfo.Postcredits);
                    if (forumPostcredits != null) //使用版块内积分
                    {
                        UserCredits.UpdateUserCreditsByPostTopic(TypeConverter.ObjectToInt(topicInfo["posterid"]), forumPostcredits);
                    }
                    else //使用默认积分
                    {
                        UserCredits.UpdateUserCreditsByPostTopic(TypeConverter.ObjectToInt(topicInfo["posterid"]));
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public static DataTable LogList(int pagesize, int currentpage, string condition)
        {
            DataTable paymentLogList = Discuz.Data.PaymentLogs.GetPaymentLogList(pagesize, currentpage, condition);

            if (paymentLogList != null)
            {
                DataColumn dataColumn = new DataColumn();
                dataColumn.ColumnName   = "forumname";
                dataColumn.DataType     = typeof(String);
                dataColumn.DefaultValue = "";
                dataColumn.AllowDBNull  = false;
                paymentLogList.Columns.Add(dataColumn);
                DataTable forumListForDataTable = Forums.GetForumListForDataTable();
                foreach (DataRow dataRow in paymentLogList.Rows)
                {
                    if (dataRow["fid"].ToString().Trim() != "")
                    {
                        DataRow[] array = forumListForDataTable.Select("fid=" + dataRow["fid"].ToString());
                        int       num   = 0;
                        if (num < array.Length)
                        {
                            DataRow dataRow2 = array[num];
                            dataRow["forumname"] = dataRow2["name"].ToString();
                        }
                    }
                }
            }
            return(paymentLogList);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 设置论坛字版数和显示顺序
        /// </summary>
        public static void SetForumsSubForumCountAndDispalyorder()
        {
            DataTable dt = Forums.GetForumListForDataTable();

            foreach (DataRow dr in dt.Rows)
            {
                Discuz.Data.Forums.UpdateSubForumCount(int.Parse(dt.Select("parentid=" + dr["fid"].ToString()).Length.ToString()), int.Parse(dr["fid"].ToString()));
            }

            if (dt.Rows.Count == 1)
            {
                return;
            }
            int    displayorder = 1;
            string fidlist;

            foreach (DataRow dr in dt.Select("parentid=0"))
            {
                if (dr["parentid"].ToString() == "0")
                {
                    ChildNode = "0";
                    fidlist   = ("," + FindChildNode(dr["fid"].ToString())).Replace(",0,", "");

                    foreach (string fidstr in fidlist.Split(','))
                    {
                        Data.Forums.UpdateDisplayorderInForumByFid(displayorder, TypeConverter.StrToInt(fidstr));
                        displayorder++;
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public static void DeleteForumTopicTypes(string typeidlist)
        {
            string[] array = typeidlist.Split(',');
            SortedList <int, string> sortedList = new SortedList <int, string>();

            sortedList = Caches.GetTopicTypeArray();
            DataTable forumListForDataTable = Forums.GetForumListForDataTable();

            foreach (DataRow dataRow in forumListForDataTable.Rows)
            {
                if (!(dataRow["topictypes"].ToString() == ""))
                {
                    string   text   = dataRow["topictypes"].ToString();
                    string[] array2 = array;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        string text2 = array2[i];
                        text = text.Replace(text2 + "," + sortedList[int.Parse(text2)].ToString() + ",0|", "");
                        text = text.Replace(text2 + "," + sortedList[int.Parse(text2)].ToString() + ",1|", "");
                        Discuz.Data.Topics.ClearTopicType(int.Parse(text2));
                    }
                    ForumInfo forumInfo = Forums.GetForumInfo(int.Parse(dataRow["fid"].ToString()));
                    forumInfo.Topictypes = text;
                    AdminForums.UpdateForumInfo(forumInfo);
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 获取访问过的版块信息
        /// </summary>
        /// <returns></returns>
        public static SimpleForumInfo[] GetVisitedForums()
        {
            string visitedForums = Utils.GetCookie("visitedforums");

            if (visitedForums == "")
            {
                return(new SimpleForumInfo[0]);
            }

            List <SimpleForumInfo> simpleForumList = new List <SimpleForumInfo>();

            foreach (string fid in visitedForums.Split(','))
            {
                foreach (ForumInfo forumInfo in Forums.GetForumList())
                {
                    if (forumInfo.Fid.ToString() == fid)
                    {
                        SimpleForumInfo simpleForumInfo = new SimpleForumInfo();
                        simpleForumInfo.Fid             = forumInfo.Fid;
                        simpleForumInfo.Name            = Utils.RemoveHtml(forumInfo.Name); //如果不过滤掉HTML代码,则如果版块名称中存在html代码,会出现js错误,并且快速发帖出显示也不正常
                        simpleForumInfo.Url             = Urls.ShowForumAspxRewrite(forumInfo.Fid, 1, forumInfo.Rewritename);
                        simpleForumInfo.Postbytopictype = forumInfo.Postbytopictype;
                        simpleForumInfo.Topictypes      = forumInfo.Topictypes;
                        simpleForumList.Add(simpleForumInfo);
                        break;
                    }
                }
            }
            return(simpleForumList.ToArray());
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 移动主题到指定版块
        /// </summary>
        /// <param name="topiclist">要移动的主题列表</param>
        /// <param name="fid">转到的版块ID</param>
        /// <returns>更新记录数</returns>
        public static int MoveTopics(string topiclist, int fid, int oldfid, int topicType)
        {
            if (!Utils.IsNumericList(topiclist))
            {
                return(-1);
            }

            //更新帖子
            foreach (string tid in topiclist.Split(','))
            {
                DatabaseProvider.GetInstance().UpdatePost(topiclist, fid, PostTables.GetPostTableName(TypeConverter.StrToInt(tid)));
            }

            //更新主题
            int reval = Discuz.Data.Topics.UpdateTopic(topiclist, fid, topicType);

            if (reval > 0)
            {
                AdminForumStats.ReSetFourmTopicAPost(fid);
                AdminForumStats.ReSetFourmTopicAPost(oldfid);
                Forums.SetRealCurrentTopics(fid);
                Forums.SetRealCurrentTopics(oldfid);
            }

            //生成置顶帖
            ResetTopTopicList();
            return(reval);
        }
Ejemplo n.º 14
0
        public static bool DownloadAttachment(ForumInfo forum, int userid, UserGroupInfo usergroupinfo)
        {
            bool allowdownloadattach = false;

            //当前用户是否有允许下载附件权限
            if (Forums.AllowGetAttachByUserID(forum.Permuserlist, userid))
            {
                allowdownloadattach = true;
            }
            else
            {
                if (Utils.StrIsNullOrEmpty(forum.Getattachperm)) //权限设置为空时,根据用户组权限判断
                {
                    // 验证用户是否有有允许下载附件权限
                    if (usergroupinfo.Allowgetattach == 1)
                    {
                        allowdownloadattach = true;
                    }
                }
                else if (Forums.AllowGetAttach(forum.Getattachperm, usergroupinfo.Groupid))
                {
                    allowdownloadattach = true;
                }
            }
            return(allowdownloadattach);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 更新用户名
        /// </summary>
        /// <param name="userInfo">当前用户信息</param>
        /// <param name="oldusername">以前用户的名称</param>
        /// <returns></returns>
        public static bool UserNameChange(UserInfo userInfo, string oldusername)
        {
            //将新主题表
            Data.Topics.UpdateTopicLastPoster(userInfo.Uid, userInfo.Username);
            Data.Topics.UpdateTopicPoster(userInfo.Uid, userInfo.Username);

            //更新帖子表
            //foreach (DataRow dr in Data.PostTables.GetAllPostTableName().Rows)
            //{
            Data.Posts.UpdatePostPoster(userInfo.Uid, userInfo.Username);
            //}

            //更新短消息
            Data.PrivateMessages.UpdatePMSenderAndReceiver(userInfo.Uid, userInfo.Username);
            //更新公告
            Data.Announcements.UpdateAnnouncementPoster(userInfo.Uid, userInfo.Username);
            //更新统计表中的信息
            if (Data.Statistics.UpdateStatisticsLastUserName(userInfo.Uid, userInfo.Username) != 0)
            {
                Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/Statistics");
            }

            //更新论坛版主相关信息
            //foreach (DataRow dr in Data.Forums.GetModerators(oldusername).Rows)
            //{
            //    string moderators = "," + dr["moderators"].ToString().Trim() + ",";
            //    if (moderators.IndexOf("," + oldusername + ",") >= 0)
            //        Forums.UpdateForumField(Utils.StrToInt(dr["fid"], 0),"moderators",dr["moderators"].ToString().Trim().Replace(oldusername, userInfo.Username));
            //}

            //更新版块版主的名字
            Forums.UpdateModeratorName(oldusername, userInfo.Username);
            return(true);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 将主题置顶/解除置顶
        /// </summary>
        /// <param name="topiclist">要设置的主题列表</param>
        /// <param name="intValue">置顶级别( 0 为解除置顶)</param>
        /// <returns>更新主题个数</returns>
        public static int SetTopTopicList(int fid, string topiclist, short intValue)
        {
            //只有在应用memcached的情况下才可以使用主题缓存
            if ((mcci != null && mcci.ApplyMemCached) || (rci != null && rci.ApplyRedis))
            {
                //因为考虑到某些置顶主题是全局置顶所以这里一旦出现置顶操作,则清除所有置顶缓存信息
                foreach (ForumInfo forumInfo in Forums.GetForumList())
                {
                    if (forumInfo.Layer > 0)
                    {
                        Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/ShowTopic/TopList/" + forumInfo.Fid + "/");
                    }
                }
            }

            if (SetTopicStatus(topiclist, "displayorder", intValue) > 0 && ResetTopTopicList() == 1)
            {
                return(1);
            }

            if (Utils.FileExists(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/topic/" + fid.ToString() + ".xml")))
            {
                File.Delete(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/topic/" + fid.ToString() + ".xml"));
            }

            return(-1);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 获得指定版块最新的20个主题的Rss描述
        /// </summary>
        /// <param name="ttl">TTL数值</param>
        /// <param name="fid">版块id</param>
        /// <returns>Rss描述</returns>
        public static string GetForumRssXml(int ttl, int fid)
        {
            DNTCache cache      = DNTCache.GetCacheService();
            string   rssContent = cache.RetrieveObject("/Forum/RSS/Forum" + fid) as string;

            if (rssContent == null)
            {
                ForumInfo forum = Forums.GetForumInfo(fid);
                if (forum == null)
                {
                    return("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Rss>Specified forum not found</Rss>\r\n");
                }

                //板块d有权限设置,按照用户组权限走,RSS仅检查游客权限
                if (!Utils.StrIsNullOrEmpty(forum.Viewperm) && !Utils.InArray("7", forum.Viewperm, ","))
                {
                    return("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Rss>Guest Denied</Rss>\r\n");
                }
                else if (UserGroups.GetUserGroupInfo(7).Allowvisit == 0)
                {
                    return("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Rss>Guest Denied</Rss>\r\n");
                }

                rssContent = Discuz.Data.Feeds.BuildRssOutput(ttl, fid.ToString(), forum.Name);
                cache.AddObject("/Forum/RSS/Forum" + fid, rssContent, ttl * 60);
            }
            return(rssContent);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 获取需要审核的主题
        /// </summary>
        /// <param name="forumidlist">版块ID</param>
        /// <param name="tpp">每页主题数</param>
        /// <param name="pageid">页数</param>
        /// <returns></returns>
        public static Discuz.Common.Generic.List <TopicInfo> GetUnauditNewTopic(string forumidlist, int tpp, int pageid, int filter)
        {
            Discuz.Common.Generic.List <TopicInfo> list = Data.Topics.GetUnauditNewTopic(forumidlist, tpp, pageid, filter);
            foreach (TopicInfo info in list)
            {
                info.Forumname = Forums.GetForumInfo(info.Fid).Name;
            }

            return(list);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 获取我的未通过审核主题
        /// </summary>
        /// <param name="posterid">作者ID</param>
        /// <param name="filter">-2为未审核</param>
        /// <param name="tpp">单页显示多少条</param>
        /// <param name="pageindex">起始页</param>
        public static Discuz.Common.Generic.List <TopicInfo> GetMyUnauditTopic(int posterId, int tpp, int pageId, int filter)
        {
            Discuz.Common.Generic.List <TopicInfo> list = Data.Topics.GetMyUnauditTopic(posterId, tpp, pageId, filter);
            foreach (TopicInfo info in list)
            {
                info.Forumname = Forums.GetForumInfo(info.Fid).Name;
            }

            return(list);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 获得论坛最新的20个主题的Rss描述
        /// </summary>
        /// <param name="ttl">TTL数值</param>
        /// <returns>Rss描述</returns>
        public static string GetRssXml(int ttl)
        {
            DNTCache cache      = DNTCache.GetCacheService();
            string   rssContent = cache.RetrieveObject("/Forum/RSS/Index") as string;

            if (rssContent == null)
            {
                UserGroupInfo guestinfo = UserGroups.GetUserGroupInfo(7);
                StringBuilder forumlist = new StringBuilder();//允许访问的板块Id列表

                foreach (ForumInfo f in Forums.GetForumList())
                {
                    //当前版块允许rss订阅
                    if (f.Allowrss == 1)
                    {
                        //板块有权限设置信息时
                        if (!Utils.StrIsNullOrEmpty(f.Viewperm))
                        {
                            if (Utils.InArray("7", f.Viewperm, ","))
                            {
                                forumlist.AppendFormat(",{0}", f.Fid);
                            }
                        }
                        else
                        {
                            if (guestinfo.Allowvisit == 1)
                            {
                                forumlist.AppendFormat(",{0}", f.Fid);
                            }
                        }
                    }

                    //if (f.Allowrss == 0)
                    //    forumlist.AppendFormat(",{0}", f.Fid);
                    //else
                    //{
                    //    //板块权限设置为空,按照用户组权限走,RSS仅检查游客权限
                    //    if (Utils.StrIsNullOrEmpty(f.Viewperm))
                    //    {
                    //        if (guestinfo.Allowvisit == 0)
                    //            forumlist.AppendFormat(",{0}", f.Fid);
                    //    }
                    //    else
                    //    {
                    //        if (!Utils.InArray("7", f.Viewperm, ","))
                    //            forumlist.AppendFormat(",{0}", f.Fid);
                    //    }
                    //}
                }
                rssContent = Discuz.Data.Feeds.BuildRssOutput(ttl, forumlist.ToString().Trim(','), "");
                cache.AddObject("/Forum/RSS/Index", rssContent, ttl * 60);
            }
            return(rssContent);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 在数据库中删除指定主题
        /// </summary>
        /// <param name="topiclist">主题列表</param>
        /// <param name="subtractCredits">是否减少用户积分(0不减少,1减少)</param>
        /// <returns>删除个数</returns>
        public static int DeleteTopics(string topicList, int subTractCredits, bool reserveAttach)
        {
            if (!Utils.IsNumericList(topicList))
            {
                return(-1);
            }

            DataTable dt = Topics.GetTopicList(topicList);

            if (dt == null)
            {
                return(-1);
            }

            foreach (DataRow dr in dt.Rows)
            {
                if (TypeConverter.ObjectToInt(dr["digest"]) > 0)
                {
                    //UserCredits.UpdateUserExtCredits(TypeConverter.ObjectToInt(dr["posterid"]), -1, CreditsOperationType.Digest, 1, true);
                    CreditsFacade.UnDigest(TypeConverter.ObjectToInt(dr["posterid"]));
                }
            }

            List <PostInfo> list = Posts.GetPostList(topicList);

            if (list != null && list.Count != 0)
            {
                int       lastFid   = 0;
                ForumInfo forumInfo = null;
                foreach (PostInfo postInfo in list)
                {
                    //如果与上一个帖子是同一版块,将不再重新读取版块信息
                    if (lastFid != postInfo.Fid)
                    {
                        lastFid   = postInfo.Fid;
                        forumInfo = Forums.GetForumInfo(lastFid);
                    }
                    CreditsFacade.DeletePost(postInfo, forumInfo, reserveAttach);
                }
            }

            int reval = 0;

            foreach (string posttableid in Posts.GetPostTableIdArray(topicList))
            {
                reval = Discuz.Data.TopicAdmins.DeleteTopicByTidList(topicList, posttableid);
            }
            if (reval > 0 && !reserveAttach)
            {
                Attachments.DeleteAttachmentByTid(topicList);
            }
            return(reval);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 获得版主所见下拉列表选项
        /// </summary>
        /// <param name="username">版主用户名</param>
        /// <returns></returns>
        public static string GetModerDropdownOptions(string username)
        {
            StringBuilder stringbuilder = new StringBuilder();

            foreach (ForumInfo f in Forums.GetForumList())
            {
                if (Utils.InArray(username, f.Moderators))
                {
                    stringbuilder.AppendFormat("<option value=\"{0}\">{1}</option>", f.Fid, f.Name.Trim());
                }
            }
            return(stringbuilder.ToString());
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 获取当前版块及子版块fid列表
        /// </summary>
        /// <param name="fid">版块ID</param>
        private static string SubForumList(int fid)
        {
            string subfidList = fid.ToString() + ",";

            foreach (ForumInfo forumInfo in Forums.GetForumList())
            {
                if (("," + forumInfo.Parentidlist + ",").IndexOf("," + fid + ",") >= 0)
                {
                    subfidList += forumInfo.Fid + ",";
                }
            }
            return(subfidList.TrimEnd(','));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 通过版主用户名获取其管理的版块列表
        /// </summary>
        /// <param name="moderatorUserName"></param>
        /// <returns></returns>
        public static string GetFidListByModerator(string moderatorUserName)
        {
            string fidList = "";

            foreach (ForumInfo forumInfo in Forums.GetForumList())
            {
                if (("," + forumInfo.Moderators + ",").Contains("," + moderatorUserName + ","))
                {
                    fidList += forumInfo.Fid + ",";
                }
            }
            return(fidList.TrimEnd(','));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 通过待验证的主题
        /// </summary>
        /// <param name="postTableId">当前帖子分表Id</param>
        /// <param name="tid">主题Id</param>
        public static void PassAuditNewTopic(string tidList)
        {
            //string[] tidarray = tidList.Split(',');
            //float[] values = null;
            //ForumInfo forum = null;
            //TopicInfo topic = null;
            //int fid = -1;
            foreach (string tid in tidList.Split(','))
            {
                TopicInfo topic = Topics.GetTopicInfo(int.Parse(tid));    //获取主题信息
                CreditsFacade.PostTopic(topic.Posterid, Forums.GetForumInfo(topic.Fid));
                //if (fid != topic.Fid)    //当上一个和当前主题不在一个版块内时,重新读取版块的积分设置
                //{
                //    fid = topic.Fid;
                //    forum = Discuz.Forum.Forums.GetForumInfo(fid);
                //    if (!forum.Postcredits.Equals(""))
                //    {
                //        int index = 0;
                //        float tempval = 0;
                //        values = new float[8];
                //        foreach (string ext in Utils.SplitString(forum.Postcredits, ","))
                //        {
                //            if (index == 0)
                //            {
                //                if (!ext.Equals("True"))
                //                {
                //                    values = null;
                //                    break;
                //                }
                //                index++;
                //                continue;
                //            }
                //            tempval = Utils.StrToFloat(ext, 0);
                //            values[index - 1] = tempval;
                //            index++;
                //            if (index > 8)
                //            {
                //                break;
                //            }
                //        }
                //    }
                //}

                //if (values != null) //使用版块内积分
                //    UserCredits.UpdateUserCreditsByPostTopic(topic.Posterid, values);
                //else //使用默认积分
                //    UserCredits.UpdateUserCreditsByPostTopic(topic.Posterid);
            }

            Data.Topics.PassAuditNewTopic(PostTables.GetPostTableId(), tidList);
        }
Ejemplo n.º 26
0
        private static void ReSetFourmTopicPost(IDataReader reader, ref int fid, bool fixTopicCount)
        {
            if (reader != null)
            {
                int    topiccount     = 0;
                int    postcount      = 0;
                int    todaypostcount = 0;
                int    lasttid        = 0;
                string lasttitle      = "";
                string lastpost       = "1900-1-1";
                int    lastposterid   = 0;
                string lastposter     = "";

                while (reader.Read())
                {
                    fid        = Utils.StrToInt(reader["fid"], -1);
                    topiccount = Data.Topics.GetTopicCountOfForumWithSub(fid);
                    postcount  = GetPostsCountByFid(fid, out todaypostcount);
                    if (fixTopicCount)
                    {
                        Forums.SetRealCurrentTopics(fid);
                    }
                    else
                    {
                        lasttid      = 0;
                        lasttitle    = "";
                        lastpost     = "1900-1-1";
                        lastposterid = 0;
                        lastposter   = "";
                    }
                    IDataReader postreader = Discuz.Data.Posts.GetForumLastPost(fid, Posts.GetPostTableName(), topiccount, postcount, lasttid, lasttitle, lastpost, lastposterid, lastposter, todaypostcount);
                    if (postreader.Read())
                    {
                        TopicInfo topic = Topics.GetTopicInfo(TypeConverter.ObjectToInt(postreader["tid"]));
                        if (topic == null)
                        {
                            continue;
                        }
                        lasttid      = topic.Tid;
                        lasttitle    = topic.Title;//postreader["title"].ToString();
                        lastpost     = postreader["postdatetime"].ToString();
                        lastposterid = Utils.StrToInt(postreader["posterid"], 0);
                        lastposter   = postreader["poster"].ToString();
                    }
                    postreader.Close();

                    Discuz.Data.Forums.UpdateForum(fid, topiccount, postcount, lasttid, lasttitle, lastpost, lastposterid, lastposter, todaypostcount);
                }
                reader.Close();
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 前台版块列表弹出菜单
        /// </summary>
        /// <param name="usergroupid">用户组id</param>
        /// <param name="userid">当前用户id</param>
        /// <param name="extname">扩展名称</param>
        /// <returns>版块列表弹出菜单</returns>
        public static string GetForumListMenuDivCache(int usergroupid, int userid, string extname)
        {
            DNTCache cache = DNTCache.GetCacheService();
            string   str   = cache.RetrieveObject("/Forum/ForumListMenuDiv") as string;

            if (Utils.StrIsNullOrEmpty(str))
            {
                StringBuilder    sb        = new StringBuilder();
                List <ForumInfo> forumList = Forums.GetForumList();

                if (forumList.Count > 0)
                {
                    sb.Append("<div class=\"popupmenu_popup\" id=\"forumlist_menu\" style=\"overflow-y: auto; display:none\">");

                    foreach (ForumInfo info in forumList)
                    {
                        if (info.Layer >= 0 && info.Layer <= 1 && info.Status == 1)
                        {
                            //判断是否为私密论坛
                            //if (info.Viewperm != "" && !Utils.InArray(usergroupid.ToString(), info.Viewperm))
                            //如果对当前执行该程序的用户组权限进行判断,则会将整站的导航下拉缓存都以当前用户组权限去设置,
                            //这样会出现用户有时能看到自己并没有权限访问的论坛板块
                            if (info.Viewperm.Trim() == string.Empty || Utils.InArray("7", info.Viewperm))
                            {
                                if (info.Layer == 0)
                                {
                                    sb.AppendFormat("<dl><dt><a href=\"{0}\">{1}</a></dt><dd><ul>",
                                                    BaseConfigs.GetForumPath + Urls.ShowForumAspxRewrite(info.Fid, 0, info.Rewritename),
                                                    info.Name);

                                    foreach (ForumInfo forum in forumList)
                                    {
                                        if (Utils.StrToInt(forum.Parentidlist.Split(',')[0], 0) == info.Fid && forum.Layer == 1 && forum.Status == 1)
                                        {
                                            sb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>",
                                                            BaseConfigs.GetForumPath + Urls.ShowForumAspxRewrite(forum.Fid, 0, forum.Rewritename),
                                                            forum.Name.Trim());
                                        }
                                    }
                                    sb.Append("</ul></dd></dl>");
                                }
                            }
                        }
                    }
                }
                sb.Append("</div>");
                str = sb.ToString().Replace("<dd><ul></ul></dd>", "");
                cache.AddObject("/Forum/ForumListMenuDiv", str);
            }
            return(str);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 转换热门图片为数组
        /// </summary>
        /// <param name="topNumber">获取的数量</param>
        /// <param name="orderBy">排序方式</param>
        /// <param name="cachetime">缓存时间</param>
        /// <returns></returns>
        public static string HotImagesArray(ForumHotItemInfo forumHotItemInfo)
        {
            string        imagesItemTemplate = "<li><a href=\"{0}\" target=\"_blank\"><img src=\"{1}\" alt=\"{2}\"/></a></li>";
            string        imagesPageTemplate = "<a href=\"#\" rel=\"{0}\">{0}</a>";
            StringBuilder hotImagesLi        = new StringBuilder();
            StringBuilder hotImagePage       = new StringBuilder();

            //如果没有缩略图目录,则去生成
            if (!Directory.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/")))
            {
                Utils.CreateDir(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/"));
            }

            //如果版块idlist设置为空,则默认读取所有可见板块的idlist
            string forumList = string.IsNullOrEmpty(forumHotItemInfo.Forumlist) ? Forums.GetVisibleForum() : forumHotItemInfo.Forumlist;
            int    i         = 1;

            foreach (DataRow dr in HotImages(forumHotItemInfo.Dataitemcount, forumHotItemInfo.Cachetimeout, forumHotItemInfo.Sorttype, forumHotItemInfo.Id, forumList, forumHotItemInfo.Enabled).Rows)
            {
                int    tid      = TypeConverter.ObjectToInt(dr["tid"]);
                string fileName = dr["filename"].ToString().Trim();
                string title    = dr["title"].ToString().Trim();

                title = Utils.JsonCharFilter(title).Replace("'", "\\'");

                if (fileName.StartsWith("http://"))
                {
                    DeleteCacheImageFile();
                    Thumbnail.MakeRemoteThumbnailImage(fileName, Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/r_" + Utils.GetFilename(fileName)), 360, 240);
                    hotImagesLi.AppendFormat(imagesItemTemplate, Urls.ShowTopicAspxRewrite(tid, 0), "cache/rotatethumbnail/r_" + Utils.GetFilename(fileName), title);
                }
                else
                {
                    //图片文件名称
                    string fullFileName = BaseConfigs.GetForumPath + "upload/" + fileName.Replace('\\', '/').Trim();
                    //图片缩略后的名称
                    string thumbnailFileName = "cache/rotatethumbnail/r_" + Utils.GetFilename(fullFileName);

                    if (!File.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + thumbnailFileName)) && File.Exists(Utils.GetMapPath(fullFileName)))
                    {
                        DeleteCacheImageFile();
                        Thumbnail.MakeThumbnailImage(Utils.GetMapPath(fullFileName), Utils.GetMapPath(BaseConfigs.GetForumPath + thumbnailFileName), 360, 240);
                    }
                    hotImagesLi.AppendFormat(imagesItemTemplate, Urls.ShowTopicAspxRewrite(tid, 0), "cache/rotatethumbnail/r_" + Utils.GetFilename(fullFileName), title);
                }
                hotImagePage.AppendFormat(imagesPageTemplate, i);
                i++;
            }

            return("<div class=\"image_reel\"><ul>" + hotImagesLi.ToString() + "</ul></div><div class=\"paging\"><span></span>" + hotImagePage.ToString() + "</div>");
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 重建论坛帖数
        /// </summary>
        /// <param name="statcount">要设置的版块数量</param>
        /// <param name="lastfid">输出参数:最后一个版块ID</param>
        public static void ReSetFourmTopicAPost(int statcount, ref int lastfid)
        {
            if (statcount < 1)
            {
                lastfid = -1;
                return;
            }


            Forums.SetRealCurrentTopics(lastfid);


            IDataReader reader = DatabaseProvider.GetInstance().GetTopForumFids(lastfid, statcount);

            lastfid = -1;
            if (reader != null)
            {
                int topiccount     = 0;
                int postcount      = 0;
                int todaypostcount = 0;

                while (reader.Read())
                {
                    lastfid = Utils.StrToInt(reader["fid"], -1);

                    topiccount = Topics.GetAllTopicCount(lastfid);

                    postcount = GetPostsCountByFid(lastfid, out todaypostcount);
                    int    lasttid      = 0;
                    string lasttitle    = "";
                    string lastpost     = "1900-1-1";
                    int    lastposterid = 0;
                    string lastposter   = "";

                    IDataReader postreader = DatabaseProvider.GetInstance().GetForumLastPost(lastfid, Posts.GetPostTableName(), topiccount, postcount, 0, "", "1900-1-1", 0, "", todaypostcount);
                    if (postreader.Read())
                    {
                        lasttid      = Utils.StrToInt(postreader["tid"], 0);
                        lasttitle    = Topics.GetTopicInfo(lasttid).Title;//postreader["title"].ToString();
                        lastpost     = postreader["postdatetime"].ToString();
                        lastposterid = Utils.StrToInt(postreader["posterid"], 0);
                        lastposter   = postreader["poster"].ToString();
                    }
                    postreader.Close();

                    DatabaseProvider.GetInstance().UpdateForum(lastfid, topiccount, postcount, lasttid, lasttitle, lastpost, lastposterid, lastposter, todaypostcount);
                }
                reader.Close();
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 转换热门图片为数组
        /// </summary>
        /// <param name="topNumber">获取的数量</param>
        /// <param name="orderBy">排序方式</param>
        /// <param name="cachetime">缓存时间</param>
        /// <returns></returns>
        public static string HotImagesArray(ForumHotItemInfo forumHotItemInfo)
        {
            string        imagesItemTemplate = "title:\"{0}\",img:\"{1}\",url:\"{2}\"";
            StringBuilder hotImagesArray     = new StringBuilder();

            //如果没有缩略图目录,则去生成
            if (!Directory.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/")))
            {
                Utils.CreateDir(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/"));
            }

            //如果版块idlist设置为空,则默认读取所有可见板块的idlist
            string forumList = string.IsNullOrEmpty(forumHotItemInfo.Forumlist) ? Forums.GetVisibleForum() : forumHotItemInfo.Forumlist;

            foreach (DataRow dr in HotImages(forumHotItemInfo.Dataitemcount, forumHotItemInfo.Cachetimeout, forumHotItemInfo.Sorttype, forumHotItemInfo.Id, forumList, forumHotItemInfo.Enabled).Rows)
            {
                int    tid      = TypeConverter.ObjectToInt(dr["tid"]);
                string fileName = dr["filename"].ToString().Trim();
                string title    = dr["title"].ToString().Trim();

                title = Utils.JsonCharFilter(title).Replace("'", "\\'");

                if (fileName.StartsWith("http://"))
                {
                    DeleteCacheImageFile();
                    Thumbnail.MakeRemoteThumbnailImage(fileName, Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/r_" + Utils.GetFilename(fileName)), 360, 240);
                    hotImagesArray.Append("{");
                    hotImagesArray.AppendFormat(imagesItemTemplate, title, "cache/rotatethumbnail/r_" + Utils.GetFilename(fileName), Urls.ShowTopicAspxRewrite(tid, 0));
                    hotImagesArray.Append("},");
                    continue;
                }
                //图片文件名称
                string fullFileName = BaseConfigs.GetForumPath + "upload/" + fileName.Replace('\\', '/').Trim();
                //图片缩略后的名称
                string thumbnailFileName = "cache/rotatethumbnail/r_" + Utils.GetFilename(fullFileName);

                if (!File.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + thumbnailFileName)) && File.Exists(Utils.GetMapPath(fullFileName)))
                {
                    DeleteCacheImageFile();
                    Thumbnail.MakeThumbnailImage(Utils.GetMapPath(fullFileName), Utils.GetMapPath(BaseConfigs.GetForumPath + thumbnailFileName), 360, 240);
                }
                hotImagesArray.Append("{");
                hotImagesArray.AppendFormat(imagesItemTemplate, title, "cache/rotatethumbnail/r_" + Utils.GetFilename(fullFileName), Urls.ShowTopicAspxRewrite(tid, 0));
                hotImagesArray.Append("},");
            }

            return("[" + hotImagesArray.ToString().TrimEnd(',') + "]");
        }