protected override void ShowPage() { GetPostAds(forumid); if (userid > 0 && useradminid > 0) { AdminGroupInfo admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid); if (admingroupinfo != null) { disablepostctrl = admingroupinfo.Disablepostctrl; } } #region 获取版块信息 if (forumid == -1) { AddLinkRss(forumpath + "tools/rss.aspx", "最新主题"); AddErrLine("无效的版块ID"); return; } forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Fid < 1) { if (config.Rssstatus == 1) { AddLinkRss(forumpath + "tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新主题"); } AddErrLine("不存在的版块ID"); return; } #endregion if (config.Rssstatus == 1) { AddLinkRss(forumpath + "tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新主题"); } if (JumpUrl(forum)) { return; } needaudit = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo); // 检查是否具有版主的身份 if (useradminid > 0) { ismoder = Moderators.IsModer(useradminid, userid, forumid); } //设置搜索和排序条件 SetSearchCondition(); showforumlogin = IsShowForumLogin(forum); pagetitle = Utils.RemoveHtml(forum.Name); navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname); forumnav = ShowForumAspxRewrite(ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname).Replace("\"showforum", "\"" + forumurl + "showforum"), forumid, pageid); topicextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); #region 主题分类设置 if (forum.Applytopictype == 1) //启用主题分类 { topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); } if (forum.Viewbytopictype == 1) //允许按类别浏览 { topictypeselectlink = Forums.GetCurrentTopicTypesLink(forum.Fid, forum.Topictypes, forumurl + "showforum.aspx"); } #endregion //更新页面Meta中的keyword,description项, 提高SEO友好性 UpdateMetaInfo(Utils.StrIsNullOrEmpty(forum.Seokeywords) ? config.Seokeywords : forum.Seokeywords, Utils.StrIsNullOrEmpty(forum.Seodescription) ? forum.Description : forum.Seodescription, config.Seohead); //设置编辑器状态 SetEditorState(); #region 访问和发帖权限校验 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = userid == -1; return; } canposttopic = UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg); // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visittime = ""; if (canposttopic && Scoresets.BetweenTime(config.Postbanperiods, out visittime)) { canposttopic = false; } isnewbie = UserAuthority.CheckNewbieSpan(userid); } //是否显示快速发主题编辑器(全局权限判定,版块权限判定,是否是游客,游客需要显示,登录用户是否允许发主题且已过新手见习期) if ((config.Fastpost == 1 || config.Fastpost == 3) && forum.Allowspecialonly <= 0 && (userid < 0 || (canposttopic && !isnewbie))) { canquickpost = true; } #endregion // 得到子版块列表 if (forum.Subforumcount > 0) { subforumlist = Forums.GetSubForumCollection(forumid, forum.Colcount, config.Hideprivate, usergroupid, config.Moddisplay); } if (!forum.Rules.Equals("")) { forum.Rules = UBB.ParseSimpleUBB(forum.Rules);//替换版规中的UBB } //获取主题总数 topiccount = Topics.GetTopicCount(forumid, true, condition); #region 设置分页及主题列表信息 // 得到Tpp设置 if (tpp <= 0) { tpp = config.Tpp; } // 得到Ppp设置 if (ppp <= 0) { ppp = config.Ppp; } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } int toptopicpagecount = 0; if (forum.Layer > 0) { //获取当前页置顶主题列表 DataRow dr = Topics.GetTopTopicListID(forumid); if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString())) { topiccount = topiccount + TypeConverter.ObjectToInt(dr["tid0Count"]); } //获取总页数 pagecount = topiccount % tpp == 0 ? topiccount / tpp : topiccount / tpp + 1; if (pagecount == 0) { pagecount = 1; } if (pageid > pagecount) { pageid = pagecount; } if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString())) { toptopiccount = TypeConverter.ObjectToInt(dr["tidCount"]); if (toptopiccount > tpp * (pageid - 1)) { toptopiclist = Topics.GetTopTopicList(forumid, tpp, pageid, dr["tid"].ToString(), forum.Autoclose, forum.Topictypeprefix); toptopicpagecount = toptopiccount / tpp; } if (toptopicpagecount >= pageid || (pageid == 1 && toptopicpagecount != toptopiccount)) { topiclist = GetTopicInfoList(tpp - toptopiccount % tpp, pageid - toptopicpagecount, 0); } else { topiclist = GetTopicInfoList(tpp, pageid - toptopicpagecount, toptopiccount % tpp); } } else { toptopicpagecount = 0; topiclist = GetTopicInfoList(tpp, pageid, 0); } //如果topiclist为空则更新当前论坛帖数 if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount) { Forums.SetRealCurrentTopics(forum.Fid); } SetPageNumber(); //当版块数大于一个并且当版块数量为一个时不是版块自身时显示下拉菜单 showvisitedforumsmenu = visitedforums != null && ((visitedforums.Length == 1 && visitedforums[0].Fid != forumid) || visitedforums.Length > 1); SetVisitedForumsCookie(); //保存查看版块的页数 Utils.WriteCookie("forumpageid", pageid.ToString(), 30); //判断是否需要生成游客缓存页面 IsGuestCachePage(); } #endregion #region 替换版规中的UBB forum.Description = UBB.ParseSimpleUBB(forum.Description); #endregion #region 更新在线信息 OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forum.Name, -1, ""); if ((forumtotalonline < config.Maxonlinelist && (config.Whosonlinestatus == 2 || config.Whosonlinestatus == 3)) || DNTRequest.GetString("showonline") == "yes") { showforumonline = true; onlineuserlist = OnlineUsers.GetForumOnlineUserCollection(forumid, out forumtotalonline, out forumtotalonlineguest, out forumtotalonlineuser, out forumtotalonlineinvisibleuser); } //if (DNTRequest.GetString("showonline") != "no") //{ // showforumonline = false; //} if (DNTRequest.GetString("showonline") == "no") { showforumonline = false; } #endregion //修正版主列表 if (forum.Moderators.Trim() != "") { string moderHtml = string.Empty; foreach (string m in forum.Moderators.Split(',')) { moderHtml += string.Format("<a href=\"{0}userinfo.aspx?username={1}\">{2}</a>,", forumpath, Utils.UrlEncode(m), m); } forum.Moderators = moderHtml.TrimEnd(','); } ForumUtils.UpdateVisitedForumsOptions(forumid); }
/// <summary> /// 创建主题信息 /// </summary> /// <param name="admininfo"></param> /// <param name="postmessage"></param> /// <param name="isbonus"></param> /// <param name="topicprice"></param> /// <returns></returns> public TopicInfo CreateTopic(AdminGroupInfo admininfo, string postmessage, bool isbonus, int topicprice) { TopicInfo topicinfo = new TopicInfo(); topicinfo.Fid = forumid; topicinfo.Iconid = (DNTRequest.GetInt("iconid", 0) < 0 || DNTRequest.GetInt("iconid", 0) > 15) ? 0 : DNTRequest.GetInt("iconid", 0); message = Posts.GetPostMessage(usergroupinfo, admininfo, postmessage, (TypeConverter.StrToInt(DNTRequest.GetString("htmlon")) == 1)); topicinfo.Title = (useradminid == 1) ? Utils.HtmlEncode(posttitle) : Utils.HtmlEncode(ForumUtils.BanWordFilter(posttitle)); if (useradminid != 1 && (ForumUtils.HasBannedWord(posttitle) || ForumUtils.HasBannedWord(postmessage))) { string bannedWord = ForumUtils.GetBannedWord(posttitle) == string.Empty ? ForumUtils.GetBannedWord(postmessage) : ForumUtils.GetBannedWord(posttitle); AddErrLine(string.Format("对不起, 您提交的内容包含不良信息 <font color=\"red\">{0}</font>, 请返回修改!", bannedWord)); return(topicinfo); } if (Utils.GetCookie("lasttopictitle") == Utils.MD5(topicinfo.Title) || Utils.GetCookie("lasttopicmessage") == Utils.MD5(message)) { AddErrLine("请勿重复发帖"); return(topicinfo); } topicinfo.Typeid = DNTRequest.GetInt("typeid", 0); if (usergroupinfo.Allowsetreadperm == 1) { topicinfo.Readperm = DNTRequest.GetInt("topicreadperm", 0) > 255 ? 255 : DNTRequest.GetInt("topicreadperm", 0); } topicinfo.Price = topicprice; topicinfo.Poster = username; topicinfo.Posterid = userid; topicinfo.Postdatetime = curdatetime; topicinfo.Lastpost = curdatetime; topicinfo.Lastposter = username; topicinfo.Displayorder = Topics.GetTitleDisplayOrder(usergroupinfo, useradminid, forum, topicinfo, message, disablepost); string htmltitle = DNTRequest.GetString("htmltitle").Trim(); if (!Utils.StrIsNullOrEmpty(htmltitle) && Utils.HtmlDecode(htmltitle).Trim() != topicinfo.Title) { //按照 附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储 例: 11001 topicinfo.Magic = 11000; } //标签(Tag)操作 string tags = DNTRequest.GetString("tags").Trim(); string[] tagArray = null; if (enabletag && !Utils.StrIsNullOrEmpty(tags)) { if (ForumUtils.InBanWordArray(tags)) { AddErrLine("标签中含有系统禁止词语,请修改"); return(topicinfo); } tagArray = Utils.SplitString(tags, " ", true, 2, 10); if (tagArray.Length > 0 && tagArray.Length <= 5) { if (topicinfo.Magic == 0) { topicinfo.Magic = 10000; } topicinfo.Magic = Utils.StrToInt(topicinfo.Magic.ToString() + "1", 0); } else { AddErrLine("超过标签数的最大限制或单个标签长度没有介于2-10之间,最多可填写 5 个标签"); return(topicinfo); } } if (isbonus) { topicinfo.Special = 2; //检查积分是否足够 if (mybonustranscredits < topicprice && usergroupinfo.Radminid != 1) { AddErrLine(string.Format("无法进行悬赏<br /><br />您当前的{0}为 {1} {3}<br/>悬赏需要{0} {2} {3}", bonusextcreditsinfo.Name, mybonustranscredits, topicprice, bonusextcreditsinfo.Unit)); return(topicinfo); } else { Users.UpdateUserExtCredits(topicinfo.Posterid, Scoresets.GetBonusCreditsTrans(), -topicprice * (Scoresets.GetCreditsTax() + 1)); //计算税后的实际支付 } } if (type == "poll") { topicinfo.Special = 1; } if (type == "debate") //辩论帖 { topicinfo.Special = 4; } if (!Moderators.IsModer(useradminid, userid, forumid)) { topicinfo.Attention = 1; } if (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) { topicinfo.Hide = 1; } topicinfo.Tid = Topics.CreateTopic(topicinfo); //canhtmltitle = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup); //canhtmltitle = config.Htmltitle == 1 && usergroupinfo.Allowhtml == 1; //保存htmltitle if (canhtmltitle && !Utils.StrIsNullOrEmpty(htmltitle) && htmltitle != topicinfo.Title) { Topics.WriteHtmlTitleFile(Utils.RemoveUnsafeHtml(htmltitle), topicinfo.Tid); } if (enabletag && tagArray != null && tagArray.Length > 0) { if (useradminid != 1 && ForumUtils.HasBannedWord(tags)) { string bannedWord = ForumUtils.GetBannedWord(tags); AddErrLine(string.Format("标签中含有系统禁止词语 <font color=\"red\">{0}</font>,请修改", bannedWord)); return(topicinfo); } ForumTags.CreateTopicTags(tagArray, topicinfo.Tid, userid, curdatetime); } if (type == "debate") { DebateInfo debatetopic = new DebateInfo(); debatetopic.Tid = topicinfo.Tid; debatetopic.Positiveopinion = DNTRequest.GetString("positiveopinion"); debatetopic.Negativeopinion = DNTRequest.GetString("negativeopinion"); debatetopic.Terminaltime = Convert.ToDateTime(DNTRequest.GetString("terminaltime")); Topics.CreateDebateTopic(debatetopic); } Topics.AddParentForumTopics(forum.Parentidlist.Trim(), 1); return(topicinfo); }
protected override void ShowPage() { if (oluserinfo.Groupid == 4) { AddErrLine("你所在的用户组,为禁止发言"); return; } #region 临时帐号发帖 //int realuserid = -1; //bool tempaccountspost = false; //string tempusername = DNTRequest.GetString("tempusername"); //if (!Utils.StrIsNullOrEmpty(tempusername) && tempusername != username) //{ // realuserid = Users.CheckTempUserInfo(tempusername, DNTRequest.GetString("temppassword"), DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer")); // if (realuserid == -1) // { // AddErrLine("临时帐号登录失败,无法继续发帖。"); return; // } // else // { // userid = realuserid; // username = tempusername; // tempaccountspost = true; // } //} #endregion if (userid > 0) { userinfo = Users.GetShortUserInfo(userid); // if (userinfo != null) // { // usergroupinfo = UserGroups.GetUserGroupInfo(userinfo.Groupid); // usergroupid = usergroupinfo.Groupid; // useradminid = userinfo.Adminid; // } } #region 获取并检查版块信息 forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Layer == 0) { forum = new ForumInfo();//如果不初始化对象,则会报错 allowposttopic = false; AddErrLine("错误的论坛ID"); return; } pagetitle = Utils.RemoveHtml(forum.Name); enabletag = (config.Enabletag & forum.Allowtag) == 1; if (forum.Applytopictype == 1) //启用主题分类 { topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); } if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } needaudit = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo); smileyoff = 1 - forum.Allowsmilies; bbcodeoff = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1; allowimg = forum.Allowimgcode; customeditbuttons = Caches.GetCustomEditButtonList(); #endregion #region 访问和发帖权限校验 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = true; return; } if (!UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = true; return; } #endregion #region 附件信息绑定 //得到用户可以上传的文件类型 string attachmentTypeSelect = Attachments.GetAllowAttachmentType(usergroupinfo, forum); attachextensions = Attachments.GetAttachmentTypeArray(attachmentTypeSelect); attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect); //得到今天允许用户上传的附件总大小(字节) int MaxTodaySize = (userid > 0 ? MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid) : 0); attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;//今天可上传得大小 //是否有上传附件的权限 canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg); if (canpostattach && (userinfo != null && userinfo.Uid > 0) && apb != null && config.Enablealbum == 1 && (UserGroups.GetUserGroupInfo(userinfo.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } #endregion canhtmltitle = usergroupinfo.Allowhtmltitle == 1; #region 积分信息 creditstrans = Scoresets.GetTopicAttachCreditsTrans(); userextcreditsinfo = Scoresets.GetScoreSet(creditstrans); bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); #endregion #region 特殊主题权限判断 if (forum.Allowspecialonly > 0 && !Utils.InArray(type, "poll,bonus,debate")) { AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", forum.Name)); return; } if (!UserAuthority.PostSpecialAuthority(forum, type, ref msg)) { AddErrLine(msg); return; } if (!UserAuthority.PostSpecialAuthority(usergroupinfo, type, ref msg)) { AddErrLine(msg); needlogin = true; return; } if (type == "bonus") { int creditTrans = Scoresets.GetBonusCreditsTrans(); //当“交易积分设置”有效时(1-8的整数): if (creditTrans <= 0) { //AddErrLine(string.Format("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏", usergroupinfo.Grouptitle)); return; AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏"); return; } mybonustranscredits = Users.GetUserExtCredits(userid, creditTrans); } userGroupInfoList.Sort(delegate(UserGroupInfo x, UserGroupInfo y) { return((x.Readaccess - y.Readaccess) + (y.Groupid - x.Groupid)); }); #endregion //发帖不受审核、过滤、灌水等限制权限 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); disablepost = admininfo != null ? admininfo.Disablepostctrl : usergroupinfo.Disableperiodctrl; //如果是提交... if (ispost) { #region 判断是否是灌水 if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg)) { AddErrLine(msg); return; } #endregion SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", forumid, type)); ForumUtils.WriteCookie("postmessage", postmessage); #region 验证提交信息 //常规项验证 NormalValidate(admininfo, postmessage, userinfo); if (IsErr()) { return; } // 如果用户上传了附件,则检测用户是否有上传附件的权限 if (ForumUtils.IsPostFile()) { if (Utils.StrIsNullOrEmpty(Attachments.GetAttachmentTypeArray(attachmentTypeSelect))) { AddErrLine("系统不允许上传附件"); } if (!UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); } } //发悬赏校验 int topicprice = 0; bool isbonus = type == "bonus"; ValidateBonus(ref topicprice, ref isbonus); //发特殊主题校验 ValidatePollAndDebate(); if (IsErr()) { return; } #endregion int hide = (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) ? 1 : 0; TopicInfo topicinfo = CreateTopic(admininfo, postmessage, isbonus, topicprice); if (IsErr()) { return; } PostInfo postinfo = CreatePost(topicinfo); if (IsErr()) { return; } #region 处理附件 //处理附件 StringBuilder sb = new StringBuilder(); AttachmentInfo[] attachmentinfo = null; string attachId = DNTRequest.GetFormString("attachid"); if (!string.IsNullOrEmpty(attachId)) { attachmentinfo = Attachments.GetNoUsedAttachmentArray(userid, attachId); Attachments.UpdateAttachment(attachmentinfo, topicinfo.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo); } //加入相册 if (config.Enablealbum == 1 && apb != null) { sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username)); } #endregion #region 添加日志的操作 SpacePluginBase spb = SpacePluginProvider.GetInstance(); if (DNTRequest.GetFormString("addtoblog") == "on" && spb != null) { if (userid != -1 && userinfo.Spaceid > 0) { spb.CreateTopic(topicinfo, postinfo, attachmentinfo); } else { AddMsgLine("您的个人空间尚未开通, 无法同时添加为日志"); } } #endregion OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forum.Name, -1, ""); #region 设置提示信息和跳转链接 if (sb.Length > 0) { SetUrl(base.ShowTopicAspxRewrite(topicinfo.Tid, 0)); SetMetaRefresh(5); SetShowBackLink(true); if (infloat == 1) { AddErrLine(sb.ToString()); return; } else { sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表主题成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>"); AddMsgLine(sb.Append("</table>").ToString()); } } else { SetShowBackLink(false); if (useradminid != 1) { //是否需要审核 if (UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo) || topicinfo.Displayorder == -2) { ForumUtils.WriteCookie("postmessage", ""); SetLastPostedForumCookie(); SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid)); SetMetaRefresh(); AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块"); } else { PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid); } } else { PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid); } } #endregion //ForumUtils.WriteCookie("postmessage", ""); //SetLastPostedForumCookie(); //如果已登录就不需要再登录 if (needlogin && userid > 0) { needlogin = false; } } else //非提交操作 { AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); } }
protected override void ShowPage() { if (this.oluserinfo.GroupID == 4) { base.AddErrLine("你所在的用户组,为禁止发言"); return; } if (this.userid > 0) { this.userinfo = BBX.Entity.User.FindByID(this.userid); } if (HttpContext.Current.Request.RawUrl.Contains("javascript:")) { base.AddErrLine("非法的链接"); return; } this.forum = XForum.FindByID(forumid); if (this.forum == null || this.forum.Layer == 0) { this.forum = new XForum(); this.allowposttopic = false; base.AddErrLine("错误的论坛ID"); return; } this.pagetitle = Utils.RemoveHtml(this.forum.Name); this.enabletag = config.Enabletag && this.forum.AllowTag; if (this.forum.ApplytopicType == 1) { this.topictypeselectoptions = Forums.GetCurrentTopicTypesOption(this.forum.Fid, this.forum.TopicTypes); } if (!String.IsNullOrEmpty(this.forum.Password) && Utils.MD5(this.forum.Password) != ForumUtils.GetCookie("forum" + this.forumid + "password")) { base.AddErrLine("本版块被管理员设置了密码"); base.SetBackLink(base.ShowForumAspxRewrite(this.forumid, 0)); return; } this.needaudit = UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo); this.smileyoff = forum.AllowSmilies ? 0 : 1; this.bbcodeoff = ((this.forum.Allowbbcode == 1 && this.usergroupinfo.AllowCusbbCode) ? 0 : 1); //this.allowimg = this.forum.Allowimgcode; this.customeditbuttons = Caches.GetCustomEditButtonList(); if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg)) { base.AddErrLine(this.msg); this.needlogin = true; return; } if (!UserAuthority.PostAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg)) { base.AddErrLine(this.msg); this.needlogin = true; return; } //string allowAttachmentType = Attachments.GetAllowAttachmentType(this.usergroupinfo, this.forum); this.attachextensions = AttachType.GetAttachmentTypeArray(usergroupinfo, this.forum); this.attachextensionsnosize = AttachType.GetAttachmentTypeString(usergroupinfo, this.forum); int num = (this.userid > 0) ? Attachment.GetUploadFileSizeByuserid(this.userid) : 0; this.attachsize = this.usergroupinfo.MaxSizeperday - num; this.canpostattach = UserAuthority.PostAttachAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg); this.canhtmltitle = this.usergroupinfo.AllowHtmlTitle; this.creditstrans = Scoresets.GetTopicAttachCreditsTrans(); this.userextcreditsinfo = Scoresets.GetScoreSet(this.creditstrans); this.bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); if (this.forum.AllowSpecialOnly && !Utils.InArray(this.type, "poll,bonus,debate")) { base.AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", this.forum.Name)); return; } if (!UserAuthority.PostSpecialAuthority(this.forum, this.type, ref this.msg)) { base.AddErrLine(this.msg); return; } if (!UserAuthority.PostSpecialAuthority(this.usergroupinfo, this.type, ref this.msg)) { base.AddErrLine(this.msg); this.needlogin = true; return; } if (this.type == "bonus") { int bonusCreditsTrans = Scoresets.GetBonusCreditsTrans(); if (bonusCreditsTrans <= 0) { base.AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏"); return; } this.mybonustranscredits = Users.GetUserExtCredits(this.userid, bonusCreditsTrans); } this.userGroupInfoList.Sort((x, y) => x.Readaccess - y.Readaccess + (y.ID - x.ID)); var adminGroupInfo = AdminGroup.FindByID(this.usergroupid); this.disablepost = adminGroupInfo != null ? adminGroupInfo.DisablePostctrl : this.usergroupinfo.DisablePeriodctrl; if (this.ispost) { if (!UserAuthority.CheckPostTimeSpan(this.usergroupinfo, adminGroupInfo, this.oluserinfo, this.userinfo, ref this.msg)) { base.AddErrLine(this.msg); return; } base.SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", this.forumid, this.type)); ForumUtils.WriteCookie("postmessage", this.postmessage); this.NormalValidate(adminGroupInfo, this.postmessage, this.userinfo); if (base.IsErr()) { return; } if (ForumUtils.IsPostFile()) { if (Utils.StrIsNullOrEmpty(AttachType.GetAttachmentTypeArray(usergroupinfo, forum))) { base.AddErrLine("系统不允许上传附件"); } if (!UserAuthority.PostAttachAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg)) { base.AddErrLine(this.msg); } } int topicprice = 0; bool isbonus = this.type == "bonus"; this.ValidateBonus(ref topicprice, ref isbonus); this.ValidatePollAndDebate(); if (base.IsErr()) { return; } if (ForumUtils.IsHidePost(this.postmessage)) { int arg_5B2_0 = this.usergroupinfo.AllowHideCode ? 1 : 0; } var topicInfo = this.CreateTopic(adminGroupInfo, this.postmessage, isbonus, topicprice); if (base.IsErr()) { return; } //var postInfo = this.CreatePost(topicInfo); var postInfo = Post.FindByID(topicInfo.LastPostID); //if (base.IsErr()) //{ // return; //} var stringBuilder = new StringBuilder(); //AttachmentInfo[] array = null; string formString = DNTRequest.GetFormString("attachid"); if (!string.IsNullOrEmpty(formString)) { var array = Attachments.GetNoUsedAttachmentArray(this.userid, formString); Attachments.UpdateAttachment(array, topicInfo.ID, postInfo.ID, postInfo, ref stringBuilder, this.userid, this.config, this.usergroupinfo); } Online.UpdateAction(this.olid, UserAction.PostTopic, this.forumid, this.forum.Name, -1, ""); if (this.isbindconnect && this.feedstatus) { // 推送到QQ空间和微博 //PushFeed pushFeed = new PushFeed(); //pushFeed.TopicPushFeed(topicInfo, postInfo, array, this.feedstatus); } if (stringBuilder.Length > 0) { base.SetUrl(base.ShowTopicAspxRewrite(topicInfo.ID, 0)); base.SetMetaRefresh(5); base.SetShowBackLink(true); if (this.infloat == 1) { base.AddErrLine(stringBuilder.ToString()); return; } stringBuilder.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表主题成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>"); base.AddMsgLine(stringBuilder.Append("</table>").ToString()); } else { base.SetShowBackLink(false); if (this.useradminid != 1 && (UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo) || topicInfo.DisplayOrder == -2)) { ForumUtils.WriteCookie("postmessage", ""); this.SetLastPostedForumCookie(); base.SetUrl(base.ShowForumAspxRewrite(this.forumid, this.forumpageid)); base.SetMetaRefresh(); base.AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块"); } else { this.PostTopicSucceed(this.forum, topicInfo); } } if (this.needlogin && this.userid > 0) { this.needlogin = false; return; } } else { base.AddLinkCss(BaseConfigs.GetForumPath + "templates/" + this.templatepath + "/editor.css", "css"); } }
public Topic CreateTopic(AdminGroup admininfo, string postmessage, bool isbonus, int topicprice) { var tp = new Topic(); tp.Fid = this.forumid; var iconid = DNTRequest.GetInt("iconid", 0); if (iconid < 0 || iconid > 15) { iconid = 0; } tp.IconID = iconid; this.message = Posts.GetPostMessage(this.usergroupinfo, admininfo, postmessage, DNTRequest.GetInt("htmlon") == 1); tp.Title = ((this.useradminid == 1) ? Utils.HtmlEncode(this.posttitle) : Utils.HtmlEncode(ForumUtils.BanWordFilter(this.posttitle))); if (this.useradminid != 1 && (ForumUtils.HasBannedWord(this.posttitle) || ForumUtils.HasBannedWord(postmessage))) { string arg = (ForumUtils.GetBannedWord(this.posttitle) == string.Empty) ? ForumUtils.GetBannedWord(postmessage) : ForumUtils.GetBannedWord(this.posttitle); base.AddErrLine(string.Format("对不起, 您提交的内容包含不良信息 <font color=\"red\">{0}</font>, 请返回修改!", arg)); return(tp); } if (Utils.GetCookie("lasttopictitle") == Utils.MD5(tp.Title) || Utils.GetCookie("lasttopicmessage") == Utils.MD5(this.message)) { base.AddErrLine("请勿重复发帖"); return(tp); } tp.TypeID = DNTRequest.GetInt("typeid", 0); if (this.usergroupinfo.AllowSetreadPerm) { tp.ReadPerm = ((DNTRequest.GetInt("topicreadperm", 0) > 255) ? 255 : DNTRequest.GetInt("topicreadperm", 0)); } tp.Price = topicprice; //tp.Poster = this.username; //tp.Posterid = this.userid; //tp.Postdatetime = this.curdatetime; //tp.Lastpost = this.curdatetime; //tp.Lastposter = this.username; tp.DisplayOrder = Topics.GetTitleDisplayOrder(this.usergroupinfo, this.useradminid, this.forum, tp, this.message, this.disablepost); string text = DNTRequest.GetString("htmltitle").Trim(); if (!text.IsNullOrEmpty() && Utils.HtmlDecode(text).Trim() != tp.Title) { tp.Magic = 11000; } string text2 = DNTRequest.GetString("tags").Trim(); string[] array = null; if (this.enabletag && !text2.IsNullOrEmpty()) { if (ForumUtils.InBanWordArray(text2)) { base.AddErrLine("标签中含有系统禁止词语,请修改"); return(tp); } array = Utils.SplitString(text2, " ", true, 2, 10); if (array.Length <= 0 || array.Length > 5) { base.AddErrLine("超过标签数的最大限制或单个标签长度没有介于2-10之间,最多可填写 5 个标签"); return(tp); } if (tp.Magic == 0) { tp.Magic = 10000; } tp.Magic = (tp.Magic + "1").ToInt(); } if (isbonus) { tp.Special = 2; if (this.mybonustranscredits < (float)topicprice && !usergroupinfo.Is管理员) { base.AddErrLine(string.Format("无法进行悬赏<br /><br />您当前的{0}为 {1} {3}<br/>悬赏需要{0} {2} {3}", new object[] { this.bonusextcreditsinfo.Name, this.mybonustranscredits, topicprice, this.bonusextcreditsinfo.Unit })); return(tp); } BBX.Entity.User.UpdateUserExtCredits(userid, Scoresets.GetBonusCreditsTrans(), (float)(-(float)topicprice) * (Scoresets.GetCreditsTax() + 1f)); } if (this.type == "poll") { tp.Special = 1; } if (this.type == "debate") { tp.Special = 4; } if (!Moderators.IsModer(this.useradminid, this.userid, this.forumid)) { tp.Attention = 1; } if (ForumUtils.IsHidePost(postmessage) && this.usergroupinfo.AllowHideCode) { tp.Hide = 1; } //tp.Tid = Topics.CreateTopic(tp); //tp.Insert(); var postInfo = this.CreatePost(tp); tp.Create(postInfo); if (this.canhtmltitle && !text.IsNullOrEmpty() && text != tp.Title) { Topics.WriteHtmlTitleFile(Utils.RemoveUnsafeHtml(text), tp.ID); } if (this.enabletag && array != null && array.Length > 0) { if (this.useradminid != 1 && ForumUtils.HasBannedWord(text2)) { string bannedWord = ForumUtils.GetBannedWord(text2); base.AddErrLine(string.Format("标签中含有系统禁止词语 <font color=\"red\">{0}</font>,请修改", bannedWord)); return(tp); } Tag.CreateTopicTags(array, tp.ID, this.userid, DateTime.Now.ToFullString()); } if (this.type == "debate") { var db = new Debate(); db.Tid = tp.ID; db.PositiveOpinion = DNTRequest.GetString("positiveopinion"); db.NegativeOpinion = DNTRequest.GetString("negativeopinion"); db.TerminalTime = Request["terminaltime"].ToDateTime(); db.Insert(); //Topics.CreateDebateTopic(new DebateInfo //{ // Tid = tp.ID, // Positiveopinion = DNTRequest.GetString("positiveopinion"), // Negativeopinion = DNTRequest.GetString("negativeopinion"), // Terminaltime = Convert.ToDateTime(DNTRequest.GetString("terminaltime")) //}); } //Topics.AddParentForumTopics(this.forum.Parentidlist.Trim(), 1); //// 所有上级论坛帖子数增加 //var ff = forum; //while (ff != null && ff.ID != 0) //{ // ff.Topics++; // ff.Save(); // ff = ff.Parent; //} return(tp); }
protected override void ShowPage() { this.GetPostAds(this.forumid); if (this.userid > 0 && this.useradminid > 0) { var adminGroupInfo = AdminGroup.FindByID(this.usergroupid); if (adminGroupInfo != null) { this.disablepostctrl = adminGroupInfo.DisablePostctrl; } } if (this.forumid == -1) { base.AddLinkRss(this.forumpath + "tools/rss.aspx", "最新主题"); base.AddErrLine("无效的版块ID"); return; } this.forum = Forums.GetForumInfo(this.forumid); if (this.forum == null || this.forum.Fid < 1) { if (this.config.Rssstatus == 1) { base.AddLinkRss(this.forumpath + "tools/rss.aspx", Utils.EncodeHtml(this.config.Forumtitle) + " 最新主题"); } base.AddErrLine("不存在的版块ID"); return; } if (this.config.Rssstatus == 1) { base.AddLinkRss(this.forumpath + "tools/" + Urls.RssAspxRewrite(this.forum.Fid), Utils.EncodeHtml(this.forum.Name) + " 最新主题"); } if (this.JumpUrl(this.forum)) { return; } this.needaudit = UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo); if (this.useradminid > 0) { this.ismoder = Moderators.IsModer(this.useradminid, this.userid, this.forumid); } //this.SetSearchCondition(); this.showforumlogin = this.IsShowForumLogin(this.forum); this.pagetitle = Utils.RemoveHtml(this.forum.Name); this.navhomemenu = Caches.GetForumListMenuDivCache(this.usergroupid, this.userid, this.config.Extname); this.forumnav = base.ShowForumAspxRewrite(ForumUtils.UpdatePathListExtname(this.forum.Pathlist.Trim(), this.config.Extname).Replace("\"showforum", "\"" + this.forumurl + "showforum"), this.forumid, this.pageid); this.topicextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); this.bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); if (this.forum.ApplytopicType == 1) { this.topictypeselectoptions = Forums.GetCurrentTopicTypesOption(this.forum.Fid, this.forum.Topictypes); } if (this.forum.ApplytopicType == 1) { this.topictypeselectlink = Forums.GetCurrentTopicTypesLink(this.forum.Fid, this.forum.Topictypes, this.forumurl + "showforum.aspx"); } meta = PageHelper.UpdateMetaInfo(meta, this.forum.Seokeywords.IsNullOrEmpty() ? this.config.Seokeywords : this.forum.Seokeywords, this.forum.Seodescription.IsNullOrEmpty() ? this.forum.Description : this.forum.Seodescription, this.config.Seohead); this.SetEditorState(); if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg)) { base.AddErrLine(this.msg); this.needlogin = (this.userid == -1); return; } this.canposttopic = UserAuthority.PostAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg); if (this.useradminid != 1 && !this.usergroupinfo.DisablePeriodctrl) { string text = ""; if (this.canposttopic && Scoresets.BetweenTime(this.config.Postbanperiods, out text)) { this.canposttopic = false; } this.isnewbie = UserAuthority.CheckNewbieSpan(this.userid); } if ((this.config.Fastpost == 1 || this.config.Fastpost == 3) && !this.forum.AllowSpecialOnly && (this.userid < 0 || (this.canposttopic && !this.isnewbie))) { this.canquickpost = true; } if ((forum as XForum).Childs.Count > 0) { this.subforumlist = Forums.GetSubForumCollection(this.forumid, this.forum.ColCount, this.config.Hideprivate, this.usergroupid, this.config.Moddisplay); } if (!this.forum.Rules.IsNullOrWhiteSpace()) { this.forum.Rules = UBB.ParseSimpleUBB(this.forum.Rules); } // 满足条件的主题数 this.topiccount = Topic.SearchCount(forumid, topictypeid, interval, filter); if (tpp <= 0) { tpp = this.config.Tpp; } if (this.ppp <= 0) { this.ppp = this.config.Ppp; } if (this.pageid < 1) { this.pageid = 1; } // 内层板块,需要显示主题列表 if (this.forum.Layer > 0) { // 置顶主题列表 var tops = Topic.GetTop(forumid); if (tops.Count > 0) { // 加上非本板块的主题数 topiccount += tops.Count(e => e.Fid != forumid); } // 根据主题总数计算分页 //pagecount = ((topiccount % tpp == 0) ? (topiccount / tpp) : (topiccount / tpp + 1)); pagecount = topiccount / tpp; if (topiccount % tpp > 0) { pagecount++; } if (pagecount == 0) { pagecount = 1; } if (pageid > pagecount) { pageid = pagecount; } // 如果有置顶主题,则先读取置顶主题,再读取部分普通主题以填满一页 if (tops.Count > 0) { // 置顶主题数 var toptopiccount = tops.Count; // 置顶主题构成的完整页数,不包括半截 int topPageCount = toptopiccount / tpp; // 置顶主题可能满好几页,如果分到当前页还有主题,则需要处理 if (toptopiccount > tpp * (pageid - 1)) { // 取出本页所属的置顶主题 toptopiclist = Topics.GetTopTopicList(tops, tpp, pageid, forum.AutoClose, forum.Topictypeprefix); if (toptopiclist.Count < tpp) { // 本页有一部分置顶主题,要注意计算本页普通主题的数量(总页大小-置顶帖在本页的大小),开始行很简单从0开始即可(因为是第一页普通主题) topiclist = GetTopicInfoList(tpp - toptopiclist.Count, pageid - topPageCount, 0); } } else { // 已经没有置顶主题,取满一页普通主题,注意开始行的计算 topiclist = GetTopicInfoList(tpp, pageid - topPageCount, toptopiccount % tpp); } } else { // 如果没有置顶主题,则直接读取一页普通主题 topiclist = GetTopicInfoList(tpp, pageid, 0); } // 如果没有主题,或者实际主题列表大于主题总数,那么更新论坛的主题数 // 在XCode支持下,即使有缓存,这种可能性也很小很小 if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount) { XForum.SetRealCurrentTopics(this.forum.Fid); } this.SetPageNumber(); var vs = visitedforums; this.showvisitedforumsmenu = (vs != null && ((vs.Length == 1 && vs[0].Fid != forumid) || vs.Length > 1)); this.SetVisitedForumsCookie(); Utils.WriteCookie("forumpageid", this.pageid.ToString(), 30); this.IsGuestCachePage(); } this.forum.Description = UBB.ParseSimpleUBB(this.forum.Description); Online.UpdateAction(this.olid, UserAction.ShowForum, this.forumid, this.forum.Name, -1, ""); if ((this.forumtotalonline < this.config.Maxonlinelist && (this.config.Whosonlinestatus == 2 || this.config.Whosonlinestatus == 3)) || DNTRequest.GetString("showonline") == "yes") { this.showforumonline = true; this.onlineuserlist = Online.GetList(this.forumid, Online._.UserID, true); var st = Online.GetStat(); this.forumtotalonline = st.Total; this.forumtotalonlineuser = st.User; this.forumtotalonlineinvisibleuser = st.Invisible; this.forumtotalonlineguest = st.Guest; } if (DNTRequest.GetString("showonline") == "no") { this.showforumonline = false; } // 这里会导致版主列表不断增大,直到最后内存溢出,临时解决 if (!forum.Moderators.IsNullOrWhiteSpace() && (forum.ModeratorsHtml.IsNullOrWhiteSpace() || !forum.ModeratorsHtml.Contains("href"))) { string text2 = string.Empty; string[] array = this.forum.Moderators.Split(','); for (int i = 0; i < array.Length; i++) { text2 += string.Format("<a href=\"{0}userinfo.aspx?username={1}\">{2}</a>,", this.forumpath, Utils.UrlEncode(array[i]), array[i]); } this.forum.ModeratorsHtml = text2.TrimEnd(','); } ForumUtils.UpdateVisitedForumsOptions(this.forumid); }