Here are some pieces of code to prevent access to parts of your site unless the user can pass a simple Turing test (also known as a CAPTCHA.
The code is pretty straightforward. You need two files: the image generating script and the protection script.
The HTTP_URL class is something I quickly hacked together a while ago. It reads a URL and returns and parses the HTTP header and body for various things.
The easiest way to explain is by example:
The site is powered by Textpattern.
I wanted to use something written in PHP (so I could hack at it), something that respected XHTML standards (so I could hack at CSS and the design) and something OpenSource. I started off by trying Serendipty. There were a few features that I wished it had, including support for Humane Web Text Markup , a.k.a. Textile.
As of January 15, 2004, I’m no longer going to maintain the PEAR Net_Dig class. The original code was a bit of a hack anyway, simply running the system’s dig command, and parsing the results with regular expressions to come up with a useable PHP array.
The Net_DNS class is a much better alternative. It provides many more query options and, best of all, it’s being maintained. I encourage you all to switch.
Copyright © 2000-2010 Colin Viebrock • All Rights Reserved