"left");
$notice = true;
$comments = false;
if (file_exists("poems/{$_GET['poem']}.poem")) {
$comments = true;
$notice = false;
$poem = file_get_contents("poems/{$_GET['poem']}.poem");
$pos = strpos($poem,"\n");
list($title,$author,$align,$date) = explode(" - ",substr($poem,0,$pos));
$date = strtotime(trim($date,"\n\r)("));
$date = (($date > 0) ? $date : filemtime("poems/{$_GET['poem']}.poem"))*1000;
$poem = substr($poem,$pos+1);
$externalurl = false;
if (preg_match("/rel=\"external\ piece\"\ href=\"(.+)\"/",$poem,$out)) {
$externalurl = $out[1];
}
$pre = false;
if (stristr($align,"x")) {
$pre = true;
$align = str_replace("x","|",$align);
}
switch(trim($align)) {
case "__|":
$page['body align'] = "right";
break;
case "_|_":
$page['body align'] = "center";
break;
case "|__":
default:
$page['body align'] = "left";
}
$name = explode(" ",$author);
$page['title'] = "$title [$author]";
$page['heading'] = "$title
$author";
$page['body'] = nl2br($poem);
if ($pre) {
$page['body'] = "
{$page['body']}";
}
$page['extra'] = "\n\n\n\n";
} else {
$date = date('U')*1000;
$_GET['author'] = trim($_GET['author'],"/");
$dir = "poems/";
$poems = array();
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
$path = pathinfo($file);
$path['filename'] = substr($path['basename'],0,-5);
if ($path['extension'] == "poem") {
$poem = file_get_contents("poems/{$path['basename']}");
$pos = strpos($poem,"\n");
list($title,$author) = explode(" - ",substr($poem,0,$pos));
$name = explode(" ",$author);
if (strtolower(end($name)) == strtolower($_GET['author']) && !$oneauthor) {
$oneauthor = $author;
}
$poems[$author][$title] = $path['filename'];
}
}
closedir($handle);
}
ksort($poems);
$page['title'] = "Selected Poetry";
if (!empty($oneauthor)) {
$author = $oneauthor;
$page['title'] .= " by $author";
$poems = array($author => $poems[$author]);
}
$page['heading'] = "{$page['title']}";
$page['body'] = "