hajime/public/read.php

42 lines
997 B
PHP

<?php
// Flashii Reader
// AKA thing used to display stuff like the terms
// Include those core modules
require_once __DIR__ . '/../startup.php';
// Array with ?r= options and their corrosponding titles
$options = json_decode(file_get_contents(FII_PRV_DIR . '/readpages.json'), true);
// Path to 404 file (since my stupid ass is probably going to change the it at some point)
$path404 = './404.php';
// Check if ?r= is set
if(!isset($_GET['r'])) {
print file_get_contents($path404);
exit;
}
// Return contents of 404.php if the set option isn't in the array above
if(!array_key_exists($_GET['r'], $options)) {
print file_get_contents($path404);
exit;
}
$readPath = FII_DOC_DIR . '/' . $_GET['r'] . '.md';
// Check if content file exists
if(!is_file($readPath)) {
print file_get_contents($path404);
exit;
}
// Initialise Markdown parser
$parser = new Parsedown();
if(isset($_GET['raw'])) {
print $parser->text(file_get_contents($readPath));
exit;
}
require_once fiiSwitch_path();