summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot2014-02-27 18:31:20 +0100
committerroot2014-02-27 18:31:20 +0100
commit17ed2c68a4b019aa8640682f55dc1430a862ccb1 (patch)
treeedc1627563b7fa989d40957defb6bc76e28bea6c
parenta5fcc7762c03a611ed6633c94f13dc6e59aad65f (diff)
downloadrandom-17ed2c68a4b019aa8640682f55dc1430a862ccb1.tar.gz
ready
-rw-r--r--blob/test3
-rw-r--r--www/puush.php37
2 files changed, 23 insertions, 17 deletions
diff --git a/blob/test b/blob/test
deleted file mode 100644
index fbaa68e..0000000
--- a/blob/test
+++ /dev/null
@@ -1,3 +0,0 @@
-This is a test file.
-Just an example.
-Do not bother to read this.
diff --git a/www/puush.php b/www/puush.php
index 43cc766..069750e 100644
--- a/www/puush.php
+++ b/www/puush.php
@@ -5,10 +5,12 @@
</head>
<body>
<center>
-<h1>A random puush image!</h1>
+<h1>A random "puu.sh" file!</h1>
<?php
-function get_image(){
+$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",
@@ -18,7 +20,7 @@ function get_image(){
$length = count($puush_array);
$id = "";
- $count = 0;
+ $string = "";
for ($i=0;$i<4;$i++){
$index = mt_rand(0,$length-1);
@@ -26,24 +28,31 @@ function get_image(){
}
if(fopen("https://puu.sh/" . $id, "r")){
- $string = $count . "|" . $id;
- return $string;
+ echo "<a href='https://puu.sh/" . $id . "'><img src='https://puu.sh/" .$id . "' alt='" . $id ."' ></a>";
+ return $count;
} else {
- $count++;
- get_image();
+ $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;
+ }
}
}
-$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>
+$count = get_image($count);
+echo "
<br><br>
-<p>We tried for <? echo $count; ?> times.</p>
+<p>We tried for " . $count . " times.</p>
+
+<br>
+<a href='/puush'>Try again</a>
</center>
+";
+?>