Example #1
0
        private static string GetAttachReplacement(PostpramsInfo postPramsInfo, int allowGetAttach, Attachment att)
        {
            string forumpath = BaseConfigInfo.Current.Forumpath;
            string arg       = "attachment.gif";

            if (Utils.InArray(Utils.GetFileExtName(att.FileName), ".rar,.zip"))
            {
                arg = "rar.gif";
            }
            string str = string.Format("<dt><img src=\"{0}images/attachicons/{1}\" alt=\"\"></dt>", forumpath, arg);
            string result;

            if (allowGetAttach != 1)
            {
                result = string.Format("<dl class=\"t_attachlist attachimg cl\">{0}</dl>", str + string.Format("<dd>{0}</dd>", "<div class=\"hide\"><span class=\"attachnotdown\">您所在的用户组无法下载或查看附件</span></div>"));
            }
            else
            {
                if (att.AllowRead)
                {
                    string fileSize;
                    if (att.FileSize > 1024L)
                    {
                        fileSize = Convert.ToString(Math.Round(Convert.ToDecimal(att.FileSize) / 1024m, 2)) + " K";
                    }
                    else
                    {
                        fileSize = att.FileSize + " B";
                    }
                    string str2 = string.Format("<em class=\"xg1\">(<script type=\"text/javascript\">ShowFormatBytesStr({0});</script>, 下载次数:{1})</em>", att.FileSize, att.Downloads);
                    if (att.ImgPost)
                    {
                        result = ParseImageAttachContent(postPramsInfo, att, fileSize);
                    }
                    else
                    {
                        //att.Attachimgpost = 0;
                        if (postPramsInfo.CurrentUserGroup.Is管理团队 || postPramsInfo.CurrentUserid == att.Uid || att.AttachPrice <= 0 || att.IsBought)
                        {
                            result = string.Format("<dl class=\"t_attachlist attachimg cl\">{0}</dl>", str + string.Format("<dd>{0}</dd>", string.Format("<a href=\"{0}attachment.aspx?attachmentid={1}\" onclick=\"return ShowDownloadTip({2});\" target=\"_blank\">{3}</a>", new object[]
                            {
                                forumpath,
                                att.ID,
                                att.Uid,
                                att.Name
                            }) + str2));
                        }
                        else
                        {
                            result = string.Format("<dl class=\"t_attachlist attachimg cl\">{0}</dl>", str + string.Format("<dd>{0}</dd>", att.Name + str2 + string.Format("<p>售价({0}):<strong>{1} </strong>[<a onclick=\"loadattachpaymentlog({2});\" href=\"javascript:void(0);\">记录</a>] [<a onclick=\"loadbuyattach({2});\" href=\"javascript:void(0);\">购买</a>]</p>", Scoresets.GetTopicAttachCreditsTransName(), att.AttachPrice, att.ID)));
                        }
                    }
                }
                else
                {
                    if (postPramsInfo.CurrentUserid > 0)
                    {
                        result = string.Format("<div class=\"hide\"><span class=\"attachnotdown\">你的下载权限 {0} 低于此附件所需权限 {1}, 你无权查看此附件</span></div>", postPramsInfo.Usergroupreadaccess, att.ReadPerm);
                    }
                    else
                    {
                        result = string.Format("<div class=\"hide\">附件: <em><span class=\"attachnotdown\">你需要<a href=\"{0}login.aspx\" onclick=\"hideWindow('register');showWindow('login', this.href);\">登录</a>才可以下载或查看附件。没有帐号? <a href=\"{0}register.aspx\" onclick=\"hideWindow('login');showWindow('register', this.href);\" title=\"注册帐号\">注册</a></span></em></div>", BaseConfigs.GetForumPath);
                    }
                }
            }
            return(result);
        }
