Пример #1
0
        /// <summary>
        /// 获得预览信息
        /// </summary>
        /// <param name="fileName">文件物理路径</param>
        /// <param name="attachment">附件对象</param>
        /// <returns>预览信息的HTML</returns>
        public string GetPreview(string fileName, ShowtopicPageAttachmentInfo attachment)
        {
            if (!PreviewHelper.IsFileExist(fileName))
                return "";
            string id = Guid.NewGuid().ToString();
            EXIFextractor exif = new EXIFextractor(fileName, string.Empty, string.Empty);
            if (exif.Count < 1)
            {
                return string.Empty;
            }
            StringBuilder builder = new StringBuilder();
            foreach (System.Web.UI.Pair s in exif)
            {
                if (s.Second.ToString().Trim() == "-" || s.Second.ToString().Trim() == string.Empty || s.Second.ToString().Trim() == "0")
                    continue;
                builder.Append("<li>");
                builder.Append(s.First.ToString().Trim() + " : " + s.Second.ToString().Replace("\0", string.Empty).Trim());
                builder.Append("</li>");
            }
            if (builder.Length == 0)
            {
                return string.Empty;
            }
            builder.Append("</ul></div>");
            
            builder.Insert(0, string.Format("<span><a onclick=\"$('{0}').style.display=$('{0}').style.display=='none'?'':'none';\" style='cursor:pointer;' title='点击显示或隐藏'>EXIF信息</a></span><div class=\"preview{1}\"><ul id=\"{0}\" style='display: none;'>", id, "jpg"));

            return builder.ToString();
        }
		/// <summary>
		/// Copies the elements of the specified <see cref="ShowtopicPageAttachmentInfo">ShowtopicPageAttachmentInfo</see> array to the end of the collection.
		/// </summary>
		/// <param name="value">An array of type <see cref="ShowtopicPageAttachmentInfo">ShowtopicPageAttachmentInfo</see> containing the Components to add to the collection.</param>
		public void AddRange(ShowtopicPageAttachmentInfo[] value) 
		{
			for (int i = 0;	(i < value.Length); i = (i + 1)) 
			{
				this.Add(value[i]);
			}
		}
Пример #3
0
        /// <summary>
        /// 获得预览信息
        /// </summary>
        /// <param name="fileName">文件物理路径</param>
        /// <param name="attachment">附件对象</param>
        /// <returns>预览信息的HTML</returns>
        public string GetPreview(string fileName, ShowtopicPageAttachmentInfo attachment)
        {
            string Result = string.Empty;
            if (!PreviewHelper.IsFileExist(fileName))
            {
                return "";
            }
            WmaMessage mp3msg = new WmaMessage(fileName);
            Result = string.Format("<div style=\"overflow:hidden; zoom:1; border:1px solid #999; font-size:13px; width:360px;\">" +
                "<dl style=\"margin:8px;\"><dt style=\"clear:both; float:left; width:80px;\">标题:</dt><dd>{1}</dd>" +
                "<dt style=\"clear:both; float:left; width:100px;\">演唱者:</dt><dd>{2}</dd>" +
                "<dt style=\"clear:both; float:left; width:100px;\">专辑:</dt><dd>{4}</dd>" +
                "<dt style=\"clear:both; float:left; width:100px;\">流派:</dt><dd>{3}</dd>" +
                "<dt style=\"clear:both; float:left; width:100px;\">文件类型:</dt><dd>{9}</dd>" +
                "<dt style=\"clear:both; float:left; width:100px;\">比特率:</dt><dd>{6}</dd>" +
                "<dt style=\"clear:both; float:left; width:100px;\">声道:</dt><dd>{8}</dd>" +
                "<dt style=\"clear:both; float:left; width:100px;\">文件大小:</dt><dd>{7}</dd>" +
                "<dt style=\"clear:both; float:left; width:100px;\">发行年份:</dt><dd>{5}</dd></dl>" +
                "<div><object classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"360\" height=\"64\"><param name=\"autostart\" value=\"1\" />" +
                "<param name=\"url\" value=\"{0}\" />" +
                "<embed src=\"{0}\" autostart=\"0\"type=\"video/x-ms-wmv\" width=\"260\"height=\"42\"></embed></object></div></div>", @"upload/" + attachment.Filename, mp3msg.Title, mp3msg.Artist, mp3msg.Genre, mp3msg.Album, mp3msg.PublishYear, mp3msg.BPS, mp3msg.Size, mp3msg.Track, mp3msg.Type);
            return Result;

        }
		public void Remove(ShowtopicPageAttachmentInfo value) 
		{
			List.Remove(value);
		}
		public void Insert(int index, ShowtopicPageAttachmentInfo value)	
		{
			List.Insert(index, value);
		}
Пример #6
0
 public void Insert(int index, ShowtopicPageAttachmentInfo value)
 {
     List.Insert(index, value);
 }
Пример #7
0
        /// <summary>
        /// 得到空间格式的帖子内容
        /// </summary>
        /// <param name="postinfo">帖子描述</param>
        /// <param name="attArray">附件集合</param>
        /// <returns>空间格式</returns>
        public static string GetPostMessageHTML(PostInfo postInfo, AttachmentInfo[] attachmentArray)
        {
            string message = "";
            PostpramsInfo postpramsInfo = new PostpramsInfo();
            //处理帖子内容
            postpramsInfo.Smileyoff = postInfo.Smileyoff;
            postpramsInfo.Bbcodeoff = postInfo.Bbcodeoff;
            postpramsInfo.Parseurloff = postInfo.Parseurloff;
            postpramsInfo.Allowhtml = postInfo.Htmlon;
            postpramsInfo.Sdetail = postInfo.Message;
            postpramsInfo.Showimages = 1 - postInfo.Smileyoff;
            postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo();
            postpramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
            postpramsInfo.Pid = postInfo.Pid;
            //强制隐藏hide内容
            postpramsInfo.Hide = 1;
            //设定这是为个人空间进行的解析
            postpramsInfo.Isforspace = 1;

            //先简单判断是否是动网兼容模式
            if (!postpramsInfo.Ubbmode)
                message = UBB.UBBToHTML(postpramsInfo);
            else
                message = Utils.HtmlEncode(postInfo.Message);

            if (postpramsInfo.Jammer == 1)
                message = ForumUtils.AddJammer(postInfo.Message);

            if (postInfo.Attachment > 0 || regexAttach.IsMatch(message) || regexAttachImg.IsMatch(message))
            {
                //获取在[hide]标签中的附件id
                string[] attHidArray = GetHiddenAttachIdList(postpramsInfo.Sdetail, postpramsInfo.Hide);

                ShowtopicPagePostInfo info = new ShowtopicPagePostInfo();
                info.Posterid = postInfo.Posterid;
                info.Pid = postInfo.Pid;

                for (int i = 0; i < attachmentArray.Length; i++)
                {
                    ShowtopicPageAttachmentInfo sAtt = new ShowtopicPageAttachmentInfo();
                    sAtt.Aid = attachmentArray[i].Aid;
                    sAtt.Attachment = attachmentArray[i].Attachment;
                    sAtt.Description = attachmentArray[i].Description;
                    sAtt.Downloads = attachmentArray[i].Downloads;
                    sAtt.Filename = attachmentArray[i].Filename;
                    sAtt.Filesize = attachmentArray[i].Filesize;
                    sAtt.Filetype = attachmentArray[i].Filetype;
                    sAtt.Pid = attachmentArray[i].Pid;
                    sAtt.Postdatetime = attachmentArray[i].Postdatetime;
                    sAtt.Readperm = attachmentArray[i].Readperm;
                    sAtt.Sys_index = attachmentArray[i].Sys_index;
                    sAtt.Sys_noupload = attachmentArray[i].Sys_noupload;
                    sAtt.Tid = attachmentArray[i].Tid;
                    sAtt.Uid = attachmentArray[i].Uid;
                    message = Attachments.GetMessageWithAttachInfo(postpramsInfo, 1, attHidArray, info, sAtt, message);
                }
            }
            return message;
        }
