Mercurial > defr > DualBlog
view atom.php @ 31:2d98421d43da
Le formulaire d'ajout de commentaire vient remplacer <tr:commentForm />
Avant, il était considéré comme un post en plus dans le document, ce
qui ne permettait pas de l'activer ou de le desactiver selon les différents
modèles de squelettes (embettant pour la feed Atom par exemple)
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Mon, 05 Nov 2007 08:59:51 +0100 |
parents | 629389204276 |
children |
line wrap: on
line source
<?php include("classes.php"); function utf8_ensure($str) { return seems_utf8($str)?$str:utf8_encode($str); } function seems_utf8($Str) { for ($i=0; $i<strlen($Str) && $i<150; $i++) { if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b else return false; # Does not match any model for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ? if ((++$i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80)) return false; } } return true; } if(stristr($_SERVER['HTTP_ACCEPT'], "application/atom+xml")) header("Content-Type: application/atom+xml; charset=utf-8"); else header("Content-Type: application/xml; charset=utf-8"); echo("<?xml version='1.0' encoding='utf-8'?>\n"); $Data = new DataAccess(); $Data->Query("SELECT * FROM Mess ORDER BY num_mess DESC LIMIT 0, 1"); $val=$Data->GetRow(); $modifiedDate=gmdate("Y-m-d", strtotime($val['DatePost'])) . "T" . gmdate("H:i:s-02:00", strtotime($val['DatePost'])); ?> <feed xmlns="http://www.w3.org/2005/Atom" xml:lang='fr-FR'> <title>Dual Blog</title> <subtitle>Le blog de DeFr, parlant de tout et de rien ^^;</subtitle> <link rel='alternate' type='text/html' href='http://defr.org/blog/' /> <link rel='self' type='application/atom+xml' href='http://defr.org/blog/dualblog.atom' /> <updated><?php echo $modifiedDate; ?></updated> <author> <name>Deroche Franck</name> <uri>http://defr.org</uri> </author> <id>urn:uuid:cface534-634f-4ce8-a07b-3a4187982583</id> <?php $result=$Data->Query("SELECT * FROM Mess ORDER BY num_mess DESC LIMIT 0, 20"); while($val=$Data->GetRow()) { $utf8_Mess=str_replace("</P>", "</p>", str_replace("<P>", "<p>", (str_replace("€", "€", utf8_ensure($val['Message']))))); $utf8_Mess = str_replace(" ", " ", $utf8_Mess); $utf8_Titre=utf8_ensure($val['Titre']); $issuedDate=gmdate("Y-m-d", strtotime($val['DatePost'])) . "T" . gmdate("H:i:s-02:00", strtotime($val['DatePost'])); echo(" <entry> <title type='xhtml'> <div xmlns='http://www.w3.org/1999/xhtml'> {$utf8_Titre} </div> </title> <id>tag:defr.org,2006:{$val['num_mess']}</id> <content type='xhtml'> <div xmlns='http://www.w3.org/1999/xhtml'> {$utf8_Mess} </div> </content> <published>{$issuedDate}</published> <updated>{$issuedDate}</updated> <link rel='alternate' type='text/html' href='http://www.defr.org/blog/posts/{$val['id']}' /> </entry> "); } ?> </feed>