function threeDigits($num)
{
$num = "" . $num;
while (strlen($num) < 3)
$num = "0" . $num;
return $num;
}
$chapter = $_GET["chapter"];
$pagecount[0] = 4;
$pagecount[1] = 11;
$pagecount[2] = 10;
$pagecount[3] = 10;
$pagecount[4] = 12;
$pagecount[5] = 10;
$pagecount[6] = 16;
$pagecount[7] = 13;
$chapters = 7;
if ($chapter == "")
$chapter = -3;
$chapurl = "/other/obsolete/" . threeDigits($chapter) . "/";
if ($chapter >= 0 && $chapter <= $chapters)
$pagemax = $pagecount[$chapter] + 1;
else
$pagemax = 0;
$lb = "
";
$tab = " ";
$stdtab = $tab . $tab;
$stdtab2 = $stdtab . $tab;
$stdtab3 = $stdtab2 . $tab;
$stdtab4 = $stdtab3 . $tab;
$stdtab5 = $stdtab4 . $tab;
$stdtab6 = $stdtab5 . $tab;
$diamond = "◆";
$chapterlist = "";
for ($c = 0; $c <= $chapters; $c++)
{
$title = "Chapter $c";
if ($c == 0)
$title = "Prologue";
if ($c == $chapter)
$title = "$title";
$chapterlist .= ($c > 0? $stdtab5 : "") . "$title
$lb";
}
$subtitle = "";
$summary = "Summary";
$characters = "Characters";
$nextpagecontent = $lb;
$prevpagecontent = $lb;
if ($chapter == -3) // Top
{
$nextchapter = "?chapter=0";
$content = "$lb";
$nextpagecontent = "window.location.href = \"$nextchapter\";$lb";
}
else if ($chapter == -2) // Characters
{
$characters = "$characters";
$nextchapter = "/other/obsolete/";
$content = "
$lb";
$nextpagecontent = "window.location.href = \"$nextchapter\";$lb";
}
else if ($chapter == -1) // Summary
{
$summary = "$summary";
$nextchapter = "/other/obsolete/";
$content = "
$lb";
$nextpagecontent = "window.location.href = \"$nextchapter\";$lb";
}
else if ($chapter >= 0 && $chapter <= $chapters) // Real chapter
{
$subtitle = ": Chapter $chapter";
if ($chapter == 0)
$subtitle = ": Prologue";
$content = "
$lb";
for ($p = 2; $p <= $pagecount[$chapter]; $p++)
{
$pageurl = threeDigits($p) . ".png";
$content .= $stdtab4 . "
$lb";
}
$content .= $stdtab4 . "
$lb";
$content .= $stdtab4 . "
$lb"; for ($p = 1; $p <= $pagecount[$chapter]; $p++) { if ($p == 1) $content .= $stdtab6 . "$p$lb"; else $content .= $stdtab6 . "$p$lb"; } $content .= $stdtab5 . "
$lb" . $stdtab4 . "