Mercurial > defr > DualBlog
view atom.php @ 3:f8591021e45d
Fichier de test des indicateurs d'humeur, inutile
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Sat, 20 Oct 2007 15:04:27 +0200 |
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>