コード例 #1
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
        }
コード例 #2
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
        }