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.
- Browser Requirements.
- Server Requirements.
- About GD Fonts.
- Folder Structure.
- Apache configuration.
- Uploading basic resources.
- Creating your first dynamic signature.
- Creating a random signature (text).
- Creating a random signature (images).
- Last Message Posted sample.
- Latest Drupal Nodes.
- Final notes.
- Resources.
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
You could also generate images with other formats: JPG or even GIF(*).
Note (*): GIF patent expired worldwide July, 7th 2004. :P ...GD support for creating GIF images was enabled with GD library version 2.0.28. Read about it here.
« top »
Server Requirements
All the material described in this tutorial is meant to be used on Apache, which is what I know of. So, please, don't ask me about other webservers, I can't help you. ;)
GD support (not sure about the version, though). The tutorial makes use of the following image related functions: getimagesize, imagecreatefromgif, imagecolorallocate, imageloadfont, imagestring, imagepng and imagedestroy.
« 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:
User-defined Bitmap Fonts Guide by Dr.Yes. Note this guide is now hosted by widgnet.
They also provide a nice gallery of GD Fonts for PHP imageloadfont().
All credits should go to them. I learnt a lot reading their guide. Thanks! :-)
Though, I have uploaded several GD fonts to this site, just as a "safe resource" (please, use it only if their link fails).
« 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 »










Recent comments
1 year 26 weeks ago
1 year 29 weeks ago
1 year 30 weeks ago
1 year 31 weeks ago
1 year 31 weeks ago
1 year 31 weeks ago
1 year 34 weeks ago
1 year 34 weeks ago
1 year 37 weeks ago
1 year 37 weeks ago