Exemple #1
0
        internal TopicStats GetTopicsStats()
        {
            TopicStats topicStats = new TopicStats();

            topicStats.TopicName = Name;

            lock (_mutex)
            {
                topicStats.CurrentMessageCount = _messages.Count;
            }

            int subscriberCount = 0;
            int publisherCount  = 0;

            lock (_mutex)
            {
                foreach (ClientSubscriptionManager client in _subscriptions.Values)
                {
                    client.GetClientStats(ref subscriberCount, ref publisherCount);
                    topicStats.SubscriberCount += subscriberCount;
                    topicStats.PublisherCount  += publisherCount;
                }
            }
            return(topicStats);
        }
Exemple #2
0
 public void RemoveTopic(string topic)
 {
     lock (this)
     {
         TopicStats stats = null;
         if (_topicWiseDataSize.TryGetValue(topic, out stats))
         {
             _count    -= stats.Count;
             _dataSize -= stats.Size;
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// 判断页面是否需要游客缓存页
        /// </summary>
        /// <param name="pagename"></param>
        /// <returns>不需要返回false</returns>
        private bool GetUserCachePage(string pagename)
        {
            switch (pagename)
            {
            case "website.aspx":
                isguestcachepage = GetCachePage(pagename);
                break;

            case "forumindex.aspx":
                isguestcachepage = GetCachePage(pagename);
                break;

            case "spaceindex.aspx":
                isguestcachepage = GetCachePage(pagename);
                break;

            case "albumindex.aspx":
                isguestcachepage = GetCachePage(pagename);
                break;

            case "showtopic.aspx":
            {
                int pageid  = DNTRequest.GetQueryInt("page", 1);
                int topicid = DNTRequest.GetQueryInt("topicid", 0);
                //参数数目为2或0表示当前页面可能为第一页帖子列表
                if ((DNTRequest.GetParamCount() == 2 || DNTRequest.GetParamCount() == 3) && topicid > 0 && ForumUtils.ResponseShowTopicCacheFile(topicid, pageid))
                {
                    TopicStats.Track(topicid, 1);
                    return(true);
                }
                break;
            }

            case "showforum.aspx":
            {
                int pageid  = DNTRequest.GetQueryInt("page", 1);
                int forumid = DNTRequest.GetQueryInt("forumid", 0);
                //参数数目为2或0表示当前页面可能为第一页帖子列表
                if ((DNTRequest.GetParamCount() == 2 || DNTRequest.GetParamCount() == 3) && forumid > 0 && ForumUtils.ResponseShowForumCacheFile(forumid, pageid))
                {
                    return(true);
                }

                break;
            }

            default:
                break;
            }
            return(false);
        }
Exemple #4
0
 public void DecrementTopicStats(string topic, long dataSize)
 {
     lock (this)
     {
         TopicStats stats = null;
         if (_topicWiseDataSize.TryGetValue(topic, out stats))
         {
             stats.Count = stats.Count - 1;
             stats.Size  = stats.Size - dataSize;
             _count--;
             _dataSize -= dataSize;
         }
     }
 }
 public void IncrementTopicStats(string topic, long dataSize)
 {
     lock (this)
     {
         TopicStats stats = null;
         if (!_topicWiseDataSize.TryGetValue(topic, out stats))
         {
             stats = new TopicStats();
             _topicWiseDataSize.Add(topic, stats);
         }
         stats.Count = stats.Count + 1;
         stats.Size  = stats.Size + dataSize;
         _count++;
         _dataSize += dataSize;
     }
 }
Exemple #6
0
 /// <summary>
 /// Counts the questions in file and updates the tracker
 /// </summary>
 /// <param name="topic">Topic to update</param>
 /// <returns><see langword="true"/> if file exists, <see langword="false"/> if not</returns>
 public static void QuestionsPerTopic(string topic)
 {
     if (TopicStats.ContainsKey(topic))
     {
         //count question in file, assuming each is 7 lines long
         int len    = File.ReadAllLines(ActiveFile).Length;
         int qCount = len / 7 + 1;
         if (qCount == 0)
         {
             TopicStats[topic][0] = 1;
         }
         else
         {
             TopicStats[topic][0] = qCount;
         }
     }
     else
     {
         TopicStats[topic] = new int[] { 1, 0, 0, 0, 0 };
         //TopicStats[topic][0] = 1;
     }
 }
Exemple #7
0
        internal TopicStats GetTopicsStats()
        {
            TopicStats topicStats = new TopicStats();

            topicStats.TopicName = Name;

            lock (_mutex)
            {
                topicStats.CurrentMessageCount = _messages.Count;
            }

            int subscriberCount    = 0;
            int publisherCount     = 0;
            int durableSharedCount = 0;
            int durableExclCount   = 0;
            int nonDurableCount    = 0;

            lock (_mutex)
            {
                foreach (ClientSubscriptionManager client in _subscribers.Values)
                {
                    client.GetClientStats(ref subscriberCount, ref publisherCount);
                    topicStats.SubscriberCount += subscriberCount;
                    topicStats.PublisherCount  += publisherCount;
                }
                foreach (KeyValuePair <SubscriptionIdentifier, Subscriptions> subscription in _subscriptions)
                {
                    if (subscription.Key.SubscriptionPolicy == SubscriptionPolicyType.NonDurableExclusiveSubscription)
                    {
                        nonDurableCount++;
                    }
                }
                topicStats.DurableSharedCount    = durableSharedCount;
                topicStats.DurableExclusiveCount = durableExclCount;
                topicStats.NonDurableSubCount    = nonDurableCount;
            }
            return(topicStats);
        }
Exemple #8
0
        protected override void ShowPage()
        {
            //获取主题信息
            topic = GetTopicInfo();
            if (topic == null || IsErr())
            {
                return;
            }

            topicid = topic.Tid;
            forumid = topic.Fid;
            forum   = Forums.GetForumInfo(forumid);
            if (forum == null)
            {
                AddErrLine("不存在的版块ID"); return;
            }

            pagetitle = string.Format("{0} - {1}", topic.Title, Utils.RemoveHtml(forum.Name));
            ///得到广告列表
            GetForumAds(forum.Fid);

            // 检查是否具有版主的身份
            if (useradminid != 0)
            {
                ismoder   = Moderators.IsModer(useradminid, userid, forum.Fid) ? 1 : 0;
                admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); //得到管理组信息
                if (admininfo != null)
                {
                    disablepostctrl = admininfo.Disablepostctrl;
                }
            }

            //验证不通过则返回
            if (!ValidateInfo())
            {
                return;
            }

            Caches.GetTopicTypeArray().TryGetValue(topic.Typeid, out topictypes);
            topictypes = topictypes != "" ? "[" + topictypes + "]" : "";

            showratelog = GeneralConfigs.GetConfig().DisplayRateCount > 0 ? 1 : 0;
            score       = Scoresets.GetValidScoreName();
            scoreunit   = Scoresets.GetValidScoreUnit();

            //编辑器状态
            EditorState();
            navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);
            usesig      = ForumUtils.GetCookie("sigstatus") == "0" ? 0 : 1;

            int price = 0;

            if (topic.Special != 4)//不是辩论帖,就跳转到showtopic页面显示
            {
                HttpContext.Current.Response.Redirect(forumpath + this.ShowTopicAspxRewrite(topic.Tid, 1)); return;
            }

            if (topic.Moderated > 0)
            {
                moderactions = TopicAdmins.GetTopicListModeratorLog(topicid);
            }

            // 获取帖子总数
            onlyauthor = Utils.StrIsNullOrEmpty(onlyauthor) ? "0" : onlyauthor;

            // 获取分页相关信息
            BindPageCountAndId();

            PostpramsInfo postpramsInfo = GetPostPramsInfo(price);

            //获取当前正反方列表
            positivepostlist = Debates.GetPositivePostList(postpramsInfo, out attachmentlist, ismoder == 1);
            negativepostlist = Debates.GetNegativePostList(postpramsInfo, out attachmentlist, ismoder == 1);

            GetPostAds(postpramsInfo, positivepostlist.Count);

            //辩论帖
            if (topic.Special == 4)
            {
                GetDebateInfo(postpramsInfo);
            }

            enabletag = (config.Enabletag & forum.Allowtag) == 1;
            if (enabletag)
            {
                relatedtopics = Topics.GetRelatedTopicList(topicid, 5);
            }

            //更新页面Meta信息
            UpdateMetaInfo(Utils.RemoveHtml(debatepost.Message));

            ///更新主题查看次数和在线用户信息
            TopicStats.Track(topicid, 1);
            Topics.MarkOldTopic(topic);
            topicviews = topic.Views + 1 + (config.TopicQueueStats == 1 ? TopicStats.GetStoredTopicViewCount(topic.Tid) : 0);
            OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forumid, forum.Name, topicid, topic.Title);
            BindDownloadAttachmentTip();
        }
