예제 #1
0
        protected void Page_Load( object sender, System.EventArgs e )
        {
            // Put user code to initialize the page here
            RssFeed rf = new RssFeed();

            XmlTextWriter writer = new XmlTextWriter( Response.OutputStream, System.Text.Encoding.UTF8 );

            writer.Formatting = Formatting.Indented;
            rf.WriteRSSPrologue( writer, this );

            // Usage rf.AddRSSItem(writer, "Item Title", "http://test.com", "This is a test item");

            switch ( Request.QueryString ["pg"] )
            {
                case "posts":
                    if ( !ForumReadAccess )
                        Data.AccessDenied();

                    if ( Request.QueryString ["t"] != null )
                    {
                        using ( DataTable dt = DB.post_list( PageTopicID, 1 ) )
                        {
                            foreach ( DataRow row in dt.Rows )
                                rf.AddRSSItem( writer, row ["Subject"].ToString(), ServerURL + Forum.GetLink( Pages.posts, "t={0}", Request.QueryString ["t"] ), row ["Message"].ToString(), Convert.ToDateTime( row ["Posted"] ).ToString( "r" ) );
                        }
                    }

                    break;
                case "forum":
                    using ( DataTable dt = DB.forum_listread( PageBoardID, PageUserID, null, null ) )
                    {
                        foreach ( DataRow row in dt.Rows )
                        {
                            if ( row ["LastTopicID"] != DBNull.Value )
                            {
                                rf.AddRSSItem( writer, row ["Forum"].ToString(), ServerURL + Forum.GetLink( Pages.topics, "f={0}", row ["ForumID"] ), row ["Description"].ToString() );
                            }
                            else
                            {
                                rf.AddRSSItem( writer, row ["Forum"].ToString(), ServerURL + Forum.GetLink( Pages.topics, "f={0}", row ["ForumID"] ), row ["Description"].ToString() );
                            }
                        }
                    }
                    break;
                case "topics":
                    if ( !ForumReadAccess )
                        Data.AccessDenied();

                    if ( Request.QueryString ["f"] != null )
                    {
                        string tSQL = "select Topic = a.Topic, TopicID = a.TopicID, Name = b.Name, Posted = a.Posted from yaf_Topic a, yaf_Forum b where a.ForumID=" + Request.QueryString ["f"] + " and b.ForumID = a.ForumID";
                        using ( DataTable dt = DB.GetData( tSQL ) )
                        {
                            foreach ( DataRow row in dt.Rows )
                            {
                                rf.AddRSSItem( writer, row ["Topic"].ToString(), ServerURL + Forum.GetLink( Pages.posts, "t={0}", row ["TopicID"] ), row ["Topic"].ToString(), Convert.ToDateTime( row ["Posted"] ).ToString( "r" ) );
                            }
                        }
                    }

                    break;
                case "active":
                    object categoryIDObject = null;
                    if ( ForumControl.CategoryID != 0 ) categoryIDObject = ForumControl.CategoryID;

                    using ( DataTable dt = DB.topic_active( PageBoardID, PageUserID, DateTime.Now + TimeSpan.FromHours( -24 ), categoryIDObject ) )
                    {
                        foreach ( DataRow row in dt.Rows )
                        {
                            rf.AddRSSItem( writer, row ["Subject"].ToString(), ServerURL + Forum.GetLink( Pages.posts, "t={0}", row ["LinkTopicID"] ), row ["Subject"].ToString() );
                        }
                    }
                    break;
                default:
                    break;
            }

            rf.WriteRSSClosing( writer );
            writer.Flush();

            writer.Close();

            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability( HttpCacheability.Public );

            Response.End();
        }
예제 #2
0
		protected void Page_Load(object sender, EventArgs e)
		{
			// Put user code to initialize the page here
			RssFeed rf = new RssFeed();

			XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);

			writer.Formatting = Formatting.Indented;
			rf.WriteRSSPrologue(writer);

			// Usage rf.AddRSSItem(writer, "Item Title", "http://test.com", "This is a test item");

			switch (Request.QueryString["pg"])
			{
				case "latestposts":
					if (!PageContext.ForumReadAccess)
						YafBuildLink.AccessDenied();
					using (DataTable dt = DB.topic_latest(PageContext.PageBoardID, 7, PageContext.PageUserID))
					{
						foreach (DataRow row in dt.Rows)
							rf.AddRSSItem(writer,
							              General.BadWordReplace(row["Subject"].ToString()),
							              YafForumInfo.ServerURL +
							              YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", Request.QueryString["t"]),
							              General.BadWordReplace(row["Message"].ToString()),
							              Convert.ToDateTime(row["Posted"]).ToString("r"));
					}
					break;
				case "latestannouncements":
					if (!PageContext.ForumReadAccess)
						YafBuildLink.AccessDenied();
					using (DataTable dt = DB.topic_announcements(PageContext.PageBoardID, 7, PageContext.PageUserID))
					{
						foreach (DataRow row in dt.Rows)
							rf.AddRSSItem(writer,
							              General.BadWordReplace(row["Subject"].ToString()),
							              YafForumInfo.ServerURL +
							              YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", Request.QueryString["t"]),
							              General.BadWordReplace(row["Message"].ToString()),
							              Convert.ToDateTime(row["Posted"]).ToString("r"));
					}
					break;
				case "posts":
					if (!PageContext.ForumReadAccess)
						YafBuildLink.AccessDenied();

					if (Request.QueryString["t"] != null)
					{
						using (
							DataTable dt =
								DB.post_list(PageContext.PageTopicID, 1, PageContext.BoardSettings.ShowDeletedMessages))
						{
							foreach (DataRow row in dt.Rows)
								rf.AddRSSItem(writer,
								              General.BadWordReplace(row["Subject"].ToString()),
								              YafForumInfo.ServerURL +
								              YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", Request.QueryString["t"]),
								              FormatMsg.FormatMessage(row["Message"].ToString(), new MessageFlags(row["Flags"])),
								              Convert.ToDateTime(row["Posted"]).ToString("r"));
						}
					}

					break;
				case "forum":
					using (
						DataTable dt = DB.forum_listread(PageContext.PageBoardID, PageContext.PageUserID, null, null))
					{
						foreach (DataRow row in dt.Rows)
						{
							rf.AddRSSItem(writer,
							              General.BadWordReplace(row["Forum"].ToString()),
							              YafForumInfo.ServerURL + YafBuildLink.GetLinkNotEscaped(ForumPages.topics, "f={0}", row["ForumID"]),
							              General.BadWordReplace(row["Description"].ToString()));
						}
					}
					break;
				case "topics":
					if (!PageContext.ForumReadAccess)
						YafBuildLink.AccessDenied();

					int forumId;
					if (Request.QueryString["f"] != null &&
					    int.TryParse(Request.QueryString["f"], out forumId))
					{
                        //vzrus changed to separate DLL specific code
                        using (DataTable dt = DB.rsstopic_list(forumId))
                        {
                            foreach (DataRow row in dt.Rows)
                            {
                                rf.AddRSSItem(writer,
                                              General.BadWordReplace(row["Topic"].ToString()),
                                              YafForumInfo.ServerURL + YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", row["TopicID"]),
                                              General.BadWordReplace(row["Topic"].ToString()),
                                              Convert.ToDateTime(row["Posted"]).ToString("r"));
                            }
                        }
				
					}

					break;
				case "active":
using (
	DataTable dt =
		DB.topic_active(PageContext.PageBoardID, PageContext.PageUserID,
		DateTime.Now + TimeSpan.FromHours( -24 ), ( PageContext.Settings.CategoryID == 0 ) ? null : (object)PageContext.Settings.CategoryID ) )
{
	foreach (DataRow row in dt.Rows)
	{
		rf.AddRSSItem(writer,
		              General.BadWordReplace(row["Subject"].ToString()),
		              YafForumInfo.ServerURL +
		              YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", row["LinkTopicID"]),
		              General.BadWordReplace(row["Subject"].ToString()));
	}
}
break;
				default:
					break;
			}

			rf.WriteRSSClosing(writer);
			writer.Flush();

			writer.Close();

			Response.ContentEncoding = Encoding.UTF8;
			Response.ContentType = "text/xml";
			Response.Cache.SetCacheability(HttpCacheability.Public);

			Response.End();
		}
