diff options
| author | Horus3 | 2014-02-27 17:49:24 +0100 |
|---|---|---|
| committer | Horus3 | 2014-02-27 17:49:24 +0100 |
| commit | d3b1fa54a9a55bfb8e9f70ca82bc1b1e731c26a2 (patch) | |
| tree | 6cd9b20f4510a86b6a727e530715979eed72ee64 | |
| parent | 71da2f74b621c838f835fd04d6f2d737bfceb6b0 (diff) | |
| download | random-d3b1fa54a9a55bfb8e9f70ca82bc1b1e731c26a2.tar.gz | |
puush randomizer
| -rw-r--r-- | www/puush.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/www/puush.php b/www/puush.php new file mode 100644 index 0000000..43cc766 --- /dev/null +++ b/www/puush.php @@ -0,0 +1,49 @@ +<!Doctype html> +<head> +<title>Random Youtube Video</title> +<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> +</head> +<body> +<center> +<h1>A random puush image!</h1> +<?php + +function get_image(){ + + $puush_array = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", + "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", + "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", + "5", "6", "7", "8", "9" ); + + $length = count($puush_array); + + $id = ""; + $count = 0; + + for ($i=0;$i<4;$i++){ + $index = mt_rand(0,$length-1); + $id = "$id".$puush_array[$index]; + } + + if(fopen("https://puu.sh/" . $id, "r")){ + $string = $count . "|" . $id; + return $string; + } else { + $count++; + get_image(); + } + +} + +$result = get_image(); +$count = preg_replace("/|(.*)$/", "", $string); +$image = preg_replace("/^(.*)|/", "", $string); +echo +?> +<a href="https://puu.sh/<? echo $image; ?>"><img src="https://puu.sh/<? echo $image; ?>" alt="<? echo $image; ?>></a> + +<br><br> + +<p>We tried for <? echo $count; ?> times.</p> + +</center> |
