a poorly-written personal website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

138 lines
3.8 KiB

<?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">&lt;&lt;</span>';
} else {
echo '<a id="first" href="/projects/digitise/?p=';
echo $page . '&n=0';
echo '">&lt;&lt;</a>';
}
/* prev */
if($chapter == 0) {
echo '<span id="prev">&lt;</span>';
} else {
echo '<a rel="prev" id="prev" href="/projects/digitise/?p=';
echo $page . '&n=' . ($chapter - 1);
echo '">&lt;</a>';
}
/* index */
echo '<a id="index" href="/projects/digitise/">';
echo 'index';
echo '</a>';
/* next */
if($chapter >= (count($chapters) - 1)) {
echo '<span id="next">&gt;</span>';
} else {
echo '<a rel="next" id="next" href="/projects/digitise/?p=';
echo $page . '&n=' . ($chapter + 1);
echo '">&gt;</a>';
}
/* last */
if($chapter >= (count($chapters) - 1)) {
echo '<span id="last">&gt;&gt;</span>';
} else {
echo '<a id="first" href="/projects/digitise/?p=';
echo $page . '&n=' . (count($chapters) - 1);
echo '">&gt;&gt;</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>