Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
 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);
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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();
            }
        }
        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;
                }
            }
        }
Beispiel #6
0
        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 { }
                }
            }
        }
Beispiel #7
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);
        }