/// <summary> /// 创建一个投票 /// </summary> /// <param name="tid">关联的主题id</param> /// <param name="multiple">投票类型, 0为单选, 1为多选</param> /// <param name="itemcount">投票项总数</param> /// <param name="itemnamelist">投票项目列表</param> /// <param name="itemvaluelist">投票项目结果列表</param> /// <param name="usernamelist">用户名列表</param> /// <param name="enddatetime">截止日期</param> /// <param name="userid">用户id</param> /// <param name="maxchoices">最多可选项数</param> /// <param name="visible">提交投票后结果才可见, 0为可见, 1为投票后可见</param> /// <returns>成功则返回true, 否则返回false</returns> public static bool CreatePoll(int tid, int multiple, int itemcount, string itemnamelist, string itemvaluelist, string enddatetime, int userid, int maxchoices, int visible) { string[] itemname = Utils.SplitString(itemnamelist, "\r\n"); string[] itemvalue = Utils.SplitString(itemvaluelist, "\r\n"); if ((itemname.Length != itemcount) || (itemvalue.Length != itemcount)) { return false; } PollInfo pollinfo = new PollInfo(); pollinfo.Displayorder = 0; pollinfo.Expiration = Utils.GetStandardDateTime(enddatetime); pollinfo.Maxchoices = maxchoices; pollinfo.Multiple = multiple; pollinfo.Tid = tid; pollinfo.Uid = userid; pollinfo.Visible = visible; int pollid = DatabaseProvider.GetInstance().CreatePoll(pollinfo); if (pollid > 0) { for (int i = 0; i < itemcount; i++) { PollOptionInfo polloptioninfo = new PollOptionInfo(); polloptioninfo.Displayorder = i + 1; polloptioninfo.Pollid = pollid; polloptioninfo.Polloption = Utils.GetSubString(itemname[i], 80, ""); polloptioninfo.Tid = tid; polloptioninfo.Voternames = ""; polloptioninfo.Votes = 0; DatabaseProvider.GetInstance().CreatePollOption(polloptioninfo); } return true; } else { return false; } }
public int CreatePoll(PollInfo pollInfo) { DbParameter[] parms = { DbHelper.MakeInParam("@tid",(DbType)SqlDbType.Int,4,pollInfo.Tid), DbHelper.MakeInParam("@displayorder",(DbType)SqlDbType.Int,4,pollInfo.Displayorder), DbHelper.MakeInParam("@multiple",(DbType)SqlDbType.Int,4,pollInfo.Multiple), DbHelper.MakeInParam("@visible",(DbType)SqlDbType.Int,4,pollInfo.Visible), DbHelper.MakeInParam("@allowview",(DbType)SqlDbType.Int,4,pollInfo.Allowview), DbHelper.MakeInParam("@maxchoices",(DbType)SqlDbType.Int,4,pollInfo.Maxchoices), DbHelper.MakeInParam("@expiration",(DbType)SqlDbType.DateTime,8,pollInfo.Expiration), DbHelper.MakeInParam("@uid",(DbType)SqlDbType.Int,4,pollInfo.Uid), DbHelper.MakeInParam("@voternames",(DbType)SqlDbType.NText,0,pollInfo.Voternames) }; string commandText = string.Format("INSERT INTO [{0}polls] ( [tid] ,[displayorder] ,[multiple] ,[visible] , [allowview],[maxchoices] ,[expiration] ,[uid] ,[voternames] ) VALUES (@tid, @displayorder, @multiple, @visible, @allowview, @maxchoices, @expiration, @uid, @voternames);SELECT SCOPE_IDENTITY() AS 'pollid'", BaseConfigs.GetTablePrefix); return TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.Text, commandText, parms), -1); }
public bool UpdatePoll(PollInfo pollInfo) { DbParameter[] parms = { DbHelper.MakeInParam("@tid",(DbType)SqlDbType.Int,4,pollInfo.Tid), DbHelper.MakeInParam("@displayorder",(DbType)SqlDbType.Int,4,pollInfo.Displayorder), DbHelper.MakeInParam("@multiple",(DbType)SqlDbType.Int,4,pollInfo.Multiple), DbHelper.MakeInParam("@visible",(DbType)SqlDbType.Int,4,pollInfo.Visible), DbHelper.MakeInParam("@allowview",(DbType)SqlDbType.Int,4,pollInfo.Allowview), DbHelper.MakeInParam("@maxchoices",(DbType)SqlDbType.Int,4,pollInfo.Maxchoices), DbHelper.MakeInParam("@expiration",(DbType)SqlDbType.DateTime,8,pollInfo.Expiration), DbHelper.MakeInParam("@uid",(DbType)SqlDbType.Int,4,pollInfo.Uid), DbHelper.MakeInParam("@voternames",(DbType)SqlDbType.NText,0,pollInfo.Voternames), DbHelper.MakeInParam("@pollid",(DbType)SqlDbType.Int,4,pollInfo.Pollid), }; string commandText = string.Format("UPDATE [{0}polls] set [tid] = @tid, [displayorder] = @displayorder, [multiple] = @multiple, [visible] = @visible, [allowview] = @allowview, [maxchoices] = @maxchoices, [expiration] = @expiration, [uid] = @uid, [voternames] = @voternames WHERE [pollid] = @pollid", BaseConfigs.GetTablePrefix); return DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms) > 0; }
/// <summary> /// 获取投票信息 /// </summary> public void GetPollInfo() { pollinfo = Polls.GetPollInfo(topicid); voters = Polls.GetVoters(topicid, userid, username, out allowvote); if (pollinfo.Uid != userid && useradminid != 1) //当前用户不是投票发起人或不是管理组成员 { if (pollinfo.Visible == 1 && //当为投票才可见时 (allowvote || (userid == -1 && !Utils.InArray(topicid.ToString(), ForumUtils.GetCookie("dnt_polled")))))//当允许投票或为游客(且并未投过票时)时 { showpollresult = false; } } if (Utils.StrIsNullOrEmpty(pollinfo.Expiration)) pollinfo.Expiration = DateTime.Now.ToString(); if (DateTime.Parse(pollinfo.Expiration) < DateTime.Now) allowvote = false; }
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> /// 通过主题ID获取相应的投票信息 /// </summary> /// <param name="tid">投票主题的id</param> /// <returns>投票信息</returns> public static PollInfo GetPollInfo(int tid) { PollInfo pollinfo = new PollInfo(); IDataReader idatareader = DatabaseProvider.GetInstance().GetPollList(tid); while (idatareader.Read()) { pollinfo.Pollid = TypeConverter.ObjectToInt(idatareader["pollid"], 0); pollinfo.Displayorder = TypeConverter.ObjectToInt(idatareader["displayorder"], 0); pollinfo.Expiration = Utils.GetStandardDate(idatareader["expiration"].ToString()); pollinfo.Maxchoices = TypeConverter.ObjectToInt(idatareader["maxchoices"], 0); pollinfo.Multiple = TypeConverter.ObjectToInt(idatareader["multiple"], 0); pollinfo.Tid = TypeConverter.ObjectToInt(idatareader["tid"], 0); pollinfo.Visible = TypeConverter.ObjectToInt(idatareader["visible"], 0); pollinfo.Allowview = TypeConverter.ObjectToInt(idatareader["allowview"], 0); pollinfo.Voternames = idatareader["voternames"].ToString().Trim(); pollinfo.Uid = TypeConverter.ObjectToInt(idatareader["uid"], 0); break; //目前一个主题只有一个投票,因此在绑定了第一条投票信息后退出 } idatareader.Close(); return pollinfo; }
/// <summary> /// 更新投票 /// </summary> /// <param name="pollinfo">更新投票</param> /// <returns></returns> public static bool UpdatePoll(PollInfo pollinfo) { return DatabaseProvider.GetInstance().UpdatePoll(pollinfo); }
/// <summary> /// 创建一个投票 /// </summary> /// <param name="pollinfo">投票信息</param> /// <returns></returns> public static int CreatePoll(PollInfo pollinfo) { return DatabaseProvider.GetInstance().CreatePoll(pollinfo); }
/// <summary> /// 根据投票信息更新数据库中的记录 /// </summary> /// <param name="tid">主题id</param> /// <param name="selitemidlist">选择的投票项id列表</param> /// <param name="username">用户名</param> /// <returns>如果执行成功则返回0, 非法提交返回负值</returns> //public int UpdatePoll(int tid, string usernamelist, StringBuilder newselitemidlist) //{ // DbParameter[] parms = { // DbHelper.MakeInParam("@itemvaluelist",DbType.String,0,newselitemidlist.ToString().Trim()), // DbHelper.MakeInParam("@usernamelist",DbType.String,0,usernamelist.ToString().Trim()), // DbHelper.MakeInParam("@tid",DbType.Int32,4,tid) // }; // if (DbHelper.ExecuteNonQuery(CommandType.Text, "UPDATE [" + BaseConfigs.GetTablePrefix + "polls] SET [itemvaluelist]=@itemvaluelist, [usernamelist]=@usernamelist WHERE [tid]=@tid", parms) > 0) // { // return 0; // } // else // { // return -4; // } //} public bool UpdatePoll(PollInfo pollinfo) { DbParameter[] parms = { DbHelper.MakeInParam("@tid",DbType.Int32,4,pollinfo.Tid), DbHelper.MakeInParam("@displayorder",DbType.Int32,4,pollinfo.Displayorder), DbHelper.MakeInParam("@multiple",DbType.Int32,4,pollinfo.Multiple), DbHelper.MakeInParam("@visible",DbType.Int32,4,pollinfo.Visible), DbHelper.MakeInParam("@maxchoices",DbType.Int32,4,pollinfo.Maxchoices), DbHelper.MakeInParam("@expiration",DbType.DateTime,8,pollinfo.Expiration), DbHelper.MakeInParam("@uid",DbType.Int32,4,pollinfo.Uid), DbHelper.MakeInParam("@voternames",DbType.String,0,pollinfo.Voternames), DbHelper.MakeInParam("@pollid",DbType.Int32,4,pollinfo.Pollid), }; string sql = "UPDATE [" + BaseConfigs.GetTablePrefix + "polls] set [tid] = @tid, [displayorder] = @displayorder, [multiple] = @multiple, [visible] = @visible, [maxchoices] = @maxchoices, [expiration] = @expiration, [uid] = @uid, [voternames] = @voternames WHERE [pollid] = @pollid"; return DbHelper.ExecuteNonQuery(CommandType.Text, sql, parms) > 0; }
/// <summary> /// 创建一个投票 /// </summary> /// <param name="tid">关联的主题id</param> /// <param name="polltype">投票类型, 0为单选, 1为多选</param> /// <param name="itemcount">投票项总数</param> /// <param name="itemnamelist">投票项目列表</param> /// <param name="itemvaluelist">投票项目结果列表</param> /// <param name="enddatetime">截止日期</param> /// <returns>成功则返回true, 否则返回false</returns> ////public bool CreatePoll(int tid, int polltype, int itemcount, string itemnamelist, string itemvaluelist, string enddatetime, int userid) ////{ //// DbParameter[] parms = { //// DbHelper.MakeInParam("@tid",DbType.Int32,4,tid), //// DbHelper.MakeInParam("@polltype",DbType.Int32,4,polltype), //// DbHelper.MakeInParam("@itemcount",DbType.Int32,4,itemcount), //// DbHelper.MakeInParam("@itemnamelist",DbType.String,0,itemnamelist), //// DbHelper.MakeInParam("@itemvaluelist",DbType.String,0,itemvaluelist), //// DbHelper.MakeInParam("@usernamelist",DbType.String,0,""), //// DbHelper.MakeInParam("@enddatetime",DbType.AnsiString,19,enddatetime), //// DbHelper.MakeInParam("@userid",DbType.Int32,4,userid) //// }; //// return DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, BaseConfigs.GetTablePrefix + "createpoll", parms) > 0; ////} public int CreatePoll(PollInfo pollinfo) { DbParameter[] parms = { DbHelper.MakeInParam("@tid",DbType.Int32,4,pollinfo.Tid), DbHelper.MakeInParam("@displayorder",DbType.Int32,4,pollinfo.Displayorder), DbHelper.MakeInParam("@multiple",DbType.Int32,4,pollinfo.Multiple), DbHelper.MakeInParam("@visible",DbType.Int32,4,pollinfo.Visible), DbHelper.MakeInParam("@maxchoices",DbType.Int32,4,pollinfo.Maxchoices), DbHelper.MakeInParam("@expiration",DbType.DateTime,8,pollinfo.Expiration), DbHelper.MakeInParam("@uid",DbType.Int32,4,pollinfo.Uid), DbHelper.MakeInParam("@voternames",DbType.String,0,pollinfo.Voternames) }; string sql = "INSERT INTO [" + BaseConfigs.GetTablePrefix + "polls] ( [tid] ,[displayorder] ,[multiple] ,[visible] ,[maxchoices] ,[expiration] ,[uid] ,[voternames] ) VALUES (@tid, @displayorder, @multiple, @visible, @maxchoices, @expiration, @uid, @voternames);SELECT SCOPE_IDENTITY() AS 'pollid'"; return Utils.StrToInt(DbHelper.ExecuteScalar(CommandType.Text, sql, parms), -1); }
protected override void ShowPage() { forumnav = ""; //maxprice = usergroupinfo.Maxprice > Scoresets.GetMaxIncPerTopic() ? Scoresets.GetMaxIncPerTopic() : usergroupinfo.Maxprice; maxprice = usergroupinfo.Maxprice; AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(useradminid); firstpagesmilies = Caches.GetSmiliesFirstPageCache(); this.disablepostctrl = 0; if (admininfo != null) { this.disablepostctrl = admininfo.Disablepostctrl; } int topicid = DNTRequest.GetInt("topicid", -1); int postid = DNTRequest.GetInt("postid", -1); if (userid == -1) { AddErrLine("你尚未登录"); return; } // 如果帖子ID非数字 if (postid == -1) { // AddErrLine("无效的帖子ID"); return; } postinfo = Posts.GetPostInfo(topicid, postid); // 如果帖子不存在 if (postinfo == null) { // AddErrLine("不存在的帖子ID"); return; } // 获取主题ID if (topicid != postinfo.Tid) { AddErrLine("主题ID无效"); return; } // 如果主题ID非数字 if (topicid == -1) { // AddErrLine("无效的主题ID"); return; } // 获取该主题的信息 topic = Topics.GetTopicInfo(topicid); // 如果该主题不存在 if (topic == null) { AddErrLine("不存在的主题ID"); return; } //非创始人且作者与当前编辑者不同时 if (postinfo.Posterid != userid && BaseConfigs.GetFounderUid != userid) { if (postinfo.Posterid == BaseConfigs.GetFounderUid) { AddErrLine("您无权编辑创始人的帖子"); return; } if (postinfo.Posterid != -1) { UserGroupInfo postergroup = UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(postinfo.Posterid).Groupid); if (postergroup.Radminid > 0 && postergroup.Radminid < useradminid) { AddErrLine("您无权编辑更高权限人的帖子"); return; } } } pagetitle = postinfo.Title; ///得到所在版块信息 forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); // 如果该版块不存在 if (forum == null) { AddErrLine("版块已不存在"); forum = new ForumInfo(); return; } if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } forumname = forum.Name; forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); if (forum.Applytopictype == 1) //启用主题分类 { topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); } //得到用户可以上传的文件类型 System.Text.StringBuilder sbAttachmentTypeSelect = new StringBuilder(); if (!usergroupinfo.Attachextensions.Trim().Equals("")) { sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions); sbAttachmentTypeSelect.Append(")"); } if (!forum.Attachextensions.Trim().Equals("")) { if (sbAttachmentTypeSelect.Length > 0) { sbAttachmentTypeSelect.Append(" AND "); } sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(forum.Attachextensions); sbAttachmentTypeSelect.Append(")"); } attachextensions = Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()); attachextensionsnosize = Attachments.GetAttachmentTypeString(sbAttachmentTypeSelect.ToString()); //得到今天允许用户上传的附件总大上(字节) int MaxTodaySize = 0; if (userid > 0) { MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid); //今天已上传大小 } attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize; //-------------设置帖子的可用功能allhtml,smileyoff,parseurlof,bbcodeoff System.Text.StringBuilder sb = new System.Text.StringBuilder(); //sb.Append("var Allowhtml=1;\r\n"); //+ allhtml.ToString() + " parseurloff = 0; smileyoff = 1 - forum.Allowsmilies; //sb.Append("var Allowsmilies=" + (1-smileyoff).ToString() + ";\r\n"); bbcodeoff = 1; if (forum.Allowbbcode == 1) { if (usergroupinfo.Allowcusbbcode == 1) { bbcodeoff = 0; } } //sb.Append("var Allowbbcode=" + (1-bbcodeoff).ToString() + ";\r\n"); usesig = 1; allowimg = forum.Allowimgcode; //sb.Append("var Allowimgcode=" + allowimg.ToString() + ";\r\n"); //AddScript(sb.ToString()); //--------------- parseurloff = postinfo.Parseurloff; if (!DNTRequest.IsPost()) { smileyoff = postinfo.Smileyoff; } bbcodeoff = 1; if (usergroupinfo.Allowcusbbcode == 1) { bbcodeoff = postinfo.Bbcodeoff; } usesig = postinfo.Usesig; if (!Forums.AllowViewByUserID(forum.Permuserlist, userid)) //判断当前用户在当前版块浏览权限 { if (forum.Viewperm == null || forum.Viewperm == string.Empty)//当板块权限为空时,按照用户组权限 { if (usergroupinfo.Allowvisit != 1) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限"); return; } } else//当板块权限不为空,按照板块权限 { if (!Forums.AllowView(forum.Viewperm, usergroupid)) { AddErrLine("您没有浏览该版块的权限"); return; } } } //当前用户是否有允许下载附件权限 if (Forums.AllowGetAttachByUserID(forum.Permuserlist, userid)) { allowviewattach = true; } else { if (forum.Getattachperm == null || forum.Getattachperm == string.Empty)//权限设置为空时,根据用户组权限判断 { // 验证用户是否有有允许下载附件权限 if (usergroupinfo.Allowgetattach == 1) { allowviewattach = true; } } else if (Forums.AllowGetAttach(forum.Getattachperm, usergroupid)) { allowviewattach = true; } } //是否有上传附件的权限 if (Forums.AllowPostAttachByUserID(forum.Permuserlist, userid)) { canpostattach = true; } else { if (forum.Postattachperm == null || forum.Postattachperm == "") { if (usergroupinfo.Allowpostattach == 1) { canpostattach = true; } } else { if (Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) { canpostattach = true; } } } // 判断当前用户是否有修改权限 // 检查是否具有版主的身份 //if (!Moderators.IsModer(useradminid, userid, forumid) || AdminGroups.GetAdminGroupInfo(useradminid) == null) 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.ToString() + "分钟内才可以修改"); return; } } userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetCreditsTrans()); //bool allowvote = false; if (topic.Special == 1 && postinfo.Layer == 0) { pollinfo = Polls.GetPollInfo(topicid); //if (Polls.GetVoters(topicid, userid, username, out allowvote).Equals("")) { polloptionlist = Polls.GetPollOptionList(topicid); } } if (postinfo.Layer == 0) { canhtmltitle = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup); } attachmentlist = Attachments.GetAttachmentListByPid(postid); attachmentcount = attachmentlist.Rows.Count; ShortUserInfo user = Discuz.Forum.Users.GetShortUserInfo(userid); caninsertalbum = false; if (Topics.GetMagicValue(topic.Magic, MagicType.HtmlTitle) == 1) { htmltitle = Topics.GetHtmlTitle(topic.Tid).Replace("\"", "\\\"").Replace("'", "\\'"); } enabletag = (config.Enabletag & forum.Allowtag) == 1; if (enabletag && Topics.GetMagicValue(topic.Magic, MagicType.TopicTag) == 1) { List<TagInfo> tags = ForumTags.GetTagsListByTopic(topic.Tid); foreach (TagInfo tag in tags) { if (tag.Orderid > -1) { topictags += string.Format(" {0}", tag.Tagname); } } topictags = topictags.Trim(); } if (!ispost) { AddLinkCss("/" + "templates/" + templatepath + "/editor.css", "css"); // 帖子内容 message = postinfo.Message; smilies = Caches.GetSmiliesCache(); smilietypes = Caches.GetSmilieTypesCache(); customeditbuttons = Caches.GetCustomEditButtonList(); topicicons = Caches.GetTopicIconsCache(); } else { SetBackLink("editpost.aspx?topicid=" + postinfo.Tid + "&postid=" + this.postinfo.Pid.ToString()); if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } if (postinfo.Layer == 0 && forum.Applytopictype == 1 && forum.Postbytopictype == 1 && topictypeselectoptions != string.Empty) { if (DNTRequest.GetString("typeid").Trim().Equals("") || DNTRequest.GetString("typeid").Trim().Equals("0")) { AddErrLine("主题类型不能为空"); return; } if (!Forums.IsCurrentForumTopicType(DNTRequest.GetString("typeid").Trim(), forum.Topictypes)) { AddErrLine("错误的主题类型"); return; } } ///删除附件 if (DNTRequest.GetInt("isdeleteatt", 0) == 1) { int aid = DNTRequest.GetFormInt("aid", 0); if (aid > 0) { if (Attachments.DeleteAttachment(aid) > 0) { attachmentlist = Attachments.GetAttachmentListByPid(postid); attachmentcount = Attachments.GetAttachmentCountByPid(postid); } } AddLinkCss("/" + "templates/" + templatepath + "/editor.css", "css"); // 帖子内容 message = postinfo.Message; smilies = Caches.GetSmiliesCache(); customeditbuttons = Caches.GetCustomEditButtonList(); topicicons = Caches.GetTopicIconsCache(); ispost = false; return; } if (DNTRequest.GetString("title").Trim().Equals("") && postinfo.Layer == 0) { AddErrLine("标题不能为空"); } else if (DNTRequest.GetString("title").IndexOf(" ") != -1) { AddErrLine("标题不能包含全角空格符"); } else if (DNTRequest.GetString("title").Length > 60) { AddErrLine("标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length.ToString() + " 个字符"); } string postmessage = DNTRequest.GetString("message"); if (postmessage.Equals("")) { AddErrLine("内容不能为空"); } if (admininfo != null && this.disablepostctrl != 1) { if (postmessage.Length < config.Minpostsize) { AddErrLine("您发表的内容过少, 系统设置要求帖子内容不得少于 " + config.Minpostsize.ToString() + " 字多于 " + config.Maxpostsize.ToString() + " 字"); } else if (postmessage.Length > config.Maxpostsize) { AddErrLine("您发表的内容过多, 系统设置要求帖子内容不得少于 " + config.Minpostsize.ToString() + " 字多于 " + config.Maxpostsize.ToString() + " 字"); } } string enddatetime = DNTRequest.GetString("enddatetime"); string[] pollitem = { }; if (!DNTRequest.GetString("updatepoll").Equals("") && topic.Special == 1) { pollinfo.Multiple = DNTRequest.GetInt("multiple", 0); // 验证用户是否有发布投票的权限 if (usergroupinfo.Allowpostpoll != 1) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布投票的权限"); return; } //createpoll = true; pollitem = Utils.SplitString(DNTRequest.GetString("PollItemname"), "\r\n"); if (pollitem.Length < 2) { AddErrLine("投票项不得少于2个"); } else if (pollitem.Length > config.Maxpolloptions) { AddErrLine("系统设置为投票项不得多于" + config.Maxpolloptions + "个"); } else { for (int i = 0; i < pollitem.Length; i++) { if (pollitem[i].Trim().Equals("")) { AddErrLine("投票项不能为空"); } } } } int topicprice = 0; string tmpprice = DNTRequest.GetString("topicprice"); if (Regex.IsMatch(tmpprice, "^[0-9]*[0-9][0-9]*$") || tmpprice == string.Empty) { if (topic.Special != 2) { topicprice = Utils.StrToInt(tmpprice, 0); if (topicprice > maxprice && maxprice > 0) { if (userextcreditsinfo.Unit.Equals("")) { AddErrLine(string.Format("主题售价不能高于 {0} {1}", maxprice.ToString(), userextcreditsinfo.Name)); } else { AddErrLine(string.Format("主题售价不能高于 {0} {1}({2})", maxprice.ToString(), userextcreditsinfo.Name, userextcreditsinfo.Unit)); } } else if (topicprice > 0 && maxprice <= 0) { AddErrLine(string.Format("您当前的身份 \"{0}\" 未被允许出售主题", usergroupinfo.Grouptitle)); } else if (topicprice < 0) { AddErrLine("主题售价不能为负数"); } } else { topicprice = Utils.StrToInt(tmpprice, 0); if (usergroupinfo.Allowbonus == 0) { AddErrLine(string.Format("您当前的身份 \"{0}\" 未被允许进行悬赏", usergroupinfo.Grouptitle)); } if (topicprice < usergroupinfo.Minbonusprice || topicprice > usergroupinfo.Maxbonusprice) { AddErrLine(string.Format("悬赏价格超出范围, 您应在 {0} - {1} {2}{3} 范围内进行悬赏", usergroupinfo.Minbonusprice, usergroupinfo.Maxbonusprice, userextcreditsinfo.Unit, userextcreditsinfo.Name)); } } } else { if (topic.Special != 2) { AddErrLine("主题售价只能为整数"); } else { AddErrLine("悬赏价格只能为整数"); } } //新用户广告强力屏蔽检查 if ((config.Disablepostad == 1) && useradminid < 1 || userid == -1) //如果开启新用户广告强力屏蔽检查或是游客 { if (userid == -1 || (config.Disablepostadpostcount != 0 && user.Posts <= config.Disablepostadpostcount) || (config.Disablepostadregminute != 0 && DateTime.Now.AddMinutes(-config.Disablepostadregminute) <= Convert.ToDateTime(user.Joindate))) { foreach (string regular in config.Disablepostadregular.Replace("\r", "").Split('\n')) { if (Posts.IsAD(regular, DNTRequest.GetString("title"), postmessage)) { AddErrLine("发帖失败,内容中似乎有广告信息,请检查标题和内容,如有疑问请与管理员联系"); return; } } } } if (IsErr()) { return; } string curdatetime = Utils.GetDateTime(); if (useradminid == 1) { postinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title")); postinfo.Message = Shove._Web.Utility.FilteSqlInfusion(DNTRequest.GetString("message")).Replace("<hide>", "[hide]").Replace("</hide>", "[/hide]"); //postinfo.Message = Utils.HtmlEncode(DNTRequest.GetString("message")); } else { postinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title"))); postinfo.Message = Shove._Web.Utility.FilteSqlInfusion(DNTRequest.GetString("message")).Replace("<hide>", "[hide]").Replace("</hide>", "[/hide]"); //postinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("message"))); } if (ForumUtils.HasBannedWord(postinfo.Title) || ForumUtils.HasBannedWord(postinfo.Message)) { AddErrLine("对不起, 您提交的内容包含不良信息, 因此无法提交, 请返回修改!"); return; } if (useradminid != 1) { if (ForumUtils.HasAuditWord(postinfo.Title) || ForumUtils.HasAuditWord(postinfo.Message)) { AddErrLine("对不起, 管理员设置了需要对发帖进行审核, 您没有权力编辑已通过审核的帖子, 请返回修改!"); return; //postinfo.Invisible = 1; //if (postinfo.Layer == 0) //当为主题帖时 //{ // topic.Displayorder = -2; //} } } //如果是不是管理员组,或者编辑间隔超过60秒,则附加编辑信息 if (Utils.StrDateDiffSeconds(postinfo.Postdatetime, 60) > 0 && config.Editedby == 1 && useradminid != 1) { postinfo.Lastedit = username + " 最后编辑于 " + Utils.GetDateTime(); } postinfo.Usesig = Utils.StrToInt(DNTRequest.GetString("usesig"), 0); postinfo.Htmlon = 1; postinfo.Smileyoff = smileyoff; if (smileyoff == 0) { postinfo.Smileyoff = Utils.StrToInt(DNTRequest.GetString("smileyoff"), 0); } postinfo.Bbcodeoff = 1; if (usergroupinfo.Allowcusbbcode == 1) { postinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0); } postinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0); // 如果所在管理组存在且所在管理组有删帖的管理权限 if (admininfo != null && admininfo.Alloweditpost == 1 && Moderators.IsModer(useradminid, userid, forumid)) { alloweditpost = true; } else if (userid != postinfo.Posterid) { AddErrLine("您当前的身份不是作者"); return; } else { alloweditpost = true; } if (alloweditpost) { if (postinfo.Layer == 0) { ///修改投票信息 StringBuilder itemvaluelist = new StringBuilder(""); if (topic.Special == 1) { string pollItemname = Utils.HtmlEncode(DNTRequest.GetFormString("PollItemname")); if (pollItemname != "") { int multiple = DNTRequest.GetString("multiple") == "on" ? 1 : 0; int maxchoices = 0; if (multiple == 1) { maxchoices = DNTRequest.GetInt("maxchoices", 0); if (maxchoices > pollitem.Length) { maxchoices = pollitem.Length; } } if (!Polls.UpdatePoll(topicid, multiple, pollitem.Length, DNTRequest.GetFormString("PollOptionID").Trim(), pollItemname.Trim(), DNTRequest.GetFormString("PollOptionDisplayOrder").Trim(), enddatetime, maxchoices, DNTRequest.GetString("visiblepoll") == "on" ? 1 : 0)) { AddErrLine("投票错误,请检查显示顺序"); return; } } else { AddErrLine("投票项为空"); return; } } int iconid = DNTRequest.GetInt("iconid", 0); if (iconid > 15 || iconid < 0) { iconid = 0; } topic.Iconid = iconid; topic.Title = postinfo.Title; //悬赏差价处理 if (topic.Special == 2) { int pricediff = topicprice - topic.Price; if (pricediff > 0) { } else if (pricediff < 0) { AddErrLine("不能降低悬赏价格"); return; } } else if (topic.Special == 0)//普通主题,出售 { topic.Price = topicprice; } if (usergroupinfo.Allowsetreadperm == 1) { int topicreadperm = DNTRequest.GetInt("topicreadperm", 0); topicreadperm = topicreadperm > 255 ? 255 : topicreadperm; topic.Readperm = topicreadperm; } if (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) { topic.Hide = 1; } topic.Typeid = DNTRequest.GetFormInt("typeid", 0); string htmltitle = DNTRequest.GetString("htmltitle").Trim(); if (htmltitle != string.Empty && Utils.HtmlDecode(htmltitle).Trim() != topic.Title) { topic.Magic = 11000; //按照 附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储 //例: 11001 } else { topic.Magic = 0; } ForumTags.DeleteTopicTags(topic.Tid); Topics.DeleteRelatedTopics(topic.Tid); string tags = DNTRequest.GetString("tags").Trim(); string[] tagArray = null; if (enabletag && tags != string.Empty) { if (ForumUtils.HasBannedWord(tags)) { AddErrLine("标签中含有系统禁止词语,请修改"); return; } tagArray = Utils.SplitString(tags, " ", true, 10); if (tagArray.Length > 0) { topic.Magic = Topics.SetMagicValue(topic.Magic, MagicType.TopicTag, 1); ForumTags.CreateTopicTags(tagArray, topic.Tid, userid, curdatetime); } } Topics.UpdateTopic(topic); //保存htmltitle if (canhtmltitle && htmltitle != string.Empty && htmltitle != topic.Title) { Topics.WriteHtmlTitleFile(htmltitle, topic.Tid); } } else { if (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) { topic.Hide = 1; } Topics.UpdateTopicHide(topicid); } // 通过验证的用户可以编辑帖子 Posts.UpdatePost(postinfo); sb = new StringBuilder(); sb.Remove(0, sb.Length); //编辑帖子时如果进行了批量删除附件 string delAttId = DNTRequest.GetFormString("deleteaid"); if (delAttId != string.Empty) { if (Utils.IsNumericArray(delAttId.Split(',')))//如果要删除的附件ID列表为数字数组 { Attachments.DeleteAttachment(delAttId); } } //编辑帖子时如果进行了更新附件操作 string updatedAttId = DNTRequest.GetFormString("attachupdatedid");//被更新的附件Id列表 string updateAttId = DNTRequest.GetFormString("attachupdateid");//所有已上传的附件Id列表 string[] descriptionArray = DNTRequest.GetFormString("attachupdatedesc").Split(',');//所有已上传的附件的描述 string[] readpermArray = DNTRequest.GetFormString("attachupdatereadperm").Split(',');//所有已上传得附件的阅读权限 ArrayList updateAttArrayList = new ArrayList(); if (updateAttId != string.Empty) { foreach (string s in updateAttId.Split(',')) { if (!Utils.InArray(s, delAttId, ","))//已上传的附件Id不在被删除的附件Id列表中时 { updateAttArrayList.Add(s); } } } string[] updateAttArray = (string[])updateAttArrayList.ToArray(typeof(string)); if (updateAttId != string.Empty)//原来有附件 { // if (updatedAttId != string.Empty)//原来的附件有更新 // { int watermarkstate = config.Watermarkstatus; if (forum.Disablewatermark == 1) watermarkstate = 0; string[] updatedAttArray = updatedAttId.Split(','); string filekey = "attachupdated"; //保存新的文件 AttachmentInfo[] attArray = ForumUtils.SaveRequestFiles(forumid, config.Maxattachments + updateAttArray.Length, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstate, config, filekey); if (Utils.IsNumericArray(updateAttArray)) { for (int i = 0; i < updateAttArray.Length; i++) //遍历原来所有附件 { string attachmentId = updateAttArray[i]; if (Utils.InArray(attachmentId, updatedAttArray)) //附件文件被更新 { if (Utils.InArray(attachmentId, delAttId, ","))//附件进行了删除操作, 则不操作此附件,即使其也被更新 { continue; } //更新附件 int attachmentUpdatedIndex = GetAttachmentUpdatedIndex(attachmentId, updatedAttArray);//获取此次上传的被更新附件在数组中的索引 if (attachmentUpdatedIndex > -1)//附件索引存在 { if (attArray[attachmentUpdatedIndex].Sys_noupload.Equals(string.Empty)) //由此属性为空可以判断上传成功 { //获取将被更新的附件信息 AttachmentInfo attachmentInfo = Attachments.GetAttachmentInfo(Utils.StrToInt(updatedAttArray[attachmentUpdatedIndex], 0)); if (attachmentInfo != null) { if (attachmentInfo.Filename.Trim().ToLower().IndexOf("http") < 0) { //删除原来的文件 File.Delete( Utils.GetMapPath("/" + "upload/" + attachmentInfo.Filename)); } //记住Aid以便稍后更新 attArray[attachmentUpdatedIndex].Aid = attachmentInfo.Aid; attArray[attachmentUpdatedIndex].Description = descriptionArray[i]; int att_readperm = Utils.StrToInt(readpermArray[i], 0); att_readperm = att_readperm > 255 ? 255 : att_readperm; attArray[attachmentUpdatedIndex].Readperm = att_readperm; Attachments.UpdateAttachment(attArray[attachmentUpdatedIndex]); } } else //上传失败的附件,稍后提示 { sb.Append("<tr><td align=\"left\">"); sb.Append(attArray[attachmentUpdatedIndex].Attachment); sb.Append("</td>"); sb.Append("<td align=\"left\">"); sb.Append(attArray[attachmentUpdatedIndex].Sys_noupload); sb.Append("</td></tr>"); } } } else //仅修改了阅读权限和描述等 { if (Utils.InArray(updateAttArray[i], delAttId, ",")) { continue; } if ((attachmentlist.Rows[i]["readperm"].ToString() != readpermArray[i]) || (attachmentlist.Rows[i]["description"].ToString().Trim() != descriptionArray[i])) { int att_readperm = Utils.StrToInt(readpermArray[i], 0); att_readperm = att_readperm > 255 ? 255 : att_readperm; Attachments.UpdateAttachment(Utils.StrToInt(updateAttArray[i], 0), att_readperm, descriptionArray[i]); } } } } // } } ///上传附件 int watermarkstatus = config.Watermarkstatus; if (forum.Disablewatermark == 1) { watermarkstatus = 0; } AttachmentInfo[] attachmentinfo = ForumUtils.SaveRequestFiles(forumid, config.Maxattachments - updateAttArray.Length, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstatus, config, "postfile"); if (attachmentinfo != null) { if (attachmentinfo.Length > config.Maxattachments - updateAttArray.Length) { AddErrLine("系统设置为附件不得多于" + config.Maxattachments + "个"); return; } int errorAttachment = Attachments.BindAttachment(attachmentinfo, postid, sb, topicid, userid); int[] aid = Attachments.CreateAttachments(attachmentinfo); string tempMessage = Attachments.FilterLocalTags(aid, attachmentinfo, postinfo.Message); if (!tempMessage.Equals(postinfo.Message)) { postinfo.Message = tempMessage; postinfo.Pid = postid; Posts.UpdatePost(postinfo); } UserCredits.UpdateUserCreditsByUploadAttachment(userid, aid.Length - errorAttachment); } //编辑后跳转地址 if (topic.Special == 4) { //辩论地址 SetUrl(Urls.ShowDebateAspxRewrite(topicid)); } else if (DNTRequest.GetQueryString("referer") != "")//ajax快速回复将传递referer参数 { //SetUrl(Utils.UrlDecode(DNTRequest.GetQueryString("referer"))); SetUrl(string.Format("showtopic.aspx?page=end&topicid={0}#{1}", topicid.ToString().Trim(), postinfo.Pid)); } else if (DNTRequest.GetQueryString("pageid") != "")//如果不是ajax,则应该是带pageid的参数 { if (config.Aspxrewrite == 1) { SetUrl(string.Format("showtopic-{0}-{2}{1}#{3}", topicid.ToString(), config.Extname, DNTRequest.GetString("pageid"), postinfo.Pid)); } else { SetUrl(string.Format("showtopic.aspx?&topicid={0}&page={2}#{1}", topicid.ToString(), postinfo.Pid, DNTRequest.GetString("pageid"))); } } else//如果都为空.就跳转到第一页(以免意外情况) { if (config.Aspxrewrite == 1) { SetUrl(string.Format("showtopic-{0}{1}", topicid.ToString(), config.Extname)); } else { SetUrl(string.Format("showtopic.aspx?&topicid={0}", topicid.ToString())); } } if (sb.Length > 0) { SetMetaRefresh(5); SetShowBackLink(true); 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 { SetMetaRefresh(); SetShowBackLink(false); AddMsgLine("编辑帖子成功, 返回该主题"); } // 删除主题游客缓存 if (postinfo.Layer == 0) { ForumUtils.DeleteTopicCacheFile(topicid); } return; } else { AddErrLine("您当前的身份没有编辑帖子的权限"); return; } } }
protected override void ShowPage() { headerad = ""; footerad = ""; postleaderboardad = ""; doublead = ""; floatad = ""; allowrate = false; disablepostctrl = 0; // 获取主题ID topicid = DNTRequest.GetInt("topicid", -1); // 获取该主题的信息 string go = DNTRequest.GetString("go").Trim().ToLower(); int fid = DNTRequest.GetInt("forumid", 0); firstpagesmilies = Caches.GetSmiliesFirstPageCache(); if (go == "") { fid = 0; } else if (fid == 0) { go = ""; } string errmsg = ""; switch (go) { case "prev": topic = Topics.GetTopicInfo(topicid, fid, 1); errmsg = "没有更旧的主题, 请返回"; break; case "next": topic = Topics.GetTopicInfo(topicid, fid, 2); errmsg = "没有更新的主题, 请返回"; break; default: topic = Topics.GetTopicInfo(topicid); errmsg = "该主题不存在"; break; } if (topic == null) { AddErrLine(errmsg); headerad = Advertisements.GetOneHeaderAd("", 0); footerad = Advertisements.GetOneFooterAd("", 0); pagewordad = Advertisements.GetPageWordAd("", 0); doublead = Advertisements.GetDoubleAd("", 0); floatad = Advertisements.GetFloatAd("", 0); return; } if (topic.Identify > 0) { topicidentify = Caches.GetTopicIdentify(topic.Identify); } topicid = topic.Tid; forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); forumname = forum.Name; pagetitle = topic.Title; forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname); fid = forumid; ///得到广告列表 ///头部 headerad = Advertisements.GetOneHeaderAd("", fid); footerad = Advertisements.GetOneFooterAd("", fid); postleaderboardad = Advertisements.GetOnePostLeaderboardAD("", fid); pagewordad = Advertisements.GetPageWordAd("", fid); doublead = Advertisements.GetDoubleAd("", fid); floatad = Advertisements.GetFloatAd("", fid); // 检查是否具有版主的身份 if (useradminid != 0) { ismoder = Moderators.IsModer(useradminid, userid, forumid) ? 1 : 0; //得到管理组信息 admininfo = AdminGroups.GetAdminGroupInfo(useradminid); if (admininfo != null) { disablepostctrl = admininfo.Disablepostctrl; } } //验证不通过则返回 if (!IsConditionsValid()) return; showratelog = GeneralConfigs.GetConfig().DisplayRateCount > 0 ? 1 : 0; topictitle = topic.Title.Trim(); replytitle = topictitle; if (replytitle.Length >= 50) { replytitle = Utils.CutString(replytitle, 0, 50) + "..."; } //topicmagic = ForumUtils.ShowTopicMagic(topic.Magic); topicviews = topic.Views + 1 + (config.TopicQueueStats == 1 ? TopicStats.GetStoredTopicViewCount(topic.Tid) : 0); smilies = Caches.GetSmiliesCache(); smilietypes = Caches.GetSmilieTypesCache(); //编辑器状态 StringBuilder sb = new StringBuilder(); sb.Append("var Allowhtml=1;\r\n"); //+ allhtml.ToString() + " parseurloff = 0; smileyoff = 1 - forum.Allowsmilies; sb.Append("var Allowsmilies=" + (1 - smileyoff).ToString() + ";\r\n"); bbcodeoff = 1; if (forum.Allowbbcode == 1) { if (usergroupinfo.Allowcusbbcode == 1) { bbcodeoff = 0; } } sb.Append("var Allowbbcode=" + (1 - bbcodeoff).ToString() + ";\r\n"); usesig = ForumUtils.GetCookie("sigstatus") == "0" ? 0 : 1; allowimg = forum.Allowimgcode; sb.Append("var Allowimgcode=" + allowimg.ToString() + ";\r\n"); AddScript(sb.ToString()); int price = 0; if (topic.Special == 0)//普通主题 { //购买帖子操作 //判断是否为购买可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买 if (topic.Price > 0 && userid != topic.Posterid && ismoder != 1) { price = topic.Price; //时间乘以-1是因为当Configs.GetMaxChargeSpan()==0时,帖子始终为购买帖 if (PaymentLogs.IsBuyer(topicid, userid) || (Utils.StrDateDiffHours(topic.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 && Scoresets.GetMaxChargeSpan() != 0)) //判断当前用户是否已经购买 { price = -1; } } try { if (price > 0) { if (userid > 0) { float extcredits2 = Discuz.Forum.Users.GetUserExtCredits(userid, 2); if (extcredits2 < price) { //HttpContext.Current.Response.Redirect(forumpath + "buytopic.aspx?topicid=" + topic.Tid); AddErrLine("抱歉,您的金币已不足以浏览该帖!"); return; } } else { AddErrLine("您当前的身份是游客,需要登录才能浏览该帖"); } } } catch { AddErrLine("您当前的身份是游客,需要登录才能浏览该帖"); } } if (topic.Special == 3)//已给分的悬赏帖 { bonuslogs = Bonus.GetLogs(topic.Tid); } if (topic.Moderated > 0) { moderactions = TopicAdmins.GetTopicListModeratorLog(topicid); } try { topictypes = Caches.GetTopicTypeArray()[topic.Typeid].ToString(); topictypes = topictypes != "" ? "[" + topictypes + "]" : ""; } catch { } userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetCreditsTrans()); if (newpmcount > 0) { pmlist = PrivateMessages.GetPrivateMessageCollectionForIndex(userid, 5, 1, 1); showpmhint = Convert.ToInt32(Discuz.Forum.Users.GetShortUserInfo(userid).Newsletter) > 4; } ispoll = false; allowvote = false; if (topic.Special == 1) { ispoll = true; polloptionlist = Polls.GetPollOptionList(topicid); pollinfo = Polls.GetPollInfo(topicid); voters = Polls.GetVoters(topicid, userid, username, out allowvote); if (pollinfo.Uid != userid && useradminid != 1) //当前用户不是投票发起人或不是管理组成员 { if (pollinfo.Visible == 1 && //当为投票才可见时 (allowvote || (userid == -1 && !Utils.InArray(topicid.ToString(), ForumUtils.GetCookie("dnt_polled")))))//当允许投票或为游客(且并未投过票时)时 { showpollresult = false; } } } if (ispoll) { if (Utils.StrIsNullOrEmpty(pollinfo.Expiration)) { //AddErrLine("读取信息失败"); //return; pollinfo.Expiration = DateTime.Now.ToString(); } if (DateTime.Parse(pollinfo.Expiration) < DateTime.Now) { allowvote = false; } } // 获取帖子总数 //postcount = Posts.GetPostCount(topicid); onlyauthor = DNTRequest.GetString("onlyauthor"); if (onlyauthor == "" || onlyauthor == "0") { postcount = topic.Replies + 1; } else { postcount = DatabaseProvider.GetInstance().GetPostCount(Posts.GetPostTableID(topicid), topicid, topic.Posterid); } // 得到Ppp设置 ppp = Utils.StrToInt(ForumUtils.GetCookie("ppp"), config.Ppp); if (ppp <= 0) { ppp = config.Ppp; } //获取总页数 pagecount = postcount % ppp == 0 ? postcount / ppp : postcount / ppp + 1; if (pagecount == 0) { pagecount = 1; } // 得到当前用户请求的页数 if (DNTRequest.GetString("page").ToLower().Equals("end")) { pageid = pagecount; } else { pageid = DNTRequest.GetInt("page", 1); } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } if (pageid > pagecount) { pageid = pagecount; } //判断是否为回复可见帖, hide=0为不解析[hide]标签, hide>0解析为回复可见字样, hide=-1解析为以下内容回复可见字样显示真实内容 //将逻辑判断放入取列表的循环中处理,此处只做是否为回复人的判断,主题作者也该可见 int hide = 1; if (topic.Hide == 1 && (Posts.IsReplier(topicid, userid) || ismoder == 1)) { hide = -1; } //获取当前页主题列表 DataSet ds = new DataSet(); PostpramsInfo postpramsInfo = new PostpramsInfo(); postpramsInfo.Fid = forum.Fid; postpramsInfo.Tid = topicid; postpramsInfo.Jammer = forum.Jammer; postpramsInfo.Pagesize = ppp; postpramsInfo.Pageindex = pageid; postpramsInfo.Getattachperm = forum.Getattachperm; postpramsInfo.Usergroupid = usergroupid; postpramsInfo.Attachimgpost = config.Attachimgpost; postpramsInfo.Showattachmentpath = config.Showattachmentpath; postpramsInfo.Hide = hide; postpramsInfo.Price = price; postpramsInfo.Usergroupreadaccess = usergroupinfo.Readaccess; if (ismoder == 1) postpramsInfo.Usergroupreadaccess = int.MaxValue; postpramsInfo.CurrentUserid = userid; postpramsInfo.Showimages = forum.Allowimgcode; postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); postpramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo(); postpramsInfo.Smiliesmax = config.Smiliesmax; postpramsInfo.Bbcodemode = config.Bbcodemode; postpramsInfo.CurrentUserGroup = usergroupinfo; if (!(onlyauthor.Equals("") || onlyauthor.Equals("0"))) { postpramsInfo.Condition = string.Format(" {0}.posterid={1}", Posts.GetPostTableName(topicid), topic.Posterid); } postlist = Posts.GetPostList(postpramsInfo, out attachmentlist, ismoder == 1); foreach (ShowtopicPageAttachmentInfo showtopicpageattachinfo in attachmentlist) { if (Forums.AllowGetAttachByUserID(forum.Permuserlist, userid)) { showtopicpageattachinfo.Getattachperm = 1; showtopicpageattachinfo.Allowread = 1; } } if (topic.Special == 4) { debateexpand = Debates.GetDebateTopic(topicid); debateList = Debates.GetPostDebateList(topicid);//通过TID得到帖子观点 if (debateexpand.Terminaltime < DateTime.Now) { isenddebate = true; } foreach (ShowtopicPagePostInfo postlistinfo in postlist) { //设置POST的观点属性 if (debateList != null && debateList.ContainsKey(postlistinfo.Pid)) postlistinfo.Debateopinion = Convert.ToInt32(debateList[postlistinfo.Pid]); } } //加载帖内广告 inpostad = Advertisements.GetInPostAd("", fid, templatepath, postlist.Count > ppp ? ppp : postlist.Count); //快速发帖广告 quickeditorad = Advertisements.GetQuickEditorAD("", fid); //快速编辑器背景广告 string[] quickbgad = Advertisements.GetQuickEditorBgAd("", fid); if (quickbgad.Length > 1) { quickbgadimg = quickbgad[0]; quickbgadlink = quickbgad[1]; } if (postlist.Count <= 0) { AddErrLine("读取信息失败"); return; } //更新页面Meta中的Description项, 提高SEO友好性 string metadescritpion = Utils.RemoveHtml(postlist[0].Message); metadescritpion = metadescritpion.Length > 100 ? metadescritpion.Substring(0, 100) : metadescritpion; UpdateMetaInfo(config.Seokeywords, metadescritpion, config.Seohead); //获取相关主题集合 enabletag = (config.Enabletag & forum.Allowtag) == 1; if (enabletag) { relatedtopics = Topics.GetRelatedTopics(topicid, 5); } //得到页码链接 if (onlyauthor == "" || onlyauthor == "0") { if (config.Aspxrewrite == 1) { pagenumbers = Utils.GetStaticPageNumbers(pageid, pagecount, "showtopic-" + topicid.ToString(), config.Extname, 8); } else { pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showtopic.aspx?topicid=" + topicid.ToString(), 8); } } else { pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showtopic.aspx?onlyauthor=1&topicid=" + topicid, 8); } //更新查看次数 //Topics.UpdateTopicViews(topicid); TopicStats.Track(topicid, 1); OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forumid, forumname, topicid, topictitle, config.Onlinetimeout); forumlistboxoptions = Caches.GetForumListBoxOptionsCache(); //得到页码链接 if (onlyauthor == "" || onlyauthor == "0") { ForumUtils.WriteCookie("referer", string.Format("showtopic.aspx?topicid={0}&page={1}", topicid.ToString(), pageid.ToString())); } else { ForumUtils.WriteCookie("referer", string.Format("showtopic.aspx?onlyauthor=1&topicid={0}&page={1}", topicid.ToString(), pageid.ToString())); } score = Scoresets.GetValidScoreName(); scoreunit = Scoresets.GetValidScoreUnit(); string oldtopic = ForumUtils.GetCookie("oldtopic") + "D"; if (oldtopic.IndexOf("D" + topic.Tid.ToString() + "D") == -1 && DateTime.Now.AddMinutes(-1 * 600) < DateTime.Parse(topic.Lastpost)) { oldtopic = "D" + topic.Tid.ToString() + Utils.CutString(oldtopic, 0, oldtopic.Length - 1); if (oldtopic.Length > 3000) { oldtopic = Utils.CutString(oldtopic, 0, 3000); oldtopic = Utils.CutString(oldtopic, 0, oldtopic.LastIndexOf("D")); } ForumUtils.WriteCookie("oldtopic", oldtopic); } // 判断是否需要生成游客缓存页面 if (userid == -1 && pageid == 1) { int topiccachemark = 100 - (int) (topic.Displayorder * 15 + topic.Digest * 10 + Math.Min(topic.Views / 20, 50) + Math.Min(topic.Replies / config.Ppp * 1.5, 15)); if (topiccachemark < config.Topiccachemark) { isguestcachepage = 1; } } }