Exemple #9
0
        public showtopic()
        {
            // 获取主题ID
            int topicid = DNTRequest.GetInt("topicid", -1);

            // 如果主题ID非数字
            if (topicid == -1)
            {
                ShowMsg("无效的主题ID");
                return;
            }

            // 获取该主题的信息
            TopicInfo topic = Topics.GetTopicInfo(topicid);

            // 如果该主题不存在
            if (topic == null)
            {
                ShowMsg("不存在的主题ID");
                return;
            }

            if (topic.Readperm > usergroupinfo.Readaccess && topic.Posterid != userid)
            {
                ShowMsg(string.Format("本主题阅读权限为: {0}, 您当前的身份 \"{1}\" 阅读权限不够", topic.Readperm.ToString(), usergroupinfo.Grouptitle));
                return;
            }

            ForumInfo forum = Forums.GetForumInfo(topic.Fid);

            if (forum.Viewperm == null || forum.Viewperm == string.Empty)            //当板块权限为空时,按照用户组权限
            {
                if (usergroupinfo.Allowvisit != 1)
                {
                    ShowMsg("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限");
                    return;
                }
            }
            else            //当板块权限不为空,按照板块权限
            {
                if (!Forums.AllowView(forum.Viewperm, usergroupinfo.Groupid))
                {
                    ShowMsg("您没有浏览该版块的权限");
                    return;
                }
            }

            if (forum.Password != "")
            {
                ShowMsg("简洁版本无法浏览设置了密码的版块");
                return;
            }

            //验证用户是否为本版版主
            int ismoder = Moderators.IsModer(useradminid, userid, forum.Fid) ? 1 : 0;

            //购买帖子操作
            //判断是否为回复可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买
            int price = 0;

            if (topic.Price > 0 && userid != topic.Posterid && ismoder != 1)
            {
                price = topic.Price;
                //时间乘以-1是因为当Configs.GetMaxChargeSpan()==0时,帖子始终为购买帖
                if (PaymentLogs.IsBuyer(topicid, userid) || (Utils.StrDateDiffHours(topic.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 && Scoresets.GetMaxChargeSpan() != 0))//判断当前用户是否已经购买
                {
                    price = -1;
                }
            }
            if (price > 0)
            {
                ShowMsg(string.Format("此帖需转到完整版处购买后才可查看.<a href=\"{0}buytopic.aspx?topicid={1}\">点击购买</a>", "/Forum/", topic.Tid));
                return;
            }


            // 获取帖子总数
            //postcount = Posts.GetPostCount(topicid);
            int postcount = topic.Replies + 1;
            int pageid    = 1;

            // 得到Tpp设置
            int ppp = 30;

            //获取总页数
            int pagecount = postcount % ppp == 0 ? postcount / ppp : postcount / ppp + 1;

            if (pagecount == 0)
            {
                pagecount = 1;
            }
            // 得到当前用户请求的页数
            if (DNTRequest.GetString("page").ToLower().Equals("end"))
            {
                pageid = pagecount;
            }
            else
            {
                pageid = DNTRequest.GetInt("page", 1);
            }
            //修正请求页数中可能的错误
            if (pageid < 1)
            {
                pageid = 1;
            }
            if (pageid > pagecount)
            {
                pageid = pagecount;
            }

            int hide = 1;

            if (topic.Hide == 1 && (Posts.IsReplier(topicid, userid) || ismoder == 1))
            {
                hide = -1;
            }


            //获取当前页主题列表


            PostpramsInfo postpramsInfo = new PostpramsInfo();

            postpramsInfo.Fid                 = forum.Fid;
            postpramsInfo.Tid                 = topicid;
            postpramsInfo.Jammer              = forum.Jammer;
            postpramsInfo.Pagesize            = ppp;
            postpramsInfo.Pageindex           = pageid;
            postpramsInfo.Getattachperm       = forum.Getattachperm;
            postpramsInfo.Usergroupid         = usergroupinfo.Groupid;
            postpramsInfo.Attachimgpost       = config.Attachimgpost;
            postpramsInfo.Showattachmentpath  = config.Showattachmentpath;
            postpramsInfo.Hide                = hide;
            postpramsInfo.Price               = topic.Price;
            postpramsInfo.Usergroupreadaccess = usergroupinfo.Readaccess;


            postpramsInfo.CurrentUserid = userid;

            postpramsInfo.Showimages = forum.Allowimgcode;
            // 简洁版本中关闭表情符的解析
            postpramsInfo.Smileyoff              = 1;
            postpramsInfo.Smiliesmax             = 0;
            postpramsInfo.Smiliesinfo            = null;
            postpramsInfo.Customeditorbuttoninfo = null;
            postpramsInfo.Bbcodemode             = 0;
            // 简洁版本中关闭ubb转换
            postpramsInfo.Bbcodeoff        = 1;
            postpramsInfo.CurrentUserGroup = usergroupinfo;

            postpramsInfo.Onlinetimeout = config.Onlinetimeout;

            postlist = Posts.GetPostList(postpramsInfo, out attachmentlist, ismoder == 1);
            if (postlist.Count <= 0)
            {
                ShowMsg("读取信息失败");
                return;
            }

            ShowTitle(topic.Title);
            ShowBody();
            HttpContext.Current.Response.Write("<h1>" + config.Forumtitle + "</h1>");

            HttpContext.Current.Response.Write("<div class=\"forumnav\">");
            HttpContext.Current.Response.Write("<a href=\"index.aspx\">首页</a> &raquo; ");

            if (config.Aspxrewrite == 1)
            {
                HttpContext.Current.Response.Write(string.Format("{0} &raquo; <a href=\"showtopic-{1}{2}\">{3}</a>", ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname).Replace("</a><", "</a> &raquo; <"), topicid.ToString(), config.Extname, topic.Title));
            }
            else
            {
                HttpContext.Current.Response.Write(string.Format("{0} &raquo; <a href=\"showtopic.aspx?topicid={1}\">{2}</a>", ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), "aspx").Replace("</a><", "</a> &raquo; <"), topicid.ToString(), topic.Title));
            }
            HttpContext.Current.Response.Write("</div>\r\n");

            foreach (ShowtopicPagePostInfo postinfo in postlist)
            {
                HttpContext.Current.Response.Write("<div class=\"postitem\">\r\n");
                HttpContext.Current.Response.Write("\t<div class=\"postitemtitle\">\r\n");
                HttpContext.Current.Response.Write(Utils.HtmlEncode(postinfo.Poster) + " - " + postinfo.Postdatetime);
                HttpContext.Current.Response.Write("</div><div class=\"postitemcontent\">");
                HttpContext.Current.Response.Write(postinfo.Message);
                foreach (ShowtopicPageAttachmentInfo attinfo in attachmentlist)
                {
                    if (attinfo.Pid == postinfo.Pid)
                    {
                        HttpContext.Current.Response.Write(string.Format("<br /><br />附件: <a href=\"../attachment.aspx?attachmentid={0}\">{1}</a>", attinfo.Aid.ToString(), Utils.HtmlEncode(attinfo.Attachment)));
                    }
                }
                HttpContext.Current.Response.Write("\t</div>\r\n</div>\r\n");
            }
            //得到页码链接
            HttpContext.Current.Response.Write("<div class=\"pagenumbers\">");

            if (config.Aspxrewrite == 1)
            {
                HttpContext.Current.Response.Write(Utils.GetStaticPageNumbers(pageid, pagecount, "showtopic-" + topicid.ToString(), config.Extname, 8));
            }
            else
            {
                HttpContext.Current.Response.Write(Utils.GetPageNumbers(pageid, pagecount, "showtopic.aspx?topicid=" + topicid.ToString(), 8, "page"));
            }
            HttpContext.Current.Response.Write("</div>\r\n");
            //更新查看次数
            //Topics.UpdateTopicViews(topicid);
            TopicStats.Track(topicid, 1);

            if (config.Aspxrewrite == 1)
            {
                HttpContext.Current.Response.Write(string.Format("<div class=\"fullversion\">查看完整版本: <a href=\"../showtopic-{0}{1}\">{2}</a></div>\r\n", topicid.ToString(), config.Extname, topic.Title));
            }
            else
            {
                HttpContext.Current.Response.Write(string.Format("<div class=\"fullversion\">查看完整版本: <a href=\"../showtopic.aspx?topicid={0}\">{1}</a></div>\r\n", topicid.ToString(), topic.Title));
            }
            ShowFooter();
            HttpContext.Current.Response.End();
        }
Exemple #10
0
        public static Dictionary <string, TopicStats> GetTopicStat(string cacheName, string initialNodeName, Runtime.CacheManagement.CacheContext context, int port)
        {
            CacheService cacheService = GetCacheService(context);

            if (port != 0)
            {
                cacheService.Port = port;
            }
            string            startingNode      = initialNodeName;
            CacheServerConfig cacheServerConfig = null;
            ICacheServer      cacheServer       = null;



            try
            {
                if (initialNodeName.Equals(string.Empty))
                {
                    cacheServerConfig = GetCacheConfigThroughClientConfig(cacheName, port, context);
                    if (cacheServerConfig == null)
                    {
                        throw new ManagementException("cache with name " + cacheName + " not found in " + config);
                    }
                }
                else
                {
                    cacheService.ServerName = initialNodeName;
                    cacheServer             = cacheService.GetCacheServer(new TimeSpan(0, 0, 0, 30));
                    if (cacheServer == null)
                    {
                        throw new ManagementException("provided initial node not available");
                    }

                    cacheServerConfig = cacheServer.GetCacheConfiguration(cacheName);
                    if (cacheServerConfig == null)
                    {
                        throw new ManagementException("cache with name " + cacheName + " not registered on specified node");
                    }
                }

                //For Local Cache
                if (cacheServerConfig.CacheType.Equals(LOCALCACHE, StringComparison.OrdinalIgnoreCase))
                {
                    if (cacheServerConfig.InProc)
                    {
                        throw new ArgumentException("API is not supported for Local Inproc Cache");
                    }

                    cacheService.ServerName = Environment.MachineName;
                    cacheServer             = cacheService.GetCacheServer(new TimeSpan(0, 0, 0, 30));

                    if (cacheServer != null && cacheServer.IsRunning(cacheName))
                    {
                        return(cacheServer.GetTopicStats(cacheServerConfig.Name));
                    }
                }
                //For Clustered Cache
                else
                {
                    Dictionary <string, TopicStats> topicWiseStat = new Dictionary <string, TopicStats>();
                    ArrayList initialHost = InitialHostList(cacheServerConfig.Cluster.Channel.InitialHosts);
                    foreach (object host in initialHost)
                    {
                        try
                        {
                            cacheService.ServerName = (string)host;
                            cacheServer             = cacheService.GetCacheServer(new TimeSpan(0, 0, 0, 30));
                            if (cacheServer.IsRunning(cacheName))
                            {
                                Dictionary <string, TopicStats> NodeWisetopicStat = cacheServer.GetTopicStats(cacheServerConfig.Name);
                                if (NodeWisetopicStat != null)
                                {
                                    foreach (var item in NodeWisetopicStat)
                                    {
                                        if (!topicWiseStat.ContainsKey(item.Key))
                                        {
                                            item.Value.TopicName = item.Key;
                                            topicWiseStat.Add(item.Key, ((TopicStats)item.Value.Clone()));
                                        }
                                        else
                                        {
                                            TopicStats topicStat = topicWiseStat[item.Key];
                                            topicStat.CurrentMessageCount += item.Value.CurrentMessageCount;
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    return(topicWiseStat);
                }
            }
            catch (Exception ex)
            {
                throw new ManagementException(ex.Message);
            }
            finally
            {
                if (cacheServer != null)
                {
                    cacheServer.Dispose();
                }
                cacheService.Dispose();
            }
            return(null);
        }
Exemple #11
0
        private void SaveInfo_Click(object sender, EventArgs e)
        {
            #region 保存设置信息
            string[][] inputrule = new string[2][];
            inputrule[0] = new string[] { losslessdel.Text, edittimelimit.Text, tpp.Text, ppp.Text, starthreshold.Text, hottopic.Text,
                                          guestcachepagetimeout.Text, disablepostadregminute.Text, disablepostadpostcount.Text };
            inputrule[1] = new string[] { "删帖不减金币时间", "编辑帖子时间", "每页主题数", "每页主题数", "星星升级阀值", "热门话题最低帖数",
                                          "缓存游客页面的失效时间", "新用户广告强力屏蔽注册分钟数", "新用户广告强力屏蔽发帖数" };
            for (int j = 0; j < inputrule[0].Length; j++)
            {
                if (!Utils.IsInt(inputrule[0][j].ToString()))
                {
                    base.RegisterStartupScript("", "<script>alert('输入错误:" + inputrule[1][j].ToString() + ",只能是0或者正整数');window.location.href='forum_option.aspx';</script>");
                    return;
                }
            }
            if (Convert.ToInt32(losslessdel.Text) > 9999 || Convert.ToInt32(losslessdel.Text) < 0)
            {
                base.RegisterStartupScript("", "<script>alert('删帖不减金币时间期限只能在0-9999之间');window.location.href='forum_option.aspx';</script>");
                return;
            }

            if (Convert.ToInt32(edittimelimit.Text) > 9999 || Convert.ToInt32(edittimelimit.Text) < 0)
            {
                base.RegisterStartupScript("", "<script>alert('编辑帖子时间限制只能在0-9999之间');window.location.href='forum_option.aspx';</script>");
                return;
            }

            if (Convert.ToInt16(tpp.Text) > 100 || Convert.ToInt16(tpp.Text) <= 0)
            {
                base.RegisterStartupScript("", "<script>alert('每页主题数只能在1-100之间');window.location.href='forum_option.aspx';</script>");
                return;
            }

            if (Convert.ToInt16(ppp.Text) > 100 || Convert.ToInt16(ppp.Text) <= 0)
            {
                base.RegisterStartupScript("", "<script>alert('每页帖子数只能在1-100之间');window.location.href='forum_option.aspx';</script>");
                return;
            }
            if (Convert.ToInt16(starthreshold.Text) > 9999 || Convert.ToInt16(starthreshold.Text) < 0)
            {
                base.RegisterStartupScript("", "<script>alert('星星升级阀值只能在0-9999之间');window.location.href='forum_option.aspx';</script>");
                return;
            }

            if (Convert.ToInt16(hottopic.Text) > 9999 || Convert.ToInt16(hottopic.Text) < 0)
            {
                base.RegisterStartupScript("", "<script>alert('热门话题最低帖数只能在0-9999之间');window.location.href='forum_option.aspx';</script>");
                return;
            }

            if (Convert.ToInt16(hottagcount.Text) > 60 || Convert.ToInt16(hottagcount.Text) < 0)
            {
                base.RegisterStartupScript("", "<script>alert('首页热门标签(Tag)数量只能在0-60之间');window.location.href='forum_option.aspx';</script>");
            }

            if (!ValidateRatevalveset(ratevalveset1.Text))
            {
                return;
            }
            if (!ValidateRatevalveset(ratevalveset2.Text))
            {
                return;
            }
            if (!ValidateRatevalveset(ratevalveset3.Text))
            {
                return;
            }
            if (!ValidateRatevalveset(ratevalveset4.Text))
            {
                return;
            }
            if (!ValidateRatevalveset(ratevalveset5.Text))
            {
                return;
            }
            if (!(Convert.ToInt16(ratevalveset1.Text) < Convert.ToInt16(ratevalveset2.Text) &&
                  Convert.ToInt16(ratevalveset2.Text) < Convert.ToInt16(ratevalveset3.Text) &&
                  Convert.ToInt16(ratevalveset3.Text) < Convert.ToInt16(ratevalveset4.Text) &&
                  Convert.ToInt16(ratevalveset4.Text) < Convert.ToInt16(ratevalveset5.Text)))
            {
                base.RegisterStartupScript("", "<script>alert('评分阀值不是递增取值');window.location.href='forum_option.aspx';</script>");
                return;
            }
            if (disablepostad.SelectedValue == "1" && disablepostadregular.Text == "")
            {
                base.RegisterStartupScript("", "<script>alert('新用户广告强力屏蔽正则表达式为空');window.location.href='forum_option.aspx';</script>");
                return;
            }
            if (this.CheckCookie())
            {
                GeneralConfigInfo __configinfo = GeneralConfigs.Deserialize(Server.MapPath("../../config/general.config"));
                __configinfo.Fullmytopics  = Convert.ToInt16(fullmytopics.SelectedValue);
                __configinfo.Modworkstatus = Convert.ToInt16(modworkstatus.SelectedValue);
                __configinfo.Userstatusby  = Convert.ToInt16(userstatusby.SelectedValue);
                if (Topicqueuestats_1.Checked == true)
                {
                    __configinfo.TopicQueueStats = 1;
                }
                else
                {
                    __configinfo.TopicQueueStats = 0;
                }
                __configinfo.TopicQueueStatsCount  = Convert.ToInt32(topicqueuestatscount.Text);
                __configinfo.Guestcachepagetimeout = Convert.ToInt16(guestcachepagetimeout.Text);
                __configinfo.Topiccachemark        = Convert.ToInt16(topiccachemark.Text);
                __configinfo.Losslessdel           = Convert.ToInt16(losslessdel.Text);
                __configinfo.Edittimelimit         = Convert.ToInt16(edittimelimit.Text);
                __configinfo.Editedby          = Convert.ToInt16(editedby.SelectedValue);
                __configinfo.Defaulteditormode = Convert.ToInt16(defaulteditormode.SelectedValue);
                __configinfo.Allowswitcheditor = Convert.ToInt16(allowswitcheditor.SelectedValue);
                __configinfo.Reasonpm          = Convert.ToInt16(reasonpm.SelectedValue);
                __configinfo.Hottopic          = Convert.ToInt16(hottopic.Text);
                __configinfo.Starthreshold     = Convert.ToInt16(starthreshold.Text);
                __configinfo.Fastpost          = Convert.ToInt16(fastpost.SelectedValue);
                __configinfo.Tpp            = Convert.ToInt16(tpp.Text);
                __configinfo.Ppp            = Convert.ToInt16(ppp.Text);
                __configinfo.Htmltitle      = Convert.ToInt32(allowhtmltitle.SelectedValue);
                __configinfo.Enabletag      = Convert.ToInt32(enabletag.SelectedValue);
                __configinfo.Ratevalveset   = ratevalveset1.Text + "," + ratevalveset2.Text + "," + ratevalveset3.Text + "," + ratevalveset4.Text + "," + ratevalveset5.Text;
                __configinfo.Statstatus     = Convert.ToInt16(statstatus.SelectedValue);
                __configinfo.Statscachelife = Convert.ToInt16(statscachelife.Text);
                //__configinfo.Pvfrequence = Convert.ToInt16(pvfrequence.Text);
                __configinfo.Hottagcount            = Convert.ToInt16(hottagcount.Text);
                __configinfo.Oltimespan             = Convert.ToInt16(oltimespan.Text);
                __configinfo.Maxmodworksmonths      = Convert.ToInt16(maxmodworksmonths.Text);
                __configinfo.Disablepostad          = Convert.ToInt16(disablepostad.SelectedValue);
                __configinfo.Disablepostadregminute = Convert.ToInt16(disablepostadregminute.Text);
                __configinfo.Disablepostadpostcount = Convert.ToInt16(disablepostadpostcount.Text);
                __configinfo.Disablepostadregular   = disablepostadregular.Text;

                GeneralConfigs.Serialiaze(__configinfo, Server.MapPath("../../config/general.config"));
                TopicStats.SetQueueCount();
                AdminCaches.ReSetConfig();
                AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "论坛功能常规选项设置", "");
                base.RegisterStartupScript("PAGE", "window.location.href='forum_option.aspx';");
            }
            #endregion
        }
        protected override void ShowPage()
        {
            //获取主题信息
            topic = GetTopicInfo();
            if (topic == null || IsErr())
            {
                return;
            }

            //未结束的悬赏
            if (topic.Special != 3)
            {
                HttpContext.Current.Response.Redirect(BaseConfigs.GetForumPath + ShowTopicAspxRewrite(topic.Tid, 1));
                return;
            }

            topicid = topic.Tid;
            forumid = topic.Fid;
            forum   = Forums.GetForumInfo(forumid);
            if (forum == null)
            {
                AddErrLine("不存在的版块ID"); return;
            }

            pagetitle = string.Format("{0} - {1}", topic.Title, Utils.RemoveHtml(forum.Name));

            //得到广告列表
            GetForumAds(forum.Fid);

            //检查是否具有版主的身份
            IsModer();

            //验证不通过则返回
            if (!ValidateInfo())
            {
                return;
            }

            //编辑器状态
            EditorState();
            navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);
            bonuslogs   = Bonus.GetLogs(topic);

            if (topic.Moderated > 0)
            {
                moderactions = TopicAdmins.GetTopicListModeratorLog(topicid);
            }

            Caches.GetTopicTypeArray().TryGetValue(topic.Typeid, out topictypes);
            topictypes = topictypes != "" ? "[" + topictypes + "]" : "";

            if (newpmcount > 0)
            {
                pmlist = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1);
            }

            score     = Scoresets.GetValidScoreName();
            scoreunit = Scoresets.GetValidScoreUnit();

            GetPostAds(GetPostPramsInfo(), postlist.Count);

            if (postlist.Count <= 0)
            {
                AddErrLine("读取信息失败");
                return;
            }

            //更新页面Meta信息
            UpdateMetaInfo(Utils.RemoveHtml(postlist[0].Message));

            //更新主题查看次数和在线用户信息
            TopicStats.Track(topicid, 1);
            Topics.MarkOldTopic(topic);
            topicviews = topic.Views + 1 + (config.TopicQueueStats == 1 ? TopicStats.GetStoredTopicViewCount(topic.Tid) : 0);
            OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forumid, forum.Name, topicid, topic.Title);

            BindDownloadAttachmentTip();

            ForumUtils.WriteCookie("referer", string.Format("showbonus.aspx?topicid={0}", topicid.ToString()));
        }
Exemple #13
0
        protected override void ShowPage()
        {
            //获取主题信息
            topic = GetTopicInfo();
            if (topic == null)
            {
                return;
            }
            topicid = topic.Tid;
            forumid = topic.Fid;
            forum   = Forums.GetForumInfo(forumid);
            if (forum == null)
            {
                AddErrLine("不存在的版块ID"); return;
            }

            //验证不通过则返回
            if (!ValidateInfo() || IsErr())
            {
                return;
            }

            //检查是否具有管理权限
            IsModer();
            int price = GetTopicPrice(topic);

            if (topic.Special == 0 && price > 0)
            {
                HttpContext.Current.Response.Redirect(forumpath + "buytopic.aspx?topicid=" + topic.Tid);
                return;
            }

            if (postid > 0 && Posts.GetPostInfo(topicid, postid) == null)
            {
                AddErrLine("该帖可能已被删除 " + string.Format("<a href=\"{0}\">[返回主题]</a>", ShowTopicAspxRewrite(topicid, 1)));
                return;
            }
            //将版块加入到已访问版块列表中
            ForumUtils.SetVisitedForumsCookie(forumid.ToString());

            if (userid > 0)
            {
                userInfo = Users.GetShortUserInfo(userid);
            }

            if (topic.Identify > 0)
            {
                topicidentify = Caches.GetTopicIdentify(topic.Identify);
            }

            pagetitle = string.Format("{0} - {1}", topic.Title, Utils.RemoveHtml(forum.Name));

            ///得到广告列表
            GetForumAds(forum.Fid);

            //获取主题类型
            Caches.GetTopicTypeArray().TryGetValue(topic.Typeid, out topictypes);
            topictypes = Utils.StrIsNullOrEmpty(topictypes) ? "" : "[" + topictypes + "]";

            userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            score       = Scoresets.GetValidScoreName();
            scoreunit   = Scoresets.GetValidScoreUnit();
            navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);
            //编辑器状态
            EditorState();

            string[] customauthorinfo = config.Customauthorinfo.Split('|');
            postleftshow = customauthorinfo[0].Split(','); //帖子左边要显示的用户信息项目
            userfaceshow = customauthorinfo[1].Split(','); //头像上方要显示的项目
            //if (newpmcount > 0)
            //    pmlist = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1);

            onlyauthor = (onlyauthor == "1" || onlyauthor == "2") ? onlyauthor : "0";
            // 获取分页相关信息
            BindPageCountAndId();

            GetPostAds(GetPostPramsInfo(price), postlist.Count);

            #region 获取特殊主题相关信息
            bonuslogs = Bonus.GetLogs(topic);

            if (topic.Special == 1)//获取投票信息
            {
                GetPollInfo();
            }

            if (topic.Special == 4) //获取辩论信息
            {
                GetDebateInfo();
            }
            #endregion

            enabletag = (config.Enabletag & forum.Allowtag) == 1;
            //if (enabletag)
            //    relatedtopics = Topics.GetRelatedTopicList(topicid, 5);

            //更新页面Meta信息
            if (postlist != null && postlist.Count > 0)
            {
                UpdateMetaInfo(Utils.RemoveHtml(postlist[0].Message));
            }

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

            //更新主题查看次数和在线用户信息
            TopicStats.Track(topicid, 1);
            Topics.MarkOldTopic(topic);
            topicviews = topic.Views + 1 + (config.TopicQueueStats == 1 ? TopicStats.GetStoredTopicViewCount(topic.Tid) : 0);
            OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forumid, forum.Name, topicid, topic.Title);

            //如果是从
            if (DNTRequest.GetInt("fromfav", 0) > 0)
            {
                Favorites.UpdateUserFavoriteViewTime(userid, topicid);
            }
            //UserCredits.UpdateUserCredits(userInfo);此方法与后台积分设置中的条目不匹配,故注释
        }
