<?php
$url 
"http://park15.wakwak.com/~maro/tobodiary/diary.html";
//$url = "diary.html";
$TZD "+09:00";
$year date("Y");
$prefix ="http://park15.wakwak.com/~maro/tobodiary/";
$content file_get_contents($url);
$content mb_convert_encoding($content,utf8,auto);
$content ereg_replace('^.*/h2>''',$content);
$content ereg_replace('<hr>.*$''',$content);
$content preg_replace("$<h3>$""\n<h3>"$content);
$content preg_replace("$</h3>$""</h3>\n"$content);
preg_match("$<span class=\"date\">([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})</span>$",$content$updates);
$update =$year."-".$updates[1]."-".$updates[2]."T".$updates[3].":".$updates[4].":00".$TZD;
$content preg_replace("$<h3><a href=\"([0-9]{6}\.html#n[0-9]{12})\" [^>]+><span class=\"subject\">([^<]+)</span></a> <span class=\"date\">([0-9]{2})/([0-9]{2}) ([0-9]{2}:[0-9]{2})</span></h3>$""</div>\n</content>\n</entry>\n<entry>\n<title>\\2</title>\n<link rel=\"alternate\" href=\"".$prefix."\\1\"/>\n<updated>".$year."-\\3-\\4T\\5:00".$TZD."</updated>\n<id>".$prefix."\\1</id>\n<content type=\"xhtml\">\n<div xmlns=\"http://www.w3.org/1999/xhtml\">\n"$content);
$content =preg_replace("$^[\s\n]+</div>\n</content>\n</entry>$"""$content);
$content .= "</div>\n</content>\n</entry>\n</feed>";
$content preg_replace("$([\r\n])[\s]+$""\\1"$content);

$header =<<<EOD
<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="ja" xmlns="http://www.w3.org/2005/Atom">
<title>tobocchi&#39;s...memo?</title>
<link rel="alternate" href="http://park15.wakwak.com/~maro/tobodiary/diary.html" />
<link rel="self" type="application/atom+xml" href="http://diary.noasobi.net/junk/tobofeed.php" />
<author>
<name>tobocchi</name>
</author>
<updated>$update</updated>
<id>http://park15.wakwak.com/~maro/tobodiary/diary.html</id>
EOD;

$atom $header.$content;

header("Content-Type: application/atom+xml;charset=utf-8");
print 
$atom;
?>