/// <summary> /// 获得积分策略 /// </summary> /// <returns>积分策略描述</returns> public static UserExtcreditsInfo GetScoreSet(int extcredits) { UserExtcreditsInfo userextcreditsinfo = new UserExtcreditsInfo(); string extcreditsname = "extcredits" + extcredits; DataTable dt = GetScoreSet(); if (extcredits > 0) { userextcreditsinfo.Name = dt.Rows[0][extcreditsname].ToString(); userextcreditsinfo.Unit = dt.Rows[1][extcreditsname].ToString(); userextcreditsinfo.Rate = Single.Parse(dt.Rows[2][extcreditsname].ToString()); userextcreditsinfo.Init = Single.Parse(dt.Rows[3][extcreditsname].ToString()); userextcreditsinfo.Topic = Single.Parse(dt.Rows[4][extcreditsname].ToString()); userextcreditsinfo.Reply = Single.Parse(dt.Rows[5][extcreditsname].ToString()); userextcreditsinfo.Digest = Single.Parse(dt.Rows[6][extcreditsname].ToString()); userextcreditsinfo.Upload = Single.Parse(dt.Rows[7][extcreditsname].ToString()); userextcreditsinfo.Download = Single.Parse(dt.Rows[8][extcreditsname].ToString()); userextcreditsinfo.Pm = Single.Parse(dt.Rows[9][extcreditsname].ToString()); userextcreditsinfo.Search = Single.Parse(dt.Rows[10][extcreditsname].ToString()); userextcreditsinfo.Pay = Single.Parse(dt.Rows[11][extcreditsname].ToString()); userextcreditsinfo.Vote = Single.Parse(dt.Rows[12][extcreditsname].ToString()); } return userextcreditsinfo; }
protected override void ShowPage() { if (oluserinfo.Groupid == 4) { AddErrLine("你所在的用户组,为禁止发言"); return; } #region 临时帐号发帖 int realuserid = -1; bool tempaccountspost = false; string tempusername = DNTRequest.GetString("tempusername"); if (!Utils.StrIsNullOrEmpty(tempusername) && tempusername != username) { realuserid = Users.CheckTempUserInfo(tempusername, DNTRequest.GetString("temppassword"), DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer")); if (realuserid == -1) { AddErrLine("临时帐号登录失败,无法继续发帖。"); return; } else { userid = realuserid; username = tempusername; tempaccountspost = true; } } #endregion if (userid > 0) { userinfo = Users.GetShortUserInfo(userid); if (userinfo != null) { usergroupinfo = UserGroups.GetUserGroupInfo(userinfo.Groupid); usergroupid = usergroupinfo.Groupid; useradminid = userinfo.Adminid; } } #region 获取并检查版块信息 forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Layer == 0) { allowposttopic = false; AddErrLine("错误的论坛ID"); return; } pagetitle = Utils.RemoveHtml(forum.Name); enabletag = (config.Enabletag & forum.Allowtag) == 1; if (forum.Applytopictype == 1) //启用主题分类 topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } needaudit = UserAuthority.NeedAudit(forum, useradminid, userid); smileyoff = 1 - forum.Allowsmilies; bbcodeoff = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1; allowimg = forum.Allowimgcode; #endregion #region 访问和发帖权限校验 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = true; return; } if (!UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = true; return; } #endregion #region 附件信息绑定 //得到用户可以上传的文件类型 string attachmentTypeSelect = Attachments.GetAllowAttachmentType(usergroupinfo, forum); attachextensions = Attachments.GetAttachmentTypeArray(attachmentTypeSelect); attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect); //得到今天允许用户上传的附件总大小(字节) int MaxTodaySize = (userid > 0 ? MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid) : 0); attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;//今天可上传得大小 //是否有上传附件的权限 canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg); if (canpostattach && (userinfo != null && userinfo.Uid > 0) && apb != null && config.Enablealbum == 1 && (UserGroups.GetUserGroupInfo(userinfo.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } #endregion #region 判断是否是灌水 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); if (admininfo != null) disablepost = admininfo.Disablepostctrl; if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, ref msg)) { AddErrLine(msg); return; } #endregion #region 积分信息 creditstrans = Scoresets.GetTopicAttachCreditsTrans(); userextcreditsinfo = Scoresets.GetScoreSet(creditstrans); bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); #endregion #region 特殊主题权限判断 if (forum.Allowspecialonly > 0 && Utils.StrIsNullOrEmpty(type)) { AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", forum.Name)); return; } if (!UserAuthority.PostSpecialAuthority(forum, type, ref msg)) { AddErrLine(msg); return; } if (!UserAuthority.PostSpecialAuthority(usergroupinfo, type, ref msg)) { AddErrLine(msg); needlogin = true; return; } if (type == "bonus") { int creditTrans = Scoresets.GetBonusCreditsTrans(); //当“交易积分设置”有效时(1-8的整数): if (creditTrans <= 0) { //AddErrLine(string.Format("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏", usergroupinfo.Grouptitle)); return; AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏"); return; } mybonustranscredits = Users.GetUserExtCredits(userid, creditTrans); } #endregion //如果是提交... if (ispost) { SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", forumid, type)); ForumUtils.WriteCookie("postmessage", postmessage); #region 验证提交信息 //常规项验证 NormalValidate(admininfo, postmessage, userinfo); if (IsErr()) return; // 如果用户上传了附件,则检测用户是否有上传附件的权限 if (ForumUtils.IsPostFile()) { if (Utils.StrIsNullOrEmpty(Attachments.GetAttachmentTypeArray(attachmentTypeSelect))) AddErrLine("系统不允许上传附件"); if (!UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg)) AddErrLine(msg); } //发悬赏校验 int topicprice = 0; bool isbonus = type == "bonus"; ValidateBonus(ref topicprice, ref isbonus); //发特殊主题校验 ValidatePollAndDebate(); if (IsErr()) return; #endregion int hide = (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) ? 1 : 0; TopicInfo topicinfo = CreateTopic(admininfo, postmessage, isbonus, topicprice); if (IsErr()) return; PostInfo postinfo = CreatePost(topicinfo); if (IsErr()) return; //处理附件 StringBuilder sb = new StringBuilder(); AttachmentInfo[] attachmentinfo = ForumUtils.SaveRequestFiles(forumid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, forum.Disablewatermark == 1 ? 0 : config.Watermarkstatus, config, "postfile"); Attachments.UpdateAttachment(attachmentinfo, topicinfo.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo); //加入相册 if (!tempaccountspost && config.Enablealbum == 1 && apb != null) sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username)); #region 添加日志的操作 SpacePluginBase spb = SpacePluginProvider.GetInstance(); if (DNTRequest.GetFormString("addtoblog") == "on" && spb != null) { if (userid != -1 && userinfo.Spaceid > 0) spb.CreateTopic(topicinfo, postinfo, attachmentinfo); else AddMsgLine("您的个人空间尚未开通, 无法同时添加为日志"); } #endregion OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forum.Name, -1, "", config.Onlinetimeout); // 更新在线表中的用户最后发帖时间 OnlineUsers.UpdatePostTime(olid); #region 设置提示信息和跳转链接 if (sb.Length > 0) { SetUrl(base.ShowTopicAspxRewrite(topicinfo.Tid, 0)); SetMetaRefresh(5); SetShowBackLink(true); if (infloat == 1) { AddErrLine(sb.ToString()); return; } else { sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表主题成功,但以下附件上传失败:</nobr></span><br /></td></tr>"); AddMsgLine(sb.Append("</table>").ToString()); } } else { SetShowBackLink(false); if (useradminid != 1) { //是否需要审核 if (UserAuthority.NeedAudit(forum, useradminid, topicinfo, userid, disablepost)) { SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid)); SetMetaRefresh(); AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块"); } else PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid); } else PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid); } #endregion ForumUtils.WriteCookie("postmessage", ""); SetLastPostedForumCookie(); //如果已登录就不需要再登录 if (needlogin && userid > 0) needlogin = false; } else //非提交操作 AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); }
protected override void ShowPage() { //获取主题信息 topic = GetTopicInfo(); if (topic == null) return; topicid = topic.Tid; forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); if (forum == null) { AddErrLine("不存在的版块ID"); return; } //验证不通过则返回 if (!ValidateInfo() || IsErr()) return; int price = GetTopicPrice(topic); if (topic.Special == 0 && price > 0) { HttpContext.Current.Response.Redirect(forumpath + "buytopic.aspx?topicid=" + topic.Tid); return; } if (userid > 0) { userInfo = Users.GetShortUserInfo(userid); } if (topic.Identify > 0) topicidentify = Caches.GetTopicIdentify(topic.Identify); pagetitle = string.Format("{0} - {1}", topic.Title, forum.Name); ///得到广告列表 GetForumAds(forum.Fid); IsModer(); //获取主题类型 Caches.GetTopicTypeArray().TryGetValue(topic.Typeid, out topictypes); topictypes = Utils.StrIsNullOrEmpty(topictypes) ? "" : "[" + topictypes + "]"; userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); score = Scoresets.GetValidScoreName(); scoreunit = Scoresets.GetValidScoreUnit(); navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname); //编辑器状态 EditorState(); string[] customauthorinfo = GeneralConfigs.GetConfig().Customauthorinfo.Split('|'); postleftshow = customauthorinfo[0].Split(',');//帖子左边要显示的用户信息项目 userfaceshow = customauthorinfo[1].Split(',');//头像上方要显示的项目 //if (newpmcount > 0) // pmlist = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1); onlyauthor = (onlyauthor == "1" || onlyauthor == "2") ? onlyauthor : "0"; // 获取分页相关信息 BindPageCountAndId(); GetPostAds(GetPostPramsInfo(price), postlist.Count); #region 获取特殊主题相关信息 bonuslogs = Bonus.GetLogs(topic); if (topic.Special == 1)//获取投票信息 GetPollInfo(); if (topic.Special == 4) //获取辩论信息 GetDebateInfo(); #endregion if (postlist.Count <= 0) { AddErrLine("读取信息失败"); return; } enabletag = (config.Enabletag & forum.Allowtag) == 1; //if (enabletag) // relatedtopics = Topics.GetRelatedTopicList(topicid, 5); //更新页面Meta信息 UpdateMetaInfo(Utils.RemoveHtml(postlist[0].Message)); //判断是否需要生成游客缓存页面 IsGuestCachePage(); //更新主题查看次数和在线用户信息 TopicStats.Track(topicid, 1); Topics.MarkOldTopic(topic); topicviews = topic.Views + 1 + (config.TopicQueueStats == 1 ? TopicStats.GetStoredTopicViewCount(topic.Tid) : 0); OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forumid, forum.Name, topicid, topic.Title); //UserCredits.UpdateUserCredits(userInfo);此方法与后台积分设置中的条目不匹配,故注释 }
protected override void ShowPage() { GetPostAds(forumid); if (userid > 0 && useradminid > 0) { AdminGroupInfo admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid); if (admingroupinfo != null) disablepostctrl = admingroupinfo.Disablepostctrl; } #region 获取版块信息 if (forumid == -1) { AddLinkRss(forumpath + "tools/rss.aspx", "最新主题"); AddErrLine("无效的版块ID"); return; } forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Fid < 1) { if (config.Rssstatus == 1) AddLinkRss(forumpath + "tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新主题"); AddErrLine("不存在的版块ID"); return; } #endregion if (config.Rssstatus == 1) AddLinkRss(forumpath + "tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新主题"); if (JumpUrl(forum)) return; needaudit = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo); // 检查是否具有版主的身份 if (useradminid > 0) ismoder = Moderators.IsModer(useradminid, userid, forumid); //设置搜索和排序条件 SetSearchCondition(); showforumlogin = IsShowForumLogin(forum); pagetitle = Utils.RemoveHtml(forum.Name); navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname); forumnav = ShowForumAspxRewrite(ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname).Replace("\"showforum", "\"" + forumurl + "showforum"), forumid, pageid); topicextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); #region 主题分类设置 if (forum.Applytopictype == 1) //启用主题分类 topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); if (forum.Viewbytopictype == 1) //允许按类别浏览 topictypeselectlink = Forums.GetCurrentTopicTypesLink(forum.Fid, forum.Topictypes, forumurl + "showforum.aspx"); #endregion //更新页面Meta中的keyword,description项, 提高SEO友好性 UpdateMetaInfo(Utils.StrIsNullOrEmpty(forum.Seokeywords) ? config.Seokeywords : forum.Seokeywords, Utils.StrIsNullOrEmpty(forum.Seodescription) ? forum.Description : forum.Seodescription, config.Seohead); //设置编辑器状态 SetEditorState(); #region 访问和发帖权限校验 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = userid == -1; return; } canposttopic = UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg); // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visittime = ""; if (canposttopic && Scoresets.BetweenTime(config.Postbanperiods, out visittime)) canposttopic = false; isnewbie = UserAuthority.CheckNewbieSpan(userid); } //是否显示快速发主题编辑器(全局权限判定,版块权限判定,是否是游客,游客需要显示,登录用户是否允许发主题且已过新手见习期) if ((config.Fastpost == 1 || config.Fastpost == 3) && forum.Allowspecialonly <= 0 && (userid < 0 || (canposttopic && !isnewbie))) canquickpost = true; #endregion // 得到子版块列表 if (forum.Subforumcount > 0) subforumlist = Forums.GetSubForumCollection(forumid, forum.Colcount, config.Hideprivate, usergroupid, config.Moddisplay); if (!forum.Rules.Equals("")) forum.Rules = UBB.ParseSimpleUBB(forum.Rules);//替换版规中的UBB //获取主题总数 topiccount = Topics.GetTopicCount(forumid, true, condition); #region 设置分页及主题列表信息 // 得到Tpp设置 if (tpp <= 0) tpp = config.Tpp; // 得到Ppp设置 if (ppp <= 0) ppp = config.Ppp; //修正请求页数中可能的错误 if (pageid < 1) pageid = 1; int toptopicpagecount = 0; if (forum.Layer > 0) { //获取当前页置顶主题列表 DataRow dr = Topics.GetTopTopicListID(forumid); if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString())) topiccount = topiccount + TypeConverter.ObjectToInt(dr["tid0Count"]); //获取总页数 pagecount = topiccount % tpp == 0 ? topiccount / tpp : topiccount / tpp + 1; if (pagecount == 0) pagecount = 1; if (pageid > pagecount) pageid = pagecount; if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString())) { toptopiccount = TypeConverter.ObjectToInt(dr["tidCount"]); if (toptopiccount > tpp * (pageid - 1)) { toptopiclist = Topics.GetTopTopicList(forumid, tpp, pageid, dr["tid"].ToString(), forum.Autoclose, forum.Topictypeprefix); toptopicpagecount = toptopiccount / tpp; } if (toptopicpagecount >= pageid || (pageid == 1 && toptopicpagecount != toptopiccount)) topiclist = GetTopicInfoList(tpp - toptopiccount % tpp, pageid - toptopicpagecount, 0); else topiclist = GetTopicInfoList(tpp, pageid - toptopicpagecount, toptopiccount % tpp); } else { toptopicpagecount = 0; topiclist = GetTopicInfoList(tpp, pageid, 0); } //如果topiclist为空则更新当前论坛帖数 if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount) Forums.SetRealCurrentTopics(forum.Fid); SetPageNumber(); //当版块数大于一个并且当版块数量为一个时不是版块自身时显示下拉菜单 showvisitedforumsmenu = visitedforums != null && ((visitedforums.Length == 1 && visitedforums[0].Fid != forumid) || visitedforums.Length > 1); SetVisitedForumsCookie(); //保存查看版块的页数 Utils.WriteCookie("forumpageid", pageid.ToString(), 30); //判断是否需要生成游客缓存页面 IsGuestCachePage(); } #endregion #region 替换版规中的UBB forum.Description = UBB.ParseSimpleUBB(forum.Description); #endregion #region 更新在线信息 OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forum.Name, -1, ""); if ((forumtotalonline < config.Maxonlinelist && (config.Whosonlinestatus == 2 || config.Whosonlinestatus == 3)) || DNTRequest.GetString("showonline") == "yes") { showforumonline = true; onlineuserlist = OnlineUsers.GetForumOnlineUserCollection(forumid, out forumtotalonline, out forumtotalonlineguest, out forumtotalonlineuser, out forumtotalonlineinvisibleuser); } //if (DNTRequest.GetString("showonline") != "no") //{ // showforumonline = false; //} if (DNTRequest.GetString("showonline") == "no") { showforumonline = false; } #endregion //修正版主列表 if (forum.Moderators.Trim() != "") { string moderHtml = string.Empty; foreach (string m in forum.Moderators.Split(',')) { moderHtml += string.Format("<a href=\"{0}userinfo.aspx?username={1}\">{2}</a>,", forumpath, Utils.UrlEncode(m), m); } forum.Moderators = moderHtml.TrimEnd(','); } ForumUtils.UpdateVisitedForumsOptions(forumid); }
protected override void ShowPage() { if (config.Enablemall == 0) //未启用交易模式 { AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!"); return; } #region 临时帐号发帖 //int realuserid = -1; //string tempusername = DNTRequest.GetString("tempusername"); //if (tempusername != "" && tempusername != username) //{ // string temppassword = DNTRequest.GetString("temppassword"); // int question = DNTRequest.GetInt("question", 0); // string answer = DNTRequest.GetString("answer"); // realuserid = Users.CheckTempUserInfo(tempusername, temppassword, question, answer); // if (realuserid == -1) // { // AddErrLine("临时帐号登录失败,无法继续发帖。"); // return; // } // else // { // userid = realuserid; // username = tempusername; // usergroupinfo = UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(userid).Groupid); // usergroupid = usergroupinfo.Groupid; // useradminid = Users.GetShortUserInfo(userid).Adminid; // } //} #endregion canhtmltitle = true; firstpagesmilies = Caches.GetSmiliesFirstPageCache(); //内容设置为空; message = ""; int goodsid = DNTRequest.GetInt("goodsid", 0); // 如果商品交易日志不正确 if (goodsid <= 0) { AddErrLine("错误的商品ID."); return; } goodsinfo = Goods.GetGoodsInfo(goodsid); if (goodsinfo == null || goodsinfo.Goodsid <= 0) { AddErrLine("错误的商品ID."); return; } goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(goodsinfo.Categoryid); if (goodscategoryinfo == null && goodscategoryinfo.Fid <= 0) { goodscategoryinfo = new Goodscategoryinfo(); goodscategoryinfo.Categoryid = -1; } attachmentlist = GoodsAttachments.GetGoodsAttachmentsByGoodsid(goodsinfo.Goodsid); message = goodsinfo.Message; // 如果商品交易日志不正确 if (goodsinfo.Selleruid != userid) { AddErrLine("您不是当前商品的卖家!"); return; } allowpostgoods = true; if (config.Enablemall == 1) //开启普通模式 { forumid = GoodsCategories.GetCategoriesFid(goodsinfo.Categoryid); allowpostgoods = false; forumnav = ""; if (forumid == -1) { if (userid == goodsinfo.Selleruid) { forum = new ForumInfo(); forum.Attachextensions = ""; forum.Password = ""; forum.Permuserlist = ""; } else { AddErrLine("错误的商品分类ID"); return; } } else { forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Layer == 0) { AddErrLine("错误的商品分类ID"); return; } if (forum.Istrade <= 0) { AddErrLine("当前版块不允许编辑商品"); return; } forumname = forum.Name; pagetitle = Utils.RemoveHtml(forum.Name); forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); enabletag = (config.Enabletag & forum.Allowtag) == 1; } } else if (config.Enablemall == 2) //当为高级模式时 { pagetitle = "编辑商品"; forumnav = ""; enabletag = true; forum = new ForumInfo(); forum.Allowsmilies = 1; forum.Allowbbcode = 1; } //得到用户可以上传的文件类型 StringBuilder sbAttachmentTypeSelect = new StringBuilder(); if (!usergroupinfo.Attachextensions.Trim().Equals("")) { sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions); sbAttachmentTypeSelect.Append(")"); } if (config.Enablemall == 1) //开启普通模式 { if (!forum.Attachextensions.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;//今天可上传得大小 parseurloff = 0; bbcodeoff = 1; if (config.Enablemall == 1) //开启普通模式 { smileyoff = 1 - forum.Allowsmilies; if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) bbcodeoff = 0; allowimg = forum.Allowimgcode; if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } if (!Forums.AllowViewByUserId(forum.Permuserlist, userid)) //判断当前用户在当前版块浏览权限 { if (forum.Viewperm == null || forum.Viewperm == string.Empty)//当板块权限为空时,按照用户组权限 { if (useradminid != 1 && (usergroupinfo.Allowvisit != 1 || usergroupinfo.Allowtrade != 1)) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限"); return; } } else//当板块权限不为空,按照板块权限 { if (!Forums.AllowView(forum.Viewperm, usergroupid)) { AddErrLine("您没有浏览该商品分类的权限"); return; } } } //当前用户是卖家时 if (goodsinfo.Selleruid == userid) { //当前用户是否有允许下载附件权限 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 == "") { if (usergroupinfo.Allowpostattach == 1) canpostattach = true; } else { if (Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) { canpostattach = true; } } } } } else if (config.Enablemall == 2) //当为高级模式时 { canpostattach = true; allowimg = 1; smileyoff = 0; } ShortUserInfo user = Users.GetShortUserInfo(userid); if (canpostattach && user != null && apb != null && config.Enablealbum == 1 && (UserGroups.GetUserGroupInfo(user.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } else caninsertalbum = false; if (Topics.GetMagicValue(goodsinfo.Magic, MagicType.HtmlTitle) == 1) { htmltitle = Goods.GetHtmlTitle(goodsinfo.Goodsid).Replace("\"", "\\\"").Replace("'", "\\'"); } if (enabletag && Topics.GetMagicValue(goodsinfo.Magic, MagicType.TopicTag) == 1) { foreach (TagInfo tag in GoodsTags.GetTagsListByGoods(goodsinfo.Goodsid)) { if (tag.Orderid > -1) goodstags += string.Format(" {0}", tag.Tagname); } goodstags = goodstags.Trim(); } // 如果是受灌水限制用户, 则判断是否是灌水 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); disablepost = (admininfo != null) ? admininfo.Disablepostctrl : 0; creditstrans = Scoresets.GetCreditsTrans(); userextcreditsinfo = Scoresets.GetScoreSet(creditstrans); if (userid > 0) spaceid = Users.GetShortUserInfo(userid).Spaceid; //如果不是提交... if (!ispost) { AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); smilies = Caches.GetSmiliesCache(); smilietypes = Caches.GetSmilieTypesCache(); customeditbuttons = Caches.GetCustomEditButtonList(); } else { SetBackLink(string.Format("postgoods.aspx?forumid={0}&restore=1", forumid)); string postmessage = DNTRequest.GetString("message"); ForumUtils.WriteCookie("postmessage", postmessage); if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } if (DNTRequest.GetString("title").Trim().Equals("")) AddErrLine("商品标题不能为空"); else if (DNTRequest.GetString("title").IndexOf(" ") != -1) AddErrLine("商品标题不能包含全角空格符"); else if (DNTRequest.GetString("title").Length > 60) AddErrLine("商品标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length.ToString() + " 个字符"); if (postmessage.Equals("") || postmessage.Replace(" ", "").Equals("")) AddErrLine("商品内容不能为空"); if (admininfo != null && admininfo.Disablepostctrl != 1) { if (postmessage.Length < config.Minpostsize) AddErrLine("您发表的内容过少, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字"); else if (postmessage.Length > config.Maxpostsize) AddErrLine("您发表的内容过多, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字"); } if (IsErr()) return; // 如果用户上传了附件,则检测用户是否有上传附件的权限 if (ForumUtils.IsPostFile()) { if (Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()).Trim() == "") AddErrLine("系统不允许上传附件"); if (config.Enablemall == 1) //开启普通模式 { if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userid)) { if (!Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) AddErrLine("您没有在该版块上传附件的权限"); else if (usergroupinfo.Allowpostattach != 1) AddErrLine(string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", usergroupinfo.Grouptitle)); } } } if (IsErr()) return; int iconid = DNTRequest.GetInt("iconid", 0); if (iconid > 15 || iconid < 0) iconid = 0; string curdatetime = Utils.GetDateTime(); goodsinfo.Shopid = 0; //商品分类原值 int oldgoodscategoryid = goodsinfo.Categoryid; //商品父分类原值 string oldparentcategorylist = goodsinfo.Parentcategorylist; //当商品分类发生变化时 if (DNTRequest.GetInt("goodscategoryid", 0) != 0 && goodsinfo.Categoryid != DNTRequest.GetInt("goodscategoryid", 0)) { goodsinfo.Categoryid = DNTRequest.GetInt("goodscategoryid", 0); goodsinfo.Parentcategorylist = GoodsCategories.GetParentCategoryList(goodsinfo.Categoryid); } goodsinfo.Recommend = DNTRequest.GetString("recommend") == "on" ? 1 : 0; goodsinfo.Discount = DNTRequest.GetInt("discount", 0); goodsinfo.Selleruid = userid; goodsinfo.Seller = username; goodsinfo.Account = DNTRequest.GetString("account"); goodsinfo.Price = Convert.ToDecimal(DNTRequest.GetFormFloat("price", 1).ToString()); goodsinfo.Amount = DNTRequest.GetInt("amount", 0); goodsinfo.Quality = DNTRequest.GetInt("quality", 0); if(DNTRequest.GetInt("locus_2", 0) != 0) { goodsinfo.Lid = DNTRequest.GetInt("locus_2", 0); goodsinfo.Locus = Locations.GetLocusByLID(goodsinfo.Lid); } goodsinfo.Transport = DNTRequest.GetInt("transport", 0); if (goodsinfo.Transport != 0) { goodsinfo.Ordinaryfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_mail", 0).ToString()); goodsinfo.Expressfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_express", 0).ToString()); goodsinfo.Emsfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_ems", 0).ToString()); } goodsinfo.Itemtype = DNTRequest.GetInt("itemtype", 0); DateTime dateline; switch (DNTRequest.GetInt("_now", 0)) { case 1: dateline = Convert.ToDateTime(string.Format("{0} {1}:{2}:00", DNTRequest.GetString("_date"), DNTRequest.GetInt("_hour", 0), DNTRequest.GetInt("_minute", 0))); break; //设定 case 2: dateline = Convert.ToDateTime("1900-01-01 00:00:00"); break; //返回100年之后的日期作为"暂不设置" default: dateline = DateTime.Now; break; //立即 } goodsinfo.Dateline = dateline; goodsinfo.Expiration = Convert.ToDateTime(DNTRequest.GetString("expiration")); goodsinfo.Lastbuyer = ""; goodsinfo.Lastupdate = DateTime.Now; goodsinfo.Totalitems = 0; goodsinfo.Tradesum = 0; goodsinfo.Closed = 0; goodsinfo.Aid = 0; int displayorder = goodsinfo.Displayorder; goodsinfo.Displayorder = DNTRequest.GetString("displayorder") == "on" ? 0 : -3; if (config.Enablemall == 1) //当为版块交易帖是时 { if (forum.Modnewposts == 1 && useradminid != 1) { if (useradminid > 1) { if (disablepost != 1) goodsinfo.Displayorder = -2; } else goodsinfo.Displayorder = -2; } } goodsinfo.Costprice = Convert.ToDecimal(DNTRequest.GetFormFloat("costprice", 1).ToString()); goodsinfo.Invoice = DNTRequest.GetInt("invoice", 0); goodsinfo.Repair = DNTRequest.GetInt("repair", 0); if (useradminid == 1) goodsinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage)); else goodsinfo.Message = Utils.HtmlEncode(postmessage); goodsinfo.Otherlink = ""; int readperm = DNTRequest.GetInt("readperm", 0); goodsinfo.Readperm = readperm > 255 ? 255 : readperm; goodsinfo.Tradetype = DNTRequest.GetInt("tradetype", 0); if (goodsinfo.Tradetype == 1 && Utils.StrIsNullOrEmpty(goodsinfo.Account)) //当为支付宝在线支付方式下,如果"支付宝账户"为空时 { AddErrLine("请输入支付宝帐号信息。"); return; } goodsinfo.Smileyoff = smileyoff; if (smileyoff == 0 && forum.Allowsmilies == 1) goodsinfo.Smileyoff = Utils.StrToInt(DNTRequest.GetString("smileyoff"), 0); goodsinfo.Bbcodeoff = 1; if (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) goodsinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0); goodsinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0); if (useradminid == 1) goodsinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title")); else goodsinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title"))); string htmltitle = DNTRequest.GetString("htmltitle").Trim(); if (htmltitle != string.Empty && Utils.HtmlDecode(htmltitle).Trim() != goodsinfo.Title) { goodsinfo.Magic = 11000; //按照 附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储 //例: 11001 } //标签(Tag)操作 string tags = DNTRequest.GetString("tags").Trim(); string[] tagsArray = null; if (enabletag && tags != string.Empty) { tagsArray = Utils.SplitString(tags, " ", true, 2, 10); if (tagsArray.Length > 0) { if (goodsinfo.Magic == 0) goodsinfo.Magic = 10000; goodsinfo.Magic = Utils.StrToInt(goodsinfo.Magic.ToString() + "1", 0); } } Goods.UpdateGoods(goodsinfo, oldgoodscategoryid, oldparentcategorylist); if (displayorder != goodsinfo.Displayorder) //当发生变化时 { if (displayorder < 0 && goodsinfo.Displayorder > 0) //该商品转为上架 DbProvider.GetInstance().UpdateCategoryGoodsCounts(goodsinfo.Categoryid, goodsinfo.Parentcategorylist, 1); else if (displayorder >= 0 && goodsinfo.Displayorder < 0) //该商品转为下架(或进入回收站/待审核状态) DbProvider.GetInstance().UpdateCategoryGoodsCounts(goodsinfo.Categoryid, goodsinfo.Parentcategorylist, -1); } //保存htmltitle if (canhtmltitle && htmltitle != string.Empty && htmltitle != goodsinfo.Title) Goods.WriteHtmlSubjectFile(htmltitle, goodsinfo.Goodsid); if (enabletag && tagsArray != null && tagsArray.Length > 0) { DbProvider.GetInstance().CreateGoodsTags(string.Join(" ", tagsArray), goodsinfo.Goodsid, userid, curdatetime); GoodsTags.WriteGoodsTagsCacheFile(goodsinfo.Goodsid); } StringBuilder sb = new StringBuilder(); sb.Remove(0, sb.Length); //编辑帖子时如果进行了批量删除附件 string delAttId = DNTRequest.GetFormString("deleteaid"); if (delAttId != string.Empty) { if (Utils.IsNumericList(delAttId))//如果要删除的附件ID列表为数字数组 GoodsAttachments.DeleteGoodsAttachment(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)//原来有附件 { int watermarkstate = config.Watermarkstatus; if (forum.Disablewatermark == 1) watermarkstate = 0; string[] updatedAttArray = updatedAttId.Split(','); string filekey = "attachupdated"; //保存新的文件 Goodsattachmentinfo[] attArray = Discuz.Mall.MallUtils.SaveRequestFiles( goodsinfo.Categoryid, 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)) //由此属性为空可以判断上传成功 { //获取将被更新的附件信息 Goodsattachmentinfo attachmentInfo = GoodsAttachments.GetGoodsAttachmentsByAid(Utils.StrToInt(updatedAttArray[attachmentUpdatedIndex], 0)); if (attachmentInfo != null) { if (attachmentInfo.Filename.Trim().ToLower().IndexOf("http") < 0) { //删除原来的文件 File.Delete(Utils.GetMapPath(BaseConfigs.GetForumPath + "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; attArray[attachmentUpdatedIndex].Categoryid = attachmentInfo.Categoryid; attArray[attachmentUpdatedIndex].Goodscount = attachmentInfo.Goodscount; attArray[attachmentUpdatedIndex].Goodsid = attachmentInfo.Goodsid; GoodsAttachments.SaveGoodsAttachment(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[i].Readperm.ToString() != readpermArray[i]) || (attachmentlist[i].Description.Trim() != descriptionArray[i])) { int att_readperm = Utils.StrToInt(readpermArray[i], 0); att_readperm = att_readperm > 255 ? 255 : att_readperm; GoodsAttachments.SaveGoodsAttachment(Utils.StrToInt(updateAttArray[i], 0), att_readperm, descriptionArray[i]); } } } } } int watermarkstatus = config.Watermarkstatus; if (forum.Disablewatermark == 1) { watermarkstatus = 0; } Goodsattachmentinfo[] attachmentinfo = Discuz.Mall.MallUtils.SaveRequestFiles(forumid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstatus, config, "postfile"); if (attachmentinfo != null) { if (attachmentinfo.Length > config.Maxattachments) { AddErrLine("系统设置为每个商品附件不得多于" + config.Maxattachments + "个"); return; } int errorAttachment = GoodsAttachments.BindAttachment(attachmentinfo, goodsinfo.Goodsid, sb, goodsinfo.Categoryid, userid); int[] aid = GoodsAttachments.CreateAttachments(attachmentinfo); string tempMessage = GoodsAttachments.FilterLocalTags(aid, attachmentinfo, goodsinfo.Message); if (attachmentinfo.Length == (System.Web.HttpContext.Current.Request.Files.Count-2)) { goodsinfo.Goodspic = attachmentinfo[0].Filename; goodsinfo.Aid = aid[0]; } if (!tempMessage.Equals(goodsinfo.Message)) goodsinfo.Message = tempMessage; Goods.UpdateGoods(goodsinfo); UserCredits.UpdateUserExtCreditsByUploadAttachment(userid, aid.Length - errorAttachment); } //加入相册 if (config.Enablealbum == 1 && apb != null) sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username)); if (config.Enablemall == 1) //开启普通模式 { OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forumname, -1, ""); } if (sb.Length > 0) { SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid)); 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 { SetShowBackLink(false); if (config.Enablemall == 1 && forum.Modnewposts == 1 && useradminid != 1) { if (useradminid != 1) { if (disablepost == 1) { if (goodsinfo.Displayorder == -3) { SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1)); SetMetaRefresh(5); AddMsgLine("编辑商品成功, 但未上架. 您可到用户中心进行上架操作!"); } else { SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid)); SetMetaRefresh(); AddMsgLine("编辑商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回 " + forumname + "</a>)<br />"); } } else { SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1)); SetMetaRefresh(); AddMsgLine("编辑商品成功, 但需要经过审核才可以显示. 返回商品列表"); } } else { SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1)); SetMetaRefresh(); AddMsgLine("发布商品成功, 返回商品列表"); } } else { if (goodsinfo.Displayorder == -3) { SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1)); SetMetaRefresh(5); AddMsgLine("编辑商品成功, 但未上架. 您可到用户中心进行上架操作!"); } else { SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid)); SetMetaRefresh(); AddMsgLine("编辑商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回</a>)<br />"); } } } ForumUtils.WriteCookie("postmessage", ""); } topicattachscorefield = 0; }
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"); }
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; } } }
private string condition = ""; //查询条件 protected override void ShowPage() { forumnav = ""; forumallowrss = 0; forumid = DNTRequest.GetInt("forumid", -1); //ignorelink = ""; ///得到广告列表 ///头部 headerad = Advertisements.GetOneHeaderAd("", forumid); footerad = Advertisements.GetOneFooterAd("", forumid); pagewordad = Advertisements.GetPageWordAd("", forumid); doublead = Advertisements.GetDoubleAd("", forumid); floatad = Advertisements.GetFloatAd("", forumid); mediaad = Advertisements.GetMediaAd(templatepath, "", forumid); //快速发帖广告 quickeditorad = Advertisements.GetQuickEditorAD("", forumid); //快速编辑器背景广告 string[] quickbgad = Advertisements.GetQuickEditorBgAd("", forumid); if (quickbgad.Length > 1) { quickbgadimg = quickbgad[0]; quickbgadlink = quickbgad[1]; } disablepostctrl = 0; smilies = Caches.GetSmiliesCache(); smilietypes = Caches.GetSmilieTypesCache(); firstpagesmilies = Caches.GetSmiliesFirstPageCache(); if (userid > 0 && useradminid > 0) { admingroupinfo = AdminGroups.GetAdminGroupInfo(useradminid); } if (admingroupinfo != null) { this.disablepostctrl = admingroupinfo.Disablepostctrl; } if (forumid == -1) { AddLinkRss("tools/rss.aspx", "最新主题"); AddErrLine("无效的版块ID"); return; } else { forum = Forums.GetForumInfo(forumid); if (forum == null) { if (config.Rssstatus == 1) { AddLinkRss("tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新主题"); } AddErrLine("不存在的版块ID"); return; } //当版块有外部链接时,则直接跳转 if (forum.Redirect != null && forum.Redirect != string.Empty) { System.Web.HttpContext.Current.Response.Redirect(forum.Redirect); return; } if (useradminid > 0) { // 检查是否具有版主的身份 ismoder = Moderators.IsModer(useradminid, userid, forumid); } #region 对搜索条件进行检索 string orderStr = ""; condition = ""; topictypeid = DNTRequest.GetInt("typeid", 0); if (topictypeid > 0) { condition = DatabaseProvider.GetInstance().showforumcondition(1, 0) + topictypeid; } filter = DNTRequest.GetString("filter"); if (!Utils.StrIsNullOrEmpty(filter)) { condition += DatabaseProvider.GetInstance().GetTopicFilterCondition(filter); } if (DNTRequest.GetString("search").Trim() != "") //进行指定查询 { //多少时间以来的数据 cond = DNTRequest.GetInt("cond", -1); if (cond < 1) { cond = 0; } else { if (!(topictypeid > 0)) //当有主题分类时,则不加入下面的日期查询条件 { condition = DatabaseProvider.GetInstance().showforumcondition(2, cond); } } //排序的字段 order = DNTRequest.GetInt("order", -1); switch (order) { case 2: orderStr = DatabaseProvider.GetInstance().showforumcondition(3, 0); //发布时间 break; default: orderStr = ""; break; } if (DNTRequest.GetInt("direct", -1) == 0) { direct = 0; } } #endregion if (forum.Fid < 1) { if (config.Rssstatus == 1 && forum.Allowrss == 1) { AddLinkRss("tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新主题"); } AddErrLine("不存在的版块ID"); return; } if (config.Rssstatus == 1) { AddLinkRss("tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新主题"); } forumname = forum.Name; pagetitle = Utils.RemoveHtml(forum.Name); subforumcount = forum.Subforumcount; forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname); //更新页面Meta中的Description项, 提高SEO友好性 UpdateMetaInfo(config.Seokeywords, forum.Description, config.Seohead); if (forum.Applytopictype == 1) //启用主题分类 { topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); } if (forum.Viewbytopictype == 1) //允许按类别浏览 { topictypeselectlink = Forums.GetCurrentTopicTypesLink(forum.Fid, forum.Topictypes, "showforum.aspx"); } //编辑器状态 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()); // 是否显示版块密码提示 1为显示, 0不显示 showforumlogin = 1; // 如果版块未设密码 if (forum.Password == "") { showforumlogin = 0; } else { // 如果检测到相应的cookie正确 if (Utils.MD5(forum.Password) == ForumUtils.GetCookie("forum" + forumid.ToString() + "password")) { showforumlogin = 0; } else { // 如果用户提交的密码正确则保存cookie if (forum.Password == DNTRequest.GetString("forumpassword")) { ForumUtils.WriteCookie("forum" + forumid.ToString() + "password", Utils.MD5(forum.Password)); showforumlogin = 0; } } } if (!Forums.AllowViewByUserID(forum.Permuserlist, userid)) //判断当前用户在当前版块浏览权限 { if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限 { if (usergroupinfo.Allowvisit != 1) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限"); if (userid == -1) { needlogin = true; } return; } } else //当板块权限不为空,按照板块权限 { if (!Forums.AllowView(forum.Viewperm, usergroupid)) { AddErrLine("您没有浏览该版块的权限"); if (userid == -1) { needlogin = true; } return; } } } //判断是否有发主题的权限 if (userid > -1 && Forums.AllowPostByUserID(forum.Permuserlist, userid)) { canposttopic = true; } if (forum.Postperm == null || forum.Postperm == string.Empty) //权限设置为空时,根据用户组权限判断 { // 验证用户是否有发表主题的权限 if (usergroupinfo.Allowpost == 1) { canposttopic = true; } } else if (Forums.AllowPost(forum.Postperm, usergroupid)) { canposttopic = true; } // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visittime = ""; if (Scoresets.BetweenTime(config.Postbanperiods, out visittime)) { canposttopic = false; } } //判断是否有快速发主题的权限 if (canposttopic == true) { if (config.Fastpost == 1 || config.Fastpost == 3) { canquickpost = true; } } 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; } // 得到子版块列表 //subforumlist = Forums.GetForumList(forumid, config.Hideprivate, usergroupid, config.Moddisplay); if (subforumcount > 0) { subforumlist = Forums.GetSubForumCollection(forumid, forum.Colcount, config.Hideprivate, usergroupid, config.Moddisplay); } //得到当前用户请求的页数 pageid = DNTRequest.GetInt("page", 1); //获取主题总数 topiccount = Topics.GetTopicCount(forumid, condition, true); // 得到Tpp设置 tpp = Utils.StrToInt(ForumUtils.GetCookie("tpp"), config.Tpp); if (tpp <= 0) { tpp = config.Tpp; } // 得到Tpp设置 ppp = Utils.StrToInt(ForumUtils.GetCookie("ppp"), config.Ppp); if (ppp <= 0) { ppp = config.Ppp; } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } int toptopicpagecount = 0; if (forum.Layer > 0) { // 得到公告 //announcementlist = Announcements.GetSimplifiedAnnouncementList(nowdatetime, "2999-01-01 00:00:00"); //获取当前页置顶主题列表 DataRow dr = Topics.GetTopTopicListID(forumid); if (dr != null && dr["tid"].ToString() != "") { topiccount = topiccount + Utils.StrToInt(dr["tid0Count"].ToString(), 0); //获取总页数 pagecount = topiccount % tpp == 0 ? topiccount / tpp : topiccount / tpp + 1; if (pagecount == 0) { pagecount = 1; } if (pageid > pagecount) { pageid = pagecount; } toptopiccount = Utils.StrToInt(dr["tidCount"].ToString(), 0); if (toptopiccount > tpp * (pageid - 1)) { toptopiclist = Topics.GetTopTopicCollection(forumid, tpp, pageid, dr["tid"].ToString(), forum.Autoclose, forum.Topictypeprefix); toptopicpagecount = toptopiccount / tpp; } if (toptopicpagecount >= pageid || (pageid == 1 && toptopicpagecount != toptopiccount)) { if (orderStr == "" && direct == 1) { topiclist = Topics.GetTopicCollection(forumid, tpp - toptopiccount % tpp, pageid - toptopicpagecount, 0, 600, config.Hottopic, forum.Autoclose, forum.Topictypeprefix, condition); } else { if (direct == 0 && orderStr == string.Empty) { orderStr = "lastpostid"; } topiclist = Topics.GetTopicCollection(forumid, tpp - toptopiccount % tpp, pageid - toptopicpagecount, 0, 600, config.Hottopic, forum.Autoclose, forum.Topictypeprefix, condition, orderStr, direct); } } else { if (orderStr == "" && direct == 1) { topiclist = Topics.GetTopicCollection(forumid, tpp, pageid - toptopicpagecount, toptopiccount % tpp, 600, config.Hottopic, forum.Autoclose, forum.Topictypeprefix, condition); } else { if (direct == 0 && orderStr == string.Empty) { orderStr = "lastpostid"; } topiclist = Topics.GetTopicCollection(forumid, tpp, pageid - toptopicpagecount, toptopiccount % tpp, 600, config.Hottopic, forum.Autoclose, forum.Topictypeprefix, condition, orderStr, direct); } } } else { #if NET1 toptopiclist = new ShowforumPageTopicInfoCollection(); #else toptopiclist = new Topics.ShowforumPageTopicInfoCollection<ShowforumPageTopicInfo>(); #endif //获取总页数 pagecount = topiccount % tpp == 0 ? topiccount / tpp : topiccount / tpp + 1; if (pagecount == 0) { pagecount = 1; } if (pageid > pagecount) { pageid = pagecount; } //toptopiclist = new DataTable(); toptopicpagecount = 0; if (orderStr == "" && direct == 1) { topiclist = Topics.GetTopicCollection(forumid, tpp, pageid, 0, 600, config.Hottopic, forum.Autoclose, forum.Topictypeprefix, condition); } else { if (direct == 0 && orderStr == string.Empty) { orderStr = "lastpostid"; } topiclist = Topics.GetTopicCollection(forumid, tpp, pageid, 0, 600, config.Hottopic, forum.Autoclose, forum.Topictypeprefix, condition, orderStr, direct); } } // // if(forum.Topictypeprefix==1) // { // toptopiclist = Topics.GetTopicTypeName(toptopiclist); // topiclist = Topics.GetTopicTypeName(topiclist); // } //如果topiclist为空则更新当前论坛帖数 if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount) { Forums.SetRealCurrentTopics(forum.Fid); } //得到页码链接 if (DNTRequest.GetString("search") == "") { if (topictypeid == 0) { if (config.Aspxrewrite == 1) { if (Utils.StrIsNullOrEmpty(filter)) { pagenumbers = Utils.GetStaticPageNumbers(pageid, pagecount, "showforum-" + forumid.ToString(), config.Extname, 8); } else { pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showforum.aspx?forumid=" + forumid.ToString() + "&filter=" + filter, 8); } } else { pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showforum.aspx?forumid=" + forumid.ToString() + (Utils.StrIsNullOrEmpty(filter) ? "" : "&filter=" + filter), 8); } } else //当有主题类型条件时 { pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showforum.aspx?forumid=" + forumid.ToString() + "&typeid=" + topictypeid + (Utils.StrIsNullOrEmpty(filter) ? "" : "&filter=" + filter), 8); } } else { pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showforum.aspx?search=1&cond=" + DNTRequest.GetString("cond").Trim() + "&order=" + DNTRequest.GetString("order") + "&direct=" + DNTRequest.GetString("direct") + "&forumid=" + forumid.ToString() + "&typeid=" + topictypeid + (Utils.StrIsNullOrEmpty(filter) ? "" : "&filter=" + filter), 8); } } } forumlistboxoptions = Caches.GetForumListBoxOptionsCache(); OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forumname, -1, "", config.Onlinetimeout); showsplitter = false; if (toptopiclist.Count > 0 && topiclist.Count > 0) { showsplitter = true; } showforumonline = false; onlineiconlist = Caches.GetOnlineGroupIconList(); if (forumtotalonline < config.Maxonlinelist || DNTRequest.GetString("showonline") == "yes") { showforumonline = true; onlineuserlist = OnlineUsers.GetForumOnlineUserCollection(forumid, out forumtotalonline, out forumtotalonlineguest, out forumtotalonlineuser, out forumtotalonlineinvisibleuser); } if (DNTRequest.GetString("showonline") == "no") { showforumonline = false; } ForumUtils.UpdateVisitedForumsOptions(forumid); visitedforumsoptions = ForumUtils.GetVisitedForumsOptions(config.Visitedforums); forumallowrss = forum.Allowrss; }
protected override void ShowPage() { if (config.Enablemall == 0) //未启用交易模式 { AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!"); return; } #region 临时帐号发帖 int realuserid = -1; string tempusername = DNTRequest.GetString("tempusername"); if (tempusername != "" && tempusername != username) { string temppassword = DNTRequest.GetString("temppassword"); int question = DNTRequest.GetInt("question", 0); string answer = DNTRequest.GetString("answer"); realuserid = Users.CheckTempUserInfo(tempusername, temppassword, question, answer); if (realuserid == -1) { AddErrLine("临时帐号登录失败,无法继续发帖。"); return; } else { userid = realuserid; username = tempusername; usergroupinfo = UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(userid).Groupid); usergroupid = usergroupinfo.Groupid; useradminid = Users.GetShortUserInfo(userid).Adminid; } } #endregion #region 获取分类对象信息 int categoryid = DNTRequest.GetInt("categoryid", -1); //如果是提交... if (ispost) categoryid = DNTRequest.GetInt("goodscategoryid", -1); if (categoryid > 0) goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(categoryid); if (goodscategoryinfo == null) { goodscategoryinfo = new Goodscategoryinfo(); goodscategoryinfo.Categoryid = -1; } if (goodscategoryinfo.Fid <=0) { allowpostgoods = false; forumnav = ""; AddErrLine("错误的商品分类ID"); return; } #endregion canhtmltitle = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup); firstpagesmilies = Caches.GetSmiliesFirstPageCache(); //内容设置为空; message = ""; if (config.Enablemall == 1) //开启普通模式 { forumid = GoodsCategories.GetCategoriesFid(categoryid); forumnav = ""; if (forumid == -1) { allowpostgoods = false; AddErrLine("错误的商品分类ID"); return; } else { forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Layer == 0) { allowpostgoods = false; AddErrLine("错误的商品分类ID"); return; } if (forum.Istrade <= 0) { allowpostgoods = false; AddErrLine("当前版块不允许发布商品"); return; } forumname = forum.Name; pagetitle = Utils.RemoveHtml(forum.Name); forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); enabletag = (config.Enabletag & forum.Allowtag) == 1; } } else if(config.Enablemall == 2) //当为高级模式时 { pagetitle = "发布商品"; forumnav = ""; enabletag = true; forum = new ForumInfo(); forum.Allowsmilies = 1; forum.Allowbbcode = 1; } //得到用户可以上传的文件类型 StringBuilder sbAttachmentTypeSelect = new StringBuilder(); if (!usergroupinfo.Attachextensions.Trim().Equals("")) { sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions); sbAttachmentTypeSelect.Append(")"); } if (config.Enablemall == 1) //开启普通模式 { if (!forum.Attachextensions.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;//今天可上传得大小 parseurloff = 0; bbcodeoff = 1; if (config.Enablemall == 1) //开启普通模式 { smileyoff = 1 - forum.Allowsmilies; allowimg = forum.Allowimgcode; if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) bbcodeoff = 0; } // 如果当前用户非管理员并且论坛设定了禁止发布商品时间段,当前时间如果在其中的一个时间段内,不允许用户发布商品 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visittime = ""; if (Scoresets.BetweenTime(config.Postbanperiods, out visittime)) { AddErrLine("在此时间段( " + visittime + " )内用户不可以发布商品"); return; } } if (config.Enablemall == 1) //开启普通模式 { if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } if (!Forums.AllowViewByUserId(forum.Permuserlist, userid)) //判断当前用户在当前版块浏览权限 { if (forum.Viewperm == null || forum.Viewperm == string.Empty)//当板块权限为空时,按照用户组权限 { if (useradminid != 1 && (usergroupinfo.Allowvisit != 1 || usergroupinfo.Allowtrade != 1)) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布商品的权限"); return; } } else//当板块权限不为空,按照板块权限 { if (!Forums.AllowView(forum.Viewperm, usergroupid)) { AddErrLine("您没有发布商品的权限"); return; } } } if (!Forums.AllowPostByUserID(forum.Permuserlist, userid)) //判断当前用户在当前版块发布商品权限 { if (forum.Postperm == null || forum.Postperm == string.Empty)//权限设置为空时,根据用户组权限判断 { // 验证用户是否有发布商品的权限 if (useradminid != 1 && usergroupinfo.Allowtrade != 1) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布商品的权限"); return; } } else//权限设置不为空时,根据板块权限判断 { if (!Forums.AllowPost(forum.Postperm, usergroupid)) { AddErrLine("您没有发布商品的权限"); return; } } } //是否有上传附件的权限 if (Forums.AllowPostAttachByUserID(forum.Permuserlist, userid)) canpostattach = true; else { if (forum.Postattachperm == "") { if (usergroupinfo.Allowpostattach == 1) canpostattach = true; } else { if (Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) canpostattach = true; } } } else if (config.Enablemall == 2) //当为高级模式时 { canpostattach = true; allowimg = 1; smileyoff = 0; } ShortUserInfo user = Users.GetShortUserInfo(userid); if (canpostattach && user != null && apb != null && config.Enablealbum == 1 && (UserGroups.GetUserGroupInfo(user.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } else caninsertalbum = false; // 如果是受灌水限制用户, 则判断是否是灌水 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); disablepost = 0; if (admininfo != null) disablepost = admininfo.Disablepostctrl; if (admininfo == null || admininfo.Disablepostctrl != 1) { int Interval = Utils.StrDateDiffSeconds(lastposttime, config.Postinterval); if (Interval < 0) { AddErrLine("系统规定发布商品间隔为" + config.Postinterval.ToString() + "秒, 您还需要等待 " + (Interval * -1).ToString() + " 秒"); return; } else if (userid != -1) { ShortUserInfo shortUserInfo = Discuz.Data.Users.GetShortUserInfo(userid); string joindate = (shortUserInfo != null) ? shortUserInfo.Joindate : ""; if (joindate == "") { AddErrLine("您的用户资料出现错误"); return; } Interval = Utils.StrDateDiffMinutes(joindate, config.Newbiespan); if (Interval < 0) { AddErrLine("系统规定新注册用户必须要在" + config.Newbiespan.ToString() + "分钟后才可以发布商品, 您还需要等待 " + (Interval * -1).ToString() + " 分"); return; } } } creditstrans = Scoresets.GetCreditsTrans(); userextcreditsinfo = Scoresets.GetScoreSet(creditstrans); if (userid > 0) spaceid = Users.GetShortUserInfo(userid).Spaceid; //如果不是提交... if (!ispost) { AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); smilies = Caches.GetSmiliesCache(); smilietypes = Caches.GetSmilieTypesCache(); customeditbuttons = Caches.GetCustomEditButtonList(); } else { SetBackLink(string.Format("postgoods.aspx?categoryid={0}&restore=1", categoryid)); string postmessage = DNTRequest.GetString("message"); ForumUtils.WriteCookie("postmessage", postmessage); if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } if (DNTRequest.GetString("title").Trim().Equals("")) AddErrLine("商品标题不能为空"); else if (DNTRequest.GetString("title").IndexOf(" ") != -1) AddErrLine("商品标题不能包含全角空格符"); else if (DNTRequest.GetString("title").Length > 60) AddErrLine("商品标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length + " 个字符"); if (postmessage.Equals("") || postmessage.Replace(" ", "").Equals("")) AddErrLine("商品内容不能为空"); if (admininfo != null && admininfo.Disablepostctrl != 1) { if (postmessage.Length < config.Minpostsize) AddErrLine("您发表的内容过少, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字"); else if (postmessage.Length > config.Maxpostsize) AddErrLine("您发表的内容过多, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字"); } //新用户广告强力屏蔽检查 if (config.Disablepostad == 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; // 如果用户上传了附件,则检测用户是否有上传附件的权限 if (ForumUtils.IsPostFile()) { if (Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()).Trim() == "") AddErrLine("系统不允许上传附件"); if (config.Enablemall == 1) //开启普通模式 { if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userid)) { if (!Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) AddErrLine("您没有在该版块上传附件的权限"); else if (usergroupinfo.Allowpostattach != 1) AddErrLine(string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", usergroupinfo.Grouptitle)); } } } if (IsErr()) return; int iconid = DNTRequest.GetInt("iconid", 0); if (iconid > 15 || iconid < 0) iconid = 0; string curdatetime = Utils.GetDateTime(); Goodsinfo goodsinfo = new Goodsinfo(); //当在高级模式下则绑定相应店铺信息 if (config.Enablemall == 2) { Shopinfo shopinfo = Shops.GetShopByUserId(user.Uid); if (shopinfo != null) goodsinfo.Shopid = shopinfo.Shopid; } goodsinfo.Categoryid = goodscategoryinfo.Categoryid; goodsinfo.Parentcategorylist = goodscategoryinfo.Parentidlist; goodsinfo.Recommend = DNTRequest.GetString("recommend") == "on" ? 1 : 0; goodsinfo.Discount = DNTRequest.GetInt("discount", 0); goodsinfo.Selleruid = userid; goodsinfo.Seller = username; goodsinfo.Account = DNTRequest.GetString("account"); goodsinfo.Price = Convert.ToDecimal(DNTRequest.GetFormFloat("price", 1).ToString()); goodsinfo.Amount = DNTRequest.GetInt("amount", 0); goodsinfo.Quality = DNTRequest.GetInt("quality", 0); goodsinfo.Lid = DNTRequest.GetInt("locus_2", 0); goodsinfo.Locus = Locations.GetLocusByLID(goodsinfo.Lid); goodsinfo.Transport = DNTRequest.GetInt("transport", 0); if (goodsinfo.Transport != 0) { goodsinfo.Ordinaryfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_mail", 0).ToString()); goodsinfo.Expressfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_express", 0).ToString()); goodsinfo.Emsfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_ems", 0).ToString()); } goodsinfo.Itemtype = DNTRequest.GetInt("itemtype", 0); DateTime dateline; switch (DNTRequest.GetInt("_now", 0)) { case 1: dateline = Convert.ToDateTime(string.Format("{0} {1}:{2}:00", DNTRequest.GetString("_date"), DNTRequest.GetInt("_hour", 0), DNTRequest.GetInt("_minute", 0))); break; //设定 case 2: dateline = Convert.ToDateTime("1900-01-01 00:00:00"); break; //返回100年之后的日期作为"暂不设置" default: dateline = DateTime.Now; break; //立即 } goodsinfo.Dateline = dateline; goodsinfo.Expiration = Convert.ToDateTime(DNTRequest.GetString("expiration")); goodsinfo.Lastbuyer = ""; goodsinfo.Lasttrade = Convert.ToDateTime("1900-01-01 00:00:00"); goodsinfo.Lastupdate = Convert.ToDateTime(Utils.GetDateTime()); goodsinfo.Totalitems = 0; goodsinfo.Tradesum = 0; goodsinfo.Closed = 0; goodsinfo.Aid = 0; goodsinfo.Costprice = Convert.ToDecimal(DNTRequest.GetFormFloat("costprice", 1).ToString()); goodsinfo.Invoice = DNTRequest.GetInt("invoice", 0); goodsinfo.Repair = DNTRequest.GetInt("repair", 0); if (useradminid == 1) goodsinfo.Message = Utils.HtmlEncode(postmessage); else goodsinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage)); goodsinfo.Otherlink = ""; int readperm = DNTRequest.GetInt("readperm", 0); goodsinfo.Readperm = readperm > 255 ? 255 : readperm; goodsinfo.Tradetype = DNTRequest.GetInt("tradetype", 0); if (goodsinfo.Tradetype == 1 && Utils.StrIsNullOrEmpty(goodsinfo.Account)) //当为支付宝在线支付方式下,如果"支付宝账户"为空时 { AddErrLine("请输入支付宝帐号信息。"); return; } goodsinfo.Viewcount = 0; goodsinfo.Displayorder = DNTRequest.GetString("displayorder") == "on" ? 0 : -3; if (config.Enablemall == 1) //当为版块交易帖是时 { if (forum.Modnewposts == 1 && useradminid != 1) { if (useradminid > 1) { if (disablepost != 1) { goodsinfo.Displayorder = -2; disablepost = 0; } } else { goodsinfo.Displayorder = -2; disablepost = 0; } } } goodsinfo.Smileyoff = smileyoff; if (smileyoff == 0 && forum.Allowsmilies == 1) goodsinfo.Smileyoff = Utils.StrToInt(DNTRequest.GetString("smileyoff"), 0); goodsinfo.Bbcodeoff = 1; if (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) goodsinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0); goodsinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0); if (useradminid == 1) goodsinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title")); else goodsinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title"))); string htmltitle = DNTRequest.GetString("htmltitle").Trim(); if (htmltitle != string.Empty && Utils.HtmlDecode(htmltitle).Trim() != goodsinfo.Title) { goodsinfo.Magic = 11000; //按照 附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储 //例: 11001 } //标签(Tag)操作 string tags = DNTRequest.GetString("tags").Trim(); string[] tagsArray = null; if (enabletag && tags != string.Empty) { tagsArray = Utils.SplitString(tags, " ", true, 2, 10); if (tagsArray.Length > 0) { if (goodsinfo.Magic == 0) goodsinfo.Magic = 10000; goodsinfo.Magic = Utils.StrToInt(goodsinfo.Magic.ToString() + "1", 0); } } goodsinfo.Goodsid = Goods.CreateGoods(goodsinfo); //保存htmltitle if (canhtmltitle && htmltitle != string.Empty && htmltitle != goodsinfo.Title) Goods.WriteHtmlSubjectFile(htmltitle, goodsinfo.Goodsid); if (enabletag && tagsArray != null && tagsArray.Length > 0) { DbProvider.GetInstance().CreateGoodsTags(string.Join(" ", tagsArray), goodsinfo.Goodsid, userid, curdatetime); GoodsTags.WriteGoodsTagsCacheFile(goodsinfo.Goodsid); } StringBuilder sb = new StringBuilder(); sb.Remove(0, sb.Length); int watermarkstatus = (forum.Disablewatermark == 1) ? 0 : config.Watermarkstatus; Goodsattachmentinfo[] attachmentinfo = Discuz.Mall.MallUtils.SaveRequestFiles(categoryid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstatus, config, "postfile"); if (attachmentinfo != null) { if (attachmentinfo.Length > config.Maxattachments) { AddErrLine("系统设置为每个商品附件不得多于" + config.Maxattachments + "个"); return; } int errorAttachment = GoodsAttachments.BindAttachment(attachmentinfo, goodsinfo.Goodsid, sb, goodsinfo.Categoryid, userid); int[] aid = GoodsAttachments.CreateAttachments(attachmentinfo); string tempMessage = GoodsAttachments.FilterLocalTags(aid, attachmentinfo, goodsinfo.Message); goodsinfo.Goodspic = (attachmentinfo.Length > 0) ? attachmentinfo[0].Filename : ""; if (!tempMessage.Equals(goodsinfo.Message)) { goodsinfo.Message = tempMessage; goodsinfo.Aid = aid[0]; } Goods.UpdateGoods(goodsinfo); UserCredits.UpdateUserCreditsByUploadAttachment(userid, aid.Length - errorAttachment); } //加入相册 #region 相册 if (config.Enablealbum == 1 && apb != null) { sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username)); } #endregion if (config.Enablemall == 1) //开启普通模式 { OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forumname, -1, "", config.Onlinetimeout); // 更新在线表中的用户最后发布商品时间 OnlineUsers.UpdatePostTime(olid); } if (sb.Length > 0) { 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>"); SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid), sb.ToString()); } else { SetShowBackLink(false); if (config.Enablemall == 1 && forum.Modnewposts == 1 && useradminid != 1) { if (useradminid != 1) { if (disablepost == 1) { if (goodsinfo.Displayorder == -3) { SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但未上架. 您可到用户中心进行上架操作!"); } else { SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid), "发布商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回 " + forumname + "</a>)<br />"); } } else { SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但需要经过审核才可以显示. 返回商品列表"); } } else { SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 返回商品列表"); } } else { if (goodsinfo.Displayorder == -3) { SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但未上架. 您可到用户中心进行上架操作!"); } else { SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid), "发布商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回</a>)<br />"); } } } ForumUtils.WriteCookie("postmessage", ""); } topicattachscorefield = 0; }
protected override void ShowPage() { ismoder = Moderators.IsModer(useradminid, userid, forumid) ? 1 : 0; topic = GetTopicInfo(); if (IsErr()) return; forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); if (forum == null) { AddErrLine("不存在的版块ID"); return; } // 检查是否具有版主的身份 if (useradminid != 0) { ismoder = Moderators.IsModer(useradminid, userid, forum.Fid) ? 1 : 0; admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); //得到管理组信息 if (admininfo != null) disablepostctrl = admininfo.Disablepostctrl; } //验证版块密码 if (!ValidateForumPassword()) return; #region GetForumAds(forum.Fid); //快速编辑器背景广告 quickbgad = Advertisements.GetQuickEditorBgAd("", forumid); if (quickbgad.Length <= 1) quickbgad = new string[2] { "", "" }; #endregion enabletag = (config.Enabletag & forum.Allowtag) == 1; pagetitle = string.Format("{0} - {1}", topic.Title, forum.Name); smileyoff = 1 - forum.Allowsmilies; if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) bbcodeoff = 0; // 权限认证,包括回复,下载附件,发主题等 if (!ValidateAuthority()) return; //获取主题类型 Caches.GetTopicTypeArray().TryGetValue(topic.Typeid, out topictypes); topictypes = Utils.StrIsNullOrEmpty(topictypes) ? "" : "[" + topictypes + "]"; userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetCreditsTrans()); score = Scoresets.GetValidScoreName(); scoreunit = Scoresets.GetValidScoreUnit(); //购买帖子操作, 判断是否为回复可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买 int price = GetTopicPrice(topic); if (topic.Special == 0 && price > 0) { HttpContext.Current.Response.Redirect(forumpath + "buytopic.aspx?topicid=" + topic.Tid); return; } if (newpmcount > 0) pmlist = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1); PostpramsInfo postpramsInfo = GetPostPramsInfo(price); if (topic.Special == 1)//获取投票信息 GetPollInfo(); bonuslogs = Bonus.GetLogs(topic); post = Posts.GetSinglePost(postpramsInfo, out attachmentlist, ismoder == 1); if (post == null) { AddErrLine("读取信息失败"); return; } posttree = Posts.GetPostTree(topicid, postpramsInfo.Hide, Users.GetUserInfo(userid).Credits); //更新查看次数 TopicStats.Track(topic.Tid, 1); topicviews = topic.Views + 1; OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forum.Fid, forum.Name, topic.Tid, topic.Title.Trim(), config.Onlinetimeout); }
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; } } }
protected override void ShowPage() { topictitle = ""; forumnav = ""; ////加载帖内广告 //inpostad = Advertisements.GetInPostAd("", fid, templatepath, postlist.Count > ppp ? ppp : postlist.Count); //AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(useradminid); showpayments = DNTRequest.GetInt("showpayments", 0); buyit = DNTRequest.GetInt("buyit", 0); topicid = DNTRequest.GetInt("topicid", -1); // 如果主题ID非数字 if (topicid == -1) { AddErrLine(WRONG_TOPIC); return; } // 获取该主题的信息 TopicInfo topic = Topics.GetTopicInfo(topicid); // 如果该主题不存在 if (topic == null) { AddErrLine(NOT_EXIST_TOPIC); return; } if (topic.Posterid == userid) { HttpContext.Current.Response.Redirect(base.ShowTopicAspxRewrite(topic.Tid, 0)); return; } if (topic.Price <= 0) { HttpContext.Current.Response.Redirect(base.ShowTopicAspxRewrite(topic.Tid, 0)); return; } topictitle = topic.Title.Trim(); topicprice = topic.Price; poster = topic.Poster; posterid = topic.Posterid; pagetitle = topictitle.Trim(); forumid = topic.Fid; ForumInfo forum = Forums.GetForumInfo(forumid); forumname = forum.Name.Trim(); forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); //判断是否为回复可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买 price = 0; if (topic.Price > 0) { price = topic.Price; if (PaymentLogs.IsBuyer(topicid, userid) || (Utils.StrDateDiffHours(topic.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 && Scoresets.GetMaxChargeSpan() != 0))//判断当前用户是否已经购买 { price = -1; } } if (useradminid != 0) { ismoder = Moderators.IsModer(useradminid, userid, forumid) ? 1 : 0; } if (topic.Readperm > usergroupinfo.Readaccess && topic.Posterid != userid && useradminid != 1 && ismoder != 1) { AddErrLine(string.Format("本主题阅读权限为: {0}, 您当前的身份 \"{1}\" 阅读权限不够", topic.Readperm.ToString(), usergroupinfo.Grouptitle)); return; } if (topic.Displayorder == -1) { AddErrLine("此主题已被删除!"); return; } if (topic.Displayorder == -2) { AddErrLine("此主题未经审核!"); return; } if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password")) { AddErrLine("本版块被管理员设置了密码"); //SetBackLink("showforum-" + forumid.ToString() + config.Extname); HttpContext.Current.Response.Redirect("showforum-" + forumid.ToString() + config.Extname, true); return; } 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; } } } userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetCreditsTrans()); maxincpertopic = Scoresets.GetMaxIncPerTopic(); maxchargespan = Scoresets.GetMaxChargeSpan(); creditstax = Scoresets.GetCreditsTax() * 100; netamount = topicprice - topicprice * creditstax / 100; if (topicprice > maxincpertopic) { netamount = maxincpertopic - maxincpertopic * creditstax / 100; } if (price != -1) { IDataReader reader = Users.GetUserInfoToReader(userid); if (reader == null) { AddErrLine(NO_PERMISSION); return; } if (!reader.Read()) { AddErrLine(NO_PERMISSION); reader.Close(); return; } if (Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0) < topic.Price) { AddErrLine(string.Format(NOT_ENOUGH_MONEY_TO, Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0), topic.Price)); reader.Close(); return; } userlastprice = Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0) - topic.Price; reader.Close(); } //如果不是提交... if (!ispost) { buyers = PaymentLogs.GetPaymentLogByTidCount(topic.Tid); //显示购买信息列表 if (showpayments == 1) { //得到当前用户请求的页数 pageid = DNTRequest.GetInt("page", 1); //获取主题总数 //获取总页数 pagecount = buyers % pagesize == 0 ? buyers / pagesize : buyers / pagesize + 1; if (pagecount == 0) { pagecount = 1; } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } if (pageid > pagecount) { pageid = pagecount; } //获取收入记录并分页显示 paymentloglist = PaymentLogs.GetPaymentLogByTid(pagesize, pageid, topic.Tid); } //判断是否为回复可见帖, hide=0为非回复可见(正常), hide>0为回复可见, hide=-1为回复可见但当前用户已回复 int hide = 0; if (topic.Hide == 1) { hide = topic.Hide; if (Posts.IsReplier(topicid, userid)) { hide = -1; } } PostpramsInfo _postpramsinfo = new PostpramsInfo(); _postpramsinfo.Fid = forum.Fid; _postpramsinfo.Tid = topicid; _postpramsinfo.Jammer = forum.Jammer; _postpramsinfo.Pagesize = 5; _postpramsinfo.Pageindex = 1; _postpramsinfo.Getattachperm = forum.Getattachperm; _postpramsinfo.Usergroupid = usergroupid; _postpramsinfo.Attachimgpost = config.Attachimgpost; _postpramsinfo.Showattachmentpath = config.Showattachmentpath; _postpramsinfo.Hide = hide; _postpramsinfo.Price = price; _postpramsinfo.Ubbmode = false; _postpramsinfo.Showimages = forum.Allowimgcode; _postpramsinfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); _postpramsinfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo(); _postpramsinfo.Smiliesmax = config.Smiliesmax; _postpramsinfo.Bbcodemode = config.Bbcodemode; lastpostlist = Posts.GetLastPostList(_postpramsinfo); } else { int reval = PaymentLogs.BuyTopic(userid, topic.Tid, topic.Posterid, topic.Price, netamount); if (reval > 0) { SetUrl(base.ShowTopicAspxRewrite(topic.Tid, 0)); SetMetaRefresh(); SetShowBackLink(false); AddMsgLine(PURCHASE_SUCCESS); return; } else { SetBackLink(base.ShowForumAspxRewrite(topic.Fid, 0)); if (reval == -1) { AddErrLine(NOT_ENOUGH_MONEY); return; } else if (reval == -2) { AddErrLine(NO_PERMISSION); return; } else { AddErrLine(UNKNOWN_REASON); return; } } } }
protected override void ShowPage() { #region 临时帐号发帖 int realuserid = -1; string tempusername = DNTRequest.GetString("tempusername"); if (tempusername != "" && tempusername != username) { string temppassword = DNTRequest.GetString("temppassword"); int question = DNTRequest.GetInt("question", 0); string answer = DNTRequest.GetString("answer"); if (config.Passwordmode == 1) { if (config.Secques == 1) { realuserid = Discuz.Forum.Users.CheckDvBbsPasswordAndSecques(tempusername, temppassword, question, answer); } else { realuserid = Discuz.Forum.Users.CheckDvBbsPassword(tempusername, temppassword); } } else { if (config.Secques == 1) { realuserid = Discuz.Forum.Users.CheckPasswordAndSecques(tempusername, temppassword, true, question, answer); } else { realuserid = Discuz.Forum.Users.CheckPassword(tempusername, temppassword, true); } } if (realuserid == -1) { AddErrLine("临时帐号登录失败,无法继续发帖。"); return; } else { userid = realuserid; username = tempusername; usergroupinfo = UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(userid).Groupid); usergroupid = usergroupinfo.Groupid; useradminid = Discuz.Forum.Users.GetShortUserInfo(userid).Adminid; } } #endregion canhtmltitle = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup); firstpagesmilies = Caches.GetSmiliesFirstPageCache(); bool createpoll = false; string[] pollitem = { }; //内容设置为空; message = ""; //maxprice = usergroupinfo.Maxprice > Scoresets.GetMaxIncPerTopic() ? Scoresets.GetMaxIncPerTopic() : usergroupinfo.Maxprice; maxprice = usergroupinfo.Maxprice; forumid = DNTRequest.GetInt("forumid", -1); allowposttopic = true; if (forumid == -1) { allowposttopic = false; AddErrLine("错误的论坛ID"); forumnav = ""; return; } else { forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Layer == 0) { allowposttopic = false; AddErrLine("错误的论坛ID"); forumnav = ""; return; } forumname = forum.Name; pagetitle = Utils.RemoveHtml(forum.Name); forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); enabletag = (config.Enabletag & forum.Allowtag) == 1; if (forum.Applytopictype == 1) //启用主题分类 { topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); } } //得到用户可以上传的文件类型 StringBuilder sbAttachmentTypeSelect = new StringBuilder(); if (!usergroupinfo.Attachextensions.Trim().Equals("")) { sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions); sbAttachmentTypeSelect.Append(")"); } if (!forum.Attachextensions.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;//今天可上传得大小 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 && 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()); // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visittime = ""; if (Scoresets.BetweenTime(config.Postbanperiods, out visittime)) { AddErrLine("在此时间段( " + visittime + " )内用户不可以发帖"); return; } } if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } if (!Forums.AllowViewByUserID(forum.Permuserlist, userid)) //判断当前用户在当前版块浏览权限 { if (string.IsNullOrEmpty(forum.Viewperm))//当板块权限为空时,按照用户组权限 { if (usergroupinfo.Allowvisit != 1) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限"); needlogin = true; return; } } else//当板块权限不为空,按照板块权限 { if (!Forums.AllowView(forum.Viewperm, usergroupid)) { AddErrLine("您没有浏览该版块的权限"); needlogin = true; return; } } } if (!Forums.AllowPostByUserID(forum.Permuserlist, userid)) //判断当前用户在当前版块发主题权限 { if (forum.Postperm == null || forum.Postperm == string.Empty)//权限设置为空时,根据用户组权限判断 { // 验证用户是否有发表主题的权限 if (usergroupinfo.Allowpost != 1) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发表主题的权限"); needlogin = true; return; } } else//权限设置不为空时,根据板块权限判断 { if (!Forums.AllowPost(forum.Postperm, usergroupid)) { AddErrLine("您没有在该版块发表主题的权限"); needlogin = true; return; } } } //是否有上传附件的权限 if (Forums.AllowPostAttachByUserID(forum.Permuserlist, userid)) { canpostattach = true; } else { if (forum.Postattachperm == "") { if (usergroupinfo.Allowpostattach == 1) { canpostattach = true; } } else { if (Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) { canpostattach = true; } } } ShortUserInfo user = Discuz.Forum.Users.GetShortUserInfo(userid); // 如果是受灌水限制用户, 则判断是否是灌水 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(useradminid); disablepost = 0; if (admininfo != null) { disablepost = admininfo.Disablepostctrl; } if (admininfo == null || admininfo.Disablepostctrl != 1) { int Interval = Utils.StrDateDiffSeconds(lastposttime, config.Postinterval); if (Interval < 0) { AddErrLine("系统规定发帖间隔为" + config.Postinterval.ToString() + "秒, 您还需要等待 " + (Interval * -1).ToString() + " 秒"); return; } else if (userid != -1) { string joindate = Discuz.Forum.Users.GetUserJoinDate(userid); if (joindate == "") { AddErrLine("您的用户资料出现错误"); return; } Interval = Utils.StrDateDiffMinutes(joindate, config.Newbiespan); if (Interval < 0) { AddErrLine("系统规定新注册用户必须要在" + config.Newbiespan.ToString() + "分钟后才可以发帖, 您还需要等待 " + (Interval * -1).ToString() + " 分"); return; } } } creditstrans = Scoresets.GetCreditsTrans(); userextcreditsinfo = Scoresets.GetScoreSet(creditstrans); //message = ForumUtils.GetCookie("postmessage"); if (userid > 0) { spaceid = Discuz.Forum.Users.GetShortUserInfo(userid).Spaceid; } type = DNTRequest.GetString("type").ToLower(); //int specialpost = 0; if (forum.Allowspecialonly > 0 && Utils.StrIsNullOrEmpty(type)) { AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", forum.Name)); return; } if (forum.Allowpostspecial > 0) { if (type == "poll" && (forum.Allowpostspecial & 1) != 1) { AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表投票", forum.Name)); return; } if (type == "bonus" && (forum.Allowpostspecial & 4) != 4) { AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表悬赏", forum.Name)); return; } if (type == "debate" && (forum.Allowpostspecial & 16) != 16) { AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表辩论", forum.Name)); return; } } // 验证用户是否有发布投票的权限 if (type == "poll" && usergroupinfo.Allowpostpoll != 1) { AddErrLine(string.Format("您当前的身份 \"{0}\" 没有发布投票的权限", usergroupinfo.Grouptitle)); needlogin = true; return; } // 验证用户是否有发布悬赏的权限 if (type == "bonus" && usergroupinfo.Allowbonus != 1) { AddErrLine(string.Format("您当前的身份 \"{0}\" 没有发布悬赏的权限", usergroupinfo.Grouptitle)); needlogin = true; return; } // 验证用户是否有发起辩论的权限 if (type == "debate" && usergroupinfo.Allowdebate != 1) { AddErrLine(string.Format("您当前的身份 \"{0}\" 没有发起辩论的权限", usergroupinfo.Grouptitle)); needlogin = true; return; } if (type == "bonus") { //当“交易金币设置”有效时(1-8的整数): int creditTrans = Scoresets.GetCreditsTrans(); if (creditTrans <= 0) { AddErrLine(string.Format("系统未设置\"交易金币设置\", 无法判断当前要使用的(扩展)金币字段, 暂时无法发布悬赏", usergroupinfo.Grouptitle)); return; } mycurrenttranscredits = Discuz.Forum.Users.GetUserExtCredits(userid, creditTrans); } //如果不是提交... if (!ispost) { AddLinkCss("/templates/" + templatepath + "/editor.css", "css"); smilies = Caches.GetSmiliesCache(); smilietypes = Caches.GetSmilieTypesCache(); customeditbuttons = Caches.GetCustomEditButtonList(); topicicons = Caches.GetTopicIconsCache(); } else { SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", forumid, type)); string postmessage = DNTRequest.GetString("message"); postmessage = postmessage.Replace(Shove._Web.Utility.GetUrl(), Discuz.Common.XmlConfig.GetCpsClubUrl().ToString()); ForumUtils.WriteCookie("postmessage", postmessage); message = postmessage; #region 常规项验证 if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } if (forum.Applytopictype == 1 && forum.Postbytopictype == 1 && topictypeselectoptions != string.Empty) { if (DNTRequest.GetString("typeid").Trim().Equals("")) { AddErrLine("主题类型不能为空"); } //检测所选主题分类是否有效 if (!Forums.IsCurrentForumTopicType(DNTRequest.GetString("typeid").Trim(), forum.Topictypes)) { AddErrLine("错误的主题类型"); } } if (DNTRequest.GetString("title").Trim().Equals("")) { AddErrLine("标题不能为空"); } else if (DNTRequest.GetString("title").IndexOf(" ") != -1) { AddErrLine("标题不能包含全角空格符"); } else if (DNTRequest.GetString("title").Length > 60) { AddErrLine("标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length.ToString() + " 个字符"); } if (postmessage.Equals("")) { AddErrLine("内容不能为空"); } if (admininfo != null && admininfo.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() + " 字"); } } //新用户广告强力屏蔽检查 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; } // 如果用户上传了附件,则检测用户是否有上传附件的权限 if (ForumUtils.IsPostFile()) { if (Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()).Trim() == "") { AddErrLine("系统不允许上传附件"); } if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userid)) { if (!Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) { AddErrLine("您没有在该版块上传附件的权限"); } else if (usergroupinfo.Allowpostattach != 1) { AddErrLine(string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", usergroupinfo.Grouptitle)); } } } #endregion #region 投票验证 if (!DNTRequest.GetString("createpoll").Equals("")) { // 验证用户是否有发布投票的权限 if (usergroupinfo.Allowpostpoll != 1) { AddErrLine(string.Format("您当前的身份 \"{0}\" 没有发布投票的权限", 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(string.Format("系统设置为投票项不得多于{0}个", config.Maxpolloptions)); } else { for (int i = 0; i < pollitem.Length; i++) { if (pollitem[i].Trim().Equals("")) { AddErrLine("投票项不能为空"); } } } enddatetime = DNTRequest.GetString("enddatetime"); if (!Utils.IsDateString(enddatetime)) { AddErrLine("投票结束日期格式错误"); } } #endregion bool isbonus = type == "bonus"; #region 悬赏/售价验证 int topicprice = 0; string tmpprice = DNTRequest.GetString("topicprice"); if (Regex.IsMatch(tmpprice, "^[0-9]*[0-9][0-9]*$") || tmpprice == string.Empty) { if (!isbonus) { 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 (!isbonus) { AddErrLine("主题售价只能为整数"); } else { AddErrLine("悬赏价格只能为整数"); } } #endregion string positiveopinion = DNTRequest.GetString("positiveopinion"); string negativeopinion = DNTRequest.GetString("negativeopinion"); string terminaltime = DNTRequest.GetString("terminaltime"); if (type == "debate") { if (usergroupinfo.Allowdebate != 1) { AddErrLine(string.Format("您当前的身份 \"{0}\" 没有发起辩论的权限", usergroupinfo.Grouptitle)); return; } if (positiveopinion == string.Empty) { AddErrLine("正方观点不能为空"); } if (negativeopinion == string.Empty) { AddErrLine("反方观点不能为空"); } if (!Utils.IsDateString(terminaltime)) { AddErrLine("结束日期格式不正确"); } } if (IsErr()) { return; } int iconid = DNTRequest.GetInt("iconid", 0); if (iconid > 15 || iconid < 0) { iconid = 0; } int hide = 1; //if (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) //{ // hide = 1; //} string curdatetime = Utils.GetDateTime(); TopicInfo topicinfo = new TopicInfo(); topicinfo.Fid = forumid; topicinfo.Iconid = iconid; if (useradminid == 1) { topicinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title")); //message = Utils.HtmlEncode(postmessage); } else { topicinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title"))); //message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage)); } if (ForumUtils.HasBannedWord(topicinfo.Title) || ForumUtils.HasBannedWord(message)) { AddErrLine("对不起, 您提交的内容包含不良信息, 因此无法提交, 请返回修改!"); return; } topicinfo.Typeid = DNTRequest.GetInt("typeid", 0); if (usergroupinfo.Allowsetreadperm == 1) { int topicreadperm = DNTRequest.GetInt("topicreadperm", 0); topicreadperm = topicreadperm > 255 ? 255 : topicreadperm; topicinfo.Readperm = topicreadperm; } else { topicinfo.Readperm = 0; } topicinfo.Price = topicprice; topicinfo.Poster = username; topicinfo.Posterid = userid; topicinfo.Postdatetime = curdatetime; topicinfo.Lastpost = curdatetime; topicinfo.Lastposter = username; topicinfo.Views = 0; topicinfo.Replies = 0; if (forum.Modnewposts == 1 && useradminid != 1) { if (useradminid > 1) { if (disablepost == 1) { topicinfo.Displayorder = 0; } else { topicinfo.Displayorder = -2; } } else { topicinfo.Displayorder = -2; } } else { topicinfo.Displayorder = 0; } if (useradminid != 1) { if (Scoresets.BetweenTime(config.Postmodperiods) || ForumUtils.HasAuditWord(topicinfo.Title) || ForumUtils.HasAuditWord(message)) { topicinfo.Displayorder = -2; } } topicinfo.Highlight = ""; topicinfo.Digest = 0; topicinfo.Rate = 0; topicinfo.Hide = hide; //topicinfo.Poll = 0; topicinfo.Attachment = 0; topicinfo.Moderated = 0; topicinfo.Closed = 0; string htmltitle = DNTRequest.GetString("htmltitle").Trim(); if (htmltitle != string.Empty && Utils.HtmlDecode(htmltitle).Trim() != topicinfo.Title) { topicinfo.Magic = 11000; //按照 附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储 //例: 11001 } //标签(Tag)操作 string tags = DNTRequest.GetString("tags").Trim(); string[] tagArray = null; if (enabletag && tags != string.Empty) { 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("超过标签数的最大限制,最多可填写 5 个标签"); return; } } if (isbonus) { topicinfo.Special = 2; //检查金币是否足够 if (mycurrenttranscredits < topicprice) { AddErrLine("您的金币不足, 无法进行悬赏"); return; } else { Discuz.Forum.Users.UpdateUserExtCredits(topicinfo.Posterid, Scoresets.GetCreditsTrans(), -topicprice); } } if (type == "poll") { topicinfo.Special = 1; } //辩论帖 if (type == "debate") { topicinfo.Special = 4; } int topicid = Topics.CreateTopic(topicinfo); //保存htmltitle if (canhtmltitle && htmltitle != string.Empty && htmltitle != topicinfo.Title) { Topics.WriteHtmlTitleFile(htmltitle, topicid); } if (enabletag && tagArray != null && tagArray.Length > 0) { if (ForumUtils.HasBannedWord(tags)) { AddErrLine("标签中含有系统禁止词语,请修改"); return; } ForumTags.CreateTopicTags(tagArray, topicid, userid, curdatetime); } if (type == "debate") { DebateInfo debatetopic = new DebateInfo(); debatetopic.Tid = topicid; debatetopic.Positiveopinion = positiveopinion; debatetopic.Negativeopinion = negativeopinion; //debatetopic.Positivecolor = DNTRequest.GetString("positivecolor"); //debatetopic.Negativecolor = DNTRequest.GetString("negativecolor"); debatetopic.Terminaltime = Convert.ToDateTime(DNTRequest.GetString("terminaltime")); Topics.AddDebateTopic(debatetopic); } PostInfo postinfo = new PostInfo(); postinfo.Fid = forumid; postinfo.Tid = topicid; postinfo.Parentid = 0; postinfo.Layer = 0; postinfo.Poster = username; postinfo.Posterid = userid; if (useradminid == 1) { postinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title")); } else { postinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title"))); } postinfo.Postdatetime = curdatetime; postinfo.Message = message.Replace("<hide>","[hide]").Replace("</hide>","[/hide]"); postinfo.Ip = DNTRequest.GetIP(); postinfo.Lastedit = ""; if (ForumUtils.HasAuditWord(postinfo.Message)) { postinfo.Invisible = 1; } if (forum.Modnewposts == 1 && useradminid != 1) { if (useradminid > 1) { if (disablepost == 1) { postinfo.Invisible = 0; } else { postinfo.Invisible = 1; } } else { postinfo.Invisible = 1; } } else { postinfo.Invisible = 0; } // 如果当前用户非管理员并且论坛设定了发帖审核时间段,当前时间如果在其中的一个时间段内,则用户所发帖均为待审核状态 if (useradminid != 1) { if (Scoresets.BetweenTime(config.Postmodperiods)) { postinfo.Invisible = 0; } } postinfo.Usesig = Utils.StrToInt(DNTRequest.GetString("usesig"), 0); postinfo.Htmlon = 1; postinfo.Smileyoff = smileyoff; if (smileyoff == 0 && forum.Allowsmilies == 1) { postinfo.Smileyoff = Utils.StrToInt(DNTRequest.GetString("smileyoff"), 0); } postinfo.Bbcodeoff = 1; if (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) { postinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0); } postinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0); postinfo.Attachment = 0; postinfo.Rate = 0; postinfo.Ratetimes = 0; postinfo.Topictitle = topicinfo.Title; int postid = 0; try { postid = Posts.CreatePost(postinfo); } catch { TopicAdmins.DeleteTopics(topicid.ToString(), false); AddErrLine("帖子保存出现异常"); return; } Topics.AddParentForumTopics(forum.Parentidlist.Trim(), 1, 1); //设置用户的金币 ///首先读取版块内自定义金币 ///版设置了自定义金币则使用,否则使用论坛默认金币 float[] values = null; if (!forum.Postcredits.Equals("")) { int index = 0; float tempval = 0; values = new float[8]; foreach (string ext in Utils.SplitString(forum.Postcredits, ",")) { if (index == 0) { if (!ext.Equals("True")) { values = null; break; } index++; continue; } tempval = Utils.StrToFloat(ext, 0); values[index - 1] = tempval; index++; if (index > 8) { break; } } } //if (values != null) //{ // ///使用版块内金币 // UserCredits.UpdateUserCreditsByPostTopic(userid, values); //} //else //{ // ///使用默认金币 // UserCredits.UpdateUserCreditsByPostTopic(userid); //} StringBuilder itemvaluelist = new StringBuilder(""); if (createpoll) { // 生成以回车换行符为分割的项目与结果列 for (int i = 0; i < pollitem.Length; i++) { itemvaluelist.Append("0\r\n"); } string PollItemname = Utils.HtmlEncode(DNTRequest.GetFormString("PollItemname")); if (PollItemname != "") { int multiple = DNTRequest.GetString("multiple") == "on" ? 1 : 0; int maxchoices = 0; if (multiple <= 0) { multiple = 0; } if (multiple == 1) { maxchoices = DNTRequest.GetInt("maxchoices", 1); if (maxchoices > pollitem.Length) { maxchoices = pollitem.Length; } } if (!Polls.CreatePoll(topicid, multiple, pollitem.Length, PollItemname.Trim(), itemvaluelist.ToString().Trim(), enddatetime, userid, maxchoices, DNTRequest.GetString("visiblepoll") == "on" ? 1 : 0)) { AddErrLine("投票错误"); return; } } else { AddErrLine("投票项为空"); return; } } sb = new StringBuilder(); sb.Remove(0, sb.Length); int watermarkstatus = config.Watermarkstatus; if (forum.Disablewatermark == 1) { watermarkstatus = 0; } AttachmentInfo[] attachmentinfo = ForumUtils.SaveRequestFiles(forumid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstatus, config, "postfile"); if (attachmentinfo != null) { if (attachmentinfo.Length > config.Maxattachments) { 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); } OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forumname, -1, "", config.Onlinetimeout); // 更新在线表中的用户最后发帖时间 OnlineUsers.UpdatePostTime(olid); if (sb.Length > 0) { SetUrl(base.ShowTopicAspxRewrite(topicid, 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 { SetShowBackLink(false); if (useradminid != 1) { bool needaudit = false; //是否需要审核 if (Scoresets.BetweenTime(config.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, forumid)) { needaudit = true; } else { needaudit = false; } } else { needaudit = true; } } else { needaudit = true; } } else { if (useradminid != 1 && topicinfo.Displayorder == -2) { needaudit = true; } } } if (needaudit) { SetUrl(base.ShowForumAspxRewrite(forumid, 0)); SetMetaRefresh(); AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块"); } else { PostTopicSucceed(values, topicinfo, topicid); } } else { PostTopicSucceed(values, topicinfo, topicid); } } ForumUtils.WriteCookie("postmessage", ""); //如果已登录就不需要再登录 if (needlogin && userid > 0) needlogin = false; } }