8 changed files with 226 additions and 17 deletions
@ -0,0 +1,138 @@
|
||||
<?php |
||||
if (!array_key_exists('p', $_GET)) { |
||||
header('Location: /projects/#digitise'); |
||||
die(); |
||||
} |
||||
|
||||
$page = $_GET['p']; |
||||
|
||||
if (!is_readable($_SERVER['DOCUMENT_ROOT'] . '/projects/digitise/' . $page) |
||||
|| !file_exists($_SERVER['DOCUMENT_ROOT'] . '/projects/digitise/' . $page . '/pages/') |
||||
|| !file_exists($_SERVER['DOCUMENT_ROOT'] . '/projects/digitise/' . $page . '/meta.php') |
||||
) { |
||||
header('Location: /projects/#digitise'); |
||||
die(); |
||||
} |
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/projects/digitise/' . $page . '/meta.php'; |
||||
|
||||
if (!isset($title) || !isset($date) || !isset($author) ) { |
||||
header('Location: /projects/#digitise'); |
||||
die(); |
||||
} |
||||
|
||||
$chapters = array_map('basename', array_filter(glob($page . '/pages/*')) ); |
||||
sort($chapters); |
||||
|
||||
function test_int($d) { |
||||
if (is_int($d)) { |
||||
return true; |
||||
} elseif (is_string($d)) { |
||||
return ctype_digit($d); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
if(array_key_exists('n', $_GET)) { |
||||
$chapter = $_GET['n']; |
||||
if(!test_int($chapter) || $chapter >= count($chapters)) { |
||||
header('Location: /projects/digitise?p=' . $page); |
||||
die(); |
||||
} |
||||
} |
||||
?> |
||||
<!DOCTYPE html> |
||||
<html lang="en-GB"> |
||||
<head> |
||||
<?php |
||||
echo '<title>' . $title . ' - ' . $author . '</title>'; |
||||
echo '<meta property="og:type" content="book" />'; |
||||
echo '<meta property="book:author" content="'.$author.'" />'; |
||||
echo '<meta property="book:release_date" content="'.$date.'" />'; |
||||
echo '<meta property="og:url" content="https://airen-no-jikken.icu/digitise/?p=' . $page . '" />'; |
||||
|
||||
echo '<meta name="description" content="' . $title . ' - ' . $author . '" />'; |
||||
echo '<meta name="keywords" content="' . $title . ',' . $author . ',writing" />'; |
||||
|
||||
echo '<meta property="og:title" content="' . $title . ' - ' . $author . '" />'; |
||||
echo '<meta property="og:description" content="' . $title . ' - ' . $author . '" />'; |
||||
|
||||
include $_SERVER['DOCUMENT_ROOT']."/meta.php" |
||||
?> |
||||
</head> |
||||
|
||||
<body> |
||||
<div id="bg-cover"></div> |
||||
|
||||
<main class="appear"> |
||||
<section> |
||||
<?php |
||||
if (isset($chapter)) { |
||||
preg_match("/ - .*$/", $chapters[$chapter], $matches); |
||||
echo '<p><div class="font-centre font-verylarge">' . substr($matches[0], 3) . '</div></p>'; |
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/projects/digitise/' . $page . '/pages/' . $chapters[$chapter]; |
||||
|
||||
echo '<footer><div class="links">'; |
||||
|
||||
/* first */ |
||||
if($chapter == 0) { |
||||
echo '<span id="first"><<</span>'; |
||||
} else { |
||||
echo '<a id="first" href="/projects/digitise/?p='; |
||||
echo $page . '&n=0'; |
||||
echo '"><<</a>'; |
||||
} |
||||
|
||||
/* prev */ |
||||
if($chapter == 0) { |
||||
echo '<span id="prev"><</span>'; |
||||
} else { |
||||
echo '<a rel="prev" id="prev" href="/projects/digitise/?p='; |
||||
echo $page . '&n=' . ($chapter - 1); |
||||
echo '"><</a>'; |
||||
} |
||||
|
||||
/* index */ |
||||
echo '<a id="index" href="/projects/digitise/">'; |
||||
echo 'index'; |
||||
echo '</a>'; |
||||
|
||||
/* next */ |
||||
if($chapter >= (count($chapters) - 1)) { |
||||
echo '<span id="next">></span>'; |
||||
} else { |
||||
echo '<a rel="next" id="next" href="/projects/digitise/?p='; |
||||
echo $page . '&n=' . ($chapter + 1); |
||||
echo '">></a>'; |
||||
} |
||||
|
||||
/* last */ |
||||
if($chapter >= (count($chapters) - 1)) { |
||||
echo '<span id="last">>></span>'; |
||||
} else { |
||||
echo '<a id="first" href="/projects/digitise/?p='; |
||||
echo $page . '&n=' . (count($chapters) - 1); |
||||
echo '">>></a>'; |
||||
} |
||||
|
||||
echo '</div></footer>'; |
||||
} else { |
||||
echo '<p>'; |
||||
echo '<div class="font-centre font-huge">' . $title . '</div>'; |
||||
echo '<div class="font-centre font-verylarge">' . $author . '</div>'; |
||||
echo '<div class="font-centre font-large">' . $date . '</div>'; |
||||
echo '</p>'; |
||||
echo '</section>'; |
||||
echo '<section>'; |
||||
echo '<div class="font-centre font-verylarge">contents</div>'; |
||||
foreach ($chapters as $key => $value) { |
||||
preg_match("/ - .*$/", $value, $matches); |
||||
echo '<p class="font-centre"><a href="/projects/digitise/?p=' . $page . '&n=' . $key . '">' . substr($matches[0], 3) . '</a></p>'; |
||||
} |
||||
} |
||||
?> |
||||
</section> |
||||
</main> |
||||
</body> |
||||
</html> |
Loading…
Reference in new issue