function shownews($root, $limit = 5)
{
- foreach (array_reverse(glob("$root/*/*.html")) as $url) {
+ if (strpos($root, '/') === FALSE) $root .= '/*';
+ foreach (array_reverse(glob("$root/*.html")) as $url) {
print "<article>";
ob_start();
include $url;
if (--$limit <= 0) break;
}
}
+
+function printtoc($root)
+{
+ print '<ul>';
+ foreach (array_reverse(glob("$root/*.html")) as $page) {
+ $title = fgets(fopen($page, 'r'));
+ $title = strip_tags($title);
+ $linkurl = preg_replace('/\.html$/', '', $page);
+ printf('<li><a href="/%s">%s <small class="date">%s</small></a></li>',
+ $linkurl, $title, shownewsdate($linkurl));
+ }
+ print "</ul>\n";
+}