Пример #8
0
        /// <summary>
        /// 解析图片附件内容
        /// </summary>
        /// <param name="postPramsInfo">参数对象</param>
        /// <param name="attachInfo">附件对象</param>
        /// <param name="fileSize">文件大小字符串</param>
        /// <returns>解析内容</returns>
        private static string ParseImageAttachContent(PostpramsInfo postPramsInfo, ShowtopicPageAttachmentInfo attachInfo, string fileSize)
        {
            string content = string.Empty;
            string forumPath = BaseConfigs.GetBaseConfig().Forumpath;
            string tipImg = string.Format(ATTACH_TIP_IMAGE, attachInfo.Aid, forumPath);
            string attachInfoDtimg = string.Format(ATTACH_INFO_DTIMG, forumPath, "image.gif");
            string attachInfoEm = string.Format(ATTACH_INFO_EM, attachInfo.Filesize, attachInfo.Downloads);

            bool loadImageMode = GeneralConfigs.GetConfig().Showimgattachmode == 0;
            string imageAttachTemplate = loadImageMode ? IMAGE_ATTACH : IMAGE_ATTACH_MTDOWNLOAD;
            string imageAttachWidth = loadImageMode ? GetImageShowWidth(postPramsInfo.TemplateWidth, attachInfo.Width) : "";

            attachInfo.Attachimgpost = 1;

            if (postPramsInfo.Showattachmentpath == 1)
            {
                if (postPramsInfo.Isforspace == 1)
                {
                    if (attachInfo.Filename.ToLower().IndexOf("http") == 0)
                    {
                        return string.Format("<img src=\"{0}\" {1} {2}/>", attachInfo.Filename, GetImageShowWidth(postPramsInfo.TemplateWidth, attachInfo.Width), GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, true));
                    }
                    return string.Format("<img src=\"{0}upload/{1}\" {2} {3}/>", forumPath, attachInfo.Filename, GetImageShowWidth(postPramsInfo.TemplateWidth, attachInfo.Width), GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, true));
                }
                if (postPramsInfo.CurrentUserGroup.Radminid == 1 || postPramsInfo.CurrentUserid == attachInfo.Uid || attachInfo.Attachprice <= 0 || attachInfo.Isbought == 1)
                {
                    if (attachInfo.Filename.ToLower().IndexOf("http") == 0)
                    {
                        content = string.Format(imageAttachTemplate, tipImg, attachInfo.Filename, attachInfo.Aid, forumPath, attachInfo.Attachment.Trim(), fileSize, attachInfo.Postdatetime, imageAttachWidth, GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, false), attachInfo.Uid);
                        return content;
                    }
                    content = string.Format(imageAttachTemplate, tipImg, forumPath + "upload/" + attachInfo.Filename, attachInfo.Aid, forumPath, attachInfo.Attachment.Trim(), fileSize, attachInfo.Postdatetime, imageAttachWidth, GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, false), attachInfo.Uid);
                    return content;
                }
                string.Format(ATTACH_INFO_DL, attachInfoDtimg + string.Format(ATTACH_INFO_DD, attachInfo.Attachment + attachInfoEm +
                            string.Format(PAID_ATTACH_LINK, Scoresets.GetTopicAttachCreditsTransName(), attachInfo.Attachprice, attachInfo.Aid)));
            }
            if (postPramsInfo.Isforspace == 1)
            {
                return string.Format("<img src=\"{0}attachment.aspx?attachmentid={1}\" {2} {3}/>", forumPath, attachInfo.Aid, GetImageShowWidth(postPramsInfo.TemplateWidth, attachInfo.Width), GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, true));
            }
            if (postPramsInfo.CurrentUserGroup.Radminid == 1 || postPramsInfo.CurrentUserid == attachInfo.Uid || attachInfo.Attachprice <= 0 || attachInfo.Isbought == 1)
            {
                return string.Format(imageAttachTemplate, tipImg, forumPath + "attachment.aspx?attachmentid=" + attachInfo.Aid, attachInfo.Aid, forumPath, attachInfo.Attachment.Trim(), fileSize, attachInfo.Postdatetime, imageAttachWidth, GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, false), attachInfo.Uid);
            }

            return string.Format(ATTACH_INFO_DL, attachInfoDtimg + string.Format(ATTACH_INFO_DD, attachInfo.Attachment + attachInfoEm +
                            string.Format(PAID_ATTACH_LINK, Scoresets.GetTopicAttachCreditsTransName(), attachInfo.Attachprice, attachInfo.Aid)));
        }
		/// <summary>
		/// Copies the collection Components to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index.
		/// </summary>
		/// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param>
		/// <param name="index">The index of the array at which to begin inserting.</param>
		public void CopyTo(ShowtopicPageAttachmentInfo[] array, int index) 
		{
			this.List.CopyTo(array, index);
		}
