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; } } } }
/// <summary> /// 设置相关主题信息 /// </summary> /// <param name="pollitem"></param> /// <param name="topicprice"></param> /// <param name="postmessage"></param> private void SetTopicInfo(string[] pollitem, int topicprice, string postmessage) { if (postinfo.Layer == 0) { ///修改投票信息 StringBuilder itemvaluelist = new StringBuilder(""); if (topic.Special == 1) { string pollItemname = Utils.HtmlEncode(DNTRequest.GetFormString("PollItemname").Trim()); if (!Utils.StrIsNullOrEmpty(pollItemname)) { int multiple = DNTRequest.GetString("multiple") == "on" ? 1 : 0; int maxchoices = DNTRequest.GetInt("maxchoices", 0); if (multiple == 1 && maxchoices > pollitem.Length) { maxchoices = pollitem.Length; } if (!Polls.UpdatePoll(topic.Tid, multiple, pollitem.Length, DNTRequest.GetFormString("PollOptionID").Trim(), pollItemname, DNTRequest.GetFormString("PollOptionDisplayOrder").Trim(), DNTRequest.GetString("enddatetime"), maxchoices, DNTRequest.GetString("visiblepoll") == "on" ? 1 : 0, DNTRequest.GetString("allowview") == "on" ? 1 : 0)) { AddErrLine("投票错误,请检查显示顺序"); return; } } else { AddErrLine("投票项为空"); return; } } //修改辩论信息 if (topic.Special == 4) { debateinfo.Positiveopinion = DNTRequest.GetString("positiveopinion"); debateinfo.Negativeopinion = DNTRequest.GetString("negativeopinion"); debateinfo.Terminaltime = TypeConverter.StrToDateTime(DNTRequest.GetString("terminaltime")); if (!Debates.UpdateDebateTopic(debateinfo)) { AddErrLine("辩论修改选择了无效的主题"); return; } } int iconid = DNTRequest.GetInt("iconid", 0); topic.Iconid = (iconid > 15 || iconid < 0) ? 0 : iconid; topic.Title = postinfo.Title; //悬赏差价处理 if (topic.Special == 2) { int pricediff = topicprice - topic.Price; if (pricediff > 0) { if (bonusCreditsTrans < 1 || bonusCreditsTrans > 8) { AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏"); return; } //扣分 if (usergroupinfo.Radminid != 1 && Users.GetUserExtCredits(topic.Posterid, bonusCreditsTrans) < pricediff) { AddErrLine("主题作者 " + Scoresets.GetValidScoreName()[bonusCreditsTrans] + " 不足, 无法追加悬赏"); return; } else { topic.Price = topicprice; Users.UpdateUserExtCredits(topic.Posterid, bonusCreditsTrans, -pricediff * (Scoresets.GetCreditsTax() + 1)); //计算税后的实际支付 } } else if (pricediff < 0 && usergroupinfo.Radminid != 1) { AddErrLine("不能降低悬赏价格"); return; } } else if (topic.Special == 0)//普通主题,出售 { topic.Price = topicprice; } if (usergroupinfo.Allowsetreadperm == 1) { topic.Readperm = DNTRequest.GetInt("topicreadperm", 0) > 255 ? 255 : DNTRequest.GetInt("topicreadperm", 0); } if (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) { topic.Hide = 1; } topic.Typeid = DNTRequest.GetFormInt("typeid", 0); htmltitle = DNTRequest.GetString("htmltitle").Trim(); if (!Utils.StrIsNullOrEmpty(htmltitle) && Utils.HtmlDecode(htmltitle).Trim() != topic.Title) { //按照 附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储, 11001 topic.Magic = 11000; } else { topic.Magic = 0; } topic.Displayorder = Topics.GetTitleDisplayOrder(usergroupinfo, useradminid, forum, topic, message, disablepostctrl); ForumTags.DeleteTopicTags(topic.Tid); Topics.DeleteRelatedTopics(topic.Tid); string tags = DNTRequest.GetString("tags").Trim(); if (enabletag && !Utils.StrIsNullOrEmpty(tags)) { if (ForumUtils.InBanWordArray(tags)) { AddErrLine("标签中含有系统禁止词语,请修改"); return; } string[] tagArray = Utils.SplitString(tags, " ", true, 2, 10); if (tagArray.Length > 0 && tagArray.Length <= 5) { topic.Magic = Topics.SetMagicValue(topic.Magic, MagicType.TopicTag, 1); ForumTags.CreateTopicTags(tagArray, topic.Tid, userid, Utils.GetDateTime()); } else { AddErrLine("超过标签数的最大限制或单个标签长度没有介于2-10之间,最多可填写 5 个标签"); return; } } Topics.UpdateTopic(topic); //保存htmltitle if (canhtmltitle && !Utils.StrIsNullOrEmpty(htmltitle) && htmltitle != topic.Title) { Topics.WriteHtmlTitleFile(Utils.RemoveUnsafeHtml(htmltitle), topic.Tid); } } else { if (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) { topic.Hide = 1; Topics.UpdateTopic(topic); } } }
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); }
/// <summary> /// 创建主题信息 /// </summary> /// <param name="admininfo"></param> /// <param name="postmessage"></param> /// <param name="isbonus"></param> /// <param name="topicprice"></param> /// <returns></returns> public TopicInfo CreateTopic(AdminGroupInfo admininfo, string postmessage, bool isbonus, int topicprice) { TopicInfo topicinfo = new TopicInfo(); topicinfo.Fid = forumid; topicinfo.Iconid = (DNTRequest.GetInt("iconid", 0) < 0 || DNTRequest.GetInt("iconid", 0) > 15) ? 0 : DNTRequest.GetInt("iconid", 0); message = Posts.GetPostMessage(usergroupinfo, admininfo, postmessage, (TypeConverter.StrToInt(DNTRequest.GetString("htmlon")) == 1)); topicinfo.Title = (useradminid == 1) ? Utils.HtmlEncode(posttitle) : Utils.HtmlEncode(ForumUtils.BanWordFilter(posttitle)); if (useradminid != 1 && (ForumUtils.HasBannedWord(posttitle) || ForumUtils.HasBannedWord(postmessage))) { string bannedWord = ForumUtils.GetBannedWord(posttitle) == string.Empty ? ForumUtils.GetBannedWord(postmessage) : ForumUtils.GetBannedWord(posttitle); AddErrLine(string.Format("对不起, 您提交的内容包含不良信息 <font color=\"red\">{0}</font>, 请返回修改!", bannedWord)); return(topicinfo); } if (Utils.GetCookie("lasttopictitle") == Utils.MD5(topicinfo.Title) || Utils.GetCookie("lasttopicmessage") == Utils.MD5(message)) { AddErrLine("请勿重复发帖"); return(topicinfo); } topicinfo.Typeid = DNTRequest.GetInt("typeid", 0); if (usergroupinfo.Allowsetreadperm == 1) { topicinfo.Readperm = DNTRequest.GetInt("topicreadperm", 0) > 255 ? 255 : DNTRequest.GetInt("topicreadperm", 0); } topicinfo.Price = topicprice; topicinfo.Poster = username; topicinfo.Posterid = userid; topicinfo.Postdatetime = curdatetime; topicinfo.Lastpost = curdatetime; topicinfo.Lastposter = username; topicinfo.Displayorder = Topics.GetTitleDisplayOrder(usergroupinfo, useradminid, forum, topicinfo, message, disablepost); string htmltitle = DNTRequest.GetString("htmltitle").Trim(); if (!Utils.StrIsNullOrEmpty(htmltitle) && Utils.HtmlDecode(htmltitle).Trim() != topicinfo.Title) { //按照 附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储 例: 11001 topicinfo.Magic = 11000; } //标签(Tag)操作 string tags = DNTRequest.GetString("tags").Trim(); string[] tagArray = null; if (enabletag && !Utils.StrIsNullOrEmpty(tags)) { if (ForumUtils.InBanWordArray(tags)) { AddErrLine("标签中含有系统禁止词语,请修改"); return(topicinfo); } tagArray = Utils.SplitString(tags, " ", true, 2, 10); if (tagArray.Length > 0 && tagArray.Length <= 5) { if (topicinfo.Magic == 0) { topicinfo.Magic = 10000; } topicinfo.Magic = Utils.StrToInt(topicinfo.Magic.ToString() + "1", 0); } else { AddErrLine("超过标签数的最大限制或单个标签长度没有介于2-10之间,最多可填写 5 个标签"); return(topicinfo); } } if (isbonus) { topicinfo.Special = 2; //检查积分是否足够 if (mybonustranscredits < topicprice && usergroupinfo.Radminid != 1) { AddErrLine(string.Format("无法进行悬赏<br /><br />您当前的{0}为 {1} {3}<br/>悬赏需要{0} {2} {3}", bonusextcreditsinfo.Name, mybonustranscredits, topicprice, bonusextcreditsinfo.Unit)); return(topicinfo); } else { Users.UpdateUserExtCredits(topicinfo.Posterid, Scoresets.GetBonusCreditsTrans(), -topicprice * (Scoresets.GetCreditsTax() + 1)); //计算税后的实际支付 } } if (type == "poll") { topicinfo.Special = 1; } if (type == "debate") //辩论帖 { topicinfo.Special = 4; } if (!Moderators.IsModer(useradminid, userid, forumid)) { topicinfo.Attention = 1; } if (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) { topicinfo.Hide = 1; } topicinfo.Tid = Topics.CreateTopic(topicinfo); //canhtmltitle = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup); //canhtmltitle = config.Htmltitle == 1 && usergroupinfo.Allowhtml == 1; //保存htmltitle if (canhtmltitle && !Utils.StrIsNullOrEmpty(htmltitle) && htmltitle != topicinfo.Title) { Topics.WriteHtmlTitleFile(Utils.RemoveUnsafeHtml(htmltitle), topicinfo.Tid); } if (enabletag && tagArray != null && tagArray.Length > 0) { if (useradminid != 1 && ForumUtils.HasBannedWord(tags)) { string bannedWord = ForumUtils.GetBannedWord(tags); AddErrLine(string.Format("标签中含有系统禁止词语 <font color=\"red\">{0}</font>,请修改", bannedWord)); return(topicinfo); } ForumTags.CreateTopicTags(tagArray, topicinfo.Tid, userid, curdatetime); } if (type == "debate") { DebateInfo debatetopic = new DebateInfo(); debatetopic.Tid = topicinfo.Tid; debatetopic.Positiveopinion = DNTRequest.GetString("positiveopinion"); debatetopic.Negativeopinion = DNTRequest.GetString("negativeopinion"); debatetopic.Terminaltime = Convert.ToDateTime(DNTRequest.GetString("terminaltime")); Topics.CreateDebateTopic(debatetopic); } Topics.AddParentForumTopics(forum.Parentidlist.Trim(), 1); return(topicinfo); }
public Topic CreateTopic(AdminGroup admininfo, string postmessage, bool isbonus, int topicprice) { var tp = new Topic(); tp.Fid = this.forumid; var iconid = DNTRequest.GetInt("iconid", 0); if (iconid < 0 || iconid > 15) { iconid = 0; } tp.IconID = iconid; this.message = Posts.GetPostMessage(this.usergroupinfo, admininfo, postmessage, DNTRequest.GetInt("htmlon") == 1); tp.Title = ((this.useradminid == 1) ? Utils.HtmlEncode(this.posttitle) : Utils.HtmlEncode(ForumUtils.BanWordFilter(this.posttitle))); if (this.useradminid != 1 && (ForumUtils.HasBannedWord(this.posttitle) || ForumUtils.HasBannedWord(postmessage))) { string arg = (ForumUtils.GetBannedWord(this.posttitle) == string.Empty) ? ForumUtils.GetBannedWord(postmessage) : ForumUtils.GetBannedWord(this.posttitle); base.AddErrLine(string.Format("对不起, 您提交的内容包含不良信息 <font color=\"red\">{0}</font>, 请返回修改!", arg)); return(tp); } if (Utils.GetCookie("lasttopictitle") == Utils.MD5(tp.Title) || Utils.GetCookie("lasttopicmessage") == Utils.MD5(this.message)) { base.AddErrLine("请勿重复发帖"); return(tp); } tp.TypeID = DNTRequest.GetInt("typeid", 0); if (this.usergroupinfo.AllowSetreadPerm) { tp.ReadPerm = ((DNTRequest.GetInt("topicreadperm", 0) > 255) ? 255 : DNTRequest.GetInt("topicreadperm", 0)); } tp.Price = topicprice; //tp.Poster = this.username; //tp.Posterid = this.userid; //tp.Postdatetime = this.curdatetime; //tp.Lastpost = this.curdatetime; //tp.Lastposter = this.username; tp.DisplayOrder = Topics.GetTitleDisplayOrder(this.usergroupinfo, this.useradminid, this.forum, tp, this.message, this.disablepost); string text = DNTRequest.GetString("htmltitle").Trim(); if (!text.IsNullOrEmpty() && Utils.HtmlDecode(text).Trim() != tp.Title) { tp.Magic = 11000; } string text2 = DNTRequest.GetString("tags").Trim(); string[] array = null; if (this.enabletag && !text2.IsNullOrEmpty()) { if (ForumUtils.InBanWordArray(text2)) { base.AddErrLine("标签中含有系统禁止词语,请修改"); return(tp); } array = Utils.SplitString(text2, " ", true, 2, 10); if (array.Length <= 0 || array.Length > 5) { base.AddErrLine("超过标签数的最大限制或单个标签长度没有介于2-10之间,最多可填写 5 个标签"); return(tp); } if (tp.Magic == 0) { tp.Magic = 10000; } tp.Magic = (tp.Magic + "1").ToInt(); } if (isbonus) { tp.Special = 2; if (this.mybonustranscredits < (float)topicprice && !usergroupinfo.Is管理员) { base.AddErrLine(string.Format("无法进行悬赏<br /><br />您当前的{0}为 {1} {3}<br/>悬赏需要{0} {2} {3}", new object[] { this.bonusextcreditsinfo.Name, this.mybonustranscredits, topicprice, this.bonusextcreditsinfo.Unit })); return(tp); } BBX.Entity.User.UpdateUserExtCredits(userid, Scoresets.GetBonusCreditsTrans(), (float)(-(float)topicprice) * (Scoresets.GetCreditsTax() + 1f)); } if (this.type == "poll") { tp.Special = 1; } if (this.type == "debate") { tp.Special = 4; } if (!Moderators.IsModer(this.useradminid, this.userid, this.forumid)) { tp.Attention = 1; } if (ForumUtils.IsHidePost(postmessage) && this.usergroupinfo.AllowHideCode) { tp.Hide = 1; } //tp.Tid = Topics.CreateTopic(tp); //tp.Insert(); var postInfo = this.CreatePost(tp); tp.Create(postInfo); if (this.canhtmltitle && !text.IsNullOrEmpty() && text != tp.Title) { Topics.WriteHtmlTitleFile(Utils.RemoveUnsafeHtml(text), tp.ID); } if (this.enabletag && array != null && array.Length > 0) { if (this.useradminid != 1 && ForumUtils.HasBannedWord(text2)) { string bannedWord = ForumUtils.GetBannedWord(text2); base.AddErrLine(string.Format("标签中含有系统禁止词语 <font color=\"red\">{0}</font>,请修改", bannedWord)); return(tp); } Tag.CreateTopicTags(array, tp.ID, this.userid, DateTime.Now.ToFullString()); } if (this.type == "debate") { var db = new Debate(); db.Tid = tp.ID; db.PositiveOpinion = DNTRequest.GetString("positiveopinion"); db.NegativeOpinion = DNTRequest.GetString("negativeopinion"); db.TerminalTime = Request["terminaltime"].ToDateTime(); db.Insert(); //Topics.CreateDebateTopic(new DebateInfo //{ // Tid = tp.ID, // Positiveopinion = DNTRequest.GetString("positiveopinion"), // Negativeopinion = DNTRequest.GetString("negativeopinion"), // Terminaltime = Convert.ToDateTime(DNTRequest.GetString("terminaltime")) //}); } //Topics.AddParentForumTopics(this.forum.Parentidlist.Trim(), 1); //// 所有上级论坛帖子数增加 //var ff = forum; //while (ff != null && ff.ID != 0) //{ // ff.Topics++; // ff.Save(); // ff = ff.Parent; //} return(tp); }
protected override void ShowPage() { 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("金币兑换完毕, 正在返回金币兑换与转帐记录"); } }
private void SetTopicInfo(string[] pollitem, int topicprice, string postmessage) { if (this.postinfo.Layer == 0) { new StringBuilder(""); if (this.topic.Special == 1) { string text = Utils.HtmlEncode(DNTRequest.GetFormString("PollItemname").Trim()); if (text.IsNullOrEmpty()) { base.AddErrLine("投票项为空"); return; } int num = (DNTRequest.GetString("multiple") == "on") ? 1 : 0; int num2 = DNTRequest.GetInt("maxchoices", 0); if (num == 1 && num2 > pollitem.Length) { num2 = pollitem.Length; } if (!Poll.UpdatePoll( this.topic.ID, num, pollitem.Length, DNTRequest.GetFormString("PollOptionID").Trim(), text, DNTRequest.GetFormString("PollOptionDisplayOrder").Trim(), Utility.ToDateTime(DNTRequest.GetString("enddatetime")), num2, (DNTRequest.GetString("visiblepoll") == "on") ? 1 : 0, (DNTRequest.GetString("allowview") == "on") ? true : false)) { base.AddErrLine("投票错误,请检查显示顺序"); return; } } if (this.topic.Special == 4) { this.debateinfo.PositiveOpinion = DNTRequest.GetString("positiveopinion"); this.debateinfo.NegativeOpinion = DNTRequest.GetString("negativeopinion"); this.debateinfo.TerminalTime = Request["terminaltime"].ToDateTime(); if (this.debateinfo.Update() < 1) { base.AddErrLine("辩论修改选择了无效的主题"); return; } } int @int = DNTRequest.GetInt("iconid", 0); this.topic.IconID = ((@int > 15 || @int < 0) ? 0 : @int); this.topic.Title = this.postinfo.Title; if (this.topic.Special == 2) { int num3 = topicprice - this.topic.Price; if (num3 > 0) { if (this.bonusCreditsTrans < 1 || this.bonusCreditsTrans > 8) { base.AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏"); return; } if (!usergroupinfo.Is管理员 && Users.GetUserExtCredits(this.topic.PosterID, this.bonusCreditsTrans) < (float)num3) { base.AddErrLine("主题作者 " + Scoresets.GetValidScoreName()[this.bonusCreditsTrans] + " 不足, 无法追加悬赏"); return; } this.topic.Price = topicprice; BBX.Entity.User.UpdateUserExtCredits(this.topic.PosterID, this.bonusCreditsTrans, (float)(-(float)num3) * (Scoresets.GetCreditsTax() + 1f)); } else { if (num3 < 0 && !usergroupinfo.Is管理员) { base.AddErrLine("不能降低悬赏价格"); return; } } } else { if (this.topic.Special == 0) { this.topic.Price = topicprice; } } if (this.usergroupinfo.AllowSetreadPerm) { this.topic.ReadPerm = ((DNTRequest.GetInt("topicreadperm", 0) > 255) ? 255 : DNTRequest.GetInt("topicreadperm", 0)); } if (ForumUtils.IsHidePost(postmessage) && this.usergroupinfo.AllowHideCode) { this.topic.Hide = 1; } this.topic.TypeID = DNTRequest.GetFormInt("typeid", 0); this.htmltitle = DNTRequest.GetString("htmltitle").Trim(); if (!this.htmltitle.IsNullOrEmpty() && Utils.HtmlDecode(this.htmltitle).Trim() != this.topic.Title) { this.topic.Magic = 11000; } else { this.topic.Magic = 0; } this.topic.DisplayOrder = Topics.GetTitleDisplayOrder(this.usergroupinfo, this.useradminid, this.forum, this.topic, this.message, this.disablepostctrl); Tag.DeleteTopicTags(this.topic.ID); //Topics.DeleteRelatedTopics(this.topic.ID); TopicTagCache.DeleteRelatedTopics(this.topic.ID); string text2 = DNTRequest.GetString("tags").Trim(); if (this.enabletag && !text2.IsNullOrEmpty()) { if (ForumUtils.InBanWordArray(text2)) { base.AddErrLine("标签中含有系统禁止词语,请修改"); return; } string[] array = Utils.SplitString(text2, " ", true, 2, 10); if (array.Length <= 0 || array.Length > 5) { base.AddErrLine("超过标签数的最大限制或单个标签长度没有介于2-10之间,最多可填写 5 个标签"); return; } this.topic.Magic = Topics.SetMagicValue(this.topic.Magic, MagicType.TopicTag, 1); Tag.CreateTopicTags(array, this.topic.ID, this.userid, Utils.GetDateTime()); } //Topics.UpdateTopic(this.topic); topic.Update(); if (this.canhtmltitle && !this.htmltitle.IsNullOrEmpty() && this.htmltitle != this.topic.Title) { Topics.WriteHtmlTitleFile(Utils.RemoveUnsafeHtml(this.htmltitle), this.topic.ID); return; } } else { if (ForumUtils.IsHidePost(postmessage) && this.usergroupinfo.AllowHideCode) { this.topic.Hide = 1; //Topics.UpdateTopic(this.topic); topic.Update(); } } }