How to create a dynamic signature?

Filed under:  Google about "PHP"

Please, use the following PURL, if you wish to link to this guide:

http://purl.oclc.org/phpmix/guides/How_to_create_a_dynamic_signature

Thank you!



Table of Contents:


Introduction

  • This tutorial just shows you one of lots of possible implementations to create dynamic signatures. A dynamic signature is a banner image which is dynamically generated by a small script. So you can use a default background image and write over it any information. The limit is your own imagination.

  • Actually, I'm going to explain how I implemented mine and post the resources I used. As I believe it might be useful to share the basics. I hope you learn something, as well as I did, sometime ago. ;)

  • The samples described here use a GIF image for the background and generate a PNG image using GD functions present in almost all PHP installations. So, if you need another approach, you should change the relevant pieces in the code itself to adapt the samples to your own needs.


Browser Requirements


« top »

Server Requirements


« top »

About GD Fonts

  • GD library in PHP already provides several built-in fonts. They use IDs from 1 to 5.

  • However, you could also create your own fonts. Check out the following resources to learn more about it:


« top »

Folder Structure

  • Create the following folder structure:

    • webroot/sig
    • webroot/sig/gd_fonts
    • webroot/sig/includes
    • webroot/sig/images

« top »

Apache configuration

  • Upload a .htaccess file to the webroot/sig folder with the following contents:

    <FilesMatch "^.*.png">
        
    SetHandler application/x-httpd-php
    </FilesMatch>

    This tells Apache to process PNG files as PHP scripts. So, you can generate dynamic images based on PHP code and still use valid PNG images to post wherever you need. No one will notice they are, in fact, PHP files. ;)

  • Upload a .htaccess file to the webroot/sig/gd_fonts, webroot/sig/includes and webroot/sig/images folders, with the following contents:

    <Limit GET POST HEAD PUT DELETE>
        
    order deny,allow
        deny from all
    </Limit>

    This will prevent direct HTTP access to the files on these folders. So, anyone trying to do so, will (hopefully) get a nice 403 HTTP error.


« top »