devshort

private self-hosted shortlink service
git clone https://git.clttr.info/devshort.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit d669f01d70ea0e6ee0cdaf0405e8aa617927d5d5
parent fedf6519d0518134d1789a0de942dee2f864e147
Author: René Wagner <rwagner@rw-net.de>
Date:   Mon, 13 Jan 2020 20:06:44 +0100

Random shortname on index (#3)

If enabled in the config, the index shows a random shortlink when called without a shortlink.

Diffstat:
Mdata/config.json | 1+
Mindex.php | 11+++++++++++
2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/data/config.json b/data/config.json @@ -5,6 +5,7 @@ "author": "The admin", "home_link": "https://github.com/flokX/devShort", "favicon": "assets/icon.png", + "random_shortlink": false, "custom_links": { "devShort wiki": "https://github.com/flokX/devShort/wiki", "devShort author": "https://github.com/flokX" diff --git a/index.php b/index.php @@ -20,6 +20,16 @@ if ($config_content["settings"]["custom_links"]) { $links_string = substr($links_string, 0, -1); } +function show_random_shortlink() { + global $config_content; + + if (!$config_content["settings"]["random_shortlink"]) { return; } + + $random_short = array_rand($config_content["shortlinks"]); + $random_url = dirname($_SERVER['PHP_SELF']) . $random_short; + echo "<h2>Explore</h2><p class=\"text-justify\">We've choosen a random shortlink for you: <a href=\"$random_url\">$random_short</a></p>"; +} + ?> <!doctype html> @@ -48,6 +58,7 @@ if ($config_content["settings"]["custom_links"]) { </nav> <h1 class="mt-5"><?php echo $config_content["settings"]["name"]; ?></h1> <p class="lead">This is a shortlink service. You need a valid shortlink to get redirected.</p> + <?php show_random_shortlink(); ?> <ul class="list-inline"> <li class="list-inline-item"><a href="https://github.com/flokX/devShort/wiki/What-is-URL-shortening%3F">What is URL shortening?</a></li> <li class="list-inline-item">-</li>