<?php
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
  header("Content-type: application/xhtml+xml;charset=utf-8 ");
}
else {
  header("Content-type: text/html;charset=utf-8");
}

echo "
<rss version='2.0'>

<channel> <title>VisaFutis.net - Uutiset</title> 
<link>http://www.visafutis.net</link>
<description>Ajankohtaisia jalkapallouutisia Virolahdelta</description>
<language>fi</language>
";

$yhteys = mysql_connect("localhost", "visafuti_visa", "v1safut1s");
                mysql_select_db("visafuti_visafutis");
                $tulos = mysql_query("
                                        SELECT * FROM uutiset
                                        ORDER BY `date` DESC
                                        LIMIT 0, 5");

	while (list($index, $kenelle, $otsikko, $teksti, $pvm, $tekija, $date) = mysql_fetch_row($tulos))
                        {
			
			$teksti = str_replace('ä','&auml;',$teksti);
                        $teksti = str_replace('Ä','&Auml;',$teksti);
                        $teksti = str_replace('ö','&ouml;',$teksti);
                        $teksti = str_replace('Ö','&Ouml;',$teksti);
			$teksti = str_replace('å','&aring;',$teksti);
			$teksti = str_replace('Å','&Aring;',$teksti);
			/*	
			$otsikko = str_replace('ä','a',$otsikko);
                        $otsikko = str_replace('Ä','A',$otsikko);
                        $otsikko = str_replace('ö','o',$otsikko);
                        $otsikko = str_replace('Ö','O',$otsikko);
			$otsikko = str_replace('å','a',$otsikko);
                        $otsikko = str_replace('Å','A',$otsikko);	
			$otsikko = str_replace('<br />',' ',$otsikko);
			*/
			$otsikko = utf8_encode($otsikko);	

			?>
			<item>
                        	<title>
					<![CDATA[<?echo $otsikko?>]]>
				</title>
                        	
				<description>
					<![CDATA[<?echo $teksti?>]]>
				</description>
                        	
				<pubDate>
					<?echo $date;?>
				</pubDate>
                        	
				<link>
					<?
					if($kenelle == 'yleinen') echo "http://www.visafutis.net/visa/uutiset.php#".$index;
					elseif($kenelle == 'salibandy') echo "http://www.visafutis.net/visa/salibandy.php#".$index;
					elseif($kenelle == 'vellicup') echo "http://www.visafutis.net/visa/vellicup.php#".$index;
					elseif($kenelle == 'kuntofutis') echo "http://www.visafutis.net/visa/kuntofutis.php#".$index;
					elseif($kenelle == 'muut') echo "http://www.visafutis.net/visa/muut.php#".$index;
					?>
				</link>
                	</item>
			<?
			}

	mysql_close($yhteys);
?>

</channel>
</rss>
