<?
Header( "Content-type: text/xml"); 
echo '<'; ?>?xml version="1.0" encoding="ISO-8859-1"?> 
<rss version="2.0"> 
<channel>
<title>MLatina.com</title>
<description>Todo sobre la musica latina</description>
<link>http://www.mlatina.com/</link>
<language>es-ES</language> 
<copyright>COPYRIGHT 2009 - Sac2 Company</copyright>
<? 
include "/home2/mlatina/public_html/config/config.php";
$db = mysql_connect($db_host,$db_user,$db_pass); 
mysql_select_db ($db_name) or die ("Cannot connect to database"); 
$query = "SELECT id_cnt, genero, titulo, textope, date FROM noticias WHERE `main` = '1' OR `main` = '2' ORDER BY `date` DESC"; 
$result = mysql_query($query);
while($r=mysql_fetch_array($result))  {
 $id=$r['id_cnt']; 
 $title=strip_tags($r['titulo']);
 $genero=$r['genero'];
 $body=strip_tags($r['textope']);
 $body=substr($r['textope'],0,150);
 $pubDate = $r['date'];
// $pubDate=strftime("%a, %d %b %Y %T %Z",$r['date'])
  // output to client
 
  $title= xmlentities ($title);
  $body= xmlentities ($body);
  $mas = masChar($title);
?>
<item>
<title><? echo "$title";?></title>
<description><? echo "$body";?></description>
<link>http://www.mlatina.com/noticia/<? echo "$genero"; ?>/<? echo "$id"; ?>/<? echo "$mas"; ?>.htm</link>
<pubDate><? echo "$pubDate"; ?></pubDate>
<channel><? echo "$genero"; ?></channel>
<copyright>MLatina.com</copyright>
</item>
<? } ?>
</channel>
</rss>
<?
function xmlentities ( $string )
{
$string = preg_replace("/\[(.*?)\]/i", "", $string);  
$string = str_replace('<','&lt;',$string); 
$string = str_replace("\n",'',$string); 
$string = str_replace("\r",'',$string); 
$string = str_replace ( array ( '&', '"', "'", '<', '>' ), array ( 'Y' , '', '' , '' , '' ), $string );
   return $string;
}
function masChar($tex){
	$patrones[0] = '/á/'; 
	$patrones[1] = '/é/'; 
	$patrones[2] = '/í/'; 
	$patrones[3] = '/ó/'; 
	$patrones[4] = '/ú/'; 
	$patrones[5] = '/ü/'; 
	$patrones[6] = '/ñ/'; 
	$reemplazos[0] = 'a'; 
	$reemplazos[1] = 'e'; 
	$reemplazos[2] = 'i'; 
	$reemplazos[3] = 'o'; 
	$reemplazos[4] = 'u'; 
	$reemplazos[5] = 'u'; 
	$reemplazos[6] = 'n'; 
	$tex = str_replace(' ', '-', $tex);
	return preg_replace($patrones, $reemplazos, $tex);
}
?>
