Skip to main content


Showing posts from March, 2009

Image Generation Using PHP

In one of the previous posts about CAPTCHA Image Generation we made use of PHP’s image generation functions but didn’t discuss about them. So, if you had any problems or just want to know more, read on. Creating and outputting images from PHP is very simple and easy. And since PHP supports images in a number of different formats you can very easily generate images in various formats such as JPEG, PNG, GIF etc. Generating  images involves the following steps: Creating a canvas. Drawing Outputting the image. Now, let’s look at each of the steps in detail. Creating a Canvas Creating a canvas is very easy, just use the following function: resource ImageCreateTrueColor  (  int $width  ,  int $height  ) The capitalization doesn’t matter as with any function in PHP. If you want your canvas to have some background color (default is black) you can use the following function: bool ImageFill  (  resource $image  ,  int $x  ,  int $y  ,  int $color  ) Where color is t

How CAPTCHA Works? And a Simple Script in PHP

[ For this post I'm presuming that you are familiar with CAPTCHA, if not please read this  Introduction to CAPTCHA ] Today we are going to see how CAPTCHA ( C ompletely A utomated P ublic T uring test to tell C omputers and H umans A part) works and how it minimizes automatic sign-up of form s . We will also be creating a simple CAPTCHA script in PHP to illustrate this. Basically CAPTCHA works in the following manner: Create Random Value: Some random string is generated, random values are often hard to guess and predict. Generate an Image: Images are used as these are generally a lot harder to read for computers while being nice and readable to humans. This is also the most important step as simple text in images can be read (and CAPTCHA cracked) quite easily. To make it difficult for them, developers employ different techniques so that the text in the image becomes hard to read for computers. Some create zig-zag lines for background while others twist-and-turn individual c

Generating XML Feeds (RSS, Atom) Using PHP

RSS/ATOM feeds are very common these days and almost all Content Management Systems (CMS) can generate it. But in the case when you want to generate it yourself or just want to learn how you can, read on! Both RSS and ATOM feeds are written in eXtensible Markup Language (XML) standard markup. Not just standard markups, you also need to be sure of what and how you put data in those markup elements (tags). For all this refer to the feed specifications of RSS and ATOM . XML itself is very strict and the standard specifications makes it even harder to generate valid feeds. And moreover, why re-invent the wheel when we can have it – ready-made. The solution I'm referring to here is, to use a third-party Library – Universal FeedWriter. FeedWriter is a PHP class written by Anis uddin Ahmad that can dramatically  ease-off feeds (both RSS and Atom) generation. You can download this library from  here . Every feed should have at least the following data: Feed title URL(of the webs

Geany - A Good Web Development Editor (IDE)

Geany Homepage Last year I finally made a switch to GNU/Linux as my operating system and had been in search of a good editor for my web development. In Windows I used Dreamweaver for the purpose and was quite happy with it. It could can easily highlight PHP, HTML, JavaScript and other codes of some other languages related to web. It can also do some Auto-Completion – a feature I think is a must-have. I also liked the fact that it (version MX) was reasonably light on system resources. When I switched to Linux, I tried Bluefish, Komodo Edit, Netbeans IDE. Bluefish (ver 1.0.7) had  a  bad syntax highlighting feature besides other things I found to be quite irritable (working with PHP files, at least). Komodo Edit and Netbeans stood out especially Komodo Edit, in terms of functionality, usability and other small-small things. But still these were not what I was looking for. I wanted something good in terms of functionality but at the same time light on resources (Komodo Edit took about