Skip to content

Instantly share code, notes, and snippets.

@akosnikhazy
Created March 29, 2016 19:08
Show Gist options
  • Save akosnikhazy/4d22508ef936153f5ce1d8b6463f864e to your computer and use it in GitHub Desktop.
Save akosnikhazy/4d22508ef936153f5ce1d8b6463f864e to your computer and use it in GitHub Desktop.
Get a random page from Homestuck web comic
<?php
/*
Created by Ákos Nikházy
I use this in this app: http://ltats.nikhazy-dizajn.hu/
All Homestuck images are gifs numbered between 001901 and 009875 (to date). Sometimes the pages are flash animations or HTML5 games
*/
do
{//do this while the random number is not an image
$rand = rand(1901,11000);//The first Homestuck page is 1901. At this point I am sure there will be less than 11000 pages of Homestuck
$imageMaybe = getimagesize('http://www.mspaintadventures.com/storyfiles/hs2/0'.$rand.'.gif'); //I test if its image by this
$notImage = (!is_array($imageMaybe))?true:false;
}
while($notImage);
$imageNumber = str_pad($rand, 5, "0", STR_PAD_LEFT); //we need this format: 001234
?>
<img src="http://www.mspaintadventures.com/storyfiles/hs2/<?php echo $imageNumber ?>.gif">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment