1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
   | <?php
$cnx = mysql_connect('localhost','root','');
$db = mysql_select_db('rss',$cnx);
 
$xml = '<?xml version="1.0" encoding="iso-8859-1"?><rss version="2.0">';
$xml .= '<channel>'; 
$xml .= '<title>..:: Ash\'s Blog - RSS ::..</title>';
$xml .= '<link>http://romain.bertolucci.free.fr/site/</link>';
$xml .= '<description>Le blog de Ash, des articles sur WoW, WaR, developpement web, bonne lecture!</description>';
 
$sql = "SELECT *,DATE_FORMAT(date_news,'%d %b %Y %h:%i:%s') AS date FROM blog_news ORDER BY id_news DESC LIMIT 0,10";
$req = mysql_query($sql) or die("Erreur RSS");
 
while($data = mysql_fetch_array($req))
{
	$id = $data['id_news'];
	$date = $data['date'];
	$titre = $data['titre_news'];
	$accroche = $data['accroche_news'];
	$texte = $data['texte_news'];
	$lien = 'http://romain.bertolucci.free.fr/site/?r=lire&id='.$id;
 
	$xml .= '<item>';
	$xml .= '<title>'.$titre.'</title>';
	$xml .= '<link>'.$lien.'</link>';
	$xml .= '<pubDate>'.$date.' GMT</pubDate>';
	$xml .= '<description>'.$accroche.'</description>';
	$xml .= '</item>';
}
 
$xml .= '</channel>';
$xml .= '</rss>';
 
$fp = fopen("../rss.xml", 'w+');
fputs($fp, $xml);
fclose($fp);
mysql_close($cnx);
echo '<SCRIPT LANGUAGE="JavaScript">document.location.href="index.php"</SCRIPT>';
?> | 
Partager