";
$blog_file = "blog.txt";
include("load_entries.php");
error_reporting(22519);
$mode = $_GET["mode"];
if (!isset($mode) || $mode == "show")
show_blog();
elseif ($mode == "new") {
new_entry_form();
}
elseif ($mode == "add") {
add_entry();
}
function new_entry_form()
{
$tags = array();
$entries = load_entries("blog.txt");
foreach ($entries as $entry) {
foreach ($entry["tags"] as $tag) {
if (!in_array($tag, $tags))
$tags[] = $tag;
}
}
sort($tags);
?>
\n";
$entries = load_entries("blog.txt");
if (isset($_GET["filter"])) {
$filter_tag = $_GET["filter"];
echo "
Posts tagged $filter_tag
X
\n";
}
$entry_num = 1;
$posts = "";
foreach ($entries as $entry) {
if ($filter_tag && !in_array($filter_tag, $entry["tags"]))
continue;
#var_dump($entry);
$title = $entry["title"];
echo generate_date_div($entry["date"]);
echo "
\n";
$link = "
$title";
$posts = $link . $posts;
$title = hop($title);
echo "
$title
\n";
echo "
\n";
foreach (explode("\n",$entry["text"]) as $line) {
if ($line == "")
continue;
if ($line[0] == ".")
echo process_dot_line($line);
else
echo "$line\n";
}
echo "
";
if ($entry["tags"]) {
echo "
";
}
echo "
\n";
echo "
\n";
$entry_num += 1;
}
echo "
My Posts
(most recent first)
$posts\n";
echo "
\n";
}
function hop($s)
{
$result = "";
for ($i = 0; $i < strlen($s); $i++) {
$result .= "";
} elseif ($line[2] == " ") { // .X ...
$rest = substr($line, 3);
return "<{$line[1]}>$rest{$line[1]}>\n";
}
elseif ($line[3] == " ") {
if ($line[1] == "r")
$float = "right";
else
$float = "left";
$src = substr($line, 4);
return "";
}
}
function generate_date_div($date)
{
$months = "JanFebMarAprMayJunJulAugSepOctNovDec";
$month = substr($months, (substr($date, 5, 2)-1)*3, 3);
$day = ltrim(substr($date, 8, 2), "0");
$year = substr($date, 0, 4);
return "