Posts Tagged ‘ random

Pineapple

So its a quiet Wednesday evening, around 8.50pm and I think to myself…. something is wrong. Something is definately not right here yet I could not think what it was. It wasn’t that I had no clothes on. It wasn’t that I was listening to Peter Andre’s Mysterious Girl on infinite loop in Windows Media Player. No, it wasn’t even that I was trawling eBay for Justin Bieber posters. It finally dawned on me.

I didn’t have a pineapple.

The realisation of my lack of pineapple chilled me to the core. I called several close friends and family and told them not to be alarmed. Not to panic. Everything was going to be ok. It was so disturbing in fact, that I had to rectify the situation. Right there and then.

I jumped in my car (after putting some clothes on), and headed for the local ASDA, hoping and praying that they had pineapples. They did…

For £1!



I was in luck, so I picked up my pineapple and all was good. It was beautiful, from Costa Rica and was sweet and juicy. So the label said.

All was good until I became complacent. The pineapple took advantage. First it was little things here and there, like using my computer when I went to get some food (with even worse taste in music than me!)

but then I went for a shower and came back to find this

“Using my headphones?! Drinking my cider!?”



I’d had enough and I tried to drag the pineapple off the bed and show the business end of a fruit knife but in doing so, it tripped me over and smashed me over the head with the cider bottle and ran off.

I haven’t got a pineapple anymore.

Rotating Signatures

Ever wanted a signature for your forum accounts that changed randomly every time the page was loaded? Not sure how to do it? Well read on and be enlightened…

What you need

Well first of all, you need somewhere to host your images. They need to be in the same directory as each other, and you need control over the naming of the files (so somewhere like Imageshack won’t work).

Your host also needs to be running PHP.

Method:

As you know, to place an image in your signature, you use [IMG] [/IMG] tags around the path of the image. Essentially, what you will be doing in this case, is rather than referencing an image file directly, you reference a .php file which calls a random image for your signature. With me so far?

Ok, first, name all your image files you want in your rotation logically (use 1.jpg, 2.jpg, 3.jpg etc.), then upload them all into the same folder on the server.

Open notepad or any other basic text editor and paste in the following code, courtesy of this site on a single line:

<?php $files = glob('{*.PNG,*.png,*.JPG,*.jpg,*.GIF,*.gif}', GLOB_BRACE); readfile($files[array_rand($files)]); ?>

Save the file as “rotate.php” (remember to change the file extension from .txt to .php), and upload this file to the same directory as your images.

Now alter your signature on the forum as [IMG]http://somehost/sigs/rotate.php[/IMG] you should have a fully functioning rotating signature!

Notes:

Some forums have restrictions on the type of file you can use as a signature image. Sometimes, the .php extension is restricted, which obviously causes problems when using the above method. If this is the case, use the following method: paste the code below into a blank notepad document and save the resulting file as “rand.jpg” :

<?php

Header('Cache-Control: no-cache');
Header('Pragma: no-cache');

$dh = opendir(".");
while (false !== ($file = readdir($dh)))
{
if (preg_match('/\.jpg$/i', $file) and $file != "rand.jpg")
{
$filelist[] = $file;
}
}

srand((double)microtime()*1000000);
$picnum = rand(0, sizeof($filelist) - 1);

header("Location: " . $filelist[$picnum]);

closedir($dh);
?>

Upload this file to the same directory as your signature images. This bit of code basically selects a random jpg image from the bunch you uploaded earlier (similarly to the first method), but since the file itself is technically a jpg (you don’t want it to call itself during the random selection!), there is an exception statement included.

Again, use standard image tags to display your signature:

[IMG]http://somehost/sigs/rand.jpg[/IMG]

And Bob is indeed your Uncle. Any problems, post away.