Home arrow PHP arrow Page 4 - Security Images with PHP and ImageMagick

Conclusion - PHP

This article is intended to provide another look at Nathan Rohler's article that was recently published (the link is provided at the end of this article). His article illustrated how to use a database and PHP's image functions based on the GD library to create random security images. This article will demonstrate how to achieve the same goal (albeit with slightly different results) by using ImageMagick. I chose not to use hidden form fields and a database and instead opted for session variables, a much simpler and more efficient approach for our objective.

TABLE OF CONTENTS:
  1. Security Images with PHP and ImageMagick
  2. The Image Generator
  3. The Form
  4. Conclusion
By: David Fells
Rating: starstarstarstarstar / 45
October 05, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Hopefully this article demonstrated a more efficient way to handle the security image problem than the original by avoiding the use of a database and hidden form fields. A feature to be added would be a "bad word" filter. Content filtering is beyond the scope of this article, though, and if you feel that you need that feature, there are many open source PHP site engines available that have content filters built in that you could borrow from.

I also used PHP4 code to reflect more up-to-date coding practices and used ImageMagick through the command line to offer another method of creating the security image. You could easily replace the ImageMagick specific code with the GD specific code from the original article and use the method I explained in this article to generate security images using GD.

When troubleshooting this code, be sure that you have set permissions on the temp directory to 777 and that you have the correct path to convert in the command that is executed. Also be sure you have the right path to the font you wish to use and be aware that if you use a different font, you will surely have to tinker with the sizes of the text to make sure it is not too large or too small for the background.

Nathan Rohler's article can be accesssed at this link.



 
 
>>> More PHP Articles          >>> More By David Fells
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap

Dev Shed Tutorial Topics: