summaryrefslogtreecommitdiff
path: root/www/puush.php
blob: 6f754a35a16401b8bff7672826842a181ca709b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!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 "puu.sh" file!</h1>
<?php

$count = 0;

function get_image($count){

        $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 = "";
	$string = "";

        for ($i=0;$i<4;$i++){
                $index = mt_rand(0,$length-1);
                $id = "$id".$puush_array[$index];
        }

	if(fopen("https://puu.sh/" . $id, "r")){
		echo "<a href='https://puu.sh/" . $id . "'><img src='https://puu.sh/" .$id . "' alt='" . $id ."' ></a>";
		return $count;
	} else {
		$count = $count + 1;
		if($count < 50){
			$count = get_image($count);
		} else {
			echo "We tried for " . $count . " times. Now is enough. <br><br>";
			echo "<a href='/puush'>Try again</a>";
			exit;
		}
	}
	return $count;
}

$count = get_image($count);

echo "
<br><br>

<p>We tried for " . $count . " times.</p>

<br>
<a href='/puush'>Try again</a>

</center>
";
?>