Jump to content
xisto Community
snlildude87

How To Make A Sig Rotator for people with multiple sigs

Recommended Posts

Today, I will show you how to make a sig rotator similar to mine (refresh a page with my post, and you will see a different sig each time). We will use the sig rotator to display random sigs here at Xisto.

Create a folder called sig.png

Actually, the folder can be called anything, but since we will be using the rotator here, it has to be called sig.png because Invision Power Board may not allow weird extensions. You can replace png in sig.png with any valid image extensions such as gif of jpg.

 

Create a file called index.php

If you need help renaming a file to .php, post below. In the file, copy and paste the following code

index.php:

<?phpHeader("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");Header("Pragma: no-cache");Header("Content-Type: image/gif");	srand((double)microtime()*1000000);	$randnum = rand(0,1);	if($randnum == 0)	{  readfile("http://img325.imageshack.us/img325/5475/hulunes7rn.jpg");	}	else if($randnum == 1)	{  readfile("http://img325.imageshack.us/img325/2240/jnguyen5az.jpg");	}?>
This is very simple code, but if you don't understand, I'll explain everything later.

Upload sig.png (or whatever you named it) to public_html in your web space.

Go to http://forums.xisto.com/no_longer_exists/

In the big text box, add this BBCode:

[img]http://yourdomain.com/sig.png[/img]
Replace yourdomain.com to your domain. Mine is sang.trap17.com

Replace sig.png to whatever you named the folder.

Code Explanation

The first four lines will make sure that the browser does not cache sigs. If caching is enabled, then the image in the cache will be displayed instead of a random one.

srand((double)microtime()*1000000);
This one sets up a random seed. I don't know a lot of PHP, but I know that the higher the number (1000000), the more random it will be. Correct me if I'm wrong on this.

$randnum = rand(0,1);
Once our seed is set up, we have to pick a random number from 0 to 1. The random number will be stored in the variable $randnum. The number "1" depends on how many sigs you have. If you have 3 sigs, then you will put a "2" instead of the "1" (0, 1, 2). If you have 5 sigs, then you would put a 4 instead of the 1 (0, 1, 2, 3, 4).

if($randnum == 0)	{  readfile("http://img325.imageshack.us/img325/5475/hulunes7rn.jpg");	}
This basically says that if $randnum (our random number) is 0, then it will display the image at http://forums.xisto.com/no_longer_exists/. Replace http://forums.xisto.com/no_longer_exists/ with the URL of your image.

else if($randnum == 1)	{  readfile("http://img325.imageshack.us/img325/2240/jnguyen5az.jpg");	}
If $randnum is 1, then it will display http://forums.xisto.com/no_longer_exists/. Change http://forums.xisto.com/no_longer_exists/ to the URL of your 2nd image. If you have more images

else if($randnum == 2)	{  readfile("http://img325.imageshack.us/img325/2240/blah.jpg");	}
If you have more images, then add 1 to the the number after "== " and add 1 to the last number at $randnum = rand(0,1);.

Want Something Shorter?

Go here: http://forums.xisto.com/topic/24925-how-to-make-a-sig-rotator-for-people-with-multiple-sigs/page-4#entry189391

 

That's it! Post any questions below!

Edited by snlildude87 (see edit history)

Share this post


Link to post
Share on other sites

have an errorParse error: parse error, unexpected T_ELSE in /home/saint/public_html/sig.png/index.php on line 20

Share this post


Link to post
Share on other sites

yeah i had a funny feeling it was something like that but the else if statements threw me off a bit thanks again

Share this post


Link to post
Share on other sites

yeah i had a funny feeling it was something like that but the else if statements threw me off a bit thanks again

164483[/snapback]

You're welcome. If you add more sigs, copy
else if($randnum == 55){readfile("http://i14.photobucket.com/albums/a305/saint-michael/sig1-52.jpg");}
and append it. Then on the new one, instead of 55, put 56. Also, change $randnum = rand(0,54); to $randnum = rand(0,55);

 

If that doesn't work, it must be my explanation, so post your problem here, and I'll solve it.

Share this post


Link to post
Share on other sites

what confused me was the (0,1,2,3,4) and the else if statement, hmm should use the script that you gave me trimmed down a bit and just note the 2 changes that have to be made to get the script running1300 POSTS!!!!! WOOOHOOOHOOO

Share this post


Link to post
Share on other sites

what confused me was the (0,1,2,3,4) and the else if statement,  hmm should use the script that you gave me trimmed down a bit  and  just note the 2 changes that have to be made to get the script running

 

1300 POSTS!!!!! WOOOHOOOHOOO

164512[/snapback]

The (0,1,2,3,4) was there for clarification. I was trying to show why it was $randnum = rand(0,4) instead of $randnum = rand(0, 5) for 5 sigs.

 

Actually, dude, it wasn't just two changes...it was basically every other line.

 

 

By the way, I got 1300 posts a long time ago, too. ;)

Share this post


Link to post
Share on other sites

array can trim off more nice look, isnt it?

164660[/snapback]

I kinda didn't use an array....

 

 

so if I don;t want to do the processing through the internet how do I use absolute paths?

 

would it be ./sig.png/image.jpg ?

164666[/snapback]

I am using absolute paths. The one you're talking about is relative paths. ;)

 

If you're going to store the sigs in a folder called sigs inside sig.png, then it use be something like

readfile("sigs/image.jpg");
If going to store the index.php file and all the sigs in sig.png, then it would be
readfile("image.jpg");
You actually don't need the ./ at the beginning.

 

Hope that answers your question!

Share this post


Link to post
Share on other sites

Ahm Saint_Michael, wouldn't it be easier to do it this way:

<?phpHeader("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");Header("Pragma: no-cache");Header("Content-Type: image/gif");srand((double)microtime()*1000000);readfile("http://forums.xisto.com/no_longer_exists/;

I don't now your full purpose but I do think this one's easier ;)

Notice from Klass:
You need to use code tags when typing code.

Edited by Klass (see edit history)

Share this post


Link to post
Share on other sites

Ahm Saint_Michael, wouldn't it be easier to do it this way:

 



<?phpHeader("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");Header("Pragma: no-cache");Header("Content-Type: image/gif");srand((double)microtime()*1000000);readfile("saint-michael.trap17.com/images/sig1;;?>

I don't now your full purpose but I do think this one's easier :)

 

Notice from Klass:
You need to use code tags when typing code.

164771[/snapback]

 


Yeah it would actually. Thanks for posting an alternative! I would use a better naming techniques for my sigs, but I don't want to waste my bandwidth.


Share this post


Link to post
Share on other sites

but your missing something in the coding, yeah you set up the process for the image to be shown but how would you retrieve it. out of this line of the code ".rand(0,54)+2"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.