forked from Mirrors/keyoxide-web
Handle missing guide
This commit is contained in:
parent
83045e10d5
commit
ed410c6281
1 changed files with 19 additions and 9 deletions
12
index.php
12
index.php
|
@ -123,6 +123,7 @@ if(is_array($match) && is_callable($match['target'])) {
|
||||||
|
|
||||||
case 'guideId':
|
case 'guideId':
|
||||||
$id = htmlspecialchars($match['params']['id']);
|
$id = htmlspecialchars($match['params']['id']);
|
||||||
|
if (file_exists("pages/guides/$id.title.html")) {
|
||||||
$content = file_get_contents("pages/template.html");
|
$content = file_get_contents("pages/template.html");
|
||||||
$guideTitle = file_get_contents("pages/guides/$id.title.html");
|
$guideTitle = file_get_contents("pages/guides/$id.title.html");
|
||||||
$guideContent = file_get_contents("pages/guides/$id.content.html");
|
$guideContent = file_get_contents("pages/guides/$id.content.html");
|
||||||
|
@ -131,6 +132,15 @@ if(is_array($match) && is_callable($match['target'])) {
|
||||||
$content = str_replace('%CONTENT%', $guideContent, $content);
|
$content = str_replace('%CONTENT%', $guideContent, $content);
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
echo($content);
|
echo($content);
|
||||||
|
} else {
|
||||||
|
$content = file_get_contents("pages/template.html");
|
||||||
|
$pageTitle = "Guide not found";
|
||||||
|
$pageContent = "<p>404 - This guide could not be found :(</p>";
|
||||||
|
$content = str_replace('%TITLE%', $pageTitle, $content);
|
||||||
|
$content = str_replace('%CONTENT%', $pageContent, $content);
|
||||||
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
echo($content);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'util':
|
case 'util':
|
||||||
|
@ -146,7 +156,7 @@ if(is_array($match) && is_callable($match['target'])) {
|
||||||
// No route was matched
|
// No route was matched
|
||||||
$content = file_get_contents("pages/template.html");
|
$content = file_get_contents("pages/template.html");
|
||||||
$pageTitle = "404";
|
$pageTitle = "404";
|
||||||
$pageContent = "404 - This page could not be found :(";
|
$pageContent = "<p>404 - This page could not be found :(</p>";
|
||||||
$content = str_replace('%TITLE%', $pageTitle, $content);
|
$content = str_replace('%TITLE%', $pageTitle, $content);
|
||||||
$content = str_replace('%CONTENT%', $pageContent, $content);
|
$content = str_replace('%CONTENT%', $pageContent, $content);
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
|
Loading…
Reference in a new issue