Exemple #14
0
        private void SaveInfo_Click(object sender, EventArgs e)
        {
            #region 保存信息
            if (this.CheckCookie())
            {
                GeneralConfigInfo __configinfo = GeneralConfigs.Deserialize(Server.MapPath("../../config/general.config"));
                __configinfo.Forumtitle = forumtitle.Text;
                __configinfo.Forumurl   = forumurl.Text;
                if ((__configinfo.Forumurl == "") || !__configinfo.Forumurl.EndsWith(".aspx"))
                {
                    base.RegisterStartupScript("", "<script>alert('论坛URL地址不能为空且必须以\".aspx结尾\"!');</script>");
                    return;
                }


                __configinfo.Webtitle          = webtitle.Text;
                __configinfo.Weburl            = weburl.Text;
                __configinfo.Licensed          = Convert.ToInt16(licensed.SelectedValue);
                __configinfo.Icp               = icp.Text;
                __configinfo.Rssttl            = Convert.ToInt32(rssttl.Text);
                __configinfo.Sitemapttl        = Convert.ToInt32(sitemapttl.Text);
                __configinfo.Nocacheheaders    = Convert.ToInt16(nocacheheaders.SelectedValue);
                __configinfo.Debug             = Convert.ToInt16(debug.SelectedValue);
                __configinfo.Rewriteurl        = "";
                __configinfo.Maxmodworksmonths = 3;
                __configinfo.Rssstatus         = Convert.ToInt16(rssstatus.SelectedValue);
                __configinfo.Sitemapstatus     = Convert.ToInt16(sitemapstatus.SelectedValue);
                __configinfo.Cachelog          = 0;
                if (fulltextsearch.SelectedValue == "1")
                {
                    __configinfo.Fulltextsearch = 1;
                    foreach (DataRow dr in Posts.GetAllPostTableName().Rows)
                    {
                        try
                        {
                            DatabaseProvider.GetInstance().TestFullTextIndex(Utils.StrToInt(dr["id"], 0));
                        }
                        catch
                        {
                            base.RegisterStartupScript("", "<script>alert('您的数据库帖子表[" + BaseConfigs.GetTablePrefix + "posts" + dr["id"] + "]中暂未进行全文索引设置,因此使用数据库全文搜索无效');</script>");
                            __configinfo.Fulltextsearch = 0;
                            break;
                        }
                    }
                }
                else
                {
                    __configinfo.Fulltextsearch = 0;
                }
                __configinfo.Passwordmode = Convert.ToInt16(passwordmode.SelectedValue);
                __configinfo.Bbcodemode   = Convert.ToInt16(bbcodemode.SelectedValue);

                if (extname.Text.Trim() == "")
                {
                    base.RegisterStartupScript("", "<script>alert('您未输入相应的伪静态url扩展名!');</script>");
                    return;
                }

                //if (__configinfo.Extname != extname.Text.Trim())
                //{
                //    AdminForums.SetForumsPathList(true, extname.Text.Trim());
                //}

                __configinfo.Extname       = extname.Text.Trim();
                __configinfo.Silverlight   = Convert.ToInt32(enablesilverlight.SelectedValue);
                __configinfo.CookieDomain  = CookieDomain.Text;
                __configinfo.Memliststatus = Convert.ToInt32(memliststatus.SelectedValue);
                __configinfo.Indexpage     = Convert.ToInt32(Indexpage.SelectedValue);
                __configinfo.Linktext      = Linktext.Text;
                __configinfo.Statcode      = Statcode.Text;

                __configinfo.Aspxrewrite = Convert.ToInt16(aspxrewrite.SelectedValue);

                GeneralConfigs.Serialiaze(__configinfo, Server.MapPath("../../config/general.config"));

                if (__configinfo.Aspxrewrite == 1)
                {
                    AdminForums.SetForumsPathList(true, __configinfo.Extname);
                }
                else
                {
                    AdminForums.SetForumsPathList(false, __configinfo.Extname);
                }
                Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/ForumList");

                TopicStats.SetQueueCount();
                AdminCaches.ReSetConfig();
                AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "基本设置", "");
                base.RegisterStartupScript("PAGE", "window.location.href='global_baseset.aspx';");
            }
            #endregion
        }
