Created
May 4, 2018 13:22
-
-
Save aaronott/44874c877ac3221776647d4e41796854 to your computer and use it in GitHub Desktop.
blackhole_links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$max_num_links = 7; | |
$page = "/"; | |
if (isset($_SERVER['REQUEST_URI'])) { | |
$page = htmlentities(rtrim($_SERVER['REQUEST_URI'], "/")); | |
} | |
?> | |
<h1>Hidden links</h1> | |
<h2><?php echo $page; ?></h2> | |
<p>This is a listing of random links, you'll eventually get there.</p> | |
<ul> | |
<?php | |
$link_list_len = rand(1,$max_num_links); | |
for ($i=0; $i < $link_list_len; $i++) { | |
$rand_string = randStrGen($link_list_len); | |
$link = $page . "/" . $rand_string; | |
echo " <li><a href='$link'>$rand_string</a></li>"; | |
} | |
?> | |
</ul> | |
<?php | |
function randStrGen($len){ | |
$result = ""; | |
$chars = "abcdefghijklmnopqrstuvwxyz0123456789"; | |
$charArray = str_split($chars); | |
for($i = 0; $i < $len; $i++){ | |
$randItem = array_rand($charArray); | |
$result .= "".$charArray[$randItem]; | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment