«« MacBookのハードディスクを見てもらいました。 | iPhone3Gゲットしました »»
<?php
/*
* くじぇ工作所たまり場 for RSSreader
*/
// 設定
$Textfile = "./bbs.dat";
$Length_Description = 80;
$Title = "つねづね思うこと たまり場";
$Url = "http://kuze.tsukaeru.jp/tsunezune/bbs/keiji.cgi";
$Description = "『つねづね思うこと ( http://kuze.tsukaeru.jp/tsunezune/ )』の掲示板です。";
$Category = "bbs";
$Generator = "くじぇ工作所たまり場 for RSSreader";
$WebMaster = "hiroshikuze@gmail.com";
/* 本体 */
// ファイルロードと解析
mb_internal_encoding("EUC-JP");
$readed_Textfile = file($Textfile);
for($i = 0; $i < count($readed_Textfile);$i++){
$readed_Textfile[$i] = trim(stripslashes (mb_convert_encoding($readed_Textfile[$i], "EUC-JP", "SJIS")));
}a
for($i = 0; $i < count($readed_Textfile); $i = $i + 5)
{
$title_contents[] = $readed_Textfile[$i + 0];
$name_contents[] = $readed_Textfile[$i + 1];
$body_contents_kari = strip_tags ($readed_Textfile[$i + 2]);
$body_contents_kari = ereg_replace("http://.*", "", $body_contents_kari);
if(strlen($body_contents_kari) > $Length_Description) { $body_contents_kari = substr($body_contents_kari, 0, $Length_Description -4)." ..."; }
$body_contents[] = $body_contents_kari;
$category_contents[] = $Category;
$time_contents_kari = $readed_Textfile[$i + 3];
$time_contents_kari = ereg_replace(" ", "T", $time_contents_kari)."Z";
$time_contents[] = $time_contents_kari;
}
// RSS出力
// 参考: http://phpspot.org/blog/archives/2006/06/rss20php.html
$output = "";
$output .= '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$output .= '
<rss version="2.0">
<channel>
<title>'.$Title.'</title>
<link>'.$Url.'</link>
<description>'.$Description.'</description>
<category>'.$Category.'</category>
<generator>'.$Generator.'</generator>
<webMaster>'.$WebMaster.'</webMaster>
';
for($i = 0; $i < count($title_contents); $i++)
{
$output .= '
<item>
<title>'.$title_contents[$i].'</title>
<link>'.$Url.'#'.$i.'</link>
<guid>'.$Url.'#'.$i.'</guid>
<description>'.$body_contents[$i].'</description>
<author>'.$name_contents[$i].'</author>
<category>'.$category_contents[$i].'</category>
<updated>'.$time_contents[$i].'</updated>
<published>'.$time_contents[$i].'</published>
</item>
';
}
$output .= '
</channel>
</rss>
';
header("Content-type: text/xml;charset=utf-8");
$output = mb_convert_encoding($output, "UTF-8", "EUC-JP");
echo $output;
?>
投稿者 kuze : 2008年1月27日 23:48
«« MacBookのハードディスクを見てもらいました。 | iPhone3Gゲットしました »»

コメント