Jump to content
xisto Community
Spectre

Dynamic Signatures - The Real Way To Go Forget placing index.php in a signature.png folder.

Recommended Posts

This is only a very quick tutorial, meant to complement the dynamic signature tutorials that already exist here. It's nothing new, but it was just brought to my attention that not many people seem to be aware of this method. This does not cover the actual creation of dynamic signatures, per se - but rather a better 'trick' to allow you to use dynamic signatures on forums such as this one.

 

I've noticed that most of the dynamic signature tutorials on this forum state that you must place a file index.php in a folder <filename>.png, in order to trick Invision Power Board (and other forums) into thinking that it is linking to an image - but when the user's browser attempts to access the folder image.png, it is redirected to the index.php script. However, this is very 'hackish', and in my opinion, not the best way to go about it if you have a choice.

 

If your host runs Apache and it is configured to allow it, you can create a script with any extension - such as .gif, .png, .jpg, or whatever - and use a .htaccess file to cause the script to be passed to the PHP engine, and therefore treated as a script and not an image. This means there is no 'tricking' the forum into thinking that a folder is a script and causing access to be redirected to the script contained within the folder - the image is the actual script.

 

So rather than having signature.png/index.php, you can simply have signature.png - and all the PHP code is contained within that file.

 

In order to use this method, you simply need to add file handling instructions to a .htaccess file located in the same folder as your dynamic signature script. You can name the script whatever you like, but make sure it aligns with whatever type of image the script is creating and the Content-Type header it sends (which seems to be PNG for the majority of tutorials):

 

<Files signature.png>ForceType application/x-httpd-php</Files>

And that's all there is to it. No more relying on Apache's method of automatically redirecting access of a folder to a pre-defined directory index in order to use dynamic signatures in forums and other areas that only allow images with a recognised image extension to be linked to.

Share this post


Link to post
Share on other sites

Thanks for your post explaining how to go about adding dynamic signatures without having to trick the internet browsers, this will almost certainly help those people who want to have an updating signature, logo or even banner I guess.I don't really include dynamic images on my website, at least I haven't done yet. I may, however, put a dynamic banner or something on my website in the future.Even if I don't use this method, no doubt there are other people out there who are pleased they've read this topic. Thanks for sharing :)

Share this post


Link to post
Share on other sites

Sorry ?what do you understand for dynamic? I thought that a dynamic signature was only one which changes between a few images of the same size. An animated gif to speak clearly. So I guess you?re talking about something differente because I don?t need anybody need php code to put an animated gif in his signature. ?Maybe you say something like... last.fm sigs?

Share this post


Link to post
Share on other sites

If you are making the image generator for use in a forum, there's another method similar to this if you use IPB 2.0 or higher. In the ACP there's a section defining filetypes, if you find it it lists all the allowed extentions on the forum and their mime type. You can just change the one for png from image to application/x-httpd-php and it has the same effect as what Spectre mentions. If you do this, however, you do it at your own risk. I have used this before but not for this extension.

Share this post


Link to post
Share on other sites

Sorry żwhat do you understand for dynamic? I thought that a dynamic signature was only one which changes between a few images of the same size. An animated gif to speak clearly. So I guess you´re talking about something differente because I don´t need anybody need php code to put an animated gif in his signature. żMaybe you say something like... last.fm sigs?


A dynamic image is one that can be changed, for instance a single image that displays different text each time you view it. An animated GIF is not dynamic - although the frames may change to form the animation, the image is still in itself static. A dynamic image can be created in PHP via the imaging functions provided in various libraries.

Share this post


Link to post
Share on other sites

No. Only individual files specified in the .htaccess file. You could add an Apache handler that caused all images to be passed to the PHP engine, but using the mentioned method only allows for individual files to be treated in a certain way (in this case, as a PHP script).

Share this post


Link to post
Share on other sites

theres another way to do this (how i do it at least).

The url to one of my dynamic images is http://forums.xisto.com/no_longer_exists/

anything in /1/sig.gif can be changed, i use 1 as it is my forum ID, and sig.gif just fools a forum software (or whatever else) into thinking its an image file, the sig.gif part is not actually used in the script.

To get the information from the url, i just use explode;
this is how its done

$stdata = explode("/",$_SERVER['PATH_INFO']);
then to get the '1' out of the url, i use $stdata['1'], and $stdata['2'] would be the sig.gif, that allows for truely dynamic images (where user input of some sort is required, in this case a forum ID to get a few forum stats.)

Share this post


Link to post
Share on other sites

Oh so very cool. I actualy knew how to do this, but for some people that didn't, it's a very good tutorial. You have explained it very well and made it quite simple to understand. Very well done!

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.