Skip to content

Instantly share code, notes, and snippets.

@danomanion
Forked from aaronott/index.txt
Created May 4, 2018 13:24
Show Gist options
  • Save danomanion/00fec2980c3745e8164c8a926ff55dca to your computer and use it in GitHub Desktop.
Save danomanion/00fec2980c3745e8164c8a926ff55dca to your computer and use it in GitHub Desktop.
blackhole_links
<?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