<?php
// Set header for XML output
header("Content-type: application/xml");
echo '<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
    xml:base="' . htmlspecialchars($site_domain) . '"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:media="http://search.yahoo.com/mrss/"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>' . htmlspecialchars($advancenews['COMPANY_NAME']) . ' | RSS Feed</title>
        <link>' . htmlspecialchars($site_domain) . '</link>
        <description>A RSS news feed containing the latest ' . htmlspecialchars($advancenews['COMPANY_NAME']) . ' articles.</description>
        <atom:link href="' . htmlspecialchars($site_domain) . 'rss/rss.xml" rel="self" type="application/rss+xml" />
        <dc:language>bn-bd</dc:language>
        <dc:creator>' . htmlspecialchars($advancenews['COMPANY_NAME']) . '</dc:creator>
        <dc:rights>Copyright ' . date("Y") . ' ' . htmlspecialchars($advancenews['COMPANY_NAME']) . '</dc:rights>
        <dc:date>' . date("Y-m-d\TH:i:sP") . '</dc:date>';
    $get_post_data =  getArticles(null,   120, ) ;
    foreach ($get_post_data as $the_feed_post) {
        // Format post date
        $date = date_create($the_feed_post['PostDatePublic']);
        $pubDate = date_format($date, "D, d M Y H:i:s O");
        $image_url = articleImg($the_feed_post['PostId']);
        echo '<item>
                <title>' . htmlspecialchars($the_feed_post['PostTitle'], ENT_QUOTES, 'UTF-8') . '</title>
                <link>' . htmlspecialchars(articleLink($the_feed_post['PostId'])) . '</link>
                <description><![CDATA[' . str_replace('&nbsp;', '&#160;',  articleContentClean(strip_tags($the_feed_post['PostContent']))) . ']]></description>
                <pubDate>' . $pubDate . '</pubDate>
                <guid isPermaLink="false">' . htmlspecialchars(articleLink($the_feed_post['PostId'])) . '</guid>
                <media:content medium="image" width="750" height="390" url="' . htmlspecialchars($image_url) . '" />
                <content:encoded><![CDATA[' . str_replace('&nbsp;', '&#160;', strip_tags($the_feed_post['PostContent'])) . ']]></content:encoded>
            </item>';
    }
    echo '</channel></rss>';
?>
