use second line of ~/.ring as destination

This commit is contained in:
Ben Harris 2021-01-13 13:17:15 -05:00
parent e9dd5e47e9
commit 9dafe487bf
1 changed files with 21 additions and 6 deletions

View File

@ -23,7 +23,14 @@ if ($action !== "index") {
die("invalid action");
}
header("Location: https://tilde.team/~$user/");
// use custom link from second line of ~/.ring
if (filesize("/home/$user/.ring") > 0) {
$ringfile = file("/home/$user/.ring", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if (count($ringfile) > 1 && $ringfile[1] !== "")
$dest = trim($ringfile[1]);
}
$location = $dest ?? "/~$user/";
header("Location: $location");
die();
}
else {
@ -54,18 +61,26 @@ else {
<p>then create a .ring file in your ~ to be added in the webring:</p>
<pre>$ touch ~/.ring</pre>
<p>the first line of ~/.ring will be displayed here as a tagline</p>
<p>the first line of ~/.ring will be displayed here as a tagline.</p>
<p>the second line of the file is used as a custom link if your webring tags are not on your homepage.</p>
<h3 id="explore">explore webring</h3>
<p><a href="?action=random">jump to random page</a></p>
<p>all members:</p>
<ul>
<?php foreach ($users as $user):
if (filesize("/home/$user/.ring") > 0)
$tagline = htmlspecialchars(trim(fgets(fopen("/home/$user/.ring", "r"))));
else unset($tagline); ?>
if (filesize("/home/$user/.ring") > 0) {
$ringfile = file("/home/$user/.ring", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$tagline = htmlspecialchars($ringfile[0]);
if (count($ringfile) > 1 && $ringfile[1] !== "")
$link = htmlspecialchars($ringfile[1]);
}
else {
unset($tagline);
unset($link);
} ?>
<li><a href="https://tilde.team/~<?=$user?>/">~<?=$user?></a><?=(isset($tagline) ? " &mdash; " : "")?><?=$tagline ?? ""?></li>
<li><a href="<?=$link ?? "/~$user/"?>">~<?=$user?></a><?=(isset($tagline) ? " &mdash; $tagline" : "")?></li>
<?php endforeach; ?>
</ul>