Example #2
0
        private static string ParseImageAttachContent(PostpramsInfo postPramsInfo, Attachment att, string fileSize)
        {
            string empty     = string.Empty;
            string forumpath = BaseConfigInfo.Current.Forumpath;
            string text      = string.Format("<span style=\"position: absolute; display: none;\" onmouseover=\"showMenu(this.id, 0, 1)\" id=\"attach_{0}\"><img border=\"0\" src=\"{1}images/attachicons/attachimg.gif\" /></span>", att.ID, forumpath);
            string str       = string.Format("<dt><img src=\"{0}images/attachicons/{1}\" alt=\"\"></dt>", forumpath, "image.gif");
            string str2      = string.Format("<em class=\"xg1\">(<script type=\"text/javascript\">ShowFormatBytesStr({0});</script>, 下载次数:{1})</em>", att.FileSize, att.Downloads);
            bool   flag      = GeneralConfigInfo.Current.Showimgattachmode == 0;
            string format    = flag ? "{0}<img imageid=\"{2}\" src=\"{1}\" onmouseover=\"attachimginfo(this, 'attach_{2}', 1);attachimg(this, 'mouseover')\" onclick=\"zoom(this);\" onmouseout=\"attachimginfo(this, 'attach_{2}', 0, event)\" {7} /><div id=\"attach_{2}_menu\" style=\"display: none;\" class=\"t_attach\"><img border=\"0\" alt=\"\" class=\"absmiddle\" src=\"{3}images/attachicons/image.gif\" /><a target=\"_blank\"  href=\"{1}\"><strong>{4}</strong></a>({5})<br/><div class=\"t_smallfont\">{6}</div></div>" : "{0}<img alt=\"点击加载图片\" imageid=\"{2}\" inpost=\"1\" src=\"/images/common/imgloading.png\" newsrc=\"{1}\" onload=\"{8}attachimg(this, 'load');\" onclick=\"loadImg(this);\" onmouseout=\"attachimginfo(this, 'attach_{2}', 0, event)\" {7} /><div id=\"attach_{2}_menu\" style=\"display: none;\" class=\"t_attach\"><img border=\"0\" alt=\"\" class=\"absmiddle\" src=\"{3}images/attachicons/image.gif\" /><a target=\"_blank\" onclick=\"return ShowDownloadTip({9});\"  href=\"{1}\"><strong>{4}</strong></a>({5})<br/><div class=\"t_smallfont\">{6}</div></div>";
            string text2     = flag ? Attachments.GetImageShowWidth(postPramsInfo.TemplateWidth, att.Width) : "";

            //att.Attachimgpost = 1;
            if (postPramsInfo.Showattachmentpath == 1)
            {
                if (postPramsInfo.Isforspace == 1)
                {
                    if (att.IsLocal)
                    {
                        return(string.Format("<img src=\"{0}\" {1} {2}/>", att.FileName, Attachments.GetImageShowWidth(postPramsInfo.TemplateWidth, att.Width), Attachments.GetAutoImageWidthScript(postPramsInfo.TemplateWidth, att.Width, true)));
                    }
                    return(string.Format("<img src=\"{0}upload/{1}\" {2} {3}/>", new object[]
                    {
                        forumpath,
                        att.FileName,
                        Attachments.GetImageShowWidth(postPramsInfo.TemplateWidth, att.Width),
                        Attachments.GetAutoImageWidthScript(postPramsInfo.TemplateWidth, att.Width, true)
                    }));
                }
                else
                {
                    if (postPramsInfo.CurrentUserGroup.Is管理团队 || postPramsInfo.CurrentUserid == att.Uid || att.AttachPrice <= 0 || att.IsBought)
                    {
                        if (att.IsLocal)
                        {
                            return(string.Format(format, new object[]
                            {
                                text,
                                att.FileName,
                                att.ID,
                                forumpath,
                                att.Name.Trim(),
                                fileSize,
                                att.PostDateTime,
                                text2,
                                Attachments.GetAutoImageWidthScript(postPramsInfo.TemplateWidth, att.Width, false),
                                att.Uid
                            }));
                        }
                        return(string.Format(format, new object[]
                        {
                            text,
                            forumpath + "upload/" + att.FileName,
                            att.ID,
                            forumpath,
                            att.Name.Trim(),
                            fileSize,
                            att.PostDateTime,
                            text2,
                            Attachments.GetAutoImageWidthScript(postPramsInfo.TemplateWidth, att.Width, false),
                            att.Uid
                        }));
                    }
                    else
                    {
                        string.Format("<dl class=\"t_attachlist attachimg cl\">{0}</dl>", str + string.Format("<dd>{0}</dd>", att.Name + str2 + string.Format("<p>售价({0}):<strong>{1} </strong>[<a onclick=\"loadattachpaymentlog({2});\" href=\"javascript:void(0);\">记录</a>] [<a onclick=\"loadbuyattach({2});\" href=\"javascript:void(0);\">购买</a>]</p>", Scoresets.GetTopicAttachCreditsTransName(), att.AttachPrice, att.ID)));
                    }
                }
            }
            if (postPramsInfo.Isforspace == 1)
            {
                return(string.Format("<img src=\"{0}attachment.aspx?attachmentid={1}\" {2} {3}/>", new object[]
                {
                    forumpath,
                    att.ID,
                    Attachments.GetImageShowWidth(postPramsInfo.TemplateWidth, att.Width),
                    Attachments.GetAutoImageWidthScript(postPramsInfo.TemplateWidth, att.Width, true)
                }));
            }
            if (postPramsInfo.CurrentUserGroup.Is管理团队 || postPramsInfo.CurrentUserid == att.Uid || att.AttachPrice <= 0 || att.IsBought)
            {
                return(string.Format(format, new object[]
                {
                    text,
                    forumpath + "attachment.aspx?attachmentid=" + att.ID,
                    att.ID,
                    forumpath,
                    att.Name.Trim(),
                    fileSize,
                    att.PostDateTime,
                    text2,
                    Attachments.GetAutoImageWidthScript(postPramsInfo.TemplateWidth, att.Width, false),
                    att.Uid
                }));
            }
            return(string.Format("<dl class=\"t_attachlist attachimg cl\">{0}</dl>", str + string.Format("<dd>{0}</dd>", att.Name + str2 + string.Format("<p>售价({0}):<strong>{1} </strong>[<a onclick=\"loadattachpaymentlog({2});\" href=\"javascript:void(0);\">记录</a>] [<a onclick=\"loadbuyattach({2});\" href=\"javascript:void(0);\">购买</a>]</p>", Scoresets.GetTopicAttachCreditsTransName(), att.AttachPrice, att.ID))));
        }