public void BuyInviteCode() { if (invitecodecount >= invitationconfiginfo.InviteCodeMaxCountToBuy) { AddErrLine("您所拥有的邀请码数量超过了系统上限,无法再购买"); return; } string[] strExtCredits = Utils.SplitString(invitationconfiginfo.InviteCodePrice, ","); float[] extCredits = new float[8]; for (int i = 0; i < 8; i++) { extCredits[i] = Utils.StrToFloat(strExtCredits[i], 0) * -1; } if (UserCredits.UpdateUserExtCredits(userid, extCredits, false) > 0) { CreateInviteCode(); } else { string addExtCreditsTip = ""; if (EPayments.IsOpenEPayments()) { addExtCreditsTip = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>"; } AddErrLine("积分不足,无法购买邀请码" + addExtCreditsTip); return; } }
public bool CheckUserExtCredit(User userInfo) { if (userInfo == null) { base.AddErrLine("您无权购买本主题"); this.needlogin = true; return(false); } if (Users.GetUserExtCredit(userInfo, Scoresets.GetTopicAttachCreditsTrans()) < (float)this.topic.Price) { string text = ""; if (EPayments.IsOpenEPayments()) { text = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>"; } base.AddErrLine(string.Format("对不起,您的账户余额 <span class=\"bold\">{0} {1}{2}</span> 交易额为 {3}{2} ,无法进行交易.{4}", new object[] { Scoresets.GetValidScoreName()[Scoresets.GetTopicAttachCreditsTrans()], Users.GetUserExtCredit(userInfo, Scoresets.GetTopicAttachCreditsTrans()), Scoresets.GetValidScoreUnit()[Scoresets.GetTopicAttachCreditsTrans()], this.topic.Price, text })); return(false); } return(true); }
public void BuyInviteCode() { if (this.invitecodecount >= this.invitationconfiginfo.InviteCodeMaxCountToBuy) { base.AddErrLine("您所拥有的邀请码数量超过了系统上限,无法再购买"); return; } string[] array = Utils.SplitString(this.invitationconfiginfo.InviteCodePrice, ","); float[] array2 = new float[8]; for (int i = 0; i < 8; i++) { array2[i] = (Single)array[i].ToDouble() * -1f; } if (CreditsFacade.UpdateUserExtCredits(this.userid, array2, false) > 0) { this.CreateInviteCode(); return; } string str = ""; if (EPayments.IsOpenEPayments()) { str = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>"; } base.AddErrLine("积分不足,无法购买邀请码" + str); }
protected override void ShowPage() { this.pagetitle = "积分充值"; if (!EPayments.IsOpenEPayments()) { base.AddErrLine("论坛未开启积分充值服务!"); return; } string text = ""; foreach (DataRow dataRow in Scoresets.GetScorePaySet(0).Rows) { object obj = text; text = obj + "creditsrate[" + dataRow["id"] + "] = " + dataRow["rate"] + ";\r\n"; } this.jscreditsratearray = string.Format(this.jscreditsratearray, text); if (!base.IsLogin()) { return; } string @string; if (!string.IsNullOrEmpty(DNTRequest.GetString("redirect")) && (@string = DNTRequest.GetString("redirect")) != null) { if (!(@string == "alipay")) { return; } this.RedirectToAlipay(); } }
public NotifyPage() { if (EPayments.CheckPayment(DNTRequest.GetString("notify_id")))//验证请求是否来自支付宝,或者是伪造的 { //获取需要的信息 int orderStatus = EPayments.ConvertAlipayTradeStatus(DNTRequest.GetString("trade_status")); string orderCode = DNTRequest.GetString("out_trade_no", true); string tradeNo = DNTRequest.GetString("trade_no", true); if (string.IsNullOrEmpty(orderCode) || string.IsNullOrEmpty(tradeNo) || orderStatus <= 0) { return; } CreditOrderInfo orderInfo = CreditOrders.GetCreditOrderInfoByOrderCode(orderCode); //如果订单状态为未成功交易 if (orderInfo != null && orderInfo.OrderStatus < 2) { float[] extcredits = new float[8]; extcredits[orderInfo.Credit - 1] = orderInfo.Amount; if (UserCredits.UpdateUserExtCredits(orderInfo.Uid, extcredits, true) != 1) { orderStatus = 0; } CreditsLogs.AddCreditsLog(orderInfo.Uid, orderInfo.Uid, orderInfo.Credit, orderInfo.Credit, 0, orderInfo.Amount, Utils.GetDateTime(), 3);//添加积分兑换转账和充值记录 NoticeInfo notice = new NoticeInfo(); notice.Postdatetime = Utils.GetDateTime(); notice.Type = NoticeType.GoodsTradeNotice; notice.Poster = "系统"; notice.Posterid = 0; notice.Uid = orderInfo.Uid; notice.Note = string.Format("您购买的积分 {0} 已经成功充值,请<a href=\"usercpcreaditstransferlog.aspx\">查收</a>!(支付宝订单号:{1})", ForumUtils.ConvertCreditAndAmountToWord(orderInfo.Credit, orderInfo.Amount), tradeNo); Notices.CreateNoticeInfo(notice); CreditOrders.UpdateCreditOrderInfo(orderInfo.OrderId, tradeNo, orderStatus, Utils.GetDateTime());//修改积分订单记录状态 } //判断当前请求是支付宝GET式(直接跳转)或者是服务器POST式(需返回success使得支付宝停止继续发送通知) if (DNTRequest.IsPost()) { HttpContext.Current.Response.Write("success"); } else { HttpContext.Current.Response.Redirect("../usercpcreaditstransferlog.aspx?paysuccess=true"); } } else { HttpContext.Current.Response.Write("fail"); } }
public NotifyPage() { if (!EPayments.CheckPayment(DNTRequest.GetString("notify_id"))) { HttpContext.Current.Response.Write("fail"); return; } int status = EPayments.ConvertAlipayTradeStatus(DNTRequest.GetString("trade_status")); string outTradeNo = DNTRequest.GetString("out_trade_no", true); string tradeNo = DNTRequest.GetString("trade_no", true); if (string.IsNullOrEmpty(outTradeNo) || string.IsNullOrEmpty(tradeNo) || status <= 0) { return; } //var ci = CreditOrders.GetCreditOrderInfoByOrderCode(outTradeNo); var ci = Order.FindByCode(outTradeNo); if (ci != null && ci.Status < 2) { float[] array = new float[8]; array[ci.Credit - 1] = (float)ci.Amount; if (CreditsFacade.UpdateUserExtCredits(ci.Uid, array, true) != 1) { status = 0; } //CreditsLogs.AddCreditsLog(ci.Uid, ci.Uid, ci.Credit, ci.Credit, 0f, (float)ci.Amount, Utils.GetDateTime(), 3); CreditsLog.Add(ci.Uid, ci.Uid, ci.Credit, ci.Credit, 0, ci.Amount, 3); var notice = new Notice { PostDateTime = DateTime.Now, Type = (Int32)NoticeType.GoodsTradeNotice, Poster = "系统", PosterID = 0, Uid = ci.Uid, Note = string.Format("您购买的积分 {0} 已经成功充值,请<a href=\"usercpcreaditstransferlog.aspx\">查收</a>!(支付宝订单号:{1})", ForumUtils.ConvertCreditAndAmountToWord(ci.Credit, ci.Amount), tradeNo) }; notice.Insert(); //CreditOrders.UpdateCreditOrderInfo(ci.OrderId, tradeNo, num, Utils.GetDateTime()); ci.TradeNo = tradeNo; ci.Status = status; ci.ConfirmedTime = DateTime.Now; ci.Update(); } if (DNTRequest.IsPost()) { HttpContext.Current.Response.Write("success"); return; } HttpContext.Current.Response.Redirect("../usercpcreaditstransferlog.aspx?paysuccess=true"); }
protected override void ShowPage() { pagetitle = "积分充值"; if (!EPayments.IsOpenEPayments()) { AddErrLine("论坛未开启积分充值服务!"); return; } 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 (!string.IsNullOrEmpty(DNTRequest.GetString("redirect"))) { switch (DNTRequest.GetString("redirect"))//根据该值判断操作类型 { case "alipay": RedirectToAlipay(); break; default: return; } } }
protected override void ShowPage() { pagetitle = "附件下载"; if (attachmentid == -1) { AddErrLine("无效的附件ID"); return; } // 如果当前用户非管理员并且论坛设定了禁止下载附件时间段,当前时间如果在其中的一个时间段内,则不允许用户下载附件 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visitTime = ""; if (Scoresets.BetweenTime(config.Attachbanperiods, out visitTime)) { AddErrLine("在此时间段( " + visitTime + " )内用户不可以下载附件"); return; } } if (DNTRequest.GetString("goodsattach").ToLower() == "yes") GetGoodsAttachInfo(attachmentid); else { // 获取该附件的信息 attachmentinfo = Attachments.GetAttachmentInfo(attachmentid); if (attachmentinfo == null) { AddErrLine("不存在的附件ID"); return; } //当前用户已上传但是还没有绑定到帖子的附件需要特殊处理,直接输出图片 if ((userid > 0 || userid == -1) && userid == attachmentinfo.Uid && attachmentinfo.Tid == 0 && attachmentinfo.Filetype.StartsWith("image/")) { HttpContext.Current.Response.Clear(); if(attachmentinfo.Filename.IndexOf("http") < 0 ) HttpContext.Current.Response.TransmitFile(BaseConfigs.GetForumPath + "upload/" + attachmentinfo.Filename.Trim()); else HttpContext.Current.Response.Redirect(attachmentinfo.Filename.Trim()); HttpContext.Current.Response.End(); return; } // 获取该主题的信息 topic = Topics.GetTopicInfo(attachmentinfo.Tid); if (topic == null) { AddErrLine("不存在的主题ID"); return; } ForumInfo forum = Forums.GetForumInfo(topic.Fid); pagetitle = Utils.RemoveHtml(forum.Name); if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); if (userid == -1) needlogin = true; return; } //添加判断特殊用户的代码 if (!UserAuthority.CheckUsertAttachAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); if (userid == -1) needlogin = true; return; } ismoder = Moderators.IsModer(useradminid, userid, forum.Fid); // 检查用户是否拥有足够的阅读权限 if ((attachmentinfo.Readperm > usergroupinfo.Readaccess) && (attachmentinfo.Uid != userid) && (!ismoder)) { AddErrLine("您的阅读权限不够"); if (userid == -1) needlogin = true; return; } //检查附件是否存在 if (attachmentinfo.Filename.IndexOf("http") < 0 && !File.Exists(Utils.GetMapPath(string.Format(@"{0}upload/{1}", BaseConfigs.GetForumPath, attachmentinfo.Filename)))) { AddErrLine("该附件文件不存在或已被删除"); return; } //(!Utils.IsImgFilename(attachmentinfo.Filename.Trim()) || config.Showimages != 1):判断文件是否是图片和图片是否允许在帖子中直接显示 //userid != attachmentinfo.Uid && !ismoder:判断当前下载用户是否是该附件的发布者和当前用户是否具有管理权限 //Utils.StrIsNullOrEmpty(Utils.GetCookie("dnt_attachment_" + attachmentid))当前用户是否已经下载过该附件 if ((!Utils.IsImgFilename(attachmentinfo.Filename.Trim()) || config.Showimages != 1) && (userid != attachmentinfo.Uid && !ismoder && Utils.StrIsNullOrEmpty(Utils.GetCookie("dnt_attachment_" + attachmentid)))) { if (Scoresets.IsSetDownLoadAttachScore() && UserCredits.UpdateUserExtCreditsByDownloadAttachment(userid, 1) == -1) { string addExtCreditsTip = ""; if (EPayments.IsOpenEPayments()) addExtCreditsTip = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>"; AddErrLine("您的积分不足" + addExtCreditsTip); return; } //设置该附件已经下载的cookie Utils.WriteCookie("dnt_attachment_" + attachmentid, "true", 5); } //检查附件是否存在 if (AttachPaymentLogs.HasBoughtAttach(userid, usergroupinfo.Radminid, attachmentinfo)) { AddErrLine("该附件为交易附件, 请先行购买!"); return; } //如果是图片就不更新下载次数 if (!Utils.IsImgFilename(attachmentinfo.Filename.Trim())) { Attachments.UpdateAttachmentDownloads(attachmentid); } EntLibConfigInfo entLibConfigInfo = EntLibConfigs.GetConfig(); //当使用企业版squid静态文件加速时 if (attachmentinfo.Filename.IndexOf("http") < 0 && entLibConfigInfo != null && !Utils.StrIsNullOrEmpty(entLibConfigInfo.Attachmentdir)) attachmentinfo.Filename = EntLibConfigs.GetConfig().Attachmentdir.TrimEnd('/') + "/" + attachmentinfo.Filename; if (attachmentinfo.Filename.IndexOf("http") < 0) { //当使用mongodb数据库存储附件及相关信息时 if (entLibConfigInfo != null && entLibConfigInfo.Cacheattachfiles.Enable && entLibConfigInfo.Cacheattachfiles.Attachpostid > 0 && entLibConfigInfo.Cacheattachfiles.Attachpostid < attachmentinfo.Pid) Discuz.Cache.Data.DBCacheService.GetAttachFilesService().ResponseFile(attachmentinfo.Filename, Path.GetFileName(attachmentinfo.Attachment), attachmentinfo.Filetype); else Utils.ResponseFile(Utils.GetMapPath(BaseConfigs.GetForumPath + @"upload/" + attachmentinfo.Filename), Path.GetFileName(attachmentinfo.Attachment), attachmentinfo.Filetype); } else { try //添加try语法, 以防止在并发访问情况下, 服务器端远程链接被关闭后出现应用程序 '警告'(事件查看器) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Redirect(attachmentinfo.Filename.Trim()); HttpContext.Current.Response.End(); } catch { } } } }
protected override void ShowPage() { this.pagetitle = "附件下载"; if (this.attachmentid == -1) { base.AddErrLine("无效的附件ID"); return; } if (this.useradminid != 1 && !this.usergroupinfo.DisablePeriodctrl) { string str = ""; if (Scoresets.BetweenTime(this.config.Attachbanperiods, out str)) { base.AddErrLine("在此时间段( " + str + " )内用户不可以下载附件"); return; } } var att = Attachment.FindByID(attachmentid); this.attachmentinfo = att; if (att == null) { base.AddErrLine("不存在的附件ID"); return; } if ((userid > 0 || userid == -1) && userid == att.Uid && att.Tid == 0 && att.FileType.StartsWith("image/")) { Response.Clear(); if (att.IsLocal) { Response.TransmitFile(att.FullFileName); } else { Response.Redirect(att.FileName); } Response.End(); return; } this.topic = Topic.FindByID(att.Tid); if (this.topic == null) { base.AddErrLine("不存在的主题ID"); return; } var fi = XForum.FindByID(this.topic.Fid); this.pagetitle = Utils.RemoveHtml(fi.Name); if (!UserAuthority.VisitAuthority(fi, this.usergroupinfo, userid, ref this.msg)) { base.AddErrLine(this.msg); if (userid == -1) { this.needlogin = true; } return; } if (!UserAuthority.CheckUsertAttachAuthority(fi, this.usergroupinfo, userid, ref this.msg)) { base.AddErrLine(this.msg); if (userid == -1) { this.needlogin = true; } return; } this.ismoder = Moderators.IsModer(this.useradminid, userid, fi.ID); var q = WebHelper.RequestInt("q"); if (att.ReadPerm > this.usergroupinfo.Readaccess && att.Uid != userid && !this.ismoder) { if (q != 1) { Response.Clear(); Response.Redirect("/images/common/imgerror2.png"); Response.End(); return; } base.AddErrLine("您的阅读权限不够"); if (userid == -1) { this.needlogin = true; } return; } if (att.IsLocal && !File.Exists(att.FullFileName)) { base.AddErrLine("该附件文件不存在或已被删除"); return; } var key = "attachment_" + attachmentid; if ((!att.ImgPost || config.Showimages != 1) && userid != att.Uid && !ismoder && Utils.GetCookie(key).IsNullOrEmpty()) { if (Scoresets.IsSetDownLoadAttachScore() && CreditsFacade.IsEnoughCreditsDownloadAttachment(userid, 1) && CreditsFacade.DowlnLoadAttachments(userid, 1) == -1) { string msg = ""; if (EPayments.IsOpenEPayments()) { msg = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>"; } base.AddErrLine("您的积分不足" + msg); return; } Utils.WriteCookie(key, "true", 5); } if (AttachPaymentLog.HasBoughtAttach(userid, this.usergroupinfo.RadminID, att)) { if (q != 1) { Response.Clear(); Response.Redirect("/images/common/imgerror2.png"); Response.End(); return; } base.AddErrLine("该附件为交易附件, 请先行购买!"); return; } if (!attachmentinfo.ImgPost) { attachmentinfo.Downloads++; attachmentinfo.Save(); } if (!att.IsLocal) { try { Response.Clear(); Response.Redirect(att.FileName); Response.End(); } catch { } return; } Utils.ResponseFile(att.FullFileName, Path.GetFileName(att.Name), att.FileType); }