Пример #10
0
        /// <summary>
        /// 获取加载附件信息的帖子内容
        /// </summary>
        /// <param name="_postpramsinfo">参数列表</param>
        /// <param name="allowGetAttach">是否允许获取附件</param>
        /// <param name="attHidArray">隐藏在hide标签中的附件数组</param>
        /// <param name="drpost">帖子信息</param>
        /// <param name="drAttach">附件信息</param>
        /// <param name="message">帖子内容</param>
        /// <returns>帖子内容</returns>
        private static string GetMessageWithAttachInfo(PostpramsInfo postpramsinfo, int allowGetAttach, string[] attHidArray, ShowtopicPagePostInfo postinfo, ShowtopicPageAttachmentInfo attinfo, string message)
        {
            string forumPath = BaseConfigs.GetBaseConfig().Forumpath;
            string filesize;
            string replacement;
            if (Utils.InArray(attinfo.Aid.ToString(), attHidArray))
                return message;
            if ((Utils.StrToInt(attinfo.Readperm, 0) <= postpramsinfo.Usergroupreadaccess || postinfo.Posterid == postpramsinfo.CurrentUserid) && allowGetAttach == 1)
                attinfo.Allowread = 1;
            else
                attinfo.Allowread = 0;

            attinfo.Getattachperm = allowGetAttach;

            attinfo.Filename = attinfo.Filename.ToString().Replace("\\", "/");

            if (message.IndexOf("[attach]" + attinfo.Aid.ToString() + "[/attach]") != -1 || message.IndexOf("[attachimg]" + attinfo.Aid.ToString() + "[/attachimg]") != -1)
            {
                if (allowGetAttach != 1)
                {
                    replacement = "<br /><img src=\"/images/attachicons/attachment.gif\" alt=\"\">&nbsp;附件: <span class=\"attachnotdown\">您所在的用户组无法下载或查看附件</span>";
                }
                else if (attinfo.Allowread == 1)
                {
                    if (attinfo.Filesize > 1024)
                    {
                        filesize = Convert.ToString(Math.Round(Convert.ToDecimal(attinfo.Filesize) / 1024, 2)) + " K";
                    }
                    else
                    {
                        filesize = attinfo.Filesize + " B";
                    }

                    if (Utils.IsImgFilename(attinfo.Attachment))
                    {
                        attinfo.Attachimgpost = 1;

                        if (postpramsinfo.Showattachmentpath == 1)
                        {
                            if (postpramsinfo.Isforspace == 1)
                            {
                                if (attinfo.Filename.ToLower().IndexOf("http") == 0)
                                {
                                    replacement = "<img src=\"" + attinfo.Filename + "\" />";
                                }
                                else
                                {
                                    replacement = "<img src=\"" + forumPath + "upload/" + attinfo.Filename + "\" />";
                                }
                            }
                            else
                            {
                                if (attinfo.Filename.ToLower().IndexOf("http") == 0)
                                {
                                    replacement = "<span style=\"position: absolute; display: none;\" onmouseover=\"showMenu(this.id, 0, 1)\" id=\"attach_" + attinfo.Aid + "\"><img border=\"0\" src=\"" + forumPath + "images/attachicons/attachimg.gif\" /></span><img src=\"" + attinfo.Filename + "\" onload=\"attachimg(this, 'load');\" onmouseover=\"attachimginfo(this, 'attach_" + attinfo.Aid + "', 1);attachimg(this, 'mouseover')\" onclick=\"zoom(this);\" onmouseout=\"attachimginfo(this, 'attach_" + attinfo.Aid + "', 0, event)\" /><div id=\"attach_" + attinfo.Aid + "_menu\" style=\"display: none;\" class=\"t_attach\"><img border=\"0\" alt=\"\" class=\"absmiddle\" src=\"" + forumPath + "images/attachicons/image.gif\" /><a target=\"_blank\" href=\"" + attinfo.Filename + "\"><strong>" + attinfo.Attachment + "</strong></a>(" + filesize + ")<br/><div class=\"t_smallfont\">" + attinfo.Postdatetime + "</div></div>";
                                }
                                else
                                {
                                    replacement = "<span style=\"position: absolute; display: none;\" onmouseover=\"showMenu(this.id, 0, 1)\" id=\"attach_" + attinfo.Aid + "\"><img border=\"0\" src=\"" + forumPath + "images/attachicons/attachimg.gif\" /></span><img src=\"" + forumPath + "upload/" + attinfo.Filename + "\" onload=\"attachimg(this, 'load');\" onmouseover=\"attachimginfo(this, 'attach_" + attinfo.Aid + "', 1);attachimg(this, 'mouseover')\" onclick=\"zoom(this);\" onmouseout=\"attachimginfo(this, 'attach_" + attinfo.Aid + "', 0, event)\" /><div id=\"attach_" + attinfo.Aid + "_menu\" style=\"display: none;\" class=\"t_attach\"><img border=\"0\" alt=\"\" class=\"absmiddle\" src=\"" + forumPath + "images/attachicons/image.gif\" /><a target=\"_blank\" href=\"" + forumPath + "upload/" + attinfo.Filename + "\"><strong>" + attinfo.Attachment + "</strong></a>(" + filesize + ")<br/><div class=\"t_smallfont\">" + attinfo.Postdatetime + "</div></div>";
                                }

                            }
                        }
                        else
                        {
                            if (postpramsinfo.Isforspace == 1)
                            {
                                replacement = "<img src=\"" + forumPath + "attachment.aspx?attachmentid=" + attinfo.Aid.ToString() + "\" />";
                            }
                            else
                            {
                                replacement = "<span style=\"position: absolute; display: none;\" onmouseover=\"showMenu(this.id, 0, 1)\" id=\"attach_" + attinfo.Aid + "\"><img border=\"0\" src=\"" + forumPath + "images/attachicons/attachimg.gif\" /></span><img src=\"" + forumPath + "attachment.aspx?attachmentid=" + attinfo.Aid.ToString() + "\" onload=\"attachimg(this, 'load');\" onmouseover=\"attachimginfo(this, 'attach_" + attinfo.Aid + "', 1);attachimg(this, 'mouseover')\" onclick=\"zoom(this);\" onmouseout=\"attachimginfo(this, 'attach_" + attinfo.Aid + "', 0, event)\" /><div id=\"attach_" + attinfo.Aid + "_menu\" style=\"display: none;\" class=\"t_attach\"><img border=\"0\" alt=\"\" class=\"absmiddle\" src=\"" + forumPath + "images/attachicons/image.gif\" /><a target=\"_blank\" href=\"" + forumPath + "attachment.aspx?attachmentid=" + attinfo.Aid.ToString() + "\"><strong>" + attinfo.Attachment + "</strong></a>(" + filesize + ")<br/><div class=\"t_smallfont\">" + attinfo.Postdatetime + "</div></div>";
                            }
                        }
                    }
                    else
                    {
                        attinfo.Attachimgpost = 0;
                        replacement = string.Format("<p><img alt=\"\" src=\"{0}images/attachicons/attachment.gif\" border=\"0\" /><span class=\"bold\">附件</span>: <a href=\"{0}attachment.aspx?attachmentid={1}\" target=\"_blank\">{2}</a> ({3}, {4})<br />该附件被下载次数 {5}</p>", forumPath, attinfo.Aid.ToString(), attinfo.Attachment.ToString().Trim(), attinfo.Postdatetime, filesize, attinfo.Downloads.ToString());
                    }
                }
                else
                {
                    replacement = string.Format("<br /><span class=\"notdown\">你的下载权限 {0} 低于此附件所需权限 {1}, 你无法查看此附件</span>", postpramsinfo.Usergroupreadaccess.ToString(), attinfo.Readperm.ToString());
                }

                Regex r = new Regex(string.Format(@"\[attach\]{0}\[/attach\]|\[attachimg\]{0}\[/attachimg\]", attinfo.Aid));
                message = r.Replace(message, replacement, 1);

                message = message.Replace("[attach]" + attinfo.Aid.ToString() + "[/attach]", string.Empty);
                message = message.Replace("[attachimg]" + attinfo.Aid.ToString() + "[/attachimg]", string.Empty);

                if (attinfo.Pid == postinfo.Pid)
                {
                    attinfo.Pid = 0;
                }
            }
            else
            {
                if (attinfo.Pid == postinfo.Pid)
                {
                    if (Utils.IsImgFilename(attinfo.Attachment))
                    {
                        attinfo.Attachimgpost = 1;
                    }
                    else
                    {
                        attinfo.Attachimgpost = 0;
                    }

                    //加载文件预览类指定方法
                    IPreview preview = PreviewProvider.GetInstance(Path.GetExtension(attinfo.Filename).Remove(0, 1).Trim());

                    if (preview != null)
                    {
                        //当支持FTP上传附件时
                        if (FTPs.GetForumAttachInfo.Allowupload == 1)
                        {
                            preview.UseFTP = true;
                            attinfo.Preview = preview.GetPreview(attinfo.Filename, attinfo);
                        }
                        else
                        {
                            preview.UseFTP = false;
                            attinfo.Preview = preview.GetPreview(AppDomain.CurrentDomain.BaseDirectory + "/upload/" + attinfo.Filename, attinfo);
                        }
                    }
                }
            }
            return message;
        }
Пример #11
0
        /// <summary>
        /// 获得单个帖子的信息, 包括发帖人的一般资料
        /// </summary>
        /// <param name="_postpramsinfo">参数列表</param>
        /// <returns>帖子的信息</returns>
        public static ShowtopicPagePostInfo GetSinglePost(PostpramsInfo postpramsinfo, out Discuz.Common.Generic.List<ShowtopicPageAttachmentInfo> attcoll, bool ismoder)
        {
            ShowtopicPagePostInfo info = null;
            IDataReader attachments = null;
            attcoll = new Discuz.Common.Generic.List<ShowtopicPageAttachmentInfo>();


            ///得到帖子对应主题的所有附件
            IDataReader reader = DatabaseProvider.GetInstance().GetSinglePost(out attachments, postpramsinfo, GetPostTableID(postpramsinfo.Tid));
            int allowGetAttach = 0;


            if (reader != null)
            {

                if (postpramsinfo.Getattachperm.Equals("") || postpramsinfo.Getattachperm == null)
                {
                    allowGetAttach = postpramsinfo.CurrentUserGroup.Allowgetattach;
                }
                else
                {
                    if (Forums.AllowGetAttach(postpramsinfo.Getattachperm, postpramsinfo.Usergroupid))
                    {
                        allowGetAttach = 1;
                    }

                }
                if (attachments != null)
                {
                    while (attachments.Read())
                    {
                        ShowtopicPageAttachmentInfo attinfo = new ShowtopicPageAttachmentInfo();
                        //info.Uid = Int32.Parse(reader["uid"].ToString());
                        attinfo.Aid = Int32.Parse(attachments["aid"].ToString());
                        attinfo.Tid = Int32.Parse(attachments["tid"].ToString());
                        attinfo.Pid = Int32.Parse(attachments["pid"].ToString());
                        attinfo.Postdatetime = attachments["postdatetime"].ToString();
                        attinfo.Readperm = Int32.Parse(attachments["readperm"].ToString());
                        attinfo.Filename = attachments["filename"].ToString();
                        attinfo.Description = attachments["description"].ToString();
                        attinfo.Filetype = attachments["filetype"].ToString();
                        attinfo.Filesize = Int32.Parse(attachments["filesize"].ToString());
                        attinfo.Attachment = attachments["attachment"].ToString();
                        attinfo.Downloads = Int32.Parse(attachments["downloads"].ToString());
                        attcoll.Add(attinfo);
                    }
                }
                else
                {
                    while (reader.Read())
                    {
                        ShowtopicPageAttachmentInfo attinfo = new ShowtopicPageAttachmentInfo();
                        //info.Uid = Int32.Parse(reader["uid"].ToString());
                        attinfo.Aid = Int32.Parse(reader["aid"].ToString());
                        attinfo.Tid = Int32.Parse(reader["tid"].ToString());
                        attinfo.Pid = Int32.Parse(reader["pid"].ToString());
                        attinfo.Postdatetime = reader["postdatetime"].ToString();
                        attinfo.Readperm = Int32.Parse(reader["readperm"].ToString());
                        attinfo.Filename = reader["filename"].ToString();
                        attinfo.Description = reader["description"].ToString();
                        attinfo.Filetype = reader["filetype"].ToString();
                        attinfo.Filesize = Int32.Parse(reader["filesize"].ToString());
                        attinfo.Attachment = reader["attachment"].ToString();
                        attinfo.Downloads = Int32.Parse(reader["downloads"].ToString());
                        attcoll.Add(attinfo);
                    }
                }
            }

            bool next = false;
            if (attachments != null)
            {
                next = true & reader.Read();

            }
            else
            {
                next = reader.NextResult() && reader.Read();
            }

            //当帖子中的posterid字段为0时, 表示该数据出现异常
            if (reader["posterid"].ToString() == "0")
            {
                reader.Close();
                return null;
            }

            if (next)
            {

                //取帖间广告
                Random random = new Random(unchecked((int)DateTime.Now.Ticks));
                int fid = Int32.Parse(reader["fid"].ToString());
                int adcount = Advertisements.GetInPostAdCount("", fid);

                //用户组
                UserGroupInfo tmpGroupInfo;

                info = new ShowtopicPagePostInfo();

                info.Pid = Int32.Parse(reader["pid"].ToString());
                info.Fid = fid;
                info.Title = reader["title"].ToString().Trim();
                info.Layer = Int32.Parse(reader["layer"].ToString());
                info.Message = reader["message"].ToString().Trim();
                info.Lastedit = reader["lastedit"].ToString().Trim();
                info.Postdatetime = reader["postdatetime"].ToString().Trim();
                info.Attachment = Int32.Parse(reader["attachment"].ToString());
                info.Poster = reader["poster"].ToString().Trim();
                info.Posterid = Int32.Parse(reader["posterid"].ToString());
                info.Invisible = Int32.Parse(reader["invisible"].ToString());
                info.Usesig = Int32.Parse(reader["usesig"].ToString());
                info.Htmlon = Int32.Parse(reader["htmlon"].ToString());
                info.Smileyoff = Int32.Parse(reader["smileyoff"].ToString());
                info.Parseurloff = Int32.Parse(reader["parseurloff"].ToString());
                info.Bbcodeoff = Int32.Parse(reader["bbcodeoff"].ToString());
                info.Rate = Int32.Parse(reader["rate"].ToString());
                info.Ratetimes = Int32.Parse(reader["ratetimes"].ToString());
                if (info.Posterid > 0)
                {
                    info.Nickname = reader["nickname"].ToString().Trim();
                    info.Username = reader["username"].ToString().Trim();
                    info.Groupid = Utils.StrToInt(reader["groupid"], 0);
                    info.Spaceid = Utils.StrToInt(reader["spaceid"], 0);
                    info.Gender = Utils.StrToInt(reader["gender"], 2);
                    info.Bday = reader["bday"].ToString().Trim();
                    info.Showemail = Utils.StrToInt(reader["showemail"], 0);
                    info.Digestposts = Utils.StrToInt(reader["digestposts"], 0);
                    info.Credits = Utils.StrToInt(reader["credits"], 0);
                    info.Extcredits1 = reader["extcredits1"] == DBNull.Value ? 0 : float.Parse(reader["extcredits1"].ToString());
                    info.Extcredits2 = reader["extcredits2"] == DBNull.Value ? 0 : float.Parse(reader["extcredits2"].ToString());
                    info.Extcredits3 = reader["extcredits3"] == DBNull.Value ? 0 : float.Parse(reader["extcredits3"].ToString());
                    info.Extcredits4 = reader["extcredits4"] == DBNull.Value ? 0 : float.Parse(reader["extcredits4"].ToString());
                    info.Extcredits5 = reader["extcredits5"] == DBNull.Value ? 0 : float.Parse(reader["extcredits5"].ToString());
                    info.Extcredits6 = reader["extcredits6"] == DBNull.Value ? 0 : float.Parse(reader["extcredits6"].ToString());
                    info.Extcredits7 = reader["extcredits7"] == DBNull.Value ? 0 : float.Parse(reader["extcredits7"].ToString());
                    info.Extcredits8 = reader["extcredits8"] == DBNull.Value ? 0 : float.Parse(reader["extcredits8"].ToString());
                    info.Posts = Utils.StrToInt(reader["posts"], 0);
                    info.Joindate = reader["joindate"].ToString().Trim();
                    info.Lastactivity = reader["lastactivity"].ToString().Trim();
                    info.Userinvisible = Int32.Parse(reader["invisible"].ToString());
                    info.Avatar = reader["avatar"].ToString();
                    info.Avatarwidth = Utils.StrToInt(reader["avatarwidth"], 0);
                    info.Avatarheight = Utils.StrToInt(reader["avatarheight"], 0);
                    info.Medals = reader["medals"].ToString();
                    info.Signature = reader["signature"].ToString();
                    info.Location = reader["location"].ToString();
                    info.Customstatus = reader["customstatus"].ToString();
                    info.Website = reader["website"].ToString();
                    info.Icq = reader["icq"].ToString();
                    info.Qq = reader["qq"].ToString();
                    info.Msn = reader["msn"].ToString();
                    info.Yahoo = reader["yahoo"].ToString();
                    info.Skype = reader["skype"].ToString();
                    //部分属性需要根据不同情况来赋值

                    //根据用户自己的设置决定是否显示邮箱地址
                    if (info.Showemail == 0)
                    {
                        info.Email = "";
                    }
                    else
                    {
                        info.Email = reader["email"].ToString().Trim();
                    }


                    // 最后活动时间50分钟内的为在线, 否则不在线
                    if (Utils.StrDateDiffMinutes(info.Lastactivity, 50) < 0)
                    {
                        info.Onlinestate = 1;
                    }
                    else
                    {
                        info.Onlinestate = 0;
                    }


                    //作者ID为-1即表明作者为游客, 为了区分会直接公开显示游客发帖时的IP, 这里将IP最后一位修改为*
                    info.Ip = reader["ip"].ToString().Trim();

                    // 勋章
                    if (info.Medals == "")
                    {
                        info.Medals = "";
                    }
                    else
                    {
                        info.Medals = Caches.GetMedalsList(info.Medals);
                    }

                    tmpGroupInfo = UserGroups.GetUserGroupInfo(info.Groupid);
                    info.Stars = tmpGroupInfo.Stars;
                    if (tmpGroupInfo.Color.Equals(""))
                    {
                        info.Status = tmpGroupInfo.Grouptitle;
                    }
                    else
                    {
                        info.Status = string.Format("<span style=\"color:{0}>{1}</span>", tmpGroupInfo.Color, tmpGroupInfo.Grouptitle);
                    }
                }
                else
                {
                    info.Nickname = "游客";
                    info.Username = "******";
                    info.Groupid = 7;
                    info.Showemail = 0;
                    info.Digestposts = 0;
                    info.Credits = 0;
                    info.Extcredits1 = 0;
                    info.Extcredits2 = 0;
                    info.Extcredits3 = 0;
                    info.Extcredits4 = 0;
                    info.Extcredits5 = 0;
                    info.Extcredits6 = 0;
                    info.Extcredits7 = 0;
                    info.Extcredits8 = 0;
                    info.Posts = 0;
                    info.Joindate = "2006-9-1 1:1:1";
                    info.Lastactivity = "2006-9-1 1:1:1"; ;
                    info.Userinvisible = 0;
                    info.Avatar = "";
                    info.Avatarwidth = 0;
                    info.Avatarheight = 0;
                    info.Medals = "";
                    info.Signature = "";
                    info.Location = "";
                    info.Customstatus = "";
                    info.Website = "";
                    info.Icq = "";
                    info.Qq = "";
                    info.Msn = "";
                    info.Yahoo = "";
                    info.Skype = "";
                    //部分属性需要根据不同情况来赋值
                    info.Email = "";
                    info.Onlinestate = 1;
                    info.Medals = "";

                    info.Ip = reader["ip"].ToString().Trim();
                    if (info.Ip.IndexOf('.') > -1)
                    {
                        info.Ip = info.Ip.Substring(0, info.Ip.LastIndexOf(".") + 1) + "*";
                    }

                    tmpGroupInfo = UserGroups.GetUserGroupInfo(7);
                    info.Stars = tmpGroupInfo.Stars;
                    info.Status = "游客";
                }
                //扩展属性
                info.Id = 1;
                info.Adindex = random.Next(0, adcount);

                if (!Utils.InArray(info.Groupid.ToString(), "4,5,6"))
                {
                    //处理帖子内容
                    postpramsinfo.Smileyoff = info.Smileyoff;
                    postpramsinfo.Bbcodeoff = info.Bbcodeoff;
                    postpramsinfo.Parseurloff = info.Parseurloff;
                    postpramsinfo.Allowhtml = info.Htmlon;
                    postpramsinfo.Sdetail = info.Message;
                    postpramsinfo.Pid = info.Pid;
                    //校正hide处理
                    if (tmpGroupInfo.Allowhidecode == 0)
                    {
                        postpramsinfo.Hide = 0;
                    }

                    //先简单判断是否是动网兼容模式
                    if (!postpramsinfo.Ubbmode)
                    {
                        info.Message = UBB.UBBToHTML(postpramsinfo);
                    }
                    else
                    {
                        info.Message = Utils.HtmlEncode(info.Message);
                    }

                    if (postpramsinfo.Jammer == 1)
                    {
                        info.Message = ForumUtils.AddJammer(info.Message);
                    }

                    string message = info.Message;
                    if (info.Attachment > 0 || regexAttach.IsMatch(message) || regexAttachImg.IsMatch(message))
                    {


                        //获取在[hide]标签中的附件id
                        string[] attHidArray = GetHiddenAttachIdList(postpramsinfo.Sdetail, postpramsinfo.Hide);

                        List<ShowtopicPageAttachmentInfo> delattlist = new List<ShowtopicPageAttachmentInfo>();

                        foreach (ShowtopicPageAttachmentInfo attach in attcoll)
                        {
                            message = GetMessageWithAttachInfo(postpramsinfo, allowGetAttach, attHidArray, info, attach, message);
                            if (Utils.InArray(attach.Aid.ToString(), attHidArray) || attach.Pid == 0)
                            {
                                delattlist.Add(attach);
                            }
                        }

                        foreach (ShowtopicPageAttachmentInfo attach in delattlist)
                        {
                            attcoll.Remove(attach);
                        }

                        info.Message = message;

                    }
                }
                else//禁言的发帖人
                {
                    if (ismoder)
                    {
                        info.Message = "<div class='hintinfo'>该用户帖子内容已被屏蔽, 您拥有管理权限, 以下是帖子内容</div>" + info.Message;
                    }
                    else
                    {
                        info.Message = "该用户帖子内容已被屏蔽";
                        List<ShowtopicPageAttachmentInfo> delattlist = new List<ShowtopicPageAttachmentInfo>();

                        foreach (ShowtopicPageAttachmentInfo attach in attcoll)
                        {
                            if (attach.Pid == info.Pid)
                            {
                                delattlist.Add(attach);
                            }
                        }

                        foreach (ShowtopicPageAttachmentInfo attach in delattlist)
                        {
                            attcoll.Remove(attach);
                        }

                    }
                }

            }

            reader.Close();
            if (attachments != null)
            {
                attachments.Close();
            }

            return info;
        }
Пример #12
0
 /// <summary>
 /// Gets a value indicating whether the collection contains the specified <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see>.
 /// </summary>
 /// <param name="value">The <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> to search for in the collection.</param>
 /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
 public bool Contains(ShowtopicPageAttachmentInfo value)
 {
     return(this.List.Contains(value));
 }
Пример #13
0
 public int Add(ShowtopicPageAttachmentInfo value)
 {
     return(this.List.Add(value));
 }
Пример #14
0
 public void Remove(ShowtopicPageAttachmentInfo value)
 {
     List.Remove(value);
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> class containing the specified array of <see cref="ShowtopicPageAttachmentInfo">ShowtopicPageAttachmentInfo</see> Components.
		/// </summary>
		/// <param name="value">An array of <see cref="ShowtopicPageAttachmentInfo">ShowtopicPageAttachmentInfo</see> Components with which to initialize the collection. </param>
		public ShowtopicPageAttachmentInfoCollection(ShowtopicPageAttachmentInfo[] value)
		{
			this.AddRange(value);
		}
		public int Add(ShowtopicPageAttachmentInfo value) 
		{
			return this.List.Add(value);
		}
Пример #17
0
               /// <summary>
        /// 获取指定条件的帖子DataSet
        /// </summary>
        /// <param name="_postpramsinfo">参数列表</param>
        /// <returns>指定条件的帖子DataSet</returns>
        public static ShowtopicPagePostInfoCollection GetPostList(PostpramsInfo _postpramsinfo, out ShowtopicPageAttachmentInfoCollection attcoll, bool ismoder)
        {

            ShowtopicPagePostInfoCollection postcoll = new ShowtopicPagePostInfoCollection();
            attcoll = new ShowtopicPageAttachmentInfoCollection();

            IDataReader reader;
            StringBuilder pidlist = new StringBuilder();
            if (!_postpramsinfo.Condition.Equals(""))
            {
                reader = DatabaseProvider.GetInstance().GetPostListByCondition(_postpramsinfo, GetPostTableName(_postpramsinfo.Tid));
            }
            else
            {
                reader = DatabaseProvider.GetInstance().GetPostList(_postpramsinfo, GetPostTableName(_postpramsinfo.Tid));
            }



            if (reader != null)
            {
                int allowGetAttach = 0;
                if (_postpramsinfo.Getattachperm.Equals("") || _postpramsinfo.Getattachperm == null)
                {
                    allowGetAttach = _postpramsinfo.CurrentUserGroup.Allowgetattach;
                }
                else
                {
                    if (Forums.AllowGetAttach(_postpramsinfo.Getattachperm, _postpramsinfo.Usergroupid))
                    {
                        allowGetAttach = 1;
                    }

                }







                //序号(楼层)的初值
                int id = (_postpramsinfo.Pageindex - 1) * _postpramsinfo.Pagesize;

                //保存初始的hide值
                int oldHide = _postpramsinfo.Hide;

                //取帖间广告
                Random random = new Random(unchecked((int)DateTime.Now.Ticks));
                int fid = _postpramsinfo.Fid;
                int adcount = Advertisements.GetInPostAdCount("", fid);

                //用户组
                UserGroupInfo tmpGroupInfo;

                while (reader.Read())
                {
                    //当帖子中的posterid字段为0时, 表示该数据出现异常
                    if (Int32.Parse(reader["posterid"].ToString()) == 0)
                    {
                        continue;
                    }

                    ShowtopicPagePostInfo info = new ShowtopicPagePostInfo();
                    info.Pid = Int32.Parse(reader["pid"].ToString());
                    info.Attachment = Int32.Parse(reader["attachment"].ToString());
                    if (info.Attachment > 0)
                    {
                        pidlist.Append(",");
                        pidlist.Append(reader["pid"].ToString());
                    }
                    info.Fid = fid;
                    info.Title = reader["title"].ToString().Trim();
                    info.Layer = Int32.Parse(reader["layer"].ToString());
                    info.Message = reader["message"].ToString().Trim();
                    info.Lastedit = reader["lastedit"].ToString().Trim();
                    info.Postdatetime = reader["postdatetime"].ToString().Trim();

                    info.Poster = reader["poster"].ToString().Trim();
                    info.Posterid = Int32.Parse(reader["posterid"].ToString());
                    info.Invisible = Int32.Parse(reader["invisible"].ToString());
                    info.Usesig = Int32.Parse(reader["usesig"].ToString());
                    info.Htmlon = Int32.Parse(reader["htmlon"].ToString());
                    info.Smileyoff = Int32.Parse(reader["smileyoff"].ToString());
                    info.Parseurloff = Int32.Parse(reader["parseurloff"].ToString());
                    info.Bbcodeoff = Int32.Parse(reader["bbcodeoff"].ToString());
                    info.Rate = Int32.Parse(reader["rate"].ToString());
                    info.Ratetimes = Int32.Parse(reader["ratetimes"].ToString());
                    if (info.Posterid > 0)
                    {
                        info.Nickname = reader["nickname"].ToString().Trim();
                        info.Username = reader["username"].ToString().Trim();
                        info.Groupid = Utils.StrToInt(reader["groupid"], 0);
                        info.Spaceid = Utils.StrToInt(reader["spaceid"], 0);
                        info.Gender = Utils.StrToInt(reader["gender"], 2);
                        info.Bday = reader["bday"].ToString().Trim();
                        info.Showemail = Utils.StrToInt(reader["showemail"], 0);
                        info.Digestposts = Utils.StrToInt(reader["digestposts"], 0);
                        info.Credits = Utils.StrToInt(reader["credits"], 0);
                        info.Extcredits1 = reader["extcredits1"] == DBNull.Value ? 0 : float.Parse(reader["extcredits1"].ToString());
                        info.Extcredits2 = reader["extcredits2"] == DBNull.Value ? 0 : float.Parse(reader["extcredits2"].ToString());
                        info.Extcredits3 = reader["extcredits3"] == DBNull.Value ? 0 : float.Parse(reader["extcredits3"].ToString());
                        info.Extcredits4 = reader["extcredits4"] == DBNull.Value ? 0 : float.Parse(reader["extcredits4"].ToString());
                        info.Extcredits5 = reader["extcredits5"] == DBNull.Value ? 0 : float.Parse(reader["extcredits5"].ToString());
                        info.Extcredits6 = reader["extcredits6"] == DBNull.Value ? 0 : float.Parse(reader["extcredits6"].ToString());
                        info.Extcredits7 = reader["extcredits7"] == DBNull.Value ? 0 : float.Parse(reader["extcredits7"].ToString());
                        info.Extcredits8 = reader["extcredits8"] == DBNull.Value ? 0 : float.Parse(reader["extcredits8"].ToString());
                        info.Posts = Utils.StrToInt(reader["posts"], 0);
                        info.Joindate = reader["joindate"].ToString().Trim();
                        info.Lastactivity = reader["lastactivity"].ToString().Trim();
                        info.Userinvisible = Int32.Parse(reader["invisible"].ToString());
                        info.Avatar = reader["avatar"].ToString();
                        info.Avatarwidth = Utils.StrToInt(reader["avatarwidth"], 0);
                        info.Avatarheight = Utils.StrToInt(reader["avatarheight"], 0);
                        info.Medals = reader["medals"].ToString();
                        info.Signature = reader["signature"].ToString();
                        info.Location = reader["location"].ToString();
                        info.Customstatus = reader["customstatus"].ToString();
                        info.Website = reader["website"].ToString();
                        info.Icq = reader["icq"].ToString();
                        info.Qq = reader["qq"].ToString();
                        info.Msn = reader["msn"].ToString();
                        info.Yahoo = reader["yahoo"].ToString();
                        info.Skype = reader["skype"].ToString();
                        //部分属性需要根据不同情况来赋值

                        //根据用户自己的设置决定是否显示邮箱地址
                        if (info.Showemail == 0)
                        {
                            info.Email = "";
                        }
                        else
                        {
                            info.Email = reader["email"].ToString().Trim();
                        }


                        // 最后活动时间50分钟内的为在线, 否则不在线
                        if (Utils.StrDateDiffMinutes(info.Lastactivity, 50) < 0)
                        {
                            info.Onlinestate = 1;
                        }
                        else
                        {
                            info.Onlinestate = 0;
                        }


                        //作者ID为-1即表明作者为游客, 为了区分会直接公开显示游客发帖时的IP, 这里将IP最后一位修改为*
                        info.Ip = reader["ip"].ToString().Trim();

                        // 勋章
                        if (info.Medals == "")
                        {
                            info.Medals = "";
                        }
                        else
                        {
                            info.Medals = Caches.GetMedalsList(info.Medals);
                        }

                        tmpGroupInfo = UserGroups.GetUserGroupInfo(info.Groupid);
                        info.Stars = tmpGroupInfo.Stars;
                        if (tmpGroupInfo.Color.Equals(""))
                        {
                            info.Status = tmpGroupInfo.Grouptitle;
                        }
                        else
                        {
                            info.Status = string.Format("<span style=\"color:{0}\">{1}</span>", tmpGroupInfo.Color, tmpGroupInfo.Grouptitle);
                        }
                    }
                    else
                    {
                        info.Nickname = "游客";
                        info.Username = "******";
                        info.Groupid = 7;
                        info.Showemail = 0;
                        info.Digestposts = 0;
                        info.Credits = 0;
                        info.Extcredits1 = 0;
                        info.Extcredits2 = 0;
                        info.Extcredits3 = 0;
                        info.Extcredits4 = 0;
                        info.Extcredits5 = 0;
                        info.Extcredits6 = 0;
                        info.Extcredits7 = 0;
                        info.Extcredits8 = 0;
                        info.Posts = 0;
                        info.Joindate = "2006-9-1 1:1:1";
                        info.Lastactivity = "2006-9-1 1:1:1"; ;
                        info.Userinvisible = 0;
                        info.Avatar = "";
                        info.Avatarwidth = 0;
                        info.Avatarheight = 0;
                        info.Medals = "";
                        info.Signature = "";
                        info.Location = "";
                        info.Customstatus = "";
                        info.Website = "";
                        info.Icq = "";
                        info.Qq = "";
                        info.Msn = "";
                        info.Yahoo = "";
                        info.Skype = "";
                        //部分属性需要根据不同情况来赋值
                        info.Email = "";
                        info.Onlinestate = 1;
                        info.Medals = "";

                        info.Ip = reader["ip"].ToString().Trim();
                        if (info.Ip.IndexOf('.') > -1)
                        {
                            info.Ip = info.Ip.Substring(0, info.Ip.LastIndexOf(".") + 1) + "*";
                        }

                        tmpGroupInfo = UserGroups.GetUserGroupInfo(7);
                        info.Stars = tmpGroupInfo.Stars;
                        info.Status = "游客";

                    }
                    //扩展属性
                    id++;
                    info.Id = id;
                    info.Adindex = random.Next(0, adcount);

                    if (!Utils.InArray(info.Groupid.ToString(), "4,5,6"))
                    {
                        //处理帖子内容
                        _postpramsinfo.Smileyoff = info.Smileyoff;
                        _postpramsinfo.Bbcodeoff = info.Bbcodeoff;
                        _postpramsinfo.Parseurloff = info.Parseurloff;
                        _postpramsinfo.Allowhtml = info.Htmlon;
                        _postpramsinfo.Sdetail = info.Message;
                        //校正hide处理
                        if (tmpGroupInfo.Allowhidecode == 0)
                        {
                            _postpramsinfo.Hide = 0;
                        }


                        //先简单判断是否允许使用Discuz!NT代码,如果不允许,效率起见直接不进行代码转换 (虽然UBB.UBBToHTML方法内也进行判断)
                        if (!_postpramsinfo.Ubbmode)
                        {
                            info.Message = UBB.UBBToHTML(_postpramsinfo);
                        }
                        else
                        {
                            info.Message = Utils.HtmlEncode(info.Message);
                        }

                        if (_postpramsinfo.Jammer == 1)
                        {
                            info.Message = ForumUtils.AddJammer(info.Message);
                        }


                        //恢复hide初值
                        _postpramsinfo.Hide = oldHide;
                    }
                    else//发帖人已经被禁止发言
                    {
						if (ismoder)
						{
							info.Message = "<div class='hintinfo'>该用户帖子内容已被屏蔽, 您拥有管理权限, 以下是帖子内容</div>" + info.Message;
						}
						else
						{
							info.Message = "该用户帖子内容已被屏蔽";
						}
                    }

                    postcoll.Add(info);
                }
                reader.Close();

                if (pidlist.Length > 0)
                {
                    pidlist.Remove(0, 1);
                    IDataReader attachreader = DatabaseProvider.GetInstance().GetAttachmentListByPid(pidlist.ToString());
                    if (attachreader != null)
                    {
                        while (attachreader.Read())
                        {
                            ShowtopicPageAttachmentInfo attinfo = new ShowtopicPageAttachmentInfo();
                            //info.Uid = Int32.Parse(reader["uid"].ToString());
                            attinfo.Aid = Int32.Parse(attachreader["aid"].ToString());
                            attinfo.Tid = Int32.Parse(attachreader["tid"].ToString());
                            attinfo.Pid = Int32.Parse(attachreader["pid"].ToString());
                            attinfo.Postdatetime = attachreader["postdatetime"].ToString();
                            attinfo.Readperm = Int32.Parse(attachreader["readperm"].ToString());
                            attinfo.Filename = attachreader["filename"].ToString();
                            attinfo.Description = attachreader["description"].ToString();
                            attinfo.Filetype = attachreader["filetype"].ToString();
                            attinfo.Filesize = Int32.Parse(attachreader["filesize"].ToString());
                            attinfo.Attachment = attachreader["attachment"].ToString();
                            attinfo.Downloads = Int32.Parse(attachreader["downloads"].ToString());
                            attcoll.Add(attinfo);
                        }
                    }
                    attachreader.Close();
                }


                foreach (ShowtopicPagePostInfo info in postcoll)
                {
                    if (info.Groupid != 4 && info.Groupid != 5)
                    {
                        string message = info.Message;
                        if (info.Attachment > 0 || regexAttach.IsMatch(message))
                        {

                            //获取在[hide]标签中的附件id
                            string[] attHidArray = GetHiddenAttachIdList(_postpramsinfo.Sdetail, _postpramsinfo.Hide);

                            for (int i = 0; i < attcoll.Count; i++)
                            {
                                message = GetMessageWithAttachInfo(_postpramsinfo, allowGetAttach, attHidArray, info, attcoll[i], message);
                                if (Utils.InArray(attcoll[i].Aid.ToString(), attHidArray))
                                {
                                    attcoll.RemoveAt(i);
                                }
                            }
                            info.Message = message;

                        }
                    }
                    else
                    {
                        for (int i = 0; i < attcoll.Count; i++)
                        {
                            if (attcoll[i].Pid == info.Pid)
                            {
                                attcoll.RemoveAt(i);
                            }
                        }
                    }
                }
            }

            return postcoll;
        }
		/// <summary>
		/// Gets a value indicating whether the collection contains the specified <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see>.
		/// </summary>
		/// <param name="value">The <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> to search for in the collection.</param>
		/// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
		public bool Contains(ShowtopicPageAttachmentInfo value) 
		{
			return this.List.Contains(value);
		}
Пример #19
0
        /// <summary>
        /// 解析图片附件内容
        /// </summary>
        /// <param name="postPramsInfo">参数对象</param>
        /// <param name="attachInfo">附件对象</param>
        /// <param name="fileSize">文件大小字符串</param>
        /// <returns>解析内容</returns>
        private static string ParseImageAttachContent(PostpramsInfo postPramsInfo, ShowtopicPageAttachmentInfo attachInfo, string fileSize)
        {
            string content = string.Empty;
            string forumPath = BaseConfigs.GetBaseConfig().Forumpath;
            string tipImg = string.Format(ATTACH_TIP_IMAGE, attachInfo.Aid, forumPath);

            attachInfo.Attachimgpost = 1;

            if (postPramsInfo.Showattachmentpath == 1)
            {
                if (postPramsInfo.Isforspace == 1)
                {
                    if (attachInfo.Filename.ToLower().IndexOf("http") == 0)
                    {
                        return string.Format("<img src=\"{0}\" {1} {2}/>", attachInfo.Filename, GetImageShowWidth(postPramsInfo.TemplateWidth, attachInfo.Width), GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, true));
                    }
                    return string.Format("<img src=\"{0}upload/{1}\" {2} {3}/>", forumPath, attachInfo.Filename, GetImageShowWidth(postPramsInfo.TemplateWidth, attachInfo.Width), GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, true));
                }
                if (postPramsInfo.CurrentUserGroup.Radminid == 1 || postPramsInfo.CurrentUserid == attachInfo.Uid || attachInfo.Attachprice <= 0 || attachInfo.Isbought == 1)
                {
                    if (attachInfo.Filename.ToLower().IndexOf("http") == 0)
                    {
                        content = string.Format(IMAGE_ATTACH, tipImg, attachInfo.Filename, attachInfo.Aid, forumPath, attachInfo.Attachment.Trim(), fileSize, attachInfo.Postdatetime, GetImageShowWidth(postPramsInfo.TemplateWidth, attachInfo.Width), GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, false));
                        return content;
                    }
                    content = string.Format(IMAGE_ATTACH, tipImg, forumPath + "upload/" + attachInfo.Filename, attachInfo.Aid, forumPath, attachInfo.Attachment.Trim(), fileSize, attachInfo.Postdatetime, GetImageShowWidth(postPramsInfo.TemplateWidth, attachInfo.Width), GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, false));
                    return content;
                }
                return string.Format(PAID_ATTACH, tipImg, attachInfo.Attachment.Trim());
            }
            if (postPramsInfo.Isforspace == 1)
            {
                return string.Format("<img src=\"{0}attachment.aspx?attachmentid={1}\" {2} {3}/>", forumPath, attachInfo.Aid, GetImageShowWidth(postPramsInfo.TemplateWidth, attachInfo.Width), GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, true));
            }
            if (postPramsInfo.CurrentUserGroup.Radminid == 1 || postPramsInfo.CurrentUserid == attachInfo.Uid || attachInfo.Attachprice <= 0 || attachInfo.Isbought == 1)
            {
                return string.Format(IMAGE_ATTACH, tipImg, forumPath + "attachment.aspx?attachmentid=" + attachInfo.Aid, attachInfo.Aid, forumPath, attachInfo.Attachment.Trim(), fileSize, attachInfo.Postdatetime, GetImageShowWidth(postPramsInfo.TemplateWidth, attachInfo.Width), GetAutoImageWidthScript(postPramsInfo.TemplateWidth, attachInfo.Width, false));
            }
            return string.Format(PAID_ATTACH, tipImg, attachInfo.Attachment.Trim());
        }
Пример #20
0
        /// <summary>
        /// 附件内容正则替换字符串
        /// </summary>
        /// <param name="postPramsInfo">帖子参数</param>
        /// <param name="allowGetAttach">是否允许返回附件</param>
        /// <param name="attachInfo">附件对象</param>
        /// <returns>返回附件内容正则替换字符串</returns>
        private static string GetAttachReplacement(PostpramsInfo postPramsInfo, int allowGetAttach, ShowtopicPageAttachmentInfo attachInfo)
        {
            string fileSize = "";
            string replacement = "";
            string forumPath = BaseConfigs.GetBaseConfig().Forumpath;
            string attachIcon = "attachment.gif";

            //string needPayAttachTemplateRow1 = "<p><img alt=\"\" src=\"{0}images/attachicons/{2}\" border=\"0\"/><span class=\"bold\">收费附件</span>: <strong>{1}</strong><em class=\"xg1\">(<script type=\"text/javascript\">ShowFormatBytesStr({3});</script>, 下载次数:{4})</em></p>";
            //string needPayAttachTemplateRow2 = "<p>售价(" + Scoresets.GetTopicAttachCreditsTransName() + "):<strong>{5} </strong>[<a onclick=\"loadattachpaymentlog({6});\" href=\"javascript:void(0);\">记录</a>] [<a onclick=\"loadbuyattach({6});\" href=\"javascript:void(0);\">购买</a>]</p>";

            if (Utils.InArray(Utils.GetFileExtName(attachInfo.Filename), ".rar,.zip"))
                attachIcon = "rar.gif";

            string attachInfoDtimg = string.Format(ATTACH_INFO_DTIMG, forumPath, attachIcon);

            if (allowGetAttach != 1)
                replacement = string.Format(ATTACH_INFO_DL, attachInfoDtimg + string.Format(ATTACH_INFO_DD, "<span class=\"attachnotdown\">您所在的用户组无法下载或查看附件</span>"));
            //replacement = string.Format("<br /><img src=\"{0}images/attachicons/{1}\" alt=\"\">&nbsp;附件: <span class=\"attachnotdown\">您所在的用户组无法下载或查看附件</span>", forumPath, attachIcon);
            else if (attachInfo.Allowread == 1)
            {
                if (attachInfo.Filesize > 1024)
                    fileSize = Convert.ToString(Math.Round(Convert.ToDecimal(attachInfo.Filesize) / 1024, 2)) + " K";
                else
                    fileSize = attachInfo.Filesize + " B";

                string attachInfoEm = string.Format(ATTACH_INFO_EM, attachInfo.Filesize, attachInfo.Downloads);
                //string attachInfoA = string.Format("<a href=\"{0}attachment.aspx?attachmentid={1}\" onclick=\"return ShowDownloadTip({2});\" target=\"_blank\">{3}</a>", forumPath, attachInfo.Aid, attachInfo.Uid, attachInfo.Attachment);

                if (Utils.IsImgFilename(attachInfo.Attachment))
                    replacement = Attachments.ParseImageAttachContent(postPramsInfo, attachInfo, fileSize);
                else
                {
                    attachInfo.Attachimgpost = 0;
                    if (postPramsInfo.CurrentUserGroup.Radminid == 1 || postPramsInfo.CurrentUserid == attachInfo.Uid || attachInfo.Attachprice <= 0 || attachInfo.Isbought == 1)
                        replacement = string.Format(ATTACH_INFO_DL, attachInfoDtimg + string.Format(ATTACH_INFO_DD,
                            string.Format("<a href=\"{0}attachment.aspx?attachmentid={1}\" onclick=\"return ShowDownloadTip({2});\" target=\"_blank\">{3}</a>",
                            forumPath, attachInfo.Aid, attachInfo.Uid, attachInfo.Attachment) + attachInfoEm));

                    //replacement = string.Format("<p><img alt=\"\" src=\"{0}images/attachicons/{6}\" border=\"0\"/><span class=\"bold\">附件</span>: <a href=\"{0}attachment.aspx?attachmentid={1}\" onclick=\"return ShowDownloadTip({7});\" target=\"_blank\">{2}</a> ({3}, {4})<br />该附件被下载次数 {5}</p>", forumPath, attachInfo.Aid, attachInfo.Attachment.Trim(), attachInfo.Postdatetime, fileSize, attachInfo.Downloads, attachIcon, attachInfo.Uid);
                    else
                        replacement = string.Format(ATTACH_INFO_DL, attachInfoDtimg + string.Format(ATTACH_INFO_DD, attachInfo.Attachment + attachInfoEm +
                            string.Format(PAID_ATTACH_LINK, Scoresets.GetTopicAttachCreditsTransName(), attachInfo.Attachprice, attachInfo.Aid)));
                    //replacement = string.Format(needPayAttachTemplateRow1 + needPayAttachTemplateRow2, forumPath, attachInfo.Attachment, attachIcon, attachInfo.Filesize, attachInfo.Downloads, attachInfo.Attachprice, attachInfo.Aid);
                }
            }
            else
            {
                if (postPramsInfo.CurrentUserid > 0)
                    replacement = string.Format("<br /><span class=\"notdown\">你的下载权限 {0} 低于此附件所需权限 {1}, 你无权查看此附件</span><br />", postPramsInfo.Usergroupreadaccess, attachInfo.Readperm);
                else
                    replacement = 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 replacement;
        }
Пример #21
0
        /// <summary>
        /// 附件内容正则替换字符串
        /// </summary>
        /// <param name="postPramsInfo">帖子参数</param>
        /// <param name="allowGetAttach">是否允许返回附件</param>
        /// <param name="attachInfo">附件对象</param>
        /// <returns>返回附件内容正则替换字符串</returns>
        private static string GetAttachReplacement(PostpramsInfo postPramsInfo, int allowGetAttach, ShowtopicPageAttachmentInfo attachInfo)
        {
            string fileSize = "";
            string replacement = "";
            string forumPath = BaseConfigs.GetBaseConfig().Forumpath;
            string attachIcon = "attachment.gif";
            if (Utils.InArray(Utils.GetFileExtName(attachInfo.Filename), ".rar,.zip"))
                attachIcon = "rar.gif";
          

            if (allowGetAttach != 1)
                replacement = string.Format("<br /><img src=\"{0}images/attachicons/{1}\" alt=\"\">&nbsp;附件: <span class=\"attachnotdown\">您所在的用户组无法下载或查看附件</span>", forumPath, attachIcon);
            //replacement = string.Format("<br /><img src=\"{0}images/attachicons/attachment.gif\" alt=\"\">&nbsp;附件: <span class=\"attachnotdown\">您所在的用户组无法下载或查看附件</span>", forumPath);
            else if (attachInfo.Allowread == 1)
            {
                if (attachInfo.Filesize > 1024)
                    fileSize = Convert.ToString(Math.Round(Convert.ToDecimal(attachInfo.Filesize) / 1024, 2)) + " K";
                else
                    fileSize = attachInfo.Filesize + " B";

                if (Utils.IsImgFilename(attachInfo.Attachment))
                    replacement = Attachments.ParseImageAttachContent(postPramsInfo, attachInfo, fileSize);
                else
                {
                    attachInfo.Attachimgpost = 0;
                    if (postPramsInfo.CurrentUserGroup.Radminid == 1 || postPramsInfo.CurrentUserid == attachInfo.Uid || attachInfo.Attachprice <= 0 || attachInfo.Isbought == 1)
                        replacement = string.Format("<p><img alt=\"\" src=\"{0}images/attachicons/{6}\" border=\"0\"/><span class=\"bold\">附件</span>: <a href=\"{0}attachment.aspx?attachmentid={1}\" target=\"_blank\">{2}</a> ({3}, {4})<br />该附件被下载次数 {5}</p>", forumPath, attachInfo.Aid.ToString(), attachInfo.Attachment.ToString().Trim(), attachInfo.Postdatetime, fileSize, attachInfo.Downloads, attachIcon);
                    else
                        replacement = string.Format("<p><img alt=\"\" src=\"{0}images/attachicons/{2}\" border=\"0\"/><span class=\"bold\">附件</span>: <strong>收费附件:{1}</strong></p>", forumPath, attachInfo.Attachment, attachIcon);
                }
            }
            else
                replacement = string.Format("<br /><span class=\"notdown\">你的下载权限 {0} 低于此附件所需权限 {1}, 你无法查看此附件</span>", postPramsInfo.Usergroupreadaccess.ToString(), attachInfo.Readperm.ToString());

            return replacement;
        }
Пример #22
0
        /// <summary>
        /// 获取加载附件信息的帖子内容
        /// </summary>
        /// <param name="postPramsInfo">参数列表</param>
        /// <param name="allowGetAttach">是否允许获取附件</param>
        /// <param name="attHidArray">隐藏在hide标签中的附件数组</param>
        /// <param name="postInfo">帖子信息</param>
        /// <param name="attInfo">附件信息</param>
        /// <param name="message">帖子内容</param>
        /// <returns>帖子内容</returns>
        public static string GetMessageWithAttachInfo(PostpramsInfo postPramsInfo, int allowGetAttach, string[] hideAttachIdArray, ShowtopicPagePostInfo postInfo, ShowtopicPageAttachmentInfo attachInfo, string message)
        {
            string replacement;
            if (Utils.InArray(attachInfo.Aid.ToString(), hideAttachIdArray))
                return message;
            if ((attachInfo.Readperm <= postPramsInfo.Usergroupreadaccess || postInfo.Posterid == postPramsInfo.CurrentUserid) && allowGetAttach == 1)
                attachInfo.Allowread = 1;
            else
                attachInfo.Allowread = 0;

            attachInfo.Getattachperm = allowGetAttach;
            attachInfo.Filename = attachInfo.Filename.ToString().Replace("\\", "/");

            if (message.IndexOf("[attach]" + attachInfo.Aid + "[/attach]") != -1 || message.IndexOf("[attachimg]" + attachInfo.Aid + "[/attachimg]") != -1)
            {
                replacement = GetAttachReplacement(postPramsInfo, allowGetAttach, attachInfo);

                Regex r = new Regex(string.Format(@"\[attach\]{0}\[/attach\]|\[attachimg\]{0}\[/attachimg\]", attachInfo.Aid));
                message = r.Replace(message, replacement, 1);

                message = message.Replace("[attach]" + attachInfo.Aid + "[/attach]", string.Empty);
                message = message.Replace("[attachimg]" + attachInfo.Aid + "[/attachimg]", string.Empty);

                if (attachInfo.Pid == postInfo.Pid)
                    attachInfo.Inserted = 1;
            }
            else
            {
                if (attachInfo.Pid == postInfo.Pid)
                {
                    attachInfo.Attachimgpost = Utils.IsImgFilename(attachInfo.Attachment) ? 1 : 0;

                    //加载文件预览类指定方法
                    IPreview preview = PreviewProvider.GetInstance(Path.GetExtension(attachInfo.Filename).Remove(0, 1).Trim());

                    if (preview != null)
                    {
                        //当支持FTP上传附件时
                        if (attachInfo.Filename.StartsWith("http://") || attachInfo.Filename.StartsWith("ftp://"))
                        {
                            preview.UseFTP = true;
                            attachInfo.Preview = preview.GetPreview(attachInfo.Filename, attachInfo);
                        }
                        else
                        {
                            preview.UseFTP = false;
                            string filename = "";
                            if (!attachInfo.Filename.Contains("://"))
                                filename = Utils.GetMapPath(BaseConfigs.GetForumPath + @"upload/" + attachInfo.Filename);

                            attachInfo.Preview = preview.GetPreview(filename, attachInfo);
                        }
                    }
                }
            }
            return message;
        }
		/// <summary>
		/// Gets the index in the collection of the specified <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see>, if it exists in the collection.
		/// </summary>
		/// <param name="value">The <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> to locate in the collection.</param>
		/// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
		public int IndexOf(ShowtopicPageAttachmentInfo value) 
		{
			return this.List.IndexOf(value);
		}
Пример #24
0
 /// <summary>
 /// 加载单个附件实体对象
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 public static ShowtopicPageAttachmentInfo LoadSingleAttachmentInfo(IDataReader reader)
 {
     ShowtopicPageAttachmentInfo attInfo = new ShowtopicPageAttachmentInfo();
     attInfo.Aid = TypeConverter.ObjectToInt(reader["aid"]);
     attInfo.Tid = TypeConverter.ObjectToInt(reader["tid"]);
     attInfo.Pid = TypeConverter.ObjectToInt(reader["pid"]);
     attInfo.Postdatetime = reader["postdatetime"].ToString();
     attInfo.Readperm = TypeConverter.ObjectToInt(reader["readperm"]);
     attInfo.Filename = reader["filename"].ToString();
     attInfo.Description = reader["description"].ToString();
     attInfo.Filetype = reader["filetype"].ToString();
     attInfo.Filesize = TypeConverter.ObjectToInt(reader["filesize"]);
     attInfo.Attachment = reader["attachment"].ToString();
     attInfo.Downloads = TypeConverter.ObjectToInt(reader["downloads"]);
     attInfo.Attachprice = TypeConverter.ObjectToInt(reader["attachprice"]);
     attInfo.Uid = TypeConverter.ObjectToInt(reader["uid"]);
     return attInfo;
 }
Пример #25
0
 /// <summary>
 /// Gets the index in the collection of the specified <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see>, if it exists in the collection.
 /// </summary>
 /// <param name="value">The <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> to locate in the collection.</param>
 /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
 public int IndexOf(ShowtopicPageAttachmentInfo value)
 {
     return(this.List.IndexOf(value));
 }