Random images for signature

General forum for the discussion/showing off of art/sprites you have made. Preferably Pokémon-based, but it doesn't have to be!

Moderator: Forum staff

Post Reply
User avatar
Pikachu3828
Code Monkey
Code Monkey
Posts: 4829
Joined: Tue 27 May, 2003 4:42 pm
Pokémon D/P Friend code: 0
Location: UK
Contact:

Random images for signature

Post by Pikachu3828 »

People have been asking me if I know of any random image scripts they could use in their signatures. Here's one. Firstly, here is the code. Copy and paste this into Notepad or your favourite text editing software and save it as "randsig" with a .php extension (To do this in Notepad simply select the filetype as "All files" and save it with the name "randsig.php")

CREDIT: http://photomatt.net/scripts/randomimage

Code: Select all

<?php
/*
    By Matt Mullenweg > http://photomatt.net
    Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
    Latest version always at:
    http://photomatt.net/scripts/randomimage
*/

// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = '';

// Space seperated list of extensions, you probably won't have to change this.
$exts = 'jpg jpeg png gif';

$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';
$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
    foreach($exts as $ext) { // for each extension check the extension
        if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
            $files[] = $file; // it's good
            ++$i;
            }
        }
    }
closedir($handle); // We're not using it anymore
mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along

header('Location: '.$folder.$files[$rand]); // Voila!
?>
The script is annotated so you should have no problems working out what to do but if you do post here.

Upload this script and then add this to your signature:

Code: Select all

[img]http://www.yoursite.com/randsig.php[/img]
And voila, you should now have a random signature!

EDIT : Changed script, my bad. My one didn't work
Last edited by Pikachu3828 on Thu 11 Aug, 2005 5:34 pm, edited 4 times in total.

Favourites: :Gyarados: :Tyranitar: :Zangoose: :Drapion: Image

Red: 151/151 | Gold: 247/251 | Fire Red: 376/386 | Heart Gold: 493/493 | Black: 649/649

Please do not PM me about bugs on the Adoption Agency. Instead, make a topic in the bugs forum.

User avatar
Powerchu
Moderator
Moderator
Posts: 1396
Joined: Wed 31 Dec, 2003 10:23 pm
Location: alone
Contact:

Post by Powerchu »

I am having trouble yes here is what I have it edited too

Code: Select all

<?php
/*
Random images for your signature by Pikachu3828
Very basic but it doesn't need to be complex
*/

$pics = array('http://pichusrpg.1colony.com/images/pichu1.gif','http://pichusrpg.1colony.com/images/pichu2.gif',
'http://pichusrpg.1colony.com/images/powerchu.gif','http://pichusrpg.1colony.com/images/powerchu2.gif',
'http://pichusrpg.1colony.com/images/tpcbutton1.gif');

/*
Above is an array. If you wish to add a picture, add ",'pic4.gif'" onto the end of it
after 'pic3.gif' but before ");" (minus double quotes in both instances)
Currently for this to work the images must be in the same directory as this script but
it works like HTML and you can make the images point anywhere like 'www.pokemon.com/pic1.gif' etc
*/

// DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING
$size = count($pics);
$randpic = rand(0,$size);

print "<img src=\"".$pics[$randpic]."\">";
?>
it might just be the host but I wanna make sure first before I try on my angelfire acc.
Image

Friend Code: 2466-7146-9497 (Ledyba, Illumise, Heracross)

User avatar
Pikachu3828
Code Monkey
Code Monkey
Posts: 4829
Joined: Tue 27 May, 2003 4:42 pm
Pokémon D/P Friend code: 0
Location: UK
Contact:

Post by Pikachu3828 »

Sorry, my bad, I got totally the wrong end of the stick, I'm only used to displaying images with PHP, not through it, so I got someone else's script for you all to use.

Favourites: :Gyarados: :Tyranitar: :Zangoose: :Drapion: Image

Red: 151/151 | Gold: 247/251 | Fire Red: 376/386 | Heart Gold: 493/493 | Black: 649/649

Please do not PM me about bugs on the Adoption Agency. Instead, make a topic in the bugs forum.

User avatar
Powerchu
Moderator
Moderator
Posts: 1396
Joined: Wed 31 Dec, 2003 10:23 pm
Location: alone
Contact:

Post by Powerchu »

I can't get it to work. which parts if any do we need to edit?
Image

Friend Code: 2466-7146-9497 (Ledyba, Illumise, Heracross)

User avatar
stevie_2
Got Boulder Badge!
Got Boulder Badge!
Posts: 153
Joined: Thu 25 Nov, 2004 5:21 pm
Pokémon D/P Friend code: 0
Location: England

Post by stevie_2 »

What's a system path?
Image
Want a piece of graphics like that in your signature? Then go request it!
Support the Pika Club! Link to us in your signatures on other websites!

User avatar
Pikachu3828
Code Monkey
Code Monkey
Posts: 4829
Joined: Tue 27 May, 2003 4:42 pm
Pokémon D/P Friend code: 0
Location: UK
Contact:

Post by Pikachu3828 »

Try this one:

Code: Select all

<?php
/*
    By Matt Mullenweg > http://photomatt.net
    Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
    Latest version always at:
    http://photomatt.net/scripts/randomimage
*/

// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = '';

// Space seperated list of extensions, you probably won't have to change this.
$exts = 'jpg jpeg png gif';

$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';
$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
    foreach($exts as $ext) { // for each extension check the extension
        if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
            $files[] = $file; // it's good
            ++$i;
            }
        }
    }
closedir($handle); // We're not using it anymore
mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along

header('Location: '.$folder.$files[$rand]); // Voila!
?>
Just edit
$folder='';
To the images directory, like $folder= 'http://www.thepikaclub.com/images/'

http://photomatt.net/scripts/randomimage

Favourites: :Gyarados: :Tyranitar: :Zangoose: :Drapion: Image

Red: 151/151 | Gold: 247/251 | Fire Red: 376/386 | Heart Gold: 493/493 | Black: 649/649

Please do not PM me about bugs on the Adoption Agency. Instead, make a topic in the bugs forum.

User avatar
stevie_2
Got Boulder Badge!
Got Boulder Badge!
Posts: 153
Joined: Thu 25 Nov, 2004 5:21 pm
Pokémon D/P Friend code: 0
Location: England

Post by stevie_2 »

Cheers bud i think got it working, we owe you, big :wink:
You don't have to change anything if you upload the file into the same directory directory as where the images are!

Time to get working on sigs :-D

EDIT
Ha, just got it working on the avatar thing too :lol:
Image
Want a piece of graphics like that in your signature? Then go request it!
Support the Pika Club! Link to us in your signatures on other websites!

User avatar
Pikachu3828
Code Monkey
Code Monkey
Posts: 4829
Joined: Tue 27 May, 2003 4:42 pm
Pokémon D/P Friend code: 0
Location: UK
Contact:

Post by Pikachu3828 »

Nice, your signature(s) and avatar(s) look really good :thumbsup: :smile:

Favourites: :Gyarados: :Tyranitar: :Zangoose: :Drapion: Image

Red: 151/151 | Gold: 247/251 | Fire Red: 376/386 | Heart Gold: 493/493 | Black: 649/649

Please do not PM me about bugs on the Adoption Agency. Instead, make a topic in the bugs forum.

User avatar
Pikachu90000
Pokémon master
Pokémon master
Posts: 13625
Joined: Sun 14 Sep, 2003 12:20 am
Pokémon D/P Friend code: 0
Location: The People's Democratic Sovereign Elitist Commonwealth of the Union of Cascadia
Contact:

Post by Pikachu90000 »

Let me try it first on a post...
Image
Image
Have questions regarding about The Pika Club? The Pika Club Guide and FAQ

User avatar
PD Wooper
Saffron City
Saffron City
Posts: 586
Joined: Tue 08 Mar, 2005 8:43 pm
Pokémon D/P Friend code: 0
Location: Essex, England

Post by PD Wooper »

Code: Select all

<?php
header("Content-type: image/png");
$image = imagecreatefrompng("sig" . rand(1,6) . ".png");
imagepng($image);
?>
Does the trick for me ;3
Of course this will fetch sig1.png or whatever from the same directory.
Very short and simple *hic*
Hallo n_~

User avatar
Prof. Blake
First Pokémon!
Posts: 18
Joined: Fri 11 Aug, 2006 5:00 am

Post by Prof. Blake »

what do you meen upload the script how do i do that and do i get to choose what could posably come up? and if i can how?
Image

Post Reply