示例#1
0
        public static void CheckPurchasedAttachments(List <Attachment> attachList, int uid)
        {
            //string ids = "";
            //foreach (var item in attachList)
            //{
            //    //if (current.Filename.IndexOf("http") < 0 && Attachments.appSquidAttachment)
            //    //{
            //    //    current.Filename = EntLibConfigInfo.Current.Attachmentdir.TrimEnd('/') + "/" + current.Filename;
            //    //}
            //    ids = Utils.MergeString(item.Aid.ToString(), ids);
            //}
            var ids = attachList.Select(e => e.ID).ToArray();

            if (ids.Length > 0 && uid > 0)
            {
                //ids = BBX.Data.Attachments.GetPurchasedAttachmentIdList(ids, uid);
                ids = AttachPaymentLog.GetPurchasedAttachmentIdList(ids, uid);
                foreach (var att in attachList)
                {
                    //if (att.Attachprice > 0 && Utils.InArray(att.Aid.ToString(), ids))
                    if (att.AttachPrice > 0 && ids.Contains(att.ID))
                    {
                        att.IsBought = true;
                    }
                }
            }
        }
示例#2
0
 private void GetAttachPaymentLogByAid(int aid)
 {
     if (aid > 0)
     {
         HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1.0);
         HttpContext.Current.Response.Expires         = -1;
         HttpContext.Current.Response.Clear();
         HttpContext.Current.Response.Write(AttachPaymentLog.GetAttachPaymentLogJsonByAid(aid));
         HttpContext.Current.Response.End();
     }
 }
示例#3
0
        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);
        }