/// <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); }
public static UserExtcreditsInfo GetScoreSet(int extcredits) { var userExtcreditsInfo = new UserExtcreditsInfo(); string columnName = "extcredits" + extcredits; DataTable scoreSet = GetScoreSet(); if (extcredits > 0) { userExtcreditsInfo.Name = scoreSet.Rows[0][columnName].ToString(); userExtcreditsInfo.Unit = scoreSet.Rows[1][columnName].ToString(); userExtcreditsInfo.Rate = float.Parse(scoreSet.Rows[2][columnName].ToString()); userExtcreditsInfo.Init = float.Parse(scoreSet.Rows[3][columnName].ToString()); userExtcreditsInfo.Topic = float.Parse(scoreSet.Rows[4][columnName].ToString()); userExtcreditsInfo.Reply = float.Parse(scoreSet.Rows[5][columnName].ToString()); userExtcreditsInfo.Digest = float.Parse(scoreSet.Rows[6][columnName].ToString()); userExtcreditsInfo.Upload = float.Parse(scoreSet.Rows[7][columnName].ToString()); userExtcreditsInfo.Download = float.Parse(scoreSet.Rows[8][columnName].ToString()); userExtcreditsInfo.Pm = float.Parse(scoreSet.Rows[9][columnName].ToString()); userExtcreditsInfo.Search = float.Parse(scoreSet.Rows[10][columnName].ToString()); userExtcreditsInfo.Pay = float.Parse(scoreSet.Rows[11][columnName].ToString()); userExtcreditsInfo.Vote = float.Parse(scoreSet.Rows[12][columnName].ToString()); } return(userExtcreditsInfo); }
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() { //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 != "")//如果不是ajax,则应该是带pageid的参数 { if (config.Aspxrewrite == 1) { SetUrl(string.Format("showtopic-{0}-{2}{1}#{3}", topic.Tid, config.Extname, DNTRequest.GetString("pageid"), postinfo.Pid)); } else { SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={3}&page={2}#{1}", topic.Tid, postinfo.Pid, DNTRequest.GetString("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() { pagetitle = "用户控制面板"; string jsCreditsRateArray = ""; foreach (DataRow dr in Scoresets.GetScorePaySet(0).Rows) { jsCreditsRateArray += "creditsrate[" + dr["id"] + "] = " + dr["rate"] + ";\r\n"; } jscreditsratearray = string.Format(jscreditsratearray, jsCreditsRateArray); if (!IsLogin()) { return; } if (DNTRequest.IsPost()) { if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } bool isPasswordError = true; switch (config.Passwordmode) { case 1: //动网兼容模式 { isPasswordError = Utils.MD5(DNTRequest.GetString("password")) != password; break; } case 0: //默认模式 { isPasswordError = Utils.MD5(DNTRequest.GetString("password")) != password; break; } default: //第三方加密验证模式 { if (PasswordModeProvider.GetInstance() != null) { isPasswordError = !PasswordModeProvider.GetInstance().CheckPassword(user, DNTRequest.GetString("password")); } break; } } if (isPasswordError) { AddErrLine("密码错误"); return; } int paynum = DNTRequest.GetInt("paynum", 0); if (paynum <= 0) { AddErrLine("数量必须是大于0的整数"); return; } if (DNTRequest.GetInt("extcredits1", 0) < 1 || DNTRequest.GetInt("extcredits2", 0) < 1 || DNTRequest.GetInt("extcredits1", 0) > 8 || DNTRequest.GetInt("extcredits2", 0) > 8) { AddErrLine("请正确选择要兑换的积分类型!"); return; } if (DNTRequest.GetInt("extcredits1", 0) == DNTRequest.GetInt("extcredits2", 0)) { AddErrLine("不能兑换相同类型的积分"); return; } //对交易后的积分增减进行修改设置 UserExtcreditsInfo extcredits1info = Scoresets.GetScoreSet(DNTRequest.GetInt("extcredits1", 0)); UserExtcreditsInfo extcredits2info = Scoresets.GetScoreSet(DNTRequest.GetInt("extcredits2", 0)); if (Utils.StrIsNullOrEmpty(extcredits1info.Name) || Utils.StrIsNullOrEmpty(extcredits2info.Name)) { AddErrLine("错误的输入!"); return; } if ((Users.GetUserExtCredits(userid, DNTRequest.GetInt("extcredits1", 0)) - paynum) < Scoresets.GetExchangeMinCredits()) { AddErrLine("抱歉, 您的 \"" + extcredits1info.Name + "\" 不足." + Scoresets.GetExchangeMinCredits()); return; } UserInfo userInfo = Users.GetUserInfo(userid); float extcredit2paynum = (float)Math.Round(paynum * (extcredits1info.Rate / extcredits2info.Rate) * (1 - creditstax), 2); Users.UpdateUserExtCredits(userid, DNTRequest.GetInt("extcredits1", 0), paynum * -1); Users.UpdateUserExtCredits(userid, DNTRequest.GetInt("extcredits2", 0), extcredit2paynum); CreditsLogs.AddCreditsLog(userid, userid, DNTRequest.GetInt("extcredits1", 0), DNTRequest.GetInt("extcredits2", 0), paynum, extcredit2paynum, Utils.GetDateTime(), 1); SetUrl("usercpcreaditstransferlog.aspx"); SetMetaRefresh(); SetShowBackLink(false); AddMsgLine("积分兑换完毕, 正在返回积分兑换与转帐记录"); } }
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() { //获取主题信息 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; } //检查是否具有管理权限 IsModer(); int price = GetTopicPrice(topic); if (topic.Special == 0 && price > 0) { HttpContext.Current.Response.Redirect(forumpath + "buytopic.aspx?topicid=" + topic.Tid); return; } if (postid > 0 && Posts.GetPostInfo(topicid, postid) == null) { AddErrLine("该帖可能已被删除 " + string.Format("<a href=\"{0}\">[返回主题]</a>", ShowTopicAspxRewrite(topicid, 1))); return; } //将版块加入到已访问版块列表中 ForumUtils.SetVisitedForumsCookie(forumid.ToString()); if (userid > 0) { userInfo = Users.GetShortUserInfo(userid); } if (topic.Identify > 0) { topicidentify = Caches.GetTopicIdentify(topic.Identify); } pagetitle = string.Format("{0} - {1}", topic.Title, Utils.RemoveHtml(forum.Name)); ///得到广告列表 GetForumAds(forum.Fid); //获取主题类型 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 = config.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 enabletag = (config.Enabletag & forum.Allowtag) == 1; //if (enabletag) // relatedtopics = Topics.GetRelatedTopicList(topicid, 5); //更新页面Meta信息 if (postlist != null && postlist.Count > 0) { 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); //如果是从 if (DNTRequest.GetInt("fromfav", 0) > 0) { Favorites.UpdateUserFavoriteViewTime(userid, topicid); } //UserCredits.UpdateUserCredits(userInfo);此方法与后台积分设置中的条目不匹配,故注释 }
protected override void ShowPage() { pagetitle = "用户控制面板"; creditstax = Scoresets.GetCreditsTax(); if (userid == -1) { AddErrLine("你尚未登录"); return; } user = Discuz.Forum.Users.GetUserInfo(userid); if (DNTRequest.IsPost()) { if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } if (Utils.MD5(DNTRequest.GetString("password")) != password) { AddErrLine("密码错误"); return; } int paynum = DNTRequest.GetInt("paynum", 0); if (paynum <= 0) { AddErrLine("数量必须是大于等于0的整数"); return; } int fromto = Discuz.Forum.Users.GetUserID(DNTRequest.GetString("fromto").Trim()); if (fromto == -1) { AddErrLine("指定的转帐接受人不存在"); return; } int extcredits = DNTRequest.GetInt("extcredits", 0); if (extcredits < 1 || extcredits > 8) { AddErrLine("请正确选择要转帐的金币类型!"); return; } //对转帐后的金币增减进行修改设置 UserExtcreditsInfo extcreditsinfo = Scoresets.GetScoreSet(extcredits); if (extcreditsinfo.Name.Trim() == "") { AddErrLine("错误的输入!"); return; } //UserInfo __userinfo = Discuz.Forum.Users.GetUserInfo(userid); if ((Discuz.Forum.Users.GetUserExtCredits(userid, extcredits) - paynum) < Scoresets.GetTransferMinCredits()) { AddErrLine(string.Format("抱歉, 您的 \"{0}\" 不足.系统当前规定转帐余额不得小于{1}", extcreditsinfo.Name, Scoresets.GetTransferMinCredits().ToString())); return; } //计算并更新2个扩展金币的新值 float topaynum = (float)Math.Round(paynum * (1 - creditstax), 2); Discuz.Forum.Users.UpdateUserExtCredits(userid, extcredits, paynum * -1); Discuz.Forum.Users.UpdateUserExtCredits(fromto, extcredits, topaynum); CreditsLogs.AddCreditsLog(userid, fromto, extcredits, extcredits, paynum, topaynum, Utils.GetDateTime(), 2); SetUrl("usercpcreaditstransferlog.aspx"); SetMetaRefresh(); SetShowBackLink(false); AddMsgLine("金币转帐完毕, 正在返回金币兑换与转帐记录"); } score = Scoresets.GetValidScoreName(); extcreditspaylist = Scoresets.GetScorePaySet(1); }
protected override void ShowPage() { if (oluserinfo.Groupid == 4) { AddErrLine("你所在的用户组,为禁止发言"); return; } #region 临时帐号发帖 //int realuserid = -1; //bool tempaccountspost = false; //string tempusername = DNTRequest.GetString("tempusername"); //if (!Utils.StrIsNullOrEmpty(tempusername) && tempusername != username) //{ // realuserid = Users.CheckTempUserInfo(tempusername, DNTRequest.GetString("temppassword"), DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer")); // if (realuserid == -1) // { // AddErrLine("临时帐号登录失败,无法继续发帖。"); return; // } // else // { // userid = realuserid; // username = tempusername; // tempaccountspost = true; // } //} #endregion if (userid > 0) { userinfo = Users.GetShortUserInfo(userid); // if (userinfo != null) // { // usergroupinfo = UserGroups.GetUserGroupInfo(userinfo.Groupid); // usergroupid = usergroupinfo.Groupid; // useradminid = userinfo.Adminid; // } } #region 获取并检查版块信息 forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Layer == 0) { forum = new ForumInfo();//如果不初始化对象,则会报错 allowposttopic = false; AddErrLine("错误的论坛ID"); return; } pagetitle = Utils.RemoveHtml(forum.Name); enabletag = (config.Enabletag & forum.Allowtag) == 1; if (forum.Applytopictype == 1) //启用主题分类 { topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); } if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } needaudit = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo); smileyoff = 1 - forum.Allowsmilies; bbcodeoff = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1; allowimg = forum.Allowimgcode; customeditbuttons = Caches.GetCustomEditButtonList(); #endregion #region 访问和发帖权限校验 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = true; return; } if (!UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = true; return; } #endregion #region 附件信息绑定 //得到用户可以上传的文件类型 string attachmentTypeSelect = Attachments.GetAllowAttachmentType(usergroupinfo, forum); attachextensions = Attachments.GetAttachmentTypeArray(attachmentTypeSelect); attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect); //得到今天允许用户上传的附件总大小(字节) int MaxTodaySize = (userid > 0 ? MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid) : 0); attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;//今天可上传得大小 //是否有上传附件的权限 canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg); if (canpostattach && (userinfo != null && userinfo.Uid > 0) && apb != null && config.Enablealbum == 1 && (UserGroups.GetUserGroupInfo(userinfo.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } #endregion canhtmltitle = usergroupinfo.Allowhtmltitle == 1; #region 积分信息 creditstrans = Scoresets.GetTopicAttachCreditsTrans(); userextcreditsinfo = Scoresets.GetScoreSet(creditstrans); bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); #endregion #region 特殊主题权限判断 if (forum.Allowspecialonly > 0 && !Utils.InArray(type, "poll,bonus,debate")) { AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", forum.Name)); return; } if (!UserAuthority.PostSpecialAuthority(forum, type, ref msg)) { AddErrLine(msg); return; } if (!UserAuthority.PostSpecialAuthority(usergroupinfo, type, ref msg)) { AddErrLine(msg); needlogin = true; return; } if (type == "bonus") { int creditTrans = Scoresets.GetBonusCreditsTrans(); //当“交易积分设置”有效时(1-8的整数): if (creditTrans <= 0) { //AddErrLine(string.Format("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏", usergroupinfo.Grouptitle)); return; AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏"); return; } mybonustranscredits = Users.GetUserExtCredits(userid, creditTrans); } userGroupInfoList.Sort(delegate(UserGroupInfo x, UserGroupInfo y) { return((x.Readaccess - y.Readaccess) + (y.Groupid - x.Groupid)); }); #endregion //发帖不受审核、过滤、灌水等限制权限 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); disablepost = admininfo != null ? admininfo.Disablepostctrl : usergroupinfo.Disableperiodctrl; //如果是提交... if (ispost) { #region 判断是否是灌水 if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg)) { AddErrLine(msg); return; } #endregion SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", forumid, type)); ForumUtils.WriteCookie("postmessage", postmessage); #region 验证提交信息 //常规项验证 NormalValidate(admininfo, postmessage, userinfo); if (IsErr()) { return; } // 如果用户上传了附件,则检测用户是否有上传附件的权限 if (ForumUtils.IsPostFile()) { if (Utils.StrIsNullOrEmpty(Attachments.GetAttachmentTypeArray(attachmentTypeSelect))) { AddErrLine("系统不允许上传附件"); } if (!UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); } } //发悬赏校验 int topicprice = 0; bool isbonus = type == "bonus"; ValidateBonus(ref topicprice, ref isbonus); //发特殊主题校验 ValidatePollAndDebate(); if (IsErr()) { return; } #endregion int hide = (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) ? 1 : 0; TopicInfo topicinfo = CreateTopic(admininfo, postmessage, isbonus, topicprice); if (IsErr()) { return; } PostInfo postinfo = CreatePost(topicinfo); if (IsErr()) { return; } #region 处理附件 //处理附件 StringBuilder sb = new StringBuilder(); AttachmentInfo[] attachmentinfo = null; string attachId = DNTRequest.GetFormString("attachid"); if (!string.IsNullOrEmpty(attachId)) { attachmentinfo = Attachments.GetNoUsedAttachmentArray(userid, attachId); Attachments.UpdateAttachment(attachmentinfo, topicinfo.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo); } //加入相册 if (config.Enablealbum == 1 && apb != null) { sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username)); } #endregion #region 添加日志的操作 SpacePluginBase spb = SpacePluginProvider.GetInstance(); if (DNTRequest.GetFormString("addtoblog") == "on" && spb != null) { if (userid != -1 && userinfo.Spaceid > 0) { spb.CreateTopic(topicinfo, postinfo, attachmentinfo); } else { AddMsgLine("您的个人空间尚未开通, 无法同时添加为日志"); } } #endregion OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forum.Name, -1, ""); #region 设置提示信息和跳转链接 if (sb.Length > 0) { SetUrl(base.ShowTopicAspxRewrite(topicinfo.Tid, 0)); SetMetaRefresh(5); SetShowBackLink(true); if (infloat == 1) { AddErrLine(sb.ToString()); return; } else { sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表主题成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>"); AddMsgLine(sb.Append("</table>").ToString()); } } else { SetShowBackLink(false); if (useradminid != 1) { //是否需要审核 if (UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo) || topicinfo.Displayorder == -2) { ForumUtils.WriteCookie("postmessage", ""); SetLastPostedForumCookie(); SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid)); SetMetaRefresh(); AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块"); } else { PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid); } } else { PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid); } } #endregion //ForumUtils.WriteCookie("postmessage", ""); //SetLastPostedForumCookie(); //如果已登录就不需要再登录 if (needlogin && userid > 0) { needlogin = false; } } else //非提交操作 { AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); } }
protected override void ShowPage() { if (this.oluserinfo.GroupID == 4) { base.AddErrLine("你所在的用户组,为禁止发言"); return; } if (this.userid > 0) { this.userinfo = BBX.Entity.User.FindByID(this.userid); } if (HttpContext.Current.Request.RawUrl.Contains("javascript:")) { base.AddErrLine("非法的链接"); return; } this.forum = XForum.FindByID(forumid); if (this.forum == null || this.forum.Layer == 0) { this.forum = new XForum(); this.allowposttopic = false; base.AddErrLine("错误的论坛ID"); return; } this.pagetitle = Utils.RemoveHtml(this.forum.Name); this.enabletag = config.Enabletag && this.forum.AllowTag; if (this.forum.ApplytopicType == 1) { this.topictypeselectoptions = Forums.GetCurrentTopicTypesOption(this.forum.Fid, this.forum.TopicTypes); } if (!String.IsNullOrEmpty(this.forum.Password) && Utils.MD5(this.forum.Password) != ForumUtils.GetCookie("forum" + this.forumid + "password")) { base.AddErrLine("本版块被管理员设置了密码"); base.SetBackLink(base.ShowForumAspxRewrite(this.forumid, 0)); return; } this.needaudit = UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo); this.smileyoff = forum.AllowSmilies ? 0 : 1; this.bbcodeoff = ((this.forum.Allowbbcode == 1 && this.usergroupinfo.AllowCusbbCode) ? 0 : 1); //this.allowimg = this.forum.Allowimgcode; this.customeditbuttons = Caches.GetCustomEditButtonList(); if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg)) { base.AddErrLine(this.msg); this.needlogin = true; return; } if (!UserAuthority.PostAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg)) { base.AddErrLine(this.msg); this.needlogin = true; return; } //string allowAttachmentType = Attachments.GetAllowAttachmentType(this.usergroupinfo, this.forum); this.attachextensions = AttachType.GetAttachmentTypeArray(usergroupinfo, this.forum); this.attachextensionsnosize = AttachType.GetAttachmentTypeString(usergroupinfo, this.forum); int num = (this.userid > 0) ? Attachment.GetUploadFileSizeByuserid(this.userid) : 0; this.attachsize = this.usergroupinfo.MaxSizeperday - num; this.canpostattach = UserAuthority.PostAttachAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg); this.canhtmltitle = this.usergroupinfo.AllowHtmlTitle; this.creditstrans = Scoresets.GetTopicAttachCreditsTrans(); this.userextcreditsinfo = Scoresets.GetScoreSet(this.creditstrans); this.bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); if (this.forum.AllowSpecialOnly && !Utils.InArray(this.type, "poll,bonus,debate")) { base.AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", this.forum.Name)); return; } if (!UserAuthority.PostSpecialAuthority(this.forum, this.type, ref this.msg)) { base.AddErrLine(this.msg); return; } if (!UserAuthority.PostSpecialAuthority(this.usergroupinfo, this.type, ref this.msg)) { base.AddErrLine(this.msg); this.needlogin = true; return; } if (this.type == "bonus") { int bonusCreditsTrans = Scoresets.GetBonusCreditsTrans(); if (bonusCreditsTrans <= 0) { base.AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏"); return; } this.mybonustranscredits = Users.GetUserExtCredits(this.userid, bonusCreditsTrans); } this.userGroupInfoList.Sort((x, y) => x.Readaccess - y.Readaccess + (y.ID - x.ID)); var adminGroupInfo = AdminGroup.FindByID(this.usergroupid); this.disablepost = adminGroupInfo != null ? adminGroupInfo.DisablePostctrl : this.usergroupinfo.DisablePeriodctrl; if (this.ispost) { if (!UserAuthority.CheckPostTimeSpan(this.usergroupinfo, adminGroupInfo, this.oluserinfo, this.userinfo, ref this.msg)) { base.AddErrLine(this.msg); return; } base.SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", this.forumid, this.type)); ForumUtils.WriteCookie("postmessage", this.postmessage); this.NormalValidate(adminGroupInfo, this.postmessage, this.userinfo); if (base.IsErr()) { return; } if (ForumUtils.IsPostFile()) { if (Utils.StrIsNullOrEmpty(AttachType.GetAttachmentTypeArray(usergroupinfo, forum))) { base.AddErrLine("系统不允许上传附件"); } if (!UserAuthority.PostAttachAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg)) { base.AddErrLine(this.msg); } } int topicprice = 0; bool isbonus = this.type == "bonus"; this.ValidateBonus(ref topicprice, ref isbonus); this.ValidatePollAndDebate(); if (base.IsErr()) { return; } if (ForumUtils.IsHidePost(this.postmessage)) { int arg_5B2_0 = this.usergroupinfo.AllowHideCode ? 1 : 0; } var topicInfo = this.CreateTopic(adminGroupInfo, this.postmessage, isbonus, topicprice); if (base.IsErr()) { return; } //var postInfo = this.CreatePost(topicInfo); var postInfo = Post.FindByID(topicInfo.LastPostID); //if (base.IsErr()) //{ // return; //} var stringBuilder = new StringBuilder(); //AttachmentInfo[] array = null; string formString = DNTRequest.GetFormString("attachid"); if (!string.IsNullOrEmpty(formString)) { var array = Attachments.GetNoUsedAttachmentArray(this.userid, formString); Attachments.UpdateAttachment(array, topicInfo.ID, postInfo.ID, postInfo, ref stringBuilder, this.userid, this.config, this.usergroupinfo); } Online.UpdateAction(this.olid, UserAction.PostTopic, this.forumid, this.forum.Name, -1, ""); if (this.isbindconnect && this.feedstatus) { // 推送到QQ空间和微博 //PushFeed pushFeed = new PushFeed(); //pushFeed.TopicPushFeed(topicInfo, postInfo, array, this.feedstatus); } if (stringBuilder.Length > 0) { base.SetUrl(base.ShowTopicAspxRewrite(topicInfo.ID, 0)); base.SetMetaRefresh(5); base.SetShowBackLink(true); if (this.infloat == 1) { base.AddErrLine(stringBuilder.ToString()); return; } stringBuilder.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表主题成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>"); base.AddMsgLine(stringBuilder.Append("</table>").ToString()); } else { base.SetShowBackLink(false); if (this.useradminid != 1 && (UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo) || topicInfo.DisplayOrder == -2)) { ForumUtils.WriteCookie("postmessage", ""); this.SetLastPostedForumCookie(); base.SetUrl(base.ShowForumAspxRewrite(this.forumid, this.forumpageid)); base.SetMetaRefresh(); base.AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块"); } else { this.PostTopicSucceed(this.forum, topicInfo); } } if (this.needlogin && this.userid > 0) { this.needlogin = false; return; } } else { base.AddLinkCss(BaseConfigs.GetForumPath + "templates/" + this.templatepath + "/editor.css", "css"); } }
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.UpdateUserExtCreditsByUploadAttachment(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, ""); } 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() { pagetitle = "用户控制面板"; creditstax = Scoresets.GetCreditsTax(); extcreditspaylist = Scoresets.GetScorePaySet(0); score = Scoresets.GetValidScoreName(); jscreditsratearray = "<script type=\"text/javascript\">\r\nvar creditsrate = new Array();\r\n"; foreach (DataRow dr in extcreditspaylist.Rows) { jscreditsratearray = jscreditsratearray + "creditsrate[" + dr["id"].ToString() + "] = " + dr["rate"].ToString() + ";\r\n"; } jscreditsratearray = jscreditsratearray + "\r\n</script>"; if (userid == -1) { AddErrLine("你尚未登录"); return; } user = Discuz.Forum.Users.GetUserInfo(userid); if (DNTRequest.IsPost()) { if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } if (Utils.MD5(DNTRequest.GetString("password")) != password) { AddErrLine("密码错误"); return; } int paynum = DNTRequest.GetInt("paynum", 0); if (paynum <= 0) { AddErrLine("数量必须是大于0的整数"); return; } int extcredits1 = DNTRequest.GetInt("extcredits1", 0); int extcredits2 = DNTRequest.GetInt("extcredits2", 0); if (extcredits1 < 1 || extcredits2 < 1 || extcredits1 > 8 || extcredits2 > 8) { AddErrLine("请正确选择要兑换的金币类型!"); return; } if (extcredits1 == extcredits2) { AddErrLine("不能兑换相同类型的金币"); return; } //对交易后的金币增减进行修改设置 UserExtcreditsInfo extcredits1info = Scoresets.GetScoreSet(extcredits1); UserExtcreditsInfo extcredits2info = Scoresets.GetScoreSet(extcredits2); if ((extcredits1info.Name.Trim() == "") || (extcredits2info.Name.Trim() == "")) { AddErrLine("错误的输入!"); return; } UserInfo __userinfo = Discuz.Forum.Users.GetUserInfo(userid); if ((Discuz.Forum.Users.GetUserExtCredits(userid, extcredits1) - paynum) < Scoresets.GetExchangeMinCredits()) { AddErrLine("抱歉, 您的 \"" + extcredits1info.Name + "\" 不足." + Scoresets.GetExchangeMinCredits().ToString()); return; } //计算并更新2个扩展金币的新值 extcredits1rate = extcredits1info.Rate; extcredits2rate = extcredits2info.Rate; float extcredit2paynum = (float)Math.Round(paynum * (extcredits1rate / extcredits2rate) * (1 - creditstax), 2); Discuz.Forum.Users.UpdateUserExtCredits(userid, extcredits1, paynum * -1); Discuz.Forum.Users.UpdateUserExtCredits(userid, extcredits2, extcredit2paynum); CreditsLogs.AddCreditsLog(userid, userid, extcredits1, extcredits2, paynum, extcredit2paynum, Utils.GetDateTime(), 1); SetUrl("usercpcreaditstransferlog.aspx"); SetMetaRefresh(); SetShowBackLink(false); AddMsgLine("金币兑换完毕, 正在返回金币兑换与转帐记录"); } }
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() { var adminGroupInfo = AdminGroup.FindByID(this.usergroupid); this.disablepostctrl = false; if (adminGroupInfo != null) { this.disablepostctrl = adminGroupInfo.DisablePostctrl; } if (this.userid == -1) { this.forum = new XForum(); this.topic = new Topic(); this.postinfo = new Post(); base.AddErrLine("您尚未登录"); return; } if (this.postid == -1) { base.AddErrLine("无效的帖子ID"); return; } //this.postinfo = Posts.GetPostInfo(this.topicid, this.postid); postinfo = Post.FindByID(postid); if (this.postinfo == null) { base.AddErrLine("不存在的帖子ID"); return; } this.pagetitle = ((String.IsNullOrEmpty(this.postinfo.Title)) ? "编辑帖子" : this.postinfo.Title); this.htmlon = this.postinfo.HtmlOn; this.message = this.postinfo.Message; this.isfirstpost = (this.postinfo.Layer == 0); if (this.topicid != this.postinfo.Tid || this.postinfo.Tid == -1) { base.AddErrLine("无效的主题ID"); return; } //this.topic = Topics.GetTopicInfo(this.postinfo.Tid); topic = Topic.FindByID(postinfo.Tid); if (this.topic == null) { base.AddErrLine("不存在的主题ID"); return; } if (this.topic.Special == 1 && this.postinfo.Layer == 0) { //修改为Xcode方法 this.pollinfo = Poll.FindByTid(topic.ID); this.polloptionlist = PollOption.FindAllByTid(topic.ID); } if (this.topic.Special == 4 && this.postinfo.Layer == 0) { this.debateinfo = Debate.FindByTid(this.topic.ID); } this.forumid = this.topic.Fid; this.forum = Forums.GetForumInfo(this.forumid); this.needaudit = UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo, this.topic); if (this.forum == null || this.forum.Layer == 0) { base.AddErrLine("版块已不存在"); this.forum = new XForum(); return; } if (!this.forum.Password.IsNullOrEmpty() && Utils.MD5(this.forum.Password) != ForumUtils.GetCookie("forum" + this.forumid + "password")) { base.AddErrLine("本版块被管理员设置了密码"); base.SetBackLink(base.ShowForumAspxRewrite(this.forumid, 0)); return; } if (this.forum.ApplytopicType == 1) { this.topictypeselectoptions = Forums.GetCurrentTopicTypesOption(this.forum.Fid, this.forum.Topictypes); } this.customeditbuttons = Caches.GetCustomEditButtonList(); if (!UserAuthority.CanEditPost(this.postinfo, this.userid, this.useradminid, ref this.msg)) { base.AddErrLine(this.msg); return; } //string allowAttachmentType = Attachments.GetAllowAttachmentType(this.usergroupinfo, this.forum); this.attachextensions = AttachType.GetAttachmentTypeArray(usergroupinfo, forum); this.attachextensionsnosize = AttachType.GetAttachmentTypeString(usergroupinfo, forum); int num = (this.userid > 0) ? Attachment.GetUploadFileSizeByuserid(this.userid) : 0; this.attachsize = this.usergroupinfo.MaxSizeperday - num; this.canpostattach = UserAuthority.PostAttachAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg); this.userinfo = BBX.Entity.User.FindByID(this.userid); this.attachmentlist = Attachment.FindAllByPid(this.postinfo.ID); this.attachmentcount = this.attachmentlist.Count; this.allowviewattach = UserAuthority.DownloadAttachment(this.forum, this.userid, this.usergroupinfo); this.smileyoff = ((!DNTRequest.IsPost()) ? this.postinfo.SmileyOff : (forum.AllowSmilies ? 0 : 1)); //this.allowimg = this.forum.Allowimgcode; this.parseurloff = this.postinfo.ParseUrlOff; this.bbcodeoff = this.usergroupinfo.AllowCusbbCode ? this.postinfo.BBCodeOff : 1; this.usesig = this.postinfo.UseSig; this.userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); if (this.bonusCreditsTrans > 0 && this.bonusCreditsTrans < 9) { this.bonusextcreditsinfo = Scoresets.GetScoreSet(this.bonusCreditsTrans); this.mybonustranscredits = Users.GetUserExtCredits(this.userid, this.bonusCreditsTrans); } if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg)) { base.AddErrLine(this.msg); return; } if (!Moderators.IsModer(this.useradminid, this.userid, this.forumid)) { if (this.postinfo.PosterID != this.userid) { base.AddErrLine("你并非作者, 且你当前的身份 \"" + this.usergroupinfo.GroupTitle + "\" 没有修改该帖的权限"); return; } if (this.config.Edittimelimit > 0 && this.postinfo.PostDateTime.AddMinutes(this.config.Edittimelimit) < DateTime.Now) { base.AddErrLine("抱歉, 系统规定只能在帖子发表" + this.config.Edittimelimit + "分钟内才可以修改"); return; } if (this.config.Edittimelimit == -1) { base.AddErrLine("抱歉,系统不允许修改帖子"); return; } this.alloweditpost = true; } else { if (adminGroupInfo != null && adminGroupInfo.AllowEditPost && Moderators.IsModer(this.useradminid, this.userid, this.forumid)) { this.alloweditpost = true; } } if (!this.alloweditpost && this.postinfo.PosterID != this.userid) { base.AddErrLine("您当前的身份没有编辑帖子的权限"); return; } if (this.postinfo.Layer == 0) { this.canhtmltitle = this.usergroupinfo.AllowHtmlTitle; } if (Topics.GetMagicValue(this.topic.Magic, MagicType.HtmlTitle) == 1) { this.htmltitle = Topics.GetHtmlTitle(this.topic.ID).Replace("\"", "\\\"").Replace("'", "\\'"); } this.enabletag = config.Enabletag && forum.AllowTag; if (this.enabletag && Topics.GetMagicValue(this.topic.Magic, MagicType.TopicTag) == 1) { foreach (var item in Tag.GetTagsListByTopic(this.topic.ID)) { if (item.OrderID > -1) { this.topictags += string.Format(" {0}", item.Name); } } this.topictags = this.topictags.Trim(); } this.userGroupInfoList.Sort((x, y) => x.Readaccess - y.Readaccess + (y.ID - x.ID)); if (this.ispost) { base.SetBackLink("editpost.aspx?topicid=" + this.postinfo.Tid + "&postid=" + this.postinfo.ID); if (ForumUtils.IsCrossSitePost()) { base.AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } this.SetPostInfo(adminGroupInfo, this.userinfo, DNTRequest.GetString("htmlon").ToInt(0) == 1); if (base.IsErr()) { return; } //Posts.UpdatePost(this.postinfo); postinfo.Update(); var stringBuilder = this.SetAttachmentInfo(); if (base.IsErr()) { return; } CreditsFacade.UpdateUserCredits(this.userid); string url; if (this.topic.Special == 4) { url = Urls.ShowTopicAspxRewrite(this.topic.ID, this.pageid); } else { if (DNTRequest.GetQueryString("referer") != "") { url = string.Format("showtopic.aspx?page=end&forumpage={2}&topicid={0}#{1}", this.topic.ID, this.postinfo.ID, this.forumpageid); } else { if (this.pageid > 1) { if (this.config.Aspxrewrite == 1) { url = string.Format("showtopic-{0}-{2}{1}#{3}", new object[] { this.topic.ID, this.config.Extname, this.pageid, this.postinfo.ID }); } else { url = string.Format("showtopic.aspx?topicid={0}&forumpage={3}&page={2}#{1}", new object[] { this.topic.ID, this.postinfo.ID, this.pageid, this.forumpageid }); } } else { if (this.config.Aspxrewrite == 1) { url = string.Format("showtopic-{0}{1}", this.topic.ID, this.config.Extname); } else { url = string.Format("showtopic.aspx?topicid={0}&forumpage={1}", this.topic.ID, this.forumpageid); } } } } base.SetUrl(url); if (stringBuilder.Length > 0) { base.SetMetaRefresh(5); base.SetShowBackLink(true); if (this.infloat == 1) { base.AddErrLine(stringBuilder.ToString()); return; } stringBuilder.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>编辑帖子成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>"); stringBuilder.Append("</table>"); base.AddMsgLine(stringBuilder.ToString()); } else { if (this.postinfo.Layer == 0) { base.SetMetaRefresh(2, url); } else { base.SetMetaRefresh(); } base.SetShowBackLink(false); if (this.useradminid != 1 && (this.needaudit || this.topic.DisplayOrder == -2 || this.postinfo.Invisible == 1)) { if (this.postinfo.Layer == 0) { base.SetUrl(base.ShowForumAspxRewrite(this.forumid, this.forumpageid)); } else { base.SetUrl(base.ShowTopicAspxRewrite(this.topic.ID, this.forumpageid)); } base.AddMsgLine("编辑成功, 但需要经过审核才可以显示"); } else { base.MsgForward("editpost_succeed"); base.AddMsgLine("编辑帖子成功, 返回该主题"); } } if (this.postinfo.Layer == 0) { ForumUtils.DeleteTopicCacheFile(this.topic.ID); return; } } else { base.AddLinkCss(BaseConfigs.GetForumPath + "templates/" + this.templatepath + "/editor.css", "css"); } }
protected override void ShowPage() { this.topic = base.GetTopicInfo(); if (this.topic == null) { return; } this.topicid = this.topic.ID; this.forumid = this.topic.Fid; this.forum = Forums.GetForumInfo(this.forumid); if (this.forum == null) { base.AddErrLine("不存在的版块ID"); return; } if (!base.ValidateInfo() || base.IsErr()) { return; } base.IsModer(); int topicPrice = this.GetTopicPrice(this.topic); if (this.topic.Special == 0 && topicPrice > 0) { HttpContext.Current.Response.Redirect(this.forumpath + "buytopic.aspx?topicid=" + this.topic.ID); return; } if (this.postid > 0 && Post.FindByID(this.postid) == null) { base.AddErrLine("该帖可能已被删除 " + string.Format("<a href=\"{0}\">[返回主题]</a>", base.ShowTopicAspxRewrite(this.topicid, 1))); return; } ForumUtils.SetVisitedForumsCookie(this.forumid.ToString()); if (this.userid > 0) { this.userInfo = BBX.Entity.User.FindByID(this.userid); } if (this.topic.Identify > 0) { this.topicidentify = TopicIdentify.FindByID(this.topic.Identify); } this.pagetitle = string.Format("{0} - {1}", this.topic.Title, Utils.RemoveHtml(this.forum.Name)); base.GetForumAds(this.forum.Fid); TopicType.GetTopicTypeArray().TryGetValue(this.topic.TypeID, out this.topictypes); this.topictypes = (this.topictypes.IsNullOrEmpty() ? "" : ("[" + this.topictypes + "]")); this.userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); this.score = Scoresets.GetValidScoreName(); this.scoreunit = Scoresets.GetValidScoreUnit(); this.navhomemenu = Caches.GetForumListMenuDivCache(this.usergroupid, this.userid, this.config.Extname); base.EditorState(); string[] array = this.config.Customauthorinfo.Split('|'); this.postleftshow = array[0].Split(','); this.userfaceshow = array[1].Split(','); this.onlyauthor = ((this.onlyauthor == "1" || this.onlyauthor == "2") ? this.onlyauthor : "0"); this.BindPageCountAndId(); base.GetPostAds(this.GetPostPramsInfo(topicPrice), this.postlist.Count); //this.bonuslogs = Bonus.GetLogs(this.topic); if (this.topic.Special == 3) { this.bonuslogs = BonusLog.GetLogs(this.topic.ID); } if (this.topic.Special == 1) { this.GetPollInfo(); } if (this.topic.Special == 4) { this.GetDebateInfo(); } this.enabletag = config.Enabletag && forum.AllowTag; if (this.postlist != null && this.postlist.Count > 0) { base.UpdateMetaInfo(Utils.RemoveHtml(this.postlist[0].Message)); } this.IsGuestCachePage(); //Topic.UpdateViewCount(this.topicid, 1); topic.Views++; topic.SaveAsync(10000); Topics.MarkOldTopic(this.topic); this.topicviews = this.topic.Views; Online.UpdateAction(this.olid, UserAction.ShowTopic, this.forumid, this.forum.Name, this.topicid, this.topic.Title); if (DNTRequest.GetInt("fromfav", 0) > 0) { //Favorites.UpdateUserFavoriteViewTime(this.userid, this.topicid); var fav = Favorite.FindByUidAndTid(userid, topicid); if (fav != null) { fav.ViewTime = DateTime.Now; fav.Update(); } } }
protected override void ShowPage() { this.GetPostAds(this.forumid); if (this.userid > 0 && this.useradminid > 0) { var adminGroupInfo = AdminGroup.FindByID(this.usergroupid); if (adminGroupInfo != null) { this.disablepostctrl = adminGroupInfo.DisablePostctrl; } } if (this.forumid == -1) { base.AddLinkRss(this.forumpath + "tools/rss.aspx", "最新主题"); base.AddErrLine("无效的版块ID"); return; } this.forum = Forums.GetForumInfo(this.forumid); if (this.forum == null || this.forum.Fid < 1) { if (this.config.Rssstatus == 1) { base.AddLinkRss(this.forumpath + "tools/rss.aspx", Utils.EncodeHtml(this.config.Forumtitle) + " 最新主题"); } base.AddErrLine("不存在的版块ID"); return; } if (this.config.Rssstatus == 1) { base.AddLinkRss(this.forumpath + "tools/" + Urls.RssAspxRewrite(this.forum.Fid), Utils.EncodeHtml(this.forum.Name) + " 最新主题"); } if (this.JumpUrl(this.forum)) { return; } this.needaudit = UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo); if (this.useradminid > 0) { this.ismoder = Moderators.IsModer(this.useradminid, this.userid, this.forumid); } //this.SetSearchCondition(); this.showforumlogin = this.IsShowForumLogin(this.forum); this.pagetitle = Utils.RemoveHtml(this.forum.Name); this.navhomemenu = Caches.GetForumListMenuDivCache(this.usergroupid, this.userid, this.config.Extname); this.forumnav = base.ShowForumAspxRewrite(ForumUtils.UpdatePathListExtname(this.forum.Pathlist.Trim(), this.config.Extname).Replace("\"showforum", "\"" + this.forumurl + "showforum"), this.forumid, this.pageid); this.topicextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); this.bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); if (this.forum.ApplytopicType == 1) { this.topictypeselectoptions = Forums.GetCurrentTopicTypesOption(this.forum.Fid, this.forum.Topictypes); } if (this.forum.ApplytopicType == 1) { this.topictypeselectlink = Forums.GetCurrentTopicTypesLink(this.forum.Fid, this.forum.Topictypes, this.forumurl + "showforum.aspx"); } meta = PageHelper.UpdateMetaInfo(meta, this.forum.Seokeywords.IsNullOrEmpty() ? this.config.Seokeywords : this.forum.Seokeywords, this.forum.Seodescription.IsNullOrEmpty() ? this.forum.Description : this.forum.Seodescription, this.config.Seohead); this.SetEditorState(); if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg)) { base.AddErrLine(this.msg); this.needlogin = (this.userid == -1); return; } this.canposttopic = UserAuthority.PostAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg); if (this.useradminid != 1 && !this.usergroupinfo.DisablePeriodctrl) { string text = ""; if (this.canposttopic && Scoresets.BetweenTime(this.config.Postbanperiods, out text)) { this.canposttopic = false; } this.isnewbie = UserAuthority.CheckNewbieSpan(this.userid); } if ((this.config.Fastpost == 1 || this.config.Fastpost == 3) && !this.forum.AllowSpecialOnly && (this.userid < 0 || (this.canposttopic && !this.isnewbie))) { this.canquickpost = true; } if ((forum as XForum).Childs.Count > 0) { this.subforumlist = Forums.GetSubForumCollection(this.forumid, this.forum.ColCount, this.config.Hideprivate, this.usergroupid, this.config.Moddisplay); } if (!this.forum.Rules.IsNullOrWhiteSpace()) { this.forum.Rules = UBB.ParseSimpleUBB(this.forum.Rules); } // 满足条件的主题数 this.topiccount = Topic.SearchCount(forumid, topictypeid, interval, filter); if (tpp <= 0) { tpp = this.config.Tpp; } if (this.ppp <= 0) { this.ppp = this.config.Ppp; } if (this.pageid < 1) { this.pageid = 1; } // 内层板块,需要显示主题列表 if (this.forum.Layer > 0) { // 置顶主题列表 var tops = Topic.GetTop(forumid); if (tops.Count > 0) { // 加上非本板块的主题数 topiccount += tops.Count(e => e.Fid != forumid); } // 根据主题总数计算分页 //pagecount = ((topiccount % tpp == 0) ? (topiccount / tpp) : (topiccount / tpp + 1)); pagecount = topiccount / tpp; if (topiccount % tpp > 0) { pagecount++; } if (pagecount == 0) { pagecount = 1; } if (pageid > pagecount) { pageid = pagecount; } // 如果有置顶主题,则先读取置顶主题,再读取部分普通主题以填满一页 if (tops.Count > 0) { // 置顶主题数 var toptopiccount = tops.Count; // 置顶主题构成的完整页数,不包括半截 int topPageCount = toptopiccount / tpp; // 置顶主题可能满好几页,如果分到当前页还有主题,则需要处理 if (toptopiccount > tpp * (pageid - 1)) { // 取出本页所属的置顶主题 toptopiclist = Topics.GetTopTopicList(tops, tpp, pageid, forum.AutoClose, forum.Topictypeprefix); if (toptopiclist.Count < tpp) { // 本页有一部分置顶主题,要注意计算本页普通主题的数量(总页大小-置顶帖在本页的大小),开始行很简单从0开始即可(因为是第一页普通主题) topiclist = GetTopicInfoList(tpp - toptopiclist.Count, pageid - topPageCount, 0); } } else { // 已经没有置顶主题,取满一页普通主题,注意开始行的计算 topiclist = GetTopicInfoList(tpp, pageid - topPageCount, toptopiccount % tpp); } } else { // 如果没有置顶主题,则直接读取一页普通主题 topiclist = GetTopicInfoList(tpp, pageid, 0); } // 如果没有主题,或者实际主题列表大于主题总数,那么更新论坛的主题数 // 在XCode支持下,即使有缓存,这种可能性也很小很小 if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount) { XForum.SetRealCurrentTopics(this.forum.Fid); } this.SetPageNumber(); var vs = visitedforums; this.showvisitedforumsmenu = (vs != null && ((vs.Length == 1 && vs[0].Fid != forumid) || vs.Length > 1)); this.SetVisitedForumsCookie(); Utils.WriteCookie("forumpageid", this.pageid.ToString(), 30); this.IsGuestCachePage(); } this.forum.Description = UBB.ParseSimpleUBB(this.forum.Description); Online.UpdateAction(this.olid, UserAction.ShowForum, this.forumid, this.forum.Name, -1, ""); if ((this.forumtotalonline < this.config.Maxonlinelist && (this.config.Whosonlinestatus == 2 || this.config.Whosonlinestatus == 3)) || DNTRequest.GetString("showonline") == "yes") { this.showforumonline = true; this.onlineuserlist = Online.GetList(this.forumid, Online._.UserID, true); var st = Online.GetStat(); this.forumtotalonline = st.Total; this.forumtotalonlineuser = st.User; this.forumtotalonlineinvisibleuser = st.Invisible; this.forumtotalonlineguest = st.Guest; } if (DNTRequest.GetString("showonline") == "no") { this.showforumonline = false; } // 这里会导致版主列表不断增大,直到最后内存溢出,临时解决 if (!forum.Moderators.IsNullOrWhiteSpace() && (forum.ModeratorsHtml.IsNullOrWhiteSpace() || !forum.ModeratorsHtml.Contains("href"))) { string text2 = string.Empty; string[] array = this.forum.Moderators.Split(','); for (int i = 0; i < array.Length; i++) { text2 += string.Format("<a href=\"{0}userinfo.aspx?username={1}\">{2}</a>,", this.forumpath, Utils.UrlEncode(array[i]), array[i]); } this.forum.ModeratorsHtml = text2.TrimEnd(','); } ForumUtils.UpdateVisitedForumsOptions(this.forumid); }