<?php

############################################################################
#    CMS - jrem                                                            #
#    Copyright (C) 2005 by Jose Ramon Esteban Marti                        #
#    http://www.sindoc.com                                                 #
#    jrem@internautas.org                                                  #
#                                                                          #
#    This program is free software; you can redistribute it and#or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation; either version 2 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program; if not, write to the                         #
#    Free Software Foundation, Inc.,                                       #
#    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
############################################################################


include ("../config.php");
//Lee las variables generales de la aplicacion
$result=mysql_db_query($dbnombre,"select * from main") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
	$dato1 = $row["main_tipo"];
	$dato2 = $row["main_content"];
	$xa[$dato1]= $dato2;
}
mysql_free_result($result);
unset ($dato1);
unset ($dato2);

$sql = "select textoindex,met_desc from index3 where indexid='1'";
$result=mysql_db_query($dbnombre,$sql) or die(mysql_error());
$row = mysql_fetch_array($result)
$textweb = stripslashes ($row["textoindex"]);
$meta_description = stripslashes ($row["met_desc"]);
mysql_free_result($result);

header("Content-Type: application/text+xml");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n";

echo "<rss version=\"2.0\">\n\n";

$pagina = "$textweb";
$url = "$xa[url_gen]";
$descripcion = "$meta_description";
#$grafico = "http://www.internautas.org/graficos/logoai.png";

echo "<channel>\n";
echo "<title>".htmlspecialchars($pagina)."</title>\n";
#echo "<url>".htmlspecialchars($grafico)."</url>\n";
echo "<link>".htmlspecialchars($url)."</link>\n";
echo "<description>".htmlspecialchars($descripcion)."</description>\n";
echo "<language>es-es</language>\n";
echo "<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
echo "<generator>code by sindic.org</generator>\n";
echo "<copyright>http://creativecommons.org/licenses/by-sa/2.1/es/</copyright>\n";
#echo "<managingEditor>asociacion@internautas.org</managingEditor>\n";
#echo "<webMaster>jrem@internautas.org</webMaster>\n\n";

$fechaactual = date ("Y-m-d H:i:s");
$result=mysql_db_query($dbnombre,"select artid,titulo,introtext,fecha from articulos where (fecha <= '$fechaactual') order by fecha DESC limit 0,10") or die(mysql_error());

while($row = mysql_fetch_array($result)) {

    $arti = $row["titulo"];
    $intro = $row["introtext"];
    $fecha = $row["fecha"];

    echo "<item>\n";
    echo "<title>".htmlspecialchars($arti)."</title>\n";
    echo "<link>http://www.internautas.org/html/".$row[articulo_id].".html</link>\n";
    echo "<description>".htmlspecialchars($intro)."</description>\n";
    echo "<pubDate>$fecha</pubDate>\n";

    echo "</item>\n\n";
}
echo "</channel>\n";
echo "</rss>";

?>
