<?php
//Include the common file
require_once 'common.php';
header('Content-type: application/rss+xml');
echo '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
include cfg('language', 'languages_path').'lang.'.cfg('language', 'site_language').'.php';

$description = $db->fetchRowAssoc("SELECT page_meta_description FROM " . cfg('base', 'table_pages') . " p, " . cfg('base', 'table_page_translations') . " t  WHERE p.page_id = 1 AND t.language_code = '" . $site_lang . "' AND p.page_id = t.page_id LIMIT 1");

echo '<channel>
		<atom:link href="'.cfg('base', 'site_url').'rss" rel="self" type="application/rss+xml" />
        <title>'.cfg('base', 'site_title').'</title>
        <description>'.$description['page_meta_description'].'</description>
        <link>'.cfg('base', 'site_url').'rss</link>
        <lastBuildDate>'.date("r",time()).'</lastBuildDate>';

$sql = "SELECT m.mix_id, m.date_added, t.mix_title, t.mix_description FROM " . cfg('base', 'table_mixes') . " m, " . cfg('base', 'table_mix_translations') . " t WHERE t.language_code = '" . cfg('language', 'site_language') . "' AND m.mix_id = t.mix_id AND m.mix_status =1 AND TIMESTAMPDIFF(MINUTE, NOW(), m.date_added) < 10080 ORDER BY m.mix_id DESC";
foreach ($db->query($sql) as $row) {
    echo '
        <item>
                <title><![CDATA['.$row['mix_title'].']]></title>
                <description><![CDATA['.ShortenText(strip_tags($row['mix_description']),140).']]></description>
                <link>'.cfg('base', 'site_url').$lang['URL_DJMIXES'].'/'.url($row['mix_title'].'-'.$row['mix_id']).'</link>
                <pubDate>'.date("r",strtotime($row['date_added'])).'</pubDate>
				<guid>'.cfg('base', 'site_url').$lang['URL_DJMIXES'].'/'.url($row['mix_title'].'-'.$row['mix_id']).'</guid>
        </item>
 ';
}
echo '
</channel>';
echo '</rss>';