Exemple #15
0
        /// <summary>
        /// Formats the question using the format in StringHolder
        /// </summary>
        /// <param name="q"></param>
        public static void WriteSync(Question q)
        {
            //string fileName = q.FileName;
            string topic = string.Format(TestFormat.TopicFormat, q.Topic);
            string question = string.Format(TestFormat.QuestionFormat, q.QuestionText);
            string ans1, ans2, ans3, ans4;

            if (!TopicStats.ContainsKey(topic))
            {
                TopicStats[topic] = new int[] { 0, 0, 0, 0, 0 };
            }

            switch (q.Correct)
            {
            case QNum.First:
            {
                //ans1 correct
                TopicStats[q.Topic][1]++;

                ans1 = string.Format(TestFormat.CAnsFormat, q.ans1);
                ans2 = string.Format(TestFormat.WAnsFormat, q.ans2);
                ans3 = string.Format(TestFormat.WAnsFormat, q.ans3);
                ans4 = string.Format(TestFormat.WAnsFormat, q.ans4);
                break;
            }

            case QNum.Second:
            {
                //ans2 correct
                TopicStats[q.Topic][2]++;

                ans1 = string.Format(TestFormat.WAnsFormat, q.ans1);
                ans2 = string.Format(TestFormat.CAnsFormat, q.ans2);
                ans3 = string.Format(TestFormat.WAnsFormat, q.ans3);
                ans4 = string.Format(TestFormat.WAnsFormat, q.ans4);
                break;
            }

            case QNum.Third:
            {
                //ans3 correct
                TopicStats[q.Topic][3]++;

                ans1 = string.Format(TestFormat.WAnsFormat, q.ans1);
                ans2 = string.Format(TestFormat.WAnsFormat, q.ans2);
                ans3 = string.Format(TestFormat.CAnsFormat, q.ans3);
                ans4 = string.Format(TestFormat.WAnsFormat, q.ans4);
                break;
            }

            case QNum.Fourth:
            {
                //ans4 correct
                TopicStats[q.Topic][4]++;

                ans1 = string.Format(TestFormat.WAnsFormat, q.ans1);
                ans2 = string.Format(TestFormat.WAnsFormat, q.ans2);
                ans3 = string.Format(TestFormat.WAnsFormat, q.ans3);
                ans4 = string.Format(TestFormat.CAnsFormat, q.ans4);
                break;
            }

            default:
            {
                throw new ArgumentException("Could not determine the correct answer");
            }
            }

            //string[] newQuestion = { theme, question, ans1, ans2, ans3, ans4 };

            //write
            File.AppendAllLines(ActiveFile, new string[] { topic, question, ans1, ans2, ans3, ans4 });

            TopicStats[q.Topic][0]++;
        }