118 lines
3.7 KiB
PHP
118 lines
3.7 KiB
PHP
<?php
|
|
include_once("links.php");
|
|
include_once("goatcounter.php");
|
|
|
|
|
|
$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
|
|
switch ($path) {
|
|
case "/favicon.ico":
|
|
header("Location: https://fwdekker.com/favicon.ico");
|
|
exit();
|
|
default:
|
|
goatcounter_record_hit($path);
|
|
break;
|
|
}
|
|
|
|
$error = false;
|
|
$target = null;
|
|
$needs_confirmation = false;
|
|
try {
|
|
$links = new Links(".links.db", "links.sql");
|
|
list($target, $needs_confirmation) = $links->getTarget($path);
|
|
} catch (Exception $exception) {
|
|
$error = true;
|
|
}
|
|
|
|
if ($target != null && !$needs_confirmation) {
|
|
header("Location: $target");
|
|
exit();
|
|
}
|
|
?>
|
|
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<meta name="author" content="Florine W. Dekker" />
|
|
<meta name="application-name" content="Florine's URL Shortener" />
|
|
<meta name="description" content="Florine's URL Shortener" />
|
|
<meta name="theme-color" content="#0033cc" />
|
|
|
|
<meta name="fwd:nav:target" content="#nav" />
|
|
<meta name="fwd:footer:target" content="#footer" />
|
|
<meta name="fwd:footer:vcs-url" content="https://git.fwdekker.com/fwdekker.com/fwdkr.co/" />
|
|
<meta name="fwd:footer:version" content="v1.5.1" />
|
|
|
|
<title>fwdkr.co</title>
|
|
|
|
<link rel="stylesheet" href="https://static.fwdekker.com/lib/template/3.x.x/template.css" />
|
|
</head>
|
|
<body>
|
|
<nav id="nav"></nav>
|
|
<main class="container"> <!-- Do not hide without JavaScript -->
|
|
<div role="document">
|
|
<section>
|
|
<header class="fwd-header">
|
|
<hgroup>
|
|
<h1><a href=".">fwdkr.co</a></h1>
|
|
<h2>Florine's personal URL shortener.</h2>
|
|
</hgroup>
|
|
</header>
|
|
|
|
<?php
|
|
if ($error) {
|
|
?>
|
|
<article class="status-card error">
|
|
<h3>Internal server error</h3>
|
|
<p>Something went wrong internally, and you could not be redirected. Please try again later.</p>
|
|
</article>
|
|
<?php
|
|
} else if ($needs_confirmation) {
|
|
?>
|
|
<article>
|
|
<h3>Confirm redirect</h3>
|
|
<p>This URL redirects to <b><?= $target ?></b>.</p>
|
|
|
|
<p><a role="button" href="<?= $target ?>">Click here to proceed</a></p>
|
|
</article>
|
|
<?php
|
|
} else {
|
|
if ($path != "/") {
|
|
?>
|
|
<article class="status-card error">
|
|
<h3>Link not found</h3>
|
|
<p>The short URL <b>https://fwdkr.co<?= $path ?></b> could not be found.</p>
|
|
</article>
|
|
<?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>
|
|
All "fwdkr.co" links have been added by me personally.
|
|
Other people cannot create links.
|
|
</p>
|
|
|
|
<h4>Example links</h4>
|
|
<ul>
|
|
<li><a href="https://fwdkr.co/cv">fwdkr.co/cv – My CV</a></li>
|
|
<li><a href="https://fwdkr.co/pgp">fwdkr.co/pgp – My PGP key</a></li>
|
|
</ul>
|
|
<?php
|
|
}
|
|
?>
|
|
</section>
|
|
<footer id="footer"></footer>
|
|
</div>
|
|
</main>
|
|
|
|
<script src="https://static.fwdekker.com/lib/template/3.x.x/template.js"></script>
|
|
</body>
|