fwdkr.co/index.php

112 lines
3.4 KiB
PHP
Raw Normal View History

2021-03-18 18:05:49 +01:00
<?php
2021-03-22 21:13:50 +01:00
include_once("links.php");
2021-03-18 18:05:49 +01:00
$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
2021-03-22 22:25:07 +01:00
switch ($path) {
case "/admin":
$_SERVER["PHP_SELF"] = $path;
include("phpliteadmin.php");
exit();
case "/favicon.ico":
header("Location: https://fwdekker.com/favicon.ico");
exit();
2021-03-22 20:17:58 +01:00
}
$error = false;
$target = null;
$needs_confirmation = false;
try {
2021-03-22 21:13:50 +01:00
$links = new Links(".links.db", "links.sql");
list($target, $needs_confirmation) = $links->getTarget($path);
2021-03-22 21:13:50 +01:00
$links->handleVisit($path);
} catch (Exception $exception) {
$error = true;
2021-03-22 20:34:38 +01:00
}
2021-03-18 18:05:49 +01:00
if ($target != null && !$needs_confirmation) {
2021-03-18 18:05:49 +01:00
header("Location: {$target}");
exit();
}
?>
2021-03-18 18:05:49 +01:00
<!DOCTYPE html>
<html lang="en">
<head>
2021-04-21 15:35:26 +02:00
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="author" content="F.W. Dekker" />
<meta name="application-name" content="Tools" />
<meta name="description" content="FWDekker's tools" />
<meta name="theme-color" content="#0033cc" />
2021-04-21 15:35:26 +02:00
<title>fwdkr.co</title>
2021-04-21 15:35:26 +02:00
<link rel="stylesheet" href="https://static.fwdekker.com/fonts/roboto.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://static.fwdekker.com/lib/template/1.x.x/bundle.css" crossorigin="anonymous" />
</head>
<body>
<main> <!-- Do not hide without JavaScript -->
<div id="nav"></div>
<div id="contents">
<div id="header"></div>
<section class="container">
<?php
if ($error) {
?>
<h3>Internal server error</h3>
<p>Something went wrong internally, and you could not be redirected. Please try again later.</p>
<?php
} else if ($target != null && $needs_confirmation) {
?>
<h3>Confirm redirect</h3>
<p>This URL redirects to <b><?= $target ?></b>.</p>
<p><a href="<?= $target ?>">Click here to proceed</a></p>
<?php
} else {
if ($path != "/") {
?>
<h3>Link not found</h3>
<p>The short URL <b>https://fwdkr.co<?= $path ?></b> could not be found.</p>
<?php
}
?>
<h3>About fwdkr.co</h3>
<p>
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>.
</p>
<p>
Whenever you see a "fwdkr.co" link, you can trust that it will always take you to a website
affiliated with FWDekker.
</p>
<?php
}
?>
</section>
</div>
<div id="footer"></div>
</main>
<script src="https://static.fwdekker.com/lib/template/1.x.x/bundle.js" crossorigin="anonymous"></script>
<script>
// noinspection JSUnresolvedVariable
const {$, doAfterLoad, footer, header, nav, showPage, stringToHtml} = window.fwdekker;
doAfterLoad(() => {
$("#nav").appendChild(nav());
$("#header").appendChild(header({title: "fwdkr.co"}));
$("#footer").appendChild(footer({
vcsURL: "https://git.fwdekker.com/FWDekker/fwdkr.co/",
2021-04-21 19:56:32 +02:00
version: "v1.2.3"
}));
showPage();
});
</script>
</body>