Discovery Gaming Community
Rotating banner signature - Printable Version

+- Discovery Gaming Community (https://discoverygc.com/forums)
+-- Forum: The Community (https://discoverygc.com/forums/forumdisplay.php?fid=4)
+--- Forum: Media Center (https://discoverygc.com/forums/forumdisplay.php?fid=18)
+--- Thread: Rotating banner signature (/showthread.php?tid=19614)

Pages: 1 2 3


Rotating banner signature - Cyberanson - 04-23-2009

Because I can't stand services like clintonio.com, I decided to create my own rotating signature set. Here's the way it's done:

1. prerequisites
For this rotating signature you need:
  1. some webspace
  2. an enabled mod_rewrite Apache module
  3. a working PHP interpreter
2. the code
All the things which follow can be accomplished with an IDE of your choice or simply Notepad.

Copy this code into a fresh file:
Code:
<IfModule mod_rewrite.c>
&nbsp;&nbsp;&nbsp;&nbsp;RewriteEngine on

&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule ^image\.png$ image.php
&nbsp;&nbsp;&nbsp;&nbsp;
</IfModule>
This means, that your webserver will change all requests to http://mydomain.com/image.png to http://mydomain.com/image.php. This is needed, because IPB only handles image file types in signatures. You could also choose .jpg or .gif.

Save this file as .htaccess.

Next one. Create a new file and put this in it:
Code:
<?php

foreach (glob("*.png") as $filename) {
&nbsp;&nbsp;&nbsp;&nbsp;$img[] = $filename;
}

header("Content-Type: image/png");
readfile($img[rand(0,sizeof($img)-1)]);

?>
Explanation: $img is an array of image file names which is located in the current directory. Upload as many files as you wish. The only important point: the filetype has to match the given value.

The next line has to be changed, according to your images. If you prefer jpg, use this:
Code:
header("Content-Type: image/jpg");
The system should be clear.

Save this file as image.php.

Now load both files into a directory of your choice on your webserver. Copy as many image files of your preferred type into the same directory.

After you finished, change your signature to something like this:
Code:
http://mydomain.com/directory/image.png

And voila... you should have a beautifuly rotating signature.

Saving traffic
In order to use external URLs for your images, just use this code in your image.php:
Code:
<?php

$file = array(
&nbsp;&nbsp;&nbsp;&nbsp;"<put image url here>",
&nbsp;&nbsp;&nbsp;&nbsp;"<put image url here>"
);

header("Content-Type: image/png");
readfile($file[rand(0,sizeof($file)-1)]);

?>

Add as many URLs as you like, works the same and saves your server traffic.

If you have questions or problems... just ask here.


Rotating banner signature - Grimly - 04-23-2009

nice:D
Thanks for the tip


Rotating banner signature - Cyberanson - 04-23-2009

If you want the easier method, I could also provide the files, so the only thing you have to do would be to upload them to your webspace and adding images.


Rotating banner signature - Weedalot - 04-23-2009

cool, so where do you set how much seconds it will take for it to switch?


Rotating banner signature - Patriot - 04-23-2009

' Wrote:cool, so where do you set how much seconds it will take for it to switch?



Thats a rotating signature by refreshing page.




Rotating banner signature - Cyberanson - 04-23-2009

Patriot is right here. As this is a server-side PHP script, you have to refresh the page. Reload the picture without refreshing the page would require JavaScript, which isn't possible for this purpose.


Rotating banner signature - Weedalot - 04-23-2009

' Wrote:Patriot is right here. As this is a server-side PHP script, you have to refresh the page. Reload the picture without refreshing the page would require JavaScript, which isn't possible for this purpose.
oh i know that. i mean something else.... When you refresh it will it always change to the next one... In that site you mention it does not do it every time i refresh the page.


Rotating banner signature - Cyberanson - 04-23-2009

That's because I only have 3 images, yet. The rand() function pics one. So you have currently a 33,33% chance to get a certain picture.


Rotating banner signature - Recoil9000 - 05-05-2009

where might i get the webspace to host the pictures?


Rotating banner signature - Cyberanson - 05-05-2009

Recoil, I sent you a PM about that.

To all others: I could provide you a subdomain on one of my servers, where you can store up to 10MB of pictures and access them via the random signature script.
Additionaly I could offer you to set up the system so that all you have to do is upload your pictures...

I would demand a reasonable amount of virtual money for this service.