. */ header("Content-Type: application/atom+xml"); function extract_description($body) { $body = explode("\n", $body); $description = strip_tags($body[0]); /* use first line of body */ return $description; } function atom_header($metadatafile) { print("\n"); print("\n"); /* get variables to use for channel metadata */ include($_SERVER['DOCUMENT_ROOT'] . $metadatafile); print("\t" . "http://" . $_SERVER['HTTP_HOST'] . "/\n"); print("\t" . $title . "\n"); print("\t" . date("c") . "\n"); /* check format is rfc3339 */ print("\t" . $author . "\n"); print("\t\n"); if (isset($copyright) && !empty($copyright)) print("\t" . $copyright . "\n"); $description = extract_description($body); if (!empty($description)) print("\t" . $description . "\n"); } function create_entry($dir, $file) { unset($title, $body, $summary, $author, $language, $category, $updated); include($_SERVER['DOCUMENT_ROOT'] . "/" . $dir . "/" . $file); print("\t\n"); print("\t\t" . "http://" . $_SERVER['HTTP_HOST'] . "/" . $dir . "/" . $file . "\n"); print("\t\t" . $title . "\n"); $updated = filemtime($dir . "/" . $file); $updated = date("c", $updated); print("\t\t" . $updated . "\n"); if (isset($author) && !empty($author)) print("\t\t" . $author . "\n"); print("\t\t\n"); $summary = extract_description($body); if (!empty($summary)) print("\t\t" . $summary . "\n"); print("\t\t
" . $body . "
\n"); $category = ereg_replace("^text", "", $dir); /* dir after text */ if (!empty($category)) print("\t\t\n"); print("\t
\n"); } function create_entries_from_dir($dir) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (!is_dir($file)) { if ($file[0] != "." && ereg(".php$", $file)) create_entry($dir, $file); } else { if ($file[0] != ".") create_entries_from_dir($dir . "/" . $file); } } closedir($handle); } } function atom_footer() { print("
\n"); } ?>