$page = $_GET['page'];
$place = $_GET['place'];
// check if the poem page is specified
if (!isset($page)) die("Destination page is not specified.");
if (!isset($place)) {$place = "";} else {$place = "../$place/";};
if (file_exists("$place$page.htm")) {$pagefile=file("$place$page.htm");}
else die("Page $place$page.htm does not exist.");
// output the poem page line by line
if (sizeof($pagefile) == 0) die("Pagefile is empty."); // Check if this makes sense...
$i=0;
do {echo $pagefile[$i]; $i++;} while ($i < sizeof($pagefile));
// check if the source list is specified
if (file_exists("source.txt")) {$srcfile=file("source.txt");}
else die("Source list does not exist.");
$i=0;
//read each line in the source list
do {
//take the first param as $candpage
$srcfile[$i] = ltrim($srcfile[$i]);
$currpage = substr($srcfile[$i], 0, strpos($srcfile[$i], " "));
//chop the first param and leading spaces
$srcpage = chop(ltrim(substr($srcfile[$i], strpos($srcfile[$i], " "),
strlen($srcfile[$i]) - strpos($srcfile[$i], " "))));
if ($currpage == "*") {
$default = $srcpage;
} elseif ($currpage == $page) {
$default = $srcpage;
$i = count($srcfile);
};
$i++;
} while ($i < count($srcfile));
// check if the source file is exists and if so read it
if (file_exists("../src/".$default.".htm")) {$srcfile=file("../src/$default.htm");}
else die("Source $default.htm does not exist.");
// output the source file line by line
$i=0;
do {echo $srcfile[$i]; $i++;} while ($i < sizeof($srcfile));
?>
$referer = 'index.phtml';
$ndx_array = file($referer);
$i=0; $nextexit=0; $prevpage = ''; $nextpage = '';
do {
$pos = strpos($ndx_array[$i], 'pages.phtml?');
if ($pos>0) {
/* this specific string can never be at the position 0 in a html-file,
as a quote or double quote must precede. If pos=0, the needle is not found. */
$candpage=substr($ndx_array[$i], $pos, strpos($ndx_array[$i], "\"", $pos) - $pos);
if (strpos($candpage, 'page='.$page) > 0) {$nextexit++;}
/* this specific string can never be at the position 0 in a html-file,
as pages.phtml? must precede. If strpos=0, the needle is not found. */
else { if ($nextexit == 0) {$prevpage = $candpage;}
else {$nextpage = $candpage; $nextexit++;}; };
} elseif ($nextexit == 1) {$nextexit++;
} elseif ($prevpage != '') {$prevpage = '';
}
$i++;
} while (($i