PDA

View Full Version : Request: Signature Script


Mark
07-10-2005, 06:24 AM
I could use a signature script that portrays a random picture from a set of 5 jpgs upon every refreshing of a webpage. See my box in my signature now? I want to be able to have a red version of that if I refreshed. Or blue, or green, etc. I have the 5 jpgs, I just need the script that changes the picture randomly upon refreshing. I'd search for it myself but I don't know where to look and Googling is futile.

Thanks in advance.

Minus Xero
07-10-2005, 06:27 AM
Originally posted by Mark@Jul 9 2005, 11:24 PM
I could use a signature script that portrays a random picture from a set of 5 jpgs upon every refreshing of a webpage. See my box in my signature now? I want to be able to have a red version of that if I refreshed. Or blue, or green, etc. I have the 5 jpgs, I just need the script that changes the picture randomly upon refreshing. I'd search for it myself but I don't know where to look and Googling is futile.

Thanks in advance.
I'd like that too, but also that links the avatar to the signature, so that the two pictures are linked on refresh. Like when you refresh, you get avatar a and sig a, and then refresh again and get avatar c and sig c and so on and so forth.

Cale.
07-10-2005, 07:05 AM
Note: If you haven't already, you will need to enable .php as a valid image file for signatures.


Configuration:
Copy and paste the php code into notepad
Go into the code and find this:
$source = "./"
Make a folder on your host called "random_sigs", or whatever you want it to be called, then inside that folder make a folder named "sigs" set $source to "sigs". So the code will then look like this
$source = "./sigs"
Save the script as "random.php" and upload it (to a host that supports php) to your "/random_sigs" folder (or whatever you called it).
Then upload all your sigs to the "/sigs" folder
Back on the forums use
http://myurl.com/myfolder/random.php
For using the randomizer.



<?php

// seed with microseconds - nabbed straight off php.net
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
mt_srand(make_seed());

$source = "./"; //In which folder are the sigs located? Type "./" for the same folder as this file.

//-----------Don't touch below this line-----------//

$handle=opendir($source);
$i = 0;
$sigs = array();
while (false!==($file = readdir($handle)))
{
if ($file != "." && $file != ".." && eregi ( "(gif|png|jpg)" , $file ) )
{
$sigs[$i] = "$file";
$i = $i + 1;
}
}

closedir($handle);

$sig = $sigs[mt_rand(0, count($sigs)-1)];

@header ("Location: $source/$sig");

?>

Chris(tmas)
07-10-2005, 11:23 AM
riiiiight. im confused :lol:

Cale.
07-10-2005, 11:47 AM
Originally posted by Chris@Jul 10 2005, 10:23 AM
riiiiight. im confused :lol:
I'll try and make it easier to understand. Just a tic.

Edit: Ok i edited it. If you still can't understand tell me what you can't understand and hopefully I can explain.

Chris(tmas)
07-10-2005, 12:21 PM
Okay. I think I got it.

Edit: Yeah.. I got it, but they havent allowed php yet :lol:

Sylar
07-10-2005, 07:58 PM
Alright, I'm having compications with this. I'm not going to use it on this forum, but anyway...I did what you said but the .php file isn't showing up as an image but as the code itself...do you know what i did wrong?

Tomi
07-10-2005, 09:56 PM
You mean like I had for my PS3 set?

I'll try and get you the code for it...

-edit---
sig.jpg<?php
$dh = opendir(".");
while (false !== ($file = readdir($dh)))
{
if (preg_match('/\.jpg$/i', $file) and $file != "avatar.jpg") // sanning for .jpg files only and stopping avatar.jpg being loaded (you will run into errors if this isnt here)
{
$filelist[] = $file;
}
}

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

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

closedir($dh);
?>

.htaccessAddType application/x-httpd-php .jpg

Just put those two files in a directory together with .jpg files only. I don't think other filetypes work, but if they do, don't shoot me.

Hope this helped. :)

Sylar
07-10-2005, 10:20 PM
Ok so do I have to save those codes in notepad and then load them to my host? What do I save them as?

EDIT: Do I save them as sig.jpg and .htaccess?

Tomi
07-11-2005, 12:30 AM
^ Yep.

Sylar
07-11-2005, 12:50 AM
Alright. I think my host is the problem then, because it's not working.

Chris(tmas)
07-11-2005, 12:57 AM
Mine wasnt working either, but my host accepts everything

Sylar
07-11-2005, 12:59 AM
Originally posted by Chris@Jul 10 2005, 07:57 PM
Mine wasnt working either, but my host accepts everything
Im using Angelfire and it's not working but Angelfire accepts all of this.

Chris(tmas)
07-11-2005, 01:08 AM
Well Tomi. Looks like you got explaining to do! :angry: :P

Minus Xero
07-11-2005, 01:33 AM
Not just about it not working... but a big old WTF in general. :lol:

Sorry, I am t3h n00b in PHP.

Tomi
07-11-2005, 05:30 AM
If it's not working, then get a different host that allows PHP and .htaccess files. :P

I'm pretty sure lycos.co.uk allows it. I can't remember thou.

Sylar
07-11-2005, 05:46 AM
Originally posted by Tomi@Jul 11 2005, 12:30 AM
If it's not working, then get a different host that allows PHP and .htaccess files. :P

I'm pretty sure lycos.co.uk allows it. I can't remember thou.
:P

Are we going to have to do what Skywalker said ALONG with what you said or just what you said?

Cale.
07-11-2005, 06:25 AM
If Tomi's doesn't work, feel free to use my un-1337 script :whistle:

:lol:

Tomi
07-11-2005, 06:45 AM
Originally posted by Skywalker@Jul 11 2005, 12:25 AM
If Tomi's doesn't work, feel free to use my un-1337 script :whistle:

:lol:
Funny thing is, it's not my script. :P I just found it on a forum I go on. ;)