/// <summary> /// 发送回复通知 /// </summary> /// <param name="postinfo">回复信息</param> /// <param name="topicinfo">所属主题信息</param> /// <param name="replyuserid">回复的某一楼的作者</param> public static void SendPostReplyNotice(PostInfo postinfo, TopicInfo topicinfo, int replyuserid) { NoticeInfo noticeinfo = new NoticeInfo(); noticeinfo.Note = Utils.HtmlEncode(string.Format("<a href=\"userinfo.aspx?userid={0}\">{1}</a> 给您回帖, <a href =\"showtopic.aspx?topicid={2}&postid={3}#{3}\">{4}</a>.", postinfo.Posterid, postinfo.Poster, topicinfo.Tid, postinfo.Pid, topicinfo.Title)); noticeinfo.Type = NoticeType.PostReplyNotice; noticeinfo.New = 1; noticeinfo.Posterid = postinfo.Posterid; noticeinfo.Poster = postinfo.Poster; noticeinfo.Postdatetime = Utils.GetDateTime(); noticeinfo.Fromid = topicinfo.Tid; noticeinfo.Uid = replyuserid; //当回复人与帖子作者不是同一人时,则向帖子作者发送通知 if (postinfo.Posterid != replyuserid && replyuserid > 0) { Notices.CreateNoticeInfo(noticeinfo); } //当上面通知的用户与该主题作者不同,则还要向主题作者发通知 if (postinfo.Posterid != topicinfo.Posterid && topicinfo.Posterid != replyuserid && topicinfo.Posterid > 0) { noticeinfo.Uid = topicinfo.Posterid; Notices.CreateNoticeInfo(noticeinfo); } }
/// <summary> /// 创建新主题 /// </summary> /// <param name="originalTopicInfo">主题信息</param> /// <returns>返回主题ID</returns> public static int CreateTopic(TopicInfo topicinfo) { lock (lockHelper) { return (topicinfo != null ? Data.Topics.CreateTopic(topicinfo) : 0); } }
/// <summary> /// 结束悬赏并给分 /// </summary> /// <param name="topicinfo">主题信息</param> /// <param name="userid">当前执行此操作的用户Id</param> /// <param name="postIdArray">帖子Id数组</param> /// <param name="winerIdArray">获奖者Id数组</param> /// <param name="winnerNameArray">获奖者的用户名数组</param> /// <param name="costBonusArray">奖励积分数组</param> /// <param name="valuableAnswerArray">有价值答案的pid数组</param> /// <param name="bestAnswer">最佳答案的pid</param> public static void CloseBonus(TopicInfo topicinfo, int userid, int[] postIdArray, int[] winerIdArray, string[] winnerNameArray, string[] costBonusArray, string[] valuableAnswerArray, int bestAnswer) { topicinfo.Special = 3; Topics.UpdateSpecial(topicinfo);//更新标志位为已结帖状态 //开始给分和记录 int winerId = 0, isbest = 0, postid = 0, bonus=0; string winnerName = string.Empty; for (int i = 0; i < winerIdArray.Length; i++) { winerId = winerIdArray[i]; bonus = Utils.StrToInt(costBonusArray[i], 0); winnerName = winnerNameArray[i]; postid = postIdArray[i]; if (winerId > 0 && bonus > 0) { Users.UpdateUserExtCredits(winerId, Scoresets.GetCreditsTrans(), bonus); } if (Utils.InArray(postid.ToString(), valuableAnswerArray)) { isbest = 1; } if (postid == bestAnswer) { isbest = 2; } AddLog(topicinfo.Tid, topicinfo.Posterid, winerId, winnerName, postid, bonus, isbest); } }
/// <summary> /// 创建新主题 /// </summary> /// <param name="topicInfo">主题信息</param> /// <returns>返回主题ID</returns> public static int CreateTopic(TopicInfo topicInfo) { topicInfo.Tid = DatabaseProvider.GetInstance().CreateTopic(topicInfo); if (appDBCache) ITopicService.CreateTopic(topicInfo); return topicInfo.Tid; }
/// <summary> /// /// </summary> /// <param name="topicinfo"></param> /// <returns></returns> public static bool UpdateTopicAllInfo(TopicInfo topicinfo) { try { Topics.UpdateTopic(topicinfo); return true; } catch { return false; } }
protected override void OnTopicCreated(TopicInfo topic, PostInfo post, AttachmentInfo[] attachs) { SpacePostInfo spacepost = new SpacePostInfo(); spacepost.Author = post.Poster; string content = Posts.GetPostMessageHTML(post, attachs); spacepost.Category = ""; spacepost.Content = content; spacepost.Postdatetime = DateTime.Now; spacepost.PostStatus = 1; spacepost.PostUpDateTime = DateTime.Now; spacepost.Title = post.Title; spacepost.Uid = post.Posterid; DbProvider.GetInstance().AddSpacePost(spacepost); }
/// <summary> /// 根据主题的Tag获取相关主题(游客可见级别的) /// </summary> /// <param name="topicid">主题Id</param> /// <returns></returns> public static Discuz.Common.Generic.List<TopicInfo> GetRelatedTopicList(int topicId, int count) { IDataReader reader = DatabaseProvider.GetInstance().GetRelatedTopics(topicId, count); Discuz.Common.Generic.List<TopicInfo> topics = new Discuz.Common.Generic.List<TopicInfo>(); while (reader.Read()) { TopicInfo topic = new TopicInfo(); topic.Tid = TypeConverter.ObjectToInt(reader["linktid"]); topic.Title = reader["linktitle"].ToString(); topics.Add(topic); } reader.Close(); return topics; }
/// <summary> /// 结束悬赏并给分 /// </summary> /// <param name="topicinfo">主题信息</param> /// <param name="userid">当前执行此操作的用户Id</param> /// <param name="postIdArray">帖子Id数组</param> /// <param name="winerIdArray">获奖者Id数组</param> /// <param name="winnerNameArray">获奖者的用户名数组</param> /// <param name="costBonusArray">奖励积分数组</param> /// <param name="valuableAnswerArray">有价值答案的pid数组</param> /// <param name="bestAnswer">最佳答案的pid</param> public static void CloseBonus(TopicInfo topicinfo, int userid, int[] postIdArray, int[] winerIdArray, string[] winnerNameArray, string[] costBonusArray, string[] valuableAnswerArray, int bestAnswer) { int isbest = 0, bonus = 0; topicinfo.Special = 3;//标示为悬赏主题 Topics.UpdateTopic(topicinfo);//更新标志位为已结帖状态 //开始给分和记录 for (int i = 0; i < winerIdArray.Length; i++) { bonus = TypeConverter.StrToInt(costBonusArray[i]); if (winerIdArray[i] > 0 && bonus > 0) Users.UpdateUserExtCredits(winerIdArray[i], Scoresets.GetBonusCreditsTrans(), bonus); if (Utils.InArray(postIdArray[i].ToString(), valuableAnswerArray)) isbest = 1; if (postIdArray[i] == bestAnswer) isbest = 2; Discuz.Data.Bonus.AddLog(topicinfo.Tid, topicinfo.Posterid, winerIdArray[i], winnerNameArray[i], postIdArray[i], bonus, Scoresets.GetBonusCreditsTrans(), isbest); } }
public static bool PostReply(ForumInfo forum, int userid, UserGroupInfo usergroupinfo, TopicInfo topic) { bool canreply = (usergroupinfo.Radminid == 1); //是否有回复的权限 if (topic.Closed == 0) { if (userid > -1 && Forums.AllowReplyByUserID(forum.Permuserlist, userid)) { canreply = true; } else { if (Utils.StrIsNullOrEmpty(forum.Replyperm)) //权限设置为空时,根据用户组权限判断 { // 验证用户是否有发表主题的权限 if (usergroupinfo.Allowreply == 1) canreply = true; } else if (Forums.AllowReply(forum.Replyperm, usergroupinfo.Groupid)) canreply = true; } } return canreply; }
/// <summary> /// 发回复是否需要审核 /// </summary> /// <param name="forum">主题所在的版块</param> /// <param name="useradminid">用户的管理组ID</param> ///<param name="topicInfo">所回复的主题信息</param> /// <param name="userid">用户ID</param> /// <param name="disablepost">是否受灌水限制</param> /// <returns>true需要审核;false不需要审核</returns> public static bool NeedAudit(ForumInfo forum, int useradminid, TopicInfo topicInfo, int userid, int disablepost, UserGroupInfo userGroup) { if (useradminid == 1 || Moderators.IsModer(useradminid, userid, forum.Fid)) return false; if (Scoresets.BetweenTime(GeneralConfigs.GetConfig().Postmodperiods)) return true; if (forum.Modnewposts == 1 || userGroup.ModNewPosts == 1) return true; else if (topicInfo.Displayorder == -2) return true; return false; //bool needaudit = false; //是否需要审核 //if (Scoresets.BetweenTime(GeneralConfigs.GetConfig().Postmodperiods)) //{ // needaudit = true; //} //else //{ // if (forum.Modnewposts == 1 && useradminid != 1) // { // if (useradminid > 1) // { // if (disablepost == 1 && topicInfo.Displayorder != -2) // { // if (useradminid == 3 && !Moderators.IsModer(useradminid, userid, forum.Fid)) // needaudit = true; // } // else // needaudit = true; // } // else // needaudit = true; // } // else if (userGroup.ModNewPosts == 1 && !Moderators.IsModer(useradminid, userid, forum.Fid) && useradminid != 1) // needaudit = true; // else if (useradminid != 1 && topicInfo.Displayorder == -2) // needaudit = true; //} //return needaudit; }
protected override void ShowPage() { if (topicid == -1) { AddErrLine("无效的主题ID"); return; } topic = Topics.GetTopicInfo(topicid); if (topic == null) { AddErrLine("不存在的主题ID"); return; } topictitle = Utils.StrIsNullOrEmpty(topic.Title) ? "" : topic.Title; forumid = topic.Fid; ForumInfo forum = Forums.GetForumInfo(forumid); pagetitle = Utils.RemoveHtml(forum.Name); forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); if (topic.Special != 1) { AddErrLine("不存在的投票ID"); return; } if (usergroupinfo.Allowvote != 1) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有投票的权限"); return; } if (Convert.ToDateTime(Polls.GetPollEnddatetime(topic.Tid)).Date < DateTime.Today) { AddErrLine("投票已经过期"); return; } if (userid != -1 && !Polls.AllowVote(topicid, username)) { AddErrLine("你已经投过票"); return; } else if (Utils.InArray(topic.Tid.ToString(), ForumUtils.GetCookie("dnt_polled"))) { AddErrLine("你已经投过票"); return; } //当未选择任何投票项时 if(Utils.StrIsNullOrEmpty(DNTRequest.GetString("pollitemid"))) { AddErrLine("您未选择任何投票项!"); return; } if (DNTRequest.GetString("pollitemid").Split(',').Length > Polls.GetPollInfo(topicid).Maxchoices) { AddErrLine("您的投票项多于最大投票数"); return; } if (Polls.UpdatePoll(topicid, DNTRequest.GetString("pollitemid"), userid == -1 ? string.Format("{0} [{1}]", usergroupinfo.Grouptitle, DNTRequest.GetIP()) : username) < 0) { AddErrLine("提交投票信息中包括非法内容"); return; } if (userid == -1) ForumUtils.WriteCookie("dnt_polled", string.Format("{0},{1}", (userid != -1 ? "" : ForumUtils.GetCookie("dnt_polled")), topic.Tid)); SetUrl(base.ShowTopicAspxRewrite(topicid, 0)); SetMetaRefresh(); SetShowBackLink(false); MsgForward("poll_succeed"); AddMsgLine("投票成功, 返回主题"); CreditsFacade.Vote(userid); // 删除主题游客缓存 ForumUtils.DeleteTopicCacheFile(topicid); }
/// <summary> /// 发帖成功 /// </summary> /// <param name="values">版块积分设置</param> /// <param name="topicinfo">主题信息</param> /// <param name="topicid">主题ID</param> private void PostTopicSucceed(float[] values, TopicInfo topicinfo, int topicid) { if (values != null) ///使用版块内积分 UserCredits.UpdateUserExtCredits(userid, values); else ///使用默认积分 UserCredits.UpdateUserCreditsByPostTopic(userid); //当使用伪aspx if (config.Aspxrewrite == 1) SetUrl(topicinfo.Special == 4 ? ShowDebateAspxRewrite(topicid) : ShowTopicAspxRewrite(topicid, 0)); else SetUrl((topicinfo.Special == 4 ? ShowDebateAspxRewrite(topicid) : ShowTopicAspxRewrite(topicid, 0)) + "&forumpage=" + forumpageid); SetMetaRefresh(); AddMsgLine("发表主题成功, 返回该主题<br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, forumpageid) + "\">点击这里返回 " + forum.Name + "</a>)<br />"); }
public int UpdateTopic(int tid, TopicInfo __topicinfo) { IDataParameter[] prams = { DbHelper.MakeInParam("@tid", (DbType)SqlDbType.Int, 4, tid), DbHelper.MakeInParam("@lastpostid", (DbType)SqlDbType.Int, 4, __topicinfo.Lastpostid), DbHelper.MakeInParam("@lastposterid", (DbType)SqlDbType.Int, 4, __topicinfo.Lastposterid), DbHelper.MakeInParam("@lastpost", (DbType)SqlDbType.DateTime, 8, DateTime.Parse(__topicinfo.Lastpost)), DbHelper.MakeInParam("@lastposter", (DbType)SqlDbType.NChar, 20, __topicinfo.Lastposter), DbHelper.MakeInParam("@replies", (DbType)SqlDbType.Int, 4, __topicinfo.Replies) }; return DbHelper.ExecuteNonQuery(CommandType.Text, "UPDATE [" + BaseConfigs.GetTablePrefix + "topics] SET [lastpostid] = @lastpostid,[lastposterid] = @lastposterid, [lastpost] = @lastpost, [lastposter] = @lastposter, [replies] = [replies] + @replies WHERE [tid] = @tid", prams); }
protected override void ShowPage() { // 获取主题ID topicid = DNTRequest.GetInt("topicid", -1); forumnav = ""; // 如果主题ID非数字 if (topicid == -1) { AddErrLine("无效的主题ID"); return; } // 获取该主题的信息 topic = Topics.GetTopicInfo(topicid); // 如果该主题不存在 if (topic == null) { AddErrLine("不存在的主题ID"); return; } topictitle = topic.Title; forumid = topic.Fid; ForumInfo forum = Forums.GetForumInfo(forumid); forumname = forum.Name; pagetitle = Utils.RemoveHtml(forum.Name); forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); if (topic.Special != 1) { AddErrLine("不存在的投票ID"); return; } if (usergroupinfo.Allowvote != 1) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有投票的权限"); return; } if (Convert.ToDateTime(Polls.GetPollEnddatetime(topic.Tid)).Date < DateTime.Today) { AddErrLine("投票已经过期"); return; } string polled = string.Empty; if (userid != -1) { if (!Polls.AllowVote(topicid, username)) { AddErrLine("你已经投过票"); return; } } else { //写cookie polled = ForumUtils.GetCookie(POLLED_COOKIENAME); if (Utils.InArray(topic.Tid.ToString(), polled)) { AddErrLine("你已经投过票"); return; } } //当未选择任何投票项时 if(Utils.StrIsNullOrEmpty(DNTRequest.GetString("pollitemid"))) { AddErrLine("您未选择任何投票项!"); return; } if (Polls.UpdatePoll(topicid, DNTRequest.GetString("pollitemid"), userid == -1 ? string.Format("{0} [{1}]", usergroupinfo.Grouptitle, DNTRequest.GetIP()) : username) < 0) { AddErrLine("提交投票信息中包括非法内容"); return; } if (userid == -1) { ForumUtils.WriteCookie(POLLED_COOKIENAME, string.Format("{0},{1}", polled, topic.Tid)); } SetUrl(base.ShowTopicAspxRewrite(topicid, 0)); SetMetaRefresh(); SetShowBackLink(false); if (userid != -1) { UserCredits.UpdateUserCreditsByVotepoll(userid); } // 删除主题游客缓存 ForumUtils.DeleteTopicCacheFile(topicid); AddMsgLine("投票成功, 返回主题"); }
/// <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(DNTRequest.GetString("title")) : Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title"))); if (useradminid != 1 && (ForumUtils.HasBannedWord(topicinfo.Title) || ForumUtils.HasBannedWord(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); //保存htmltitle if (canhtmltitle && !Utils.StrIsNullOrEmpty(htmltitle) && htmltitle != topicinfo.Title) Topics.WriteHtmlTitleFile(htmltitle, topicinfo.Tid); if (enabletag && tagArray != null && tagArray.Length > 0) { if (ForumUtils.HasBannedWord(tags)) { AddErrLine("标签中含有系统禁止词语,请修改"); 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, 1); return topicinfo; }
/// <summary> /// 获取主题价格 /// </summary> /// <param name="topicInfo"></param> /// <returns></returns> public int GetTopicPrice(TopicInfo topicInfo) { int price = 0; if (topicInfo.Special == 0)//普通主题 { //购买帖子操作 //判断是否为购买可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买 if (topicInfo.Price > 0 && userid != topicInfo.Posterid && ismoder != 1) { price = topicInfo.Price; //时间乘以-1是因为当Configs.GetMaxChargeSpan()==0时,帖子始终为购买帖 if (PaymentLogs.IsBuyer(topicInfo.Tid, userid) || (Utils.StrDateDiffHours(topicInfo.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 && Scoresets.GetMaxChargeSpan() != 0)) //判断当前用户是否已经购买 { price = -1; } } } return price; }
/// <summary> /// 发帖成功 /// </summary> /// <param name="values">版块积分设置</param> /// <param name="topicinfo">主题信息</param> private void PostTopicSucceed(ForumInfo forum, TopicInfo topicinfo) { CreditsFacade.PostTopic(userid, forum, true); int topicid = topicinfo.Tid; //当使用伪aspx if (config.Aspxrewrite == 1) SetUrl(ShowTopicAspxRewrite(topicid, 0)); else SetUrl((ShowTopicAspxRewrite(topicid, 0)) + "&forumpage=" + forumpageid); ForumUtils.WriteCookie("postmessage", ""); ForumUtils.WriteCookie("clearUserdata", "forum"); SetLastPostedForumCookie(); SetMetaRefresh(); MsgForward("posttopic_succeed"); AddMsgLine("发表主题成功, 返回该主题<br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, forumpageid) + "\">点击这里返回 " + forum.Name + "</a>)<br />"); //通知应用有新主题 Sync.NewTopic(topicid.ToString(), topicinfo.Title, topicinfo.Poster, topicinfo.Posterid.ToString(), topicinfo.Fid.ToString(), ""); }
protected override void ShowPage() { if (postid == -1) { AddErrLine("无效的帖子ID"); return; } // 获取该帖子的信息 post = Posts.GetPostInfo(topicid, postid); if (post == null) { AddErrLine("不存在的帖子ID"); return; } // 获取该主题的信息 topic = Topics.GetTopicInfo(topicid); if (topic == null) { AddErrLine("不存在的主题ID"); return; } if (topicid != post.Tid) { AddErrLine("主题ID无效"); return; } topictitle = topic.Title; forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); forumname = forum.Name; pagetitle = string.Format("删除{0}", post.Title); forumnav = ShowForumAspxRewrite(forum.Pathlist.Trim(), forumid, forumpageid); if (!CheckPermission(post,DNTRequest.GetInt("opinion", -1))) return; if (!allowDelPost) { AddErrLine("当前不允许删帖"); return; } // 通过验证的用户可以删除帖子,如果是主题帖则另处理 if (post.Layer == 0) { TopicAdmins.DeleteTopics(topicid.ToString(), byte.Parse(forum.Recyclebin.ToString()), false); //重新统计论坛帖数 Forums.SetRealCurrentTopics(forum.Fid); ForumTags.DeleteTopicTags(topicid); } else { int reval; if (topic.Special == 4) { if (DNTRequest.GetInt("opinion", -1) != 1 && DNTRequest.GetInt("opinion", -1) != 2) { AddErrLine("参数错误"); return; } reval = Posts.DeletePost(Posts.GetPostTableId(topicid), postid, false, true); Debates.DeleteDebatePost(topicid, DNTRequest.GetInt("opinion", -1), postid); } else reval = Posts.DeletePost(Posts.GetPostTableId(topicid), postid, false, true); Posts.RemoveShowTopicCache(topicid.ToString()); // 删除主题游客缓存 ForumUtils.DeleteTopicCacheFile(topicid); //再次确保回复数精确 Topics.UpdateTopicReplyCount(topic.Tid); //更新指定版块的最新发帖数信息 Forums.UpdateLastPost(forum); if (reval > 0 && Utils.StrDateDiffHours(post.Postdatetime, config.Losslessdel * 24) < 0) UserCredits.UpdateUserCreditsByPosts(post.Posterid, -1); } SetUrl(post.Layer == 0 ? base.ShowForumAspxRewrite(post.Fid, 0) : Urls.ShowTopicAspxRewrite(post.Tid, 1)); SetMetaRefresh(); SetShowBackLink(false); AddMsgLine("删除帖子成功, 返回主题"); }
/// <summary> /// 绑定操作的标题 /// </summary> /// <returns></returns> private bool BindTitle() { switch (operation) { case "split": { #region 分割主题 operationtitle = "分割主题"; if (Utils.StrToInt(topiclist, 0) <= 0) { AddErrLine(string.Format("您的身份 \"{0}\" 没有分割主题的权限.", usergroupinfo.Grouptitle)); return false; } postlist = Posts.GetPostListTitle(Utils.StrToInt(topiclist, 0)); if (postlist != null && postlist.Rows.Count > 0) { postlist.Rows[0].Delete(); postlist.AcceptChanges(); } break; #endregion } case "rate": { #region 评分 operationtitle = "参与评分"; if (!CheckRatePermission()) return false; string repost = TopicAdmins.CheckRateState(postidlist, userid); if (config.Dupkarmarate != 1 && !repost.Equals("") && RateIsReady != 1) { AddErrLine("对不起,您不能对同一个帖子重复评分."); return false; } scorelist = UserGroups.GroupParticipateScore(userid, usergroupid); if (scorelist.Rows.Count < 1) { AddErrLine(string.Format("您的身份 \"{0}\" 没有设置评分范围或者今日可用评分已经用完", usergroupinfo.Grouptitle)); return false; } PostInfo postinfo = Posts.GetPostInfo(TypeConverter.StrToInt(topiclist), TypeConverter.StrToInt(postidlist)); if (postinfo == null) { AddErrLine("您没有选择要评分的帖子."); return false; } poster = postinfo.Poster; if (postinfo.Posterid == userid) { AddErrLine("您不能对自已的帖子评分."); return false; } title = postinfo.Title; topiclist = postinfo.Tid.ToString(); break; #endregion } case "cancelrate": { #region 取消评分 operationtitle = "撤销评分"; PostInfo postinfo = Posts.GetPostInfo(Utils.StrToInt(topiclist, 0), Utils.StrToInt(postidlist, 0)); if (postinfo == null) { AddErrLine("您没有选择要撤消评分的帖子"); return false; } if (!ismoder) { AddErrLine("您的身份 \"" + usergroupinfo.Grouptitle + "\" 没有撤消评分的权限."); return false; } poster = postinfo.Poster; title = postinfo.Title; topiclist = postinfo.Tid.ToString(); ratelogcount = AdminRateLogs.RecordCount("pid = " + postidlist); ratelog = AdminRateLogs.LogList(ratelogcount, 1, "pid = " + postidlist); ratelog.Columns.Add("extcreditname", Type.GetType("System.String")); DataTable scorePaySet = Scoresets.GetScoreSet(); //绑定积分名称属性 foreach (DataRow dr in ratelog.Rows) { int extcredits = Utils.StrToInt(dr["extcredits"].ToString(), 0); if ((extcredits > 0) && (extcredits < 9) || scorePaySet.Columns.Count > extcredits + 1) dr["extcreditname"] = scorePaySet.Rows[0][extcredits + 1].ToString(); else dr["extcreditname"] = ""; } break; #endregion } case "bonus": { #region 悬赏 operationtitle = "结帖"; int tid = Utils.StrToInt(topiclist, 0); postlist = Posts.GetPostListTitle(tid); if (postlist != null) { if (postlist.Rows.Count > 0) { postlist.Rows[0].Delete(); postlist.AcceptChanges(); } } if (postlist.Rows.Count == 0) { AddErrLine("无法对没有回复的悬赏进行结帖."); return false; } topicinfo = Topics.GetTopicInfo(tid); if (topicinfo.Special == 3) { AddErrLine("本主题的悬赏已经结束."); return false; } break; #endregion } case "delete": operationtitle = "删除主题"; break; case "move": operationtitle = "移动主题"; break; case "type": operationtitle = "主题分类"; break; case "highlight": operationtitle = "高亮显示"; break; case "close": operationtitle = "关闭/打开主题"; break; case "displayorder": operationtitle = "置顶/解除置顶"; break; case "digest": operationtitle = "加入/解除精华 "; break; case "copy": operationtitle = "复制主题"; break; case "merge": operationtitle = "合并主题"; break; case "bump": operationtitle = "提升/下沉主题"; break; case "repair": operationtitle = "修复主题"; break; case "delposts": operationtitle = "批量删帖"; break; case "banpost": operationtitle = "单帖屏蔽"; break; case "identify": operationtitle = "鉴定主题"; break; default: operationtitle = "未知操作"; break; } return true; }
/// <summary> /// 悬赏结帖 /// </summary> /// <returns></returns> private bool DoBonusOperation() { //身份验证 topicinfo = Topics.GetTopicInfo(DNTRequest.GetInt("topicid", 0)); if (topicinfo.Special == 3) { titlemessage = true; AddErrLine("本主题的悬赏已经结束"); return false; } if (topicinfo.Posterid <= 0) { titlemessage = true; AddErrLine("无法结束游客发布的悬赏"); return false; } if (topicinfo.Posterid != userid && !ismoder)//不是作者或管理者 { titlemessage = true; AddErrLine("您没有权限结束此悬赏"); return false; } int costBonus = 0; string[] costBonusArray = DNTRequest.GetString("postbonus").Split(','); foreach (string s in costBonusArray) { costBonus += Utils.StrToInt(s, 0); } if (costBonus != topicinfo.Price) { titlemessage = true; AddErrLine("获奖分数与悬赏分数不一致"); return false; } string[] addonsArray = DNTRequest.GetFormString("addons").Split(','); int[] winneridArray = new int[addonsArray.Length]; int[] postidArray = new int[addonsArray.Length]; string[] winnernameArray = new string[addonsArray.Length]; //int[] isbestArray = new int[addonsArray.Length]; foreach (string addon in addonsArray) { if (Utils.StrToInt(addon.Split('|')[0], 0) == topicinfo.Posterid) { titlemessage = true; AddErrLine("不能向悬赏者发放积分奖励"); return false; } } if (costBonusArray.Length != addonsArray.Length) { titlemessage = true; AddErrLine("获奖者数量与积分奖励数量不一致"); return false; } if (IsErr()) return false; for (int i = 0; i < addonsArray.Length; i++) { winneridArray[i] = Utils.StrToInt(addonsArray[i].Split('|')[0], 0); postidArray[i] = Utils.StrToInt(addonsArray[i].Split('|')[1], 0); winnernameArray[i] = addonsArray[i].Split('|')[2]; } Bonus.CloseBonus(topicinfo, userid, postidArray, winneridArray, winnernameArray, costBonusArray, DNTRequest.GetFormString("valuableAnswers").Split(','), DNTRequest.GetFormInt("bestAnswer", 0)); return true; }
/// <summary> /// 分割主题 /// </summary> /// <param name="postidlist">帖子id列表</param> /// <param name="subject">主题</param> /// <param name="topicId">主题id列表</param> /// <returns>更新记录数</returns> public static int SplitTopics(string postidlist, string subject, string topicId) { //验证要分割的帖子是否为有效PID号 string[] postIdArray = postidlist.Split(','); if (Utils.StrIsNullOrEmpty(postidlist) || !Utils.IsNumericArray(postIdArray)) return -1; int tid = 0; int lastPostId = TypeConverter.StrToInt(postIdArray[postIdArray.Length - 1]); //将要被分割主题的tid TopicInfo originalTopicInfo = Topics.GetTopicInfo(TypeConverter.StrToInt(topicId)); //原主题信息 TopicInfo newTopicInfo = new TopicInfo(); //新主题信息 PostInfo lastPostInfo = Posts.GetPostInfo(originalTopicInfo.Tid, lastPostId); PostInfo firstPostInfo = Posts.GetPostInfo(originalTopicInfo.Tid, TypeConverter.StrToInt(postIdArray[0])); newTopicInfo.Poster = firstPostInfo.Poster; newTopicInfo.Posterid = firstPostInfo.Posterid; newTopicInfo.Postdatetime = Utils.GetDateTime(); newTopicInfo.Displayorder = 0; newTopicInfo.Highlight = ""; newTopicInfo.Digest = 0; newTopicInfo.Rate = 0; newTopicInfo.Hide = 0; newTopicInfo.Special = 0; newTopicInfo.Attachment = 0; newTopicInfo.Moderated = 0; newTopicInfo.Closed = 0; newTopicInfo.Views = 0; newTopicInfo.Fid = originalTopicInfo.Fid; newTopicInfo.Forumname = originalTopicInfo.Forumname; newTopicInfo.Iconid = originalTopicInfo.Iconid; newTopicInfo.Typeid = originalTopicInfo.Typeid; newTopicInfo.Replies = postIdArray.Length - 1; newTopicInfo.Title = Utils.HtmlEncode(subject); newTopicInfo.Lastposterid = lastPostInfo.Posterid; newTopicInfo.Lastpost = lastPostInfo.Postdatetime; newTopicInfo.Lastposter = lastPostInfo.Poster; tid = Topics.CreateTopic(newTopicInfo); DatabaseProvider.GetInstance().UpdatePostTid(postidlist, tid, Data.PostTables.GetPostTableId(tid)); DatabaseProvider.GetInstance().SetPrimaryPost(subject, tid, postIdArray, Discuz.Data.PostTables.GetPostTableId(tid)); newTopicInfo.Tid = tid; newTopicInfo.Lastpostid = lastPostId; if (originalTopicInfo.Lastpostid == lastPostId)//当需要将原主题的最后一个发帖分割走时(即分割列表中有和原主题Lastpostid相同的值) { newTopicInfo.Lastposterid = originalTopicInfo.Posterid; newTopicInfo.Lastpost = originalTopicInfo.Lastpost; newTopicInfo.Lastposter = originalTopicInfo.Poster; DataTable dt = DatabaseProvider.GetInstance().GetLastPostNotInPidList(postidlist, originalTopicInfo.Tid, int.Parse(Posts.GetPostTableId())); originalTopicInfo.Lastpostid = TypeConverter.ObjectToInt(dt.Rows[0]["pid"]); originalTopicInfo.Lastposterid = TypeConverter.ObjectToInt(dt.Rows[0]["Posterid"].ToString()); originalTopicInfo.Lastpost = dt.Rows[0]["Postdatetime"].ToString(); originalTopicInfo.Lastposter = dt.Rows[0]["Poster"].ToString(); } originalTopicInfo.Replies = originalTopicInfo.Replies - postIdArray.Length; Topics.UpdateTopic(originalTopicInfo);//更新原主题的信息 Topics.UpdateTopicReplyCount(originalTopicInfo.Tid); Topics.UpdateTopic(newTopicInfo);//由于数据库中对lastpostid有list约束,所以不能有重复值,则必须在原主题的lastpostid修改之后再次修改才能将数据最终修正完毕 Topics.UpdateTopicReplyCount(tid); return tid; }
/// <summary> /// 获得热门回复主题html /// </summary> /// <returns></returns> public static List<TopicInfo> GetHotReplyTopicsHtml() { List<TopicInfo> topicInfoList = new List<TopicInfo>(); IDataReader reader = DatabaseProvider.GetInstance().GetHotReplyTopics(20); while (reader.Read()) { TopicInfo topicInfo = new TopicInfo(); topicInfo.Replies = TypeConverter.ObjectToInt(reader["replies"]); topicInfo.Tid = TypeConverter.ObjectToInt(reader["tid"]); topicInfo.Title = reader["title"].ToString(); topicInfoList.Add(topicInfo); } reader.Close(); return topicInfoList; }
public int CreateTopic(TopicInfo topicInfo) { DbParameter[] parms = { DbHelper.MakeInParam("@fid", (DbType)SqlDbType.SmallInt, 2, topicInfo.Fid), DbHelper.MakeInParam("@iconid", (DbType)SqlDbType.SmallInt, 2, topicInfo.Iconid), DbHelper.MakeInParam("@title", (DbType)SqlDbType.NChar, 60, topicInfo.Title), DbHelper.MakeInParam("@typeid", (DbType)SqlDbType.SmallInt, 2, topicInfo.Typeid), DbHelper.MakeInParam("@readperm", (DbType)SqlDbType.Int, 4, topicInfo.Readperm), DbHelper.MakeInParam("@price", (DbType)SqlDbType.SmallInt, 2, topicInfo.Price), DbHelper.MakeInParam("@poster", (DbType)SqlDbType.NChar, 15, topicInfo.Poster), DbHelper.MakeInParam("@posterid", (DbType)SqlDbType.Int, 4, topicInfo.Posterid), DbHelper.MakeInParam("@postdatetime", (DbType)SqlDbType.DateTime,8, DateTime.Parse(topicInfo.Postdatetime)), DbHelper.MakeInParam("@lastpost", (DbType)SqlDbType.VarChar, 0, topicInfo.Lastpost), DbHelper.MakeInParam("@lastpostid", (DbType)SqlDbType.Int, 4, topicInfo.Lastpostid), DbHelper.MakeInParam("@lastposter", (DbType)SqlDbType.NChar, 15, topicInfo.Lastposter), DbHelper.MakeInParam("@views", (DbType)SqlDbType.Int, 4, topicInfo.Views), DbHelper.MakeInParam("@replies", (DbType)SqlDbType.Int, 4, topicInfo.Replies), DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int, 4, topicInfo.Displayorder), DbHelper.MakeInParam("@highlight", (DbType)SqlDbType.VarChar, 500, topicInfo.Highlight), DbHelper.MakeInParam("@digest", (DbType)SqlDbType.Int, 4, topicInfo.Digest), DbHelper.MakeInParam("@rate", (DbType)SqlDbType.Int, 4, topicInfo.Rate), DbHelper.MakeInParam("@hide", (DbType)SqlDbType.Int, 4, topicInfo.Hide), DbHelper.MakeInParam("@attachment", (DbType)SqlDbType.Int, 4, topicInfo.Attachment), DbHelper.MakeInParam("@moderated", (DbType)SqlDbType.Int, 4, topicInfo.Moderated), DbHelper.MakeInParam("@closed", (DbType)SqlDbType.Int, 4, topicInfo.Closed), DbHelper.MakeInParam("@magic", (DbType)SqlDbType.Int, 4, topicInfo.Magic), DbHelper.MakeInParam("@special", (DbType)SqlDbType.TinyInt, 1, topicInfo.Special), DbHelper.MakeInParam("@attention", (DbType)SqlDbType.Int, 4, topicInfo.Attention) }; int tid = TypeConverter.ObjectToInt(DbHelper.ExecuteDataset(CommandType.StoredProcedure, string.Format("{0}createtopic", BaseConfigs.GetTablePrefix), parms).Tables[0].Rows[0][0], -1); if (tid != -1) { TrendType trendType = TrendType.Topic; switch (topicInfo.Special) { case 0: trendType = TrendType.Topic; break; case 1: trendType = TrendType.Poll; break; case 2: trendType = TrendType.Bonus; break; case 4: trendType = TrendType.Debate; break; } UpdateTrendStat(trendType); } return tid; }
/// <summary> /// 获取帖子参数信息(PostPramsInfo) /// </summary> /// <param name="price"></param> /// <returns></returns> private List<ShowtopicPageAttachmentInfo> GetAttachList(int price, string onlyauthor, int ismoder, int posterid, UserInfo userinfo, UserGroupInfo usergroupinfo, TopicInfo topic, ForumInfo forum) { GeneralConfigInfo config = GeneralConfigs.GetConfig(); //获取当前页主题列表 PostpramsInfo postpramsInfo = new PostpramsInfo(); postpramsInfo.Fid = forum.Fid; postpramsInfo.Tid = topic.Tid; postpramsInfo.Jammer = forum.Jammer; postpramsInfo.Pagesize = 10000; // 得到Ppp设置 postpramsInfo.Pageindex = 1; postpramsInfo.Getattachperm = forum.Getattachperm; postpramsInfo.Usergroupid = usergroupinfo.Groupid; postpramsInfo.Attachimgpost = config.Attachimgpost; postpramsInfo.Showattachmentpath = config.Showattachmentpath; postpramsInfo.Price = price; postpramsInfo.Usergroupreadaccess = (ismoder == 1) ? int.MaxValue : usergroupinfo.Readaccess; postpramsInfo.CurrentUserid = userinfo.Uid; postpramsInfo.Showimages = forum.Allowimgcode; postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); postpramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo(); postpramsInfo.Smiliesmax = config.Smiliesmax; postpramsInfo.Bbcodemode = config.Bbcodemode; postpramsInfo.CurrentUserGroup = usergroupinfo; postpramsInfo.Topicinfo = topic; //判断是否为回复可见帖, hide=0为不解析[hide]标签, hide>0解析为回复可见字样, hide=-1解析为以下内容回复可见字样显示真实内容 //将逻辑判断放入取列表的循环中处理,此处只做是否为回复人的判断,主题作者也该可见 postpramsInfo.Hide = (topic.Hide == 1 && (Posts.IsReplier(topic.Tid, userinfo.Uid) || ismoder == 1)) ? -1 : 1; postpramsInfo.Hide = topic.Posterid == userinfo.Uid ? -2 : postpramsInfo.Hide; postpramsInfo.Condition = Posts.GetPostPramsInfoCondition(onlyauthor, topic.Tid, posterid); postpramsInfo.Usercredits = userinfo == null ? 0 : userinfo.Credits; List<ShowtopicPageAttachmentInfo> attachmentlist = new List<ShowtopicPageAttachmentInfo>(); List<ShowtopicPagePostInfo> postlist = GetPostList(postpramsInfo, out attachmentlist, ismoder == 1); int allowGetAttach = GetAllowGetAttachValue(postpramsInfo); foreach (ShowtopicPageAttachmentInfo showtopicpageattachinfo in attachmentlist) { if (Forums.AllowGetAttachByUserID(forum.Permuserlist, userinfo.Uid)) { showtopicpageattachinfo.Getattachperm = 1; showtopicpageattachinfo.Allowread = 1; } } List<ShowtopicPageAttachmentInfo> attachDeleteList = new List<ShowtopicPageAttachmentInfo>(); foreach (ShowtopicPageAttachmentInfo attachInfo in attachmentlist) { if (allowGetAttach == 1 && attachInfo.Allowread == 1) { if (attachInfo.Filetype.IndexOf("jpeg") >= 0 || attachInfo.Filetype.IndexOf("png") >= 0) { if (!attachInfo.Filename.ToLower().StartsWith("http")) attachInfo.Filename = Utils.GetRootUrl(BaseConfigs.GetForumPath) + "upload/" + attachInfo.Filename.Trim(); } else attachDeleteList.Add(attachInfo);//记录不是JPG或PNG的图片,以便进行remove操作 } else attachDeleteList.Add(attachInfo);//记录不是JPG或PNG的图片,以便进行remove操作 } foreach (ShowtopicPageAttachmentInfo attach in attachDeleteList) { attachmentlist.Remove(attach); } return attachmentlist; }
/// <summary> /// 创建主题帖信息 /// </summary> /// <param name="topicinfo"></param> /// <returns></returns> public PostInfo CreatePost(TopicInfo topicinfo) { PostInfo postinfo = new PostInfo(); postinfo.Fid = forumid; postinfo.Tid = topicinfo.Tid; postinfo.Poster = username; postinfo.Posterid = userid; postinfo.Title = useradminid == 1 ? Utils.HtmlEncode(DNTRequest.GetString("title")) : postinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title"))); postinfo.Postdatetime = curdatetime; postinfo.Message = message; postinfo.Ip = DNTRequest.GetIP(); postinfo.Invisible = ForumUtils.HasAuditWord(postinfo.Message) ? 0 : 1; postinfo.Invisible = UserAuthority.GetPostInvisible(forum, useradminid, disablepost); postinfo.Usesig = TypeConverter.StrToInt(DNTRequest.GetString("usesig")); postinfo.Htmlon = (usergroupinfo.Allowhtml == 1 && (TypeConverter.StrToInt(DNTRequest.GetString("htmlon")) == 1)) ? 1 : 0; postinfo.Smileyoff = (smileyoff == 0 && forum.Allowsmilies == 1) ? TypeConverter.StrToInt(DNTRequest.GetString("smileyoff")) : smileyoff; postinfo.Bbcodeoff = (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) ? postinfo.Bbcodeoff = TypeConverter.StrToInt(DNTRequest.GetString("bbcodeoff")) : 1; postinfo.Parseurloff = TypeConverter.StrToInt(DNTRequest.GetString("parseurloff")); postinfo.Topictitle = topicinfo.Title; try { postinfo.Pid = Posts.CreatePost(postinfo); } catch { TopicAdmins.DeleteTopics(topicinfo.Tid.ToString(), false); AddErrLine("帖子保存出现异常"); } //创建投票 if (createpoll) { msg = Polls.CreatePoll(DNTRequest.GetFormString("PollItemname"), DNTRequest.GetString("multiple") == "on" ? 1 : 0, DNTRequest.GetInt("maxchoices", 1), DNTRequest.GetString("visiblepoll") == "on" ? 1 : 0, enddatetime, topicinfo.Tid, pollitem, userid); } return postinfo; }
/// <summary> /// 更新主题信息 /// </summary> /// <param name="topicinfo"></param> /// <returns></returns> public static bool UpdateTopicAllInfo(TopicInfo topicinfo) { return DatabaseProvider.GetInstance().UpdateTopicAllInfo(topicinfo); }
/// <summary> /// 更新主题信息 /// </summary> /// <param name="topicinfo"></param> /// <returns></returns> public bool UpdateTopicAllInfo(TopicInfo topicinfo) { string sqlstring = string.Format("UPDATE [" + BaseConfigs.GetTablePrefix + "topics] SET fid='{1}',iconid='{2}',typeid='{3}',readperm='{4}',price='{5}',poster='{6}'," + "title='{7}',postdatetime='{8}',lastpost='{9}',lastpostid='{10}',lastposter='{11}'," + "views='{12}',replies='{13}',displayorder='{14}',highlight='{15}',digest='{16}',rate='{17}',blog='{18}'," + "poll='{19}',attachment='{20}',moderated='{21}',closed='{22}' WHERE [tid]={0}", topicinfo.Tid.ToString(), topicinfo.Fid.ToString(), topicinfo.Iconid.ToString(), topicinfo.Typeid.ToString(), topicinfo.Readperm.ToString(), topicinfo.Price, topicinfo.Poster, topicinfo.Title, topicinfo.Postdatetime, topicinfo.Lastpost, topicinfo.Lastpostid.ToString(), topicinfo.Lastposter, topicinfo.Views.ToString(), topicinfo.Replies.ToString(), topicinfo.Displayorder.ToString(), topicinfo.Highlight, topicinfo.Digest.ToString(), topicinfo.Rate.ToString(), topicinfo.Hide.ToString(), topicinfo.Poll.ToString(), topicinfo.Attachment.ToString(), topicinfo.Moderated.ToString(), topicinfo.Closed.ToString()); DbHelper.ExecuteNonQuery(CommandType.Text, sqlstring); return true; }
protected override void ShowPage() { //pagetitle = "编辑帖子"; #region 判断是否是灌水 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); this.disablepostctrl = 0; if (admininfo != null) disablepostctrl = admininfo.Disablepostctrl; #endregion if (userid == -1) { forum = new ForumInfo(); topic = new TopicInfo(); postinfo = new PostInfo(); AddErrLine("您尚未登录"); return; } #region 获取帖子和主题相关信息 // 如果帖子ID非数字 if (postid == -1) { AddErrLine("无效的帖子ID"); return; } postinfo = Posts.GetPostInfo(topicid, postid); // 如果帖子不存在 if (postinfo == null) { AddErrLine("不存在的帖子ID"); return; } pagetitle = (postinfo.Title == "") ? "编辑帖子" : postinfo.Title; htmlon = postinfo.Htmlon; message = postinfo.Message; isfirstpost = postinfo.Layer == 0; // 获取主题ID if (topicid != postinfo.Tid || postinfo.Tid == -1) { AddErrLine("无效的主题ID"); return; } // 获取该主题的信息 topic = Topics.GetTopicInfo(postinfo.Tid); // 如果该主题不存在 if (topic == null) { AddErrLine("不存在的主题ID"); return; } if (topic.Special == 1 && postinfo.Layer == 0) { pollinfo = Polls.GetPollInfo(topic.Tid); polloptionlist = Polls.GetPollOptionList(topic.Tid); } if (topic.Special == 4 && postinfo.Layer == 0) { debateinfo = Debates.GetDebateTopic(topic.Tid); } #endregion #region 获取并检查版块信息 ///得到所在版块信息 forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); needaudit = UserAuthority.NeedAudit(forum, useradminid, topic, userid, disablepostctrl, usergroupinfo); // 如果该版块不存在 if (forum == null || forum.Layer == 0) { AddErrLine("版块已不存在"); forum = new ForumInfo(); return; } if (!Utils.StrIsNullOrEmpty(forum.Password) && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } if (forum.Applytopictype == 1) //启用主题分类 topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); customeditbuttons = Caches.GetCustomEditButtonList(); #endregion //是否有编辑帖子的权限 if (!UserAuthority.CanEditPost(postinfo, userid, useradminid, ref msg)) { AddErrLine(msg); return; } #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); userinfo = Users.GetShortUserInfo(userid); if (canpostattach && (config.Enablealbum == 1) && apb != null && (UserGroups.GetUserGroupInfo(userinfo.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } else caninsertalbum = false; attachmentlist = Attachments.GetAttachmentListByPid(postinfo.Pid); attachmentcount = attachmentlist.Rows.Count; //当前用户是否有允许下载附件权限 allowviewattach = UserAuthority.DownloadAttachment(forum, userid, usergroupinfo); #endregion smileyoff = (!DNTRequest.IsPost()) ? postinfo.Smileyoff : 1 - forum.Allowsmilies; allowimg = forum.Allowimgcode; parseurloff = postinfo.Parseurloff; bbcodeoff = (usergroupinfo.Allowcusbbcode == 1) ? postinfo.Bbcodeoff : 1; usesig = postinfo.Usesig; userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); if (bonusCreditsTrans > 0 && bonusCreditsTrans < 9) { bonusextcreditsinfo = Scoresets.GetScoreSet(bonusCreditsTrans); mybonustranscredits = Users.GetUserExtCredits(userid, bonusCreditsTrans); } //是否有访问当前版块的权限 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); return; } // 判断当前用户是否有修改权限, 检查是否具有版主的身份 if (!Moderators.IsModer(useradminid, userid, forumid)) { if (postinfo.Posterid != userid) { AddErrLine("你并非作者, 且你当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有修改该帖的权限"); return; } else if (config.Edittimelimit > 0 && Utils.StrDateDiffMinutes(postinfo.Postdatetime, config.Edittimelimit) > 0) { AddErrLine("抱歉, 系统规定只能在帖子发表" + config.Edittimelimit + "分钟内才可以修改"); return; } else if(config.Edittimelimit==-1) { AddErrLine("抱歉,系统不允许修改帖子"); return; } } #region htmltitle标题 if (postinfo.Layer == 0) canhtmltitle = usergroupinfo.Allowhtmltitle == 1; if (Topics.GetMagicValue(topic.Magic, MagicType.HtmlTitle) == 1) htmltitle = Topics.GetHtmlTitle(topic.Tid).Replace("\"", "\\\"").Replace("'", "\\'"); #endregion #region tag信息 enabletag = (config.Enabletag & forum.Allowtag) == 1; if (enabletag && Topics.GetMagicValue(topic.Magic, MagicType.TopicTag) == 1) { foreach (TagInfo tag in ForumTags.GetTagsListByTopic(topic.Tid)) { if (tag.Orderid > -1) topictags += string.Format(" {0}", tag.Tagname); } topictags = topictags.Trim(); } #endregion userGroupInfoList.Sort(delegate(UserGroupInfo x, UserGroupInfo y) { return (x.Readaccess - y.Readaccess) + (y.Groupid - x.Groupid); }); //如果是提交... if (ispost) { SetBackLink("editpost.aspx?topicid=" + postinfo.Tid + "&postid=" + postinfo.Pid); if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } //设置相关帖子信息 SetPostInfo(admininfo, userinfo, Utils.StrToInt(DNTRequest.GetString("htmlon"), 0) == 1); if (IsErr()) return; //通过验证的用户可以编辑帖子 Posts.UpdatePost(postinfo); //设置附件相关信息 System.Text.StringBuilder sb = SetAttachmentInfo(); if (IsErr()) return; UserCredits.UpdateUserCredits(userid); #region 设置提示信息和跳转链接 //辩论地址 if (topic.Special == 4) SetUrl(Urls.ShowDebateAspxRewrite(topic.Tid)); else if (DNTRequest.GetQueryString("referer") != "")//ajax快速回复将传递referer参数 SetUrl(string.Format("showtopic.aspx?page=end&forumpage={2}&topicid={0}#{1}", topic.Tid, postinfo.Pid, forumpageid)); else if (pageid > 1)//如果不是ajax,则应该是带pageid的参数 { if (config.Aspxrewrite == 1) SetUrl(string.Format("showtopic-{0}-{2}{1}#{3}", topic.Tid, config.Extname, pageid, postinfo.Pid)); else SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={3}&page={2}#{1}", topic.Tid, postinfo.Pid, pageid, forumpageid)); } else//如果都为空.就跳转到第一页(以免意外情况) { if (config.Aspxrewrite == 1) SetUrl(string.Format("showtopic-{0}{1}", topic.Tid, config.Extname)); else SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={1}", topic.Tid, forumpageid)); } if (sb.Length > 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>"); sb.Append("</table>"); AddMsgLine(sb.ToString()); } } else { //编辑主题和回复需要审核 if (postinfo.Layer == 0) SetMetaRefresh(2, base.ShowForumAspxRewrite(forumid, forumpageid)); else SetMetaRefresh(); SetShowBackLink(false); if (useradminid != 1 && (needaudit || topic.Displayorder == -2 || postinfo.Invisible == 1)) { if (postinfo.Layer == 0) SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid)); else SetUrl(base.ShowTopicAspxRewrite(topic.Tid, forumpageid)); AddMsgLine("编辑成功, 但需要经过审核才可以显示"); } else { MsgForward("editpost_succeed"); AddMsgLine("编辑帖子成功, 返回该主题"); } } #endregion // 删除主题游客缓存 if (postinfo.Layer == 0) ForumUtils.DeleteTopicCacheFile(topic.Tid); } else AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); }
/// <summary> /// 更新主题 /// </summary> /// <param name="topicinfo">主题信息</param> /// <returns>成功返回1,否则返回0</returns> public int UpdateTopic(TopicInfo topicinfo) { IDataParameter[] prams = { DbHelper.MakeInParam("@tid",(DbType)SqlDbType.Int,4, topicinfo.Tid), DbHelper.MakeInParam("@fid", (DbType)SqlDbType.SmallInt, 2, topicinfo.Fid), DbHelper.MakeInParam("@iconid", (DbType)SqlDbType.SmallInt, 2, topicinfo.Iconid), DbHelper.MakeInParam("@title", (DbType)SqlDbType.NChar, 60, topicinfo.Title), DbHelper.MakeInParam("@typeid", (DbType)SqlDbType.SmallInt, 2, topicinfo.Typeid), DbHelper.MakeInParam("@readperm", (DbType)SqlDbType.Int, 4, topicinfo.Readperm), DbHelper.MakeInParam("@price", (DbType)SqlDbType.SmallInt, 2, topicinfo.Price), DbHelper.MakeInParam("@poster", (DbType)SqlDbType.NChar, 15, topicinfo.Poster), DbHelper.MakeInParam("@posterid", (DbType)SqlDbType.Int, 4, topicinfo.Posterid), DbHelper.MakeInParam("@postdatetime", (DbType)SqlDbType.SmallDateTime, 4, DateTime.Parse(topicinfo.Postdatetime)), DbHelper.MakeInParam("@lastpost", (DbType)SqlDbType.VarChar, 0, topicinfo.Lastpost), DbHelper.MakeInParam("@lastposter", (DbType)SqlDbType.NChar, 15, topicinfo.Lastposter), //DbHelper.MakeInParam("@views", (DbType)SqlDbType.Int, 4, topicinfo.Views), DbHelper.MakeInParam("@replies", (DbType)SqlDbType.Int, 4, topicinfo.Replies), DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int, 4, topicinfo.Displayorder), DbHelper.MakeInParam("@highlight", (DbType)SqlDbType.VarChar, 500, topicinfo.Highlight), DbHelper.MakeInParam("@digest", (DbType)SqlDbType.Int, 4, topicinfo.Digest), DbHelper.MakeInParam("@rate", (DbType)SqlDbType.Int, 4, topicinfo.Rate), DbHelper.MakeInParam("@hide", (DbType)SqlDbType.Int, 4, topicinfo.Hide), DbHelper.MakeInParam("@poll", (DbType)SqlDbType.Int, 4, topicinfo.Poll), DbHelper.MakeInParam("@attachment", (DbType)SqlDbType.Int, 4, topicinfo.Attachment), DbHelper.MakeInParam("@moderated", (DbType)SqlDbType.Int, 4, topicinfo.Moderated), DbHelper.MakeInParam("@closed", (DbType)SqlDbType.Int, 4, topicinfo.Closed), DbHelper.MakeInParam("@magic", (DbType)SqlDbType.Int, 4, topicinfo.Magic) }; return DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, BaseConfigs.GetTablePrefix + "updatetopic", prams); }
protected override void ShowPage() { pagetitle = "附件下载"; if (attachmentid == -1) { AddErrLine("无效的附件ID"); return; } // 如果当前用户非管理员并且论坛设定了禁止下载附件时间段,当前时间如果在其中的一个时间段内,则不允许用户下载附件 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visitTime = ""; if (Scoresets.BetweenTime(config.Attachbanperiods, out visitTime)) { AddErrLine("在此时间段( " + visitTime + " )内用户不可以下载附件"); return; } } if (DNTRequest.GetString("goodsattach").ToLower() == "yes") GetGoodsAttachInfo(attachmentid); else { // 获取该附件的信息 attachmentinfo = Attachments.GetAttachmentInfo(attachmentid); if (attachmentinfo == null) { AddErrLine("不存在的附件ID"); return; } //当前用户已上传但是还没有绑定到帖子的附件需要特殊处理,直接输出图片 if (userid > 0 && userid == attachmentinfo.Uid && attachmentinfo.Tid == 0 && attachmentinfo.Filetype.StartsWith("image/")) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Redirect(attachmentinfo.Filename.IndexOf("http") < 0 ? BaseConfigs.GetForumPath + "upload/" + attachmentinfo.Filename.Trim() : attachmentinfo.Filename.Trim()); HttpContext.Current.Response.End(); return; } // 获取该主题的信息 topic = Topics.GetTopicInfo(attachmentinfo.Tid); if (topic == null) { AddErrLine("不存在的主题ID"); return; } ForumInfo forum = Forums.GetForumInfo(topic.Fid); pagetitle = Utils.RemoveHtml(forum.Name); if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); if (userid == -1) needlogin = true; return; } //添加判断特殊用户的代码 if (!UserAuthority.CheckUsertAttachAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); if (userid == -1) needlogin = true; return; } // 检查用户是否拥有足够的阅读权限 if ((attachmentinfo.Readperm > usergroupinfo.Readaccess) && (attachmentinfo.Uid != userid) && (!Moderators.IsModer(useradminid, userid, forum.Fid))) { AddErrLine("您的阅读权限不够"); if (userid == -1) needlogin = true; return; } //检查附件是否存在 if (attachmentinfo.Filename.IndexOf("http") < 0 && !File.Exists(Utils.GetMapPath(string.Format(@"{0}upload/{1}", BaseConfigs.GetForumPath, attachmentinfo.Filename)))) { AddErrLine("该附件文件不存在或已被删除"); return; } //如果图片是不直接显示(作为附件显示) 并且不是作者本人下载都会扣分,并判断是否已经下载过,如果下载过则不再扣积分 //if ((config.Showimages != 1 || !Utils.IsImgFilename(attachmentinfo.Filename.Trim()) && // userid != attachmentinfo.Uid) && Utils.StrIsNullOrEmpty(Utils.GetCookie("dnt_attachment_" + attachmentid))) if ((!Utils.IsImgFilename(attachmentinfo.Filename.Trim()) || config.Showimages != 1) && (userid != attachmentinfo.Uid && Utils.StrIsNullOrEmpty(Utils.GetCookie("dnt_attachment_" + attachmentid)))) { if (Scoresets.IsSetDownLoadAttachScore() && UserCredits.UpdateUserExtCreditsByDownloadAttachment(userid, 1) == -1) { string addExtCreditsTip = ""; if (EPayments.IsOpenEPayments()) addExtCreditsTip = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>"; AddErrLine("您的积分不足" + addExtCreditsTip); return; } //设置该附件已经下载的cookie Utils.WriteCookie("dnt_attachment_" + attachmentid, "true", 5); } //检查附件是否存在 if (AttachPaymentLogs.HasBoughtAttach(userid, usergroupinfo.Radminid, attachmentinfo)) { AddErrLine("该附件为交易附件, 请先行购买!"); return; } Attachments.UpdateAttachmentDownloads(attachmentid); if (attachmentinfo.Filename.IndexOf("http") < 0) Utils.ResponseFile(Utils.GetMapPath(BaseConfigs.GetForumPath + @"upload/" + attachmentinfo.Filename), Path.GetFileName(attachmentinfo.Attachment), attachmentinfo.Filetype); else { try //添加try语法, 以防止在并发访问情况下, 服务器端远程链接被关闭后出现应用程序 '警告'(事件查看器) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Redirect(attachmentinfo.Filename.Trim()); HttpContext.Current.Response.End(); } catch{} } } }