예제 #3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            RssFeed rf = new RssFeed();

            XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);

            writer.Formatting = Formatting.Indented;
            rf.WriteRSSPrologue(writer, this);

            // Usage rf.AddRSSItem(writer, "Item Title", "http://test.com", "This is a test item");

            switch (Request.QueryString["pg"])
            {
            case "posts":
                if (!ForumReadAccess)
                {
                    Data.AccessDenied();
                }

                if (Request.QueryString["t"] != null)
                {
                    using (DataTable dt = DB.post_list(PageTopicID, 1))
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            rf.AddRSSItem(writer, row["Subject"].ToString(), ServerURL + Forum.GetLink(Pages.posts, "t={0}", Request.QueryString["t"]), row["Message"].ToString());
                        }
                    }
                }

                break;

            case "forum":
                using (DataTable dt = DB.forum_listread(PageBoardID, PageUserID, null, null))
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        rf.AddRSSItem(writer, row["Forum"].ToString(), ServerURL + Forum.GetLink(Pages.posts, "t={0}", row["LastTopicID"]), row["Description"].ToString());
                    }
                }
                break;

            case "topics":
                if (!ForumReadAccess)
                {
                    Data.AccessDenied();
                }

                if (Request.QueryString["f"] != null)
                {
                    using (DataTable dt = DB.GetData("select Topic = a.Topic, TopicID = a.TopicID, Name = b.Name from yaf_Topic a, yaf_Forum b where a.ForumID=" + Request.QueryString["f"] + " and b.ForumID = a.ForumID"))
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            rf.AddRSSItem(writer, row["Topic"].ToString(), ServerURL + Forum.GetLink(Pages.posts, "t={0}", row["TopicID"]), row["Topic"].ToString());
                        }
                    }
                }

                break;

            case "active":
                using (DataTable dt = DB.topic_active(PageBoardID, PageUserID, DateTime.Now + TimeSpan.FromHours(-24), ForumControl.CategoryID))
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        rf.AddRSSItem(writer, row["Subject"].ToString(), ServerURL + Forum.GetLink(Pages.posts, "t={0}", row["LinkTopicID"]), row["Subject"].ToString());
                    }
                }
                break;

            default:
                break;
            }

            rf.WriteRSSClosing(writer);
            writer.Flush();

            writer.Close();

            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType     = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.Public);

            Response.End();
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Put user code to initialize the page here
            RssFeed rf = new RssFeed();

            XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);

            writer.Formatting = Formatting.Indented;
            rf.WriteRSSPrologue(writer);

            // Usage rf.AddRSSItem(writer, "Item Title", "http://test.com", "This is a test item");

            switch (Request.QueryString["pg"])
            {
            case "latestposts":
                if (!PageContext.ForumReadAccess)
                {
                    YafBuildLink.AccessDenied();
                }
                using (DataTable dt = DB.topic_latest(PageContext.PageBoardID, 7, PageContext.PageUserID))
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        rf.AddRSSItem(writer,
                                      General.BadWordReplace(row["Subject"].ToString()),
                                      YafForumInfo.ServerURL +
                                      YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", Request.QueryString["t"]),
                                      General.BadWordReplace(row["Message"].ToString()),
                                      Convert.ToDateTime(row["Posted"]).ToString("r"));
                    }
                }
                break;

            case "latestannouncements":
                if (!PageContext.ForumReadAccess)
                {
                    YafBuildLink.AccessDenied();
                }
                using (DataTable dt = DB.topic_announcements(PageContext.PageBoardID, 7, PageContext.PageUserID))
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        rf.AddRSSItem(writer,
                                      General.BadWordReplace(row["Subject"].ToString()),
                                      YafForumInfo.ServerURL +
                                      YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", Request.QueryString["t"]),
                                      General.BadWordReplace(row["Message"].ToString()),
                                      Convert.ToDateTime(row["Posted"]).ToString("r"));
                    }
                }
                break;

            case "posts":
                if (!PageContext.ForumReadAccess)
                {
                    YafBuildLink.AccessDenied();
                }

                if (Request.QueryString["t"] != null)
                {
                    using (
                        DataTable dt =
                            DB.post_list(PageContext.PageTopicID, 1, PageContext.BoardSettings.ShowDeletedMessages))
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            rf.AddRSSItem(writer,
                                          General.BadWordReplace(row["Subject"].ToString()),
                                          YafForumInfo.ServerURL +
                                          YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", Request.QueryString["t"]),
                                          FormatMsg.FormatMessage(row["Message"].ToString(), new MessageFlags(row["Flags"])),
                                          Convert.ToDateTime(row["Posted"]).ToString("r"));
                        }
                    }
                }

                break;

            case "forum":
                using (
                    DataTable dt = DB.forum_listread(PageContext.PageBoardID, PageContext.PageUserID, null, null))
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        rf.AddRSSItem(writer,
                                      General.BadWordReplace(row["Forum"].ToString()),
                                      YafForumInfo.ServerURL + YafBuildLink.GetLinkNotEscaped(ForumPages.topics, "f={0}", row["ForumID"]),
                                      General.BadWordReplace(row["Description"].ToString()));
                    }
                }
                break;

            case "topics":
                if (!PageContext.ForumReadAccess)
                {
                    YafBuildLink.AccessDenied();
                }

                int forumId;
                if (Request.QueryString["f"] != null &&
                    int.TryParse(Request.QueryString["f"], out forumId))
                {
                    //vzrus changed to separate DLL specific code
                    using (DataTable dt = DB.rsstopic_list(forumId))
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            rf.AddRSSItem(writer,
                                          General.BadWordReplace(row["Topic"].ToString()),
                                          YafForumInfo.ServerURL + YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", row["TopicID"]),
                                          General.BadWordReplace(row["Topic"].ToString()),
                                          Convert.ToDateTime(row["Posted"]).ToString("r"));
                        }
                    }
                }

                break;

            case "active":
                using (
                    DataTable dt =
                        DB.topic_active(PageContext.PageBoardID, PageContext.PageUserID,
                                        DateTime.Now + TimeSpan.FromHours(-24), (PageContext.Settings.CategoryID == 0) ? null : (object)PageContext.Settings.CategoryID))
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        rf.AddRSSItem(writer,
                                      General.BadWordReplace(row["Subject"].ToString()),
                                      YafForumInfo.ServerURL +
                                      YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", row["LinkTopicID"]),
                                      General.BadWordReplace(row["Subject"].ToString()));
                    }
                }
                break;

            default:
                break;
            }

            rf.WriteRSSClosing(writer);
            writer.Flush();

            writer.Close();

            Response.ContentEncoding = Encoding.UTF8;
            Response.ContentType     = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.Public);

            Response.End();
        }