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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
<?php
include ("data.php");
global $dbserver;
global $dbdb;
global $dbuser;
global $dbpass;
/*
* fonction cleanText()
*/
function cleanText($intext) {
return utf8_encode(htmlspecialchars(stripslashes($intext)));
}
// connexion base de donnees
mysql_connect ($dbserver,$dbuser,$dbpass) or die (mysql_error);
mysql_select_db($dbdb) or die (mysql_error());
// requete
$query = "SELECT date_debut, nom, description, id FROM agenda WHERE (date_debut='$this_date') OR (date_debut <= '$this_date' AND date_fin = '$this_date') OR (date_debut > '$this_date') ORDER BY date_debut ASC, date_fin ASC, id DESC LIMIT 6";
$result = mysql_query($query) or die (mysql_error());
// extraction des donnees
$row = mysql_fetch_array($result);
$date_debut = $row["date_debut"];
$id = $row["id"];
// !!!! tab_debut contient un tableau !!!!
// il doit donc être utilisé comme tel (ex : $tab_debut[0])
// sauf que je ne vois pas a quoi il sert ici...
$tab_debut=explode("-",$date_debut);
$title = cleanText($row["nom"]);
$description = cleanText($row["description"]);
$link = "http://www.herbignac.com/html/pratique/xlagenda327/evenement.php?id=$id";
echo <<<END
<item>
<title>{$title}</title>
<link>{$link}</link>
<description>{$description}</description>
<pubDate>{$date_debut}</pubDate>
<guid>{$link}</guid>
</item>
END;
header("Content-Type: text/xml;charset=utf-8");
// a quoi correspond la variable $date ?
echo <<<END
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Agenda d'Herbignac</title>
<link>http://www.herbignac.com</link>
<description>Agenda de la commune d'Herbignac</description>
<pubDate>{$date}</pubDate>
<language>fr-FR</language>
END;
?> |