'; echo << PHP中文手册 http://www.codechina.org/doc/php/ PHP中文手册 RSSHEADER; $files = getNewFiles ( "doc/php/", "*.html", 20 ); $rssItems = makeRssItems ( $files ); echo $rssItems; echo " \r\n" . "\r\n"; function getNewFiles($path, $filter, $n) { exec ( "cd $path;ls -t $filter|head -n $n", $out ); return $out; } function makeRssItems($files) { $out = ''; foreach ( $files as $f ) { $filename = "doc/php/" . $f; $html = file_get_contents ( $filename ); $title = getHtmlTitle ( $html ); $out .= ''; $out .= "$title\r\n"; $out .= "http://www.codechina.org/doc/php/$f\r\n"; $out .= "http://www.codechina.org/doc/php/$f\r\n"; $out .= "" . date ( "r", filemtime ( $filename ) ) . "\r\n"; $out .= ''; } return $out; } function getHtmlTitle($html) { preg_match ( "/(.*?)<\/title>/m", $html, $match ); if (count ( $match ) < 1) return "无标题"; return $match [1]; }