/// <summary> /// Copies the elements of the specified <see cref="ShowtopicPagePostInfo">ShowtopicPagePostInfo</see> array to the end of the collection. /// </summary> /// <param name="value">An array of type <see cref="ShowtopicPagePostInfo">ShowtopicPagePostInfo</see> containing the Components to add to the collection.</param> public void AddRange(ShowtopicPagePostInfo[] value) { for (int i = 0; (i < value.Length); i = (i + 1)) { this.Add(value[i]); } }
public int Add(ShowtopicPagePostInfo value) { return this.List.Add(value); }
/// <summary> /// Initializes a new instance of the <see cref="ShowtopicPagePostInfoCollection">ShowtopicPagePostInfoCollection</see> class containing the specified array of <see cref="ShowtopicPagePostInfo">ShowtopicPagePostInfo</see> Components. /// </summary> /// <param name="value">An array of <see cref="ShowtopicPagePostInfo">ShowtopicPagePostInfo</see> Components with which to initialize the collection. </param> public ShowtopicPagePostInfoCollection(ShowtopicPagePostInfo[] value) { this.AddRange(value); }
/// <summary> /// 装载ShowtopicPagePostInfo对象 /// </summary> /// <param name="reader"></param> /// <returns></returns> private static ShowtopicPagePostInfo LoadSingleShowtopicPagePostInfo(IDataReader reader) { ShowtopicPagePostInfo postInfo = new ShowtopicPagePostInfo(); postInfo.Pid = Int32.Parse(reader["pid"].ToString()); postInfo.Attachment = Int32.Parse(reader["attachment"].ToString()); //if (info.Attachment > 0) //{ // pidlist.Append(","); // pidlist.Append(reader["pid"].ToString()); //} postInfo.Fid = TypeConverter.ObjectToInt(reader["fid"]); postInfo.Title = reader["title"].ToString().Trim(); postInfo.Layer = Int32.Parse(reader["layer"].ToString()); postInfo.Message = reader["message"].ToString().Trim(); postInfo.Lastedit = reader["lastedit"].ToString().Trim(); postInfo.Postdatetime = reader["postdatetime"].ToString().Trim(); postInfo.Poster = reader["poster"].ToString().Trim(); postInfo.Posterid = Int32.Parse(reader["posterid"].ToString()); postInfo.Invisible = Int32.Parse(reader["invisible"].ToString()); postInfo.Usesig = Int32.Parse(reader["usesig"].ToString()); postInfo.Htmlon = Int32.Parse(reader["htmlon"].ToString()); postInfo.Smileyoff = Int32.Parse(reader["smileyoff"].ToString()); postInfo.Parseurloff = Int32.Parse(reader["parseurloff"].ToString()); postInfo.Bbcodeoff = Int32.Parse(reader["bbcodeoff"].ToString()); postInfo.Rate = Int32.Parse(reader["rate"].ToString()); postInfo.Ratetimes = Int32.Parse(reader["ratetimes"].ToString()); postInfo.Ubbmessage = reader["message"].ToString().Trim(); if (postInfo.Posterid > 0) { postInfo.Nickname = reader["nickname"].ToString().Trim(); postInfo.Username = reader["username"].ToString().Trim(); postInfo.Groupid = Utils.StrToInt(reader["groupid"], 0); postInfo.Spaceid = Utils.StrToInt(reader["spaceid"], 0); postInfo.Gender = Utils.StrToInt(reader["gender"], 2); postInfo.Bday = reader["bday"].ToString().Trim(); postInfo.Showemail = Utils.StrToInt(reader["showemail"], 0); postInfo.Digestposts = Utils.StrToInt(reader["digestposts"], 0); postInfo.Credits = Utils.StrToInt(reader["credits"], 0); postInfo.Extcredits1 = reader["extcredits1"] == DBNull.Value ? 0 : float.Parse(reader["extcredits1"].ToString()); postInfo.Extcredits2 = reader["extcredits2"] == DBNull.Value ? 0 : float.Parse(reader["extcredits2"].ToString()); postInfo.Extcredits3 = reader["extcredits3"] == DBNull.Value ? 0 : float.Parse(reader["extcredits3"].ToString()); postInfo.Extcredits4 = reader["extcredits4"] == DBNull.Value ? 0 : float.Parse(reader["extcredits4"].ToString()); postInfo.Extcredits5 = reader["extcredits5"] == DBNull.Value ? 0 : float.Parse(reader["extcredits5"].ToString()); postInfo.Extcredits6 = reader["extcredits6"] == DBNull.Value ? 0 : float.Parse(reader["extcredits6"].ToString()); postInfo.Extcredits7 = reader["extcredits7"] == DBNull.Value ? 0 : float.Parse(reader["extcredits7"].ToString()); postInfo.Extcredits8 = reader["extcredits8"] == DBNull.Value ? 0 : float.Parse(reader["extcredits8"].ToString()); postInfo.Posts = Utils.StrToInt(reader["posts"], 0); postInfo.Joindate = reader["joindate"].ToString().Trim(); postInfo.Lastactivity = reader["lastactivity"].ToString().Trim(); postInfo.Userinvisible = Int32.Parse(reader["invisible"].ToString()); postInfo.Avatar = reader["avatar"].ToString(); postInfo.Avatarwidth = Utils.StrToInt(reader["avatarwidth"], 0); postInfo.Avatarheight = Utils.StrToInt(reader["avatarheight"], 0); postInfo.Medals = reader["medals"].ToString(); postInfo.Signature = reader["signature"].ToString(); postInfo.Location = reader["location"].ToString(); postInfo.Customstatus = reader["customstatus"].ToString(); postInfo.Website = reader["website"].ToString(); postInfo.Icq = reader["icq"].ToString(); postInfo.Qq = reader["qq"].ToString(); postInfo.Msn = reader["msn"].ToString(); postInfo.Yahoo = reader["yahoo"].ToString(); postInfo.Skype = reader["skype"].ToString(); //部分属性需要根据不同情况来赋值 //根据用户自己的设置决定是否显示邮箱地址 if (postInfo.Showemail == 0) { postInfo.Email = ""; } else { postInfo.Email = reader["email"].ToString().Trim(); } // 最后活动时间50分钟内的为在线, 否则不在线 if (Utils.StrDateDiffMinutes(postInfo.Lastactivity, 50) < 0) { postInfo.Onlinestate = 1; } else { postInfo.Onlinestate = 0; } //作者ID为-1即表明作者为游客, 为了区分会直接公开显示游客发帖时的IP, 这里将IP最后一位修改为* postInfo.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); //} //if (topicinfo.Special == 4) //{ // if (UserGroups.GetUserGroupInfo(7).Allowdiggs == 1) // { // info.Digged = Debates.IsDigged(int.Parse(reader["pid"].ToString()), postpramsinfo.CurrentUserid); // } // else // { // info.Digged = diggslist.Contains(reader["pid"].ToString()); // } //} } else { postInfo.Nickname = "游客"; postInfo.Username = "******"; postInfo.Groupid = 7; postInfo.Showemail = 0; postInfo.Digestposts = 0; postInfo.Credits = 0; postInfo.Extcredits1 = 0; postInfo.Extcredits2 = 0; postInfo.Extcredits3 = 0; postInfo.Extcredits4 = 0; postInfo.Extcredits5 = 0; postInfo.Extcredits6 = 0; postInfo.Extcredits7 = 0; postInfo.Extcredits8 = 0; postInfo.Posts = 0; postInfo.Joindate = "2006-9-1 1:1:1"; postInfo.Lastactivity = "2006-9-1 1:1:1"; ; postInfo.Userinvisible = 0; postInfo.Avatar = ""; postInfo.Avatarwidth = 0; postInfo.Avatarheight = 0; postInfo.Medals = ""; postInfo.Signature = ""; postInfo.Location = ""; postInfo.Customstatus = ""; postInfo.Website = ""; postInfo.Icq = ""; postInfo.Qq = ""; postInfo.Msn = ""; postInfo.Yahoo = ""; postInfo.Skype = ""; //部分属性需要根据不同情况来赋值 postInfo.Email = ""; postInfo.Onlinestate = 1; postInfo.Medals = ""; postInfo.Ip = reader["ip"].ToString().Trim(); if (postInfo.Ip.IndexOf('.') > -1) { postInfo.Ip = postInfo.Ip.Substring(0, postInfo.Ip.LastIndexOf(".") + 1) + "*"; } } return postInfo; }
/// <summary> /// 加载帖子扩展信息 /// </summary> /// <param name="postInfo">帖子信息</param> /// <param name="adCount">帖内广告个数</param> private static void LoadExtraPostInfo(ShowtopicPagePostInfo postInfo, int adCount) { UserGroupInfo tmpGroupInfo = UserGroups.GetUserGroupInfo(postInfo.Groupid); string[] postCustomFloorNameArray = Utils.SplitString(GeneralConfigs.GetConfig().Postnocustom, "\n"); Random random = new Random(unchecked((int)DateTime.Now.Ticks)); // 勋章 if (postInfo.Medals != string.Empty) postInfo.Medals = Caches.GetMedalsList(postInfo.Medals); postInfo.Stars = tmpGroupInfo.Stars; if (tmpGroupInfo.Color.Equals("")) postInfo.Status = tmpGroupInfo.Grouptitle; else postInfo.Status = string.Format("<span style=\"color:{0}\">{1}</span>", tmpGroupInfo.Color, tmpGroupInfo.Grouptitle); if (postCustomFloorNameArray.Length >= postInfo.Id) postInfo.Postnocustom = postCustomFloorNameArray[postInfo.Id - 1]; postInfo.Adindex = random.Next(0, adCount); }
/// <summary> /// 装载ShowtopicPagePostInfo对象 /// </summary> /// <param name="reader"></param> /// <returns></returns> private static ShowtopicPagePostInfo LoadSingleShowtopicPagePostInfo(IDataReader reader) { ShowtopicPagePostInfo postInfo = new ShowtopicPagePostInfo(); postInfo.Pid = Int32.Parse(reader["pid"].ToString()); postInfo.Attachment = Int32.Parse(reader["attachment"].ToString()); postInfo.Fid = TypeConverter.ObjectToInt(reader["fid"]); postInfo.Title = reader["title"].ToString().Trim(); postInfo.Layer = Int32.Parse(reader["layer"].ToString()); postInfo.Message = reader["message"].ToString().TrimEnd(); postInfo.Lastedit = reader["lastedit"].ToString().Trim(); postInfo.Postdatetime = reader["postdatetime"].ToString().Trim(); postInfo.Poster = reader["poster"].ToString().Trim(); postInfo.Posterid = Int32.Parse(reader["posterid"].ToString()); postInfo.Invisible = Int32.Parse(reader["invisible"].ToString()); postInfo.Usesig = Int32.Parse(reader["usesig"].ToString()); postInfo.Htmlon = Int32.Parse(reader["htmlon"].ToString()); postInfo.Smileyoff = Int32.Parse(reader["smileyoff"].ToString()); postInfo.Parseurloff = Int32.Parse(reader["parseurloff"].ToString()); postInfo.Bbcodeoff = Int32.Parse(reader["bbcodeoff"].ToString()); postInfo.Rate = Int32.Parse(reader["rate"].ToString()); postInfo.Ratetimes = Int32.Parse(reader["ratetimes"].ToString()); postInfo.Ubbmessage = reader["message"].ToString().TrimEnd(); if (postInfo.Posterid > 0) { postInfo.Oltime = reader["oltime"].ToString().Trim(); postInfo.Lastvisit = reader["lastvisit"].ToString().Trim(); postInfo.Nickname = reader["nickname"].ToString().Trim(); postInfo.Username = reader["username"].ToString().Trim(); postInfo.Groupid = Utils.StrToInt(reader["groupid"], 0); postInfo.Spaceid = Utils.StrToInt(reader["spaceid"], 0); postInfo.Gender = Utils.StrToInt(reader["gender"], 2); postInfo.Bday = reader["bday"].ToString().Trim(); postInfo.Showemail = Utils.StrToInt(reader["showemail"], 0); postInfo.Digestposts = Utils.StrToInt(reader["digestposts"], 0); postInfo.Credits = Utils.StrToInt(reader["credits"], 0); postInfo.Extcredits1 = TypeConverter.StrToFloat(reader["extcredits1"].ToString()); postInfo.Extcredits2 = TypeConverter.StrToFloat(reader["extcredits2"].ToString()); postInfo.Extcredits3 = TypeConverter.StrToFloat(reader["extcredits3"].ToString()); postInfo.Extcredits4 = TypeConverter.StrToFloat(reader["extcredits4"].ToString()); postInfo.Extcredits5 = TypeConverter.StrToFloat(reader["extcredits5"].ToString()); postInfo.Extcredits6 = TypeConverter.StrToFloat(reader["extcredits6"].ToString()); postInfo.Extcredits7 = TypeConverter.StrToFloat(reader["extcredits7"].ToString()); postInfo.Extcredits8 = TypeConverter.StrToFloat(reader["extcredits8"].ToString()); postInfo.Posts = Utils.StrToInt(reader["posts"], 0); postInfo.Joindate = reader["joindate"].ToString().Trim(); postInfo.Lastactivity = reader["lastactivity"].ToString().Trim(); postInfo.Userinvisible = Int32.Parse(reader["invisible"].ToString()); postInfo.Avatar = reader["avatar"].ToString(); postInfo.Avatarwidth = Utils.StrToInt(reader["avatarwidth"], 0); postInfo.Avatarheight = Utils.StrToInt(reader["avatarheight"], 0); postInfo.Medals = reader["medals"].ToString(); postInfo.Signature = reader["signature"].ToString(); postInfo.Location = reader["location"].ToString(); postInfo.Customstatus = reader["customstatus"].ToString(); postInfo.Website = reader["website"].ToString(); postInfo.Icq = reader["icq"].ToString(); postInfo.Qq = reader["qq"].ToString(); postInfo.Msn = reader["msn"].ToString(); postInfo.Yahoo = reader["yahoo"].ToString(); postInfo.Skype = reader["skype"].ToString(); //部分属性需要根据不同情况来赋值 //根据用户自己的设置决定是否显示邮箱地址 if (postInfo.Showemail == 0) postInfo.Email = ""; else postInfo.Email = reader["email"].ToString().Trim(); // 最后活动时间50分钟内的为在线, 否则不在线 if (Utils.StrDateDiffMinutes(postInfo.Lastactivity, 50) < 0) postInfo.Onlinestate = 1; else postInfo.Onlinestate = 0; //作者ID为-1即表明作者为游客, 为了区分会直接公开显示游客发帖时的IP, 这里将IP最后一位修改为* postInfo.Ip = reader["ip"].ToString().Trim(); } else { postInfo.Nickname = "游客"; postInfo.Username = "******"; postInfo.Groupid = 7; postInfo.Showemail = 0; postInfo.Digestposts = 0; postInfo.Credits = 0; postInfo.Extcredits1 = 0; postInfo.Extcredits2 = 0; postInfo.Extcredits3 = 0; postInfo.Extcredits4 = 0; postInfo.Extcredits5 = 0; postInfo.Extcredits6 = 0; postInfo.Extcredits7 = 0; postInfo.Extcredits8 = 0; postInfo.Posts = 0; postInfo.Joindate = "2006-9-1 1:1:1"; postInfo.Lastactivity = "2006-9-1 1:1:1"; ; postInfo.Userinvisible = 0; postInfo.Avatar = ""; postInfo.Avatarwidth = 0; postInfo.Avatarheight = 0; postInfo.Medals = ""; postInfo.Signature = ""; postInfo.Location = ""; postInfo.Customstatus = ""; postInfo.Website = ""; postInfo.Icq = ""; postInfo.Qq = ""; postInfo.Msn = ""; postInfo.Yahoo = ""; postInfo.Skype = ""; //部分属性需要根据不同情况来赋值 postInfo.Email = ""; postInfo.Onlinestate = 1; postInfo.Medals = ""; postInfo.Ip = reader["ip"].ToString().Trim(); if (postInfo.Ip.IndexOf('.') > -1) { postInfo.Ip = postInfo.Ip.Substring(0, postInfo.Ip.LastIndexOf(".") + 1) + "*"; } } return postInfo; }
/// <summary> /// 获取帖子参数信息(PostPramsInfo) /// </summary> /// <param name="price"></param> /// <returns></returns> public PostpramsInfo GetPostPramsInfo(int price) { //获取当前页主题列表 PostpramsInfo postpramsInfo = new PostpramsInfo(); postpramsInfo.Fid = forum.Fid; postpramsInfo.Tid = topicid; postpramsInfo.Jammer = forum.Jammer; postpramsInfo.Pagesize = pagesize; // 得到Ppp设置 postpramsInfo.Pageindex = pageid; postpramsInfo.Getattachperm = forum.Getattachperm; postpramsInfo.Usergroupid = usergroupid; postpramsInfo.Attachimgpost = config.Attachimgpost; postpramsInfo.Showattachmentpath = config.Showattachmentpath; postpramsInfo.Price = price; postpramsInfo.Usergroupreadaccess = (ismoder == 1) ? int.MaxValue : usergroupinfo.Readaccess; postpramsInfo.CurrentUserid = userid; postpramsInfo.Showimages = forum.Allowimgcode; postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); postpramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo(); postpramsInfo.Smiliesmax = config.Smiliesmax; postpramsInfo.Bbcodemode = config.Bbcodemode; postpramsInfo.CurrentUserGroup = usergroupinfo; postpramsInfo.Topicinfo = topic; postpramsInfo.Condition = Posts.GetPostPramsInfoCondition(onlyauthor, topicid, topic.Posterid); //if (!(Utils.StrIsNullOrEmpty(onlyauthor) || onlyauthor.Equals("0"))) // postpramsInfo.Condition = string.Format(" {0}.posterid={1}", Posts.GetPostTableName(topicid), topic.Posterid); //判断是否为回复可见帖, hide=0为不解析[hide]标签, hide>0解析为回复可见字样, hide=-1解析为以下内容回复可见字样显示真实内容 //将逻辑判断放入取列表的循环中处理,此处只做是否为回复人的判断,主题作者也该可见 postpramsInfo.Hide = (topic.Hide == 1 && (Posts.IsReplier(topicid, userid) || ismoder == 1)) ? -1 : 1; postpramsInfo.Pid = Posts.GetFirstPostId(topic.Tid); debatepost = Posts.GetSinglePost(postpramsInfo, out attachmentlist, ismoder == 1); postpramsInfo.Pid = 0; //foreach (ShowtopicPageAttachmentInfo showtopicpageattachinfo in attachmentlist) //{ // if (Forums.AllowGetAttachByUserID(forum.Permuserlist, userid)) // { // showtopicpageattachinfo.Getattachperm = 1; // showtopicpageattachinfo.Allowread = 1; // } //} return postpramsInfo; }
/// <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(ShowtopicPagePostInfo[] array, int index) { this.List.CopyTo(array, index); }
/// <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; }
/* /// <summary> /// 获取指定条件的帖子DataSet /// </summary> /// <param name="_postpramsinfo">参数列表</param> /// <returns>指定条件的帖子DataSet</returns> public static Discuz.Common.Generic.List<ShowtopicPagePostInfo> GetPostList(PostpramsInfo _postpramsinfo, out Discuz.Common.Generic.List<ShowtopicPageAttachmentInfo> attcoll) { Discuz.Common.Generic.List<ShowtopicPagePostInfo> postcoll = new Discuz.Common.Generic.List<ShowtopicPagePostInfo>(); attcoll = new Discuz.Common.Generic.List<ShowtopicPageAttachmentInfo>(); IDataReader reader; IDataReader attachreader = null; if (!_postpramsinfo.Condition.Equals("")) { reader = DatabaseProvider.GetInstance().GetPostListByCondition(_postpramsinfo, GetPostTableName(_postpramsinfo.Tid), out attachreader); } else { reader = DatabaseProvider.GetInstance().GetPostList(_postpramsinfo, GetPostTableName(_postpramsinfo.Tid), out attachreader); } 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 (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); } } 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 (attachreader!=null) { next = true; } else { next = reader.NextResult() && reader != null; } if (next) { //序号(楼层)的初值 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()) { ShowtopicPagePostInfo 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.Spaceid = Utils.StrToInt(reader["spaceid"], 0); info.Nickname = reader["nickname"].ToString().Trim(); info.Username = reader["username"].ToString().Trim(); info.Groupid = Utils.StrToInt(reader["groupid"], 0); 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); //处理帖子内容 _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); } 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; } //恢复hide初值 _postpramsinfo.Hide = oldHide; postcoll.Add(info); } } return postcoll; } */ /// <summary> /// 通过主题ID得到主帖内容,此方法可继续扩展 /// </summary> /// <param name="tid"></param> /// <returns>ShowtopicPagePostInfo</returns> public static ShowtopicPagePostInfo GetSinglePost(int tid) { ShowtopicPagePostInfo info = new ShowtopicPagePostInfo();; IDataReader reader = DatabaseProvider.GetInstance().GetSinglePost(tid,Utils.StrToInt(GetPostTableID(tid),-1)); while(reader.Read()) { info.Message = reader["message"].ToString().Trim(); } reader.Close(); return info; }
/// <summary> /// Gets a value indicating whether the collection contains the specified <see cref="ShowtopicPagePostInfoCollection">ShowtopicPagePostInfoCollection</see>. /// </summary> /// <param name="value">The <see cref="ShowtopicPagePostInfoCollection">ShowtopicPagePostInfoCollection</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(ShowtopicPagePostInfo value) { return(this.List.Contains(value)); }
public int Add(ShowtopicPagePostInfo value) { return(this.List.Add(value)); }
public void Remove(ShowtopicPagePostInfo value) { List.Remove(value); }
public void Insert(int index, ShowtopicPagePostInfo value) { List.Insert(index, value); }
/// <summary> /// Gets the index in the collection of the specified <see cref="ShowtopicPagePostInfoCollection">ShowtopicPagePostInfoCollection</see>, if it exists in the collection. /// </summary> /// <param name="value">The <see cref="ShowtopicPagePostInfoCollection">ShowtopicPagePostInfoCollection</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(ShowtopicPagePostInfo value) { return(this.List.IndexOf(value)); }
/// <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=\"\"> 附件: <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; }
/// <summary> /// Gets a value indicating whether the collection contains the specified <see cref="ShowtopicPagePostInfoCollection">ShowtopicPagePostInfoCollection</see>. /// </summary> /// <param name="value">The <see cref="ShowtopicPagePostInfoCollection">ShowtopicPagePostInfoCollection</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(ShowtopicPagePostInfo value) { return this.List.Contains(value); }
/// <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> /// 获取帖子参数信息(PostPramsInfo) /// </summary> /// <param name="price"></param> /// <returns></returns> public PostpramsInfo GetPostPramsInfo(int price) { //获取当前页主题列表 PostpramsInfo postpramsInfo = new PostpramsInfo(); postpramsInfo.Fid = forum.Fid; postpramsInfo.Tid = topicid; postpramsInfo.Jammer = forum.Jammer; postpramsInfo.Pagesize = pagesize; // 得到Ppp设置 postpramsInfo.Pageindex = pageid; postpramsInfo.Getattachperm = forum.Getattachperm; postpramsInfo.Usergroupid = usergroupid; postpramsInfo.Attachimgpost = config.Attachimgpost; postpramsInfo.Showattachmentpath = config.Showattachmentpath; postpramsInfo.Price = price; postpramsInfo.Usergroupreadaccess = (ismoder == 1) ? int.MaxValue : usergroupinfo.Readaccess; postpramsInfo.CurrentUserid = userid; postpramsInfo.Showimages = forum.Allowimgcode; postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); postpramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo(); postpramsInfo.Smiliesmax = config.Smiliesmax; postpramsInfo.Bbcodemode = config.Bbcodemode; postpramsInfo.CurrentUserGroup = usergroupinfo; postpramsInfo.Topicinfo = topic; postpramsInfo.Condition = Posts.GetPostPramsInfoCondition(onlyauthor, topicid, topic.Posterid); //判断是否为回复可见帖, hide=0为不解析[hide]标签, hide>0解析为回复可见字样, hide=-1解析为以下内容回复可见字样显示真实内容 //将逻辑判断放入取列表的循环中处理,此处只做是否为回复人的判断,主题作者也该可见 postpramsInfo.Hide = (topic.Hide == 1 && (Posts.IsReplier(topicid, userid) || ismoder == 1)) ? -1 : 1; postpramsInfo.Pid = Posts.GetFirstPostId(topic.Tid); UserInfo userInfo = Users.GetUserInfo(userid); postpramsInfo.Usercredits = userInfo == null ? 0 : userInfo.Credits; debatepost = Posts.GetSinglePost(postpramsInfo, out attachmentlist, ismoder == 1); postpramsInfo.Pid = 0; return postpramsInfo; }
/// <summary> /// Gets the index in the collection of the specified <see cref="ShowtopicPagePostInfoCollection">ShowtopicPagePostInfoCollection</see>, if it exists in the collection. /// </summary> /// <param name="value">The <see cref="ShowtopicPagePostInfoCollection">ShowtopicPagePostInfoCollection</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(ShowtopicPagePostInfo value) { return this.List.IndexOf(value); }
/// <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> /// 得到空间格式的帖子内容 /// </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; }
/// <summary> /// 根据附件加载帖子内容 /// </summary> /// <param name="postpramsInfo">参数对象</param> /// <param name="attachList">附件列表</param> /// <param name="isModer">是否是管理人员</param> /// <param name="allowGetAttach">是否允许获取附件</param> /// <param name="originalHideStatus">帖子原始Hide属性</param> /// <param name="postInfo">帖子信息 </param> private static void LoadPostMessage(PostpramsInfo postpramsInfo, List<ShowtopicPageAttachmentInfo> attachList, bool isModer, int allowGetAttach, int originalHideStatus, ShowtopicPagePostInfo postInfo) { UserGroupInfo tmpGroupInfo; bool showMessage = !Utils.InArray(postInfo.Groupid.ToString(), "4,5,6") && postInfo.Invisible == 0; //如果当前帖子不可见,但是查看用户是管理组时 if (!showMessage && isModer) { postInfo.Message = "<div class='hintinfo'>该用户帖子内容已被屏蔽, 您拥有管理权限, 以下是帖子内容</div>" + postInfo.Message; } else if (!showMessage) { postInfo.Message = "<div class='hintinfo'>该用户帖子内容已被屏蔽</div>"; List<ShowtopicPageAttachmentInfo> delattlist = new List<ShowtopicPageAttachmentInfo>(); foreach (ShowtopicPageAttachmentInfo attach in attachList) { if (attach.Pid == postInfo.Pid) delattlist.Add(attach); } foreach (ShowtopicPageAttachmentInfo attach in delattlist) { attachList.Remove(attach); } } //如果当前帖子可见 或者 当前查看用户是管理组时 if (showMessage || isModer) { //处理帖子内容 postpramsInfo.Smileyoff = postInfo.Smileyoff; postpramsInfo.Bbcodeoff = postInfo.Bbcodeoff; postpramsInfo.Parseurloff = postInfo.Parseurloff; postpramsInfo.Allowhtml = postInfo.Htmlon; postpramsInfo.Sdetail = postInfo.Message; postpramsInfo.Pid = postInfo.Pid; //校正hide处理 tmpGroupInfo = UserGroups.GetUserGroupInfo(postInfo.Groupid); if (tmpGroupInfo.Allowhidecode == 0) postpramsInfo.Hide = 0; //先简单判断是否是动网兼容模式 if (!postpramsInfo.Ubbmode) postInfo.Message = UBB.UBBToHTML(postpramsInfo); else postInfo.Message = Utils.HtmlEncode(postInfo.Message); if (postpramsInfo.Jammer == 1) postInfo.Message = ForumUtils.AddJammer(postInfo.Message); string message = postInfo.Message; if (postInfo.Attachment > 0 || regexAttach.IsMatch(message) || regexAttachImg.IsMatch(message)) { //获取在[hide]标签中的附件id string[] attHidArray = GetHiddenAttachIdList(postpramsInfo.Sdetail, postpramsInfo.Hide); List<ShowtopicPageAttachmentInfo> attachDeleteList = new List<ShowtopicPageAttachmentInfo>(); foreach (ShowtopicPageAttachmentInfo attach in attachList) { message = Attachments.GetMessageWithAttachInfo(postpramsInfo, allowGetAttach, attHidArray, postInfo, attach, message); //if (attach.Inserted == 1 && (postpramsInfo.CurrentUserGroup.Radminid == 1 || attach.Uid == postpramsInfo.CurrentUserid || attach.Attachprice <= 0 || attach.Isbought == 1)//当为发帖人或不为收费附件或已购买该收费附件时 // || Utils.InArray(attach.Aid.ToString(), attHidArray)) //如果附件已经插入到帖子内容中,则显示内容控制完全交给GetMessageWithAttachInfo if ((attach.Inserted == 1 || Utils.InArray(attach.Aid.ToString(), attHidArray))) attachDeleteList.Add(attach); } foreach (ShowtopicPageAttachmentInfo attach in attachDeleteList) { attachList.Remove(attach); } postInfo.Message = message; } //恢复hide初值 postpramsInfo.Hide = originalHideStatus; } }
protected override void ShowPage() { ismoder = Moderators.IsModer(useradminid, userid, forumid) ? 1 : 0; topic = GetTopicInfo(); if (IsErr()) return; forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); if (forum == null) { AddErrLine("不存在的版块ID"); return; } // 检查是否具有版主的身份 if (useradminid != 0) { ismoder = Moderators.IsModer(useradminid, userid, forum.Fid) ? 1 : 0; admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); //得到管理组信息 if (admininfo != null) disablepostctrl = admininfo.Disablepostctrl; } //验证版块密码 if (!ValidateForumPassword()) return; #region GetForumAds(forum.Fid); //快速编辑器背景广告 quickbgad = Advertisements.GetQuickEditorBgAd("", forumid); if (quickbgad.Length <= 1) quickbgad = new string[2] { "", "" }; #endregion enabletag = (config.Enabletag & forum.Allowtag) == 1; pagetitle = string.Format("{0} - {1}", topic.Title, forum.Name); smileyoff = 1 - forum.Allowsmilies; if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) bbcodeoff = 0; // 权限认证,包括回复,下载附件,发主题等 if (!ValidateAuthority()) return; //获取主题类型 Caches.GetTopicTypeArray().TryGetValue(topic.Typeid, out topictypes); topictypes = Utils.StrIsNullOrEmpty(topictypes) ? "" : "[" + topictypes + "]"; userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetCreditsTrans()); score = Scoresets.GetValidScoreName(); scoreunit = Scoresets.GetValidScoreUnit(); //购买帖子操作, 判断是否为回复可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买 int price = GetTopicPrice(topic); if (topic.Special == 0 && price > 0) { HttpContext.Current.Response.Redirect(forumpath + "buytopic.aspx?topicid=" + topic.Tid); return; } if (newpmcount > 0) pmlist = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1); PostpramsInfo postpramsInfo = GetPostPramsInfo(price); if (topic.Special == 1)//获取投票信息 GetPollInfo(); bonuslogs = Bonus.GetLogs(topic); post = Posts.GetSinglePost(postpramsInfo, out attachmentlist, ismoder == 1); if (post == null) { AddErrLine("读取信息失败"); return; } posttree = Posts.GetPostTree(topicid, postpramsInfo.Hide, Users.GetUserInfo(userid).Credits); //更新查看次数 TopicStats.Track(topic.Tid, 1); topicviews = topic.Views + 1; OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forum.Fid, forum.Name, topic.Tid, topic.Title.Trim(), config.Onlinetimeout); }