Simplify rendering

No reusing necessary.
This commit is contained in:
Florine W. Dekker 2021-03-22 20:32:15 +01:00
parent d24f8fde32
commit a1a09f081f
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
2 changed files with 46 additions and 63 deletions

View File

@ -1,8 +1,5 @@
<?php
include("render.php");
$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
if ($path == "/admin") {
$_SERVER["PHP_SELF"] = $path;
include("phpliteadmin.php");
@ -20,27 +17,58 @@ $stmt->bindValue(":path", $path);
$stmt->execute();
$db->close();
if ($result) {
$target = $result["target"];
header("Location: {$target}");
exit();
}
?>
$body = "";
if ($path != "/") {
$body =
"<b>Link not found</b><br /><br />
The short URL https://fwdkr.co{$path} could not be found.<br /><br />
<br /><br />";
}
$body .=
"<b>About fwdkr.co</b><br /><br />
You've arrived at this page because you typed or linked to \"fwdkr.co\", the URL shortcut for
<a href=\"https://fwdekker.com/\">fwdekker.com</a>.<br /><br />
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Whenever you see a \"fwdkr.co\" link, you can trust that it will always take you to a website affiliated with
FWDekker.";
<title>FWDekker</title>
render_page("FWDekker", $body);
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<style>
* {
font-family: "Roboto", sans-serif;
}
a:link, a:visited, a:hover, a:active {
color: black;
}
#wrapper {
margin: auto;
padding-top: 50px;
width: 50%;
max-width: 800px;
min-width: 400px;
}
</style>
</head>
<body>
<div id="wrapper">
<h1><a href="https://fwdekker.com/">FWDekker</a></h1>
<?php
if ($path != "/") {
?>
<b>Link not found</b><br /><br />
The short URL https://fwdkr.co<?= $path ?> could not be found.<br /><br />
<br /><br />
<?php
}
?>
<b>About fwdkr.co</b><br /><br />
You've arrived at this page because you typed or linked to "fwdkr.co", the URL shortcut for
<a href="https://fwdekker.com/">fwdekker.com</a>.<br /><br />
Whenever you see a "fwdkr.co" link, you can trust that it will always take you to a website affiliated with
FWDekker.
</div>
</body>

View File

@ -1,45 +0,0 @@
<?php
/**
* Renders a simply fwdkr.co page.
*
* @param string $title the page's title, as displayed in the tab
* @param string $body the bit of text to display to the user
*/
function render_page(string $title, string $body)
{
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?= $title ?></title>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<style>
* {
font-family: "Roboto", sans-serif;
}
a:link, a:visited, a:hover, a:active {
color: black;
}
#wrapper {
margin: auto;
padding-top: 50px;
width: 50%;
max-width: 800px;
min-width: 400px;
}
</style>
</head>
<body>
<div id="wrapper">
<h1><a href="https://fwdekker.com/">FWDekker</a></h1>
<?= $body ?>
</div>
</body>
</html><?php
}