//***************************************************************
//** title : An damaged image generator for validating text
//**
//** story : Sometimes you need to verify that the client posting
//** or registering in your site is actually a human. By
//** asking him/her to type in the word s/he sees, you ensure
//** that the client is human, and not a bot/spider which
//** is probably trying to harm your system.
//** Play around with the values when constructing this
//** object, but also feel free to experiment with the
//** maths inside the image manipulating loops.
//** Note that this class is writing a png file on disk,
//** so you might need to have a png with the same name
//** already present in that location with write
//** permissions set.
//**
//** author : Ioannis Cherouvim
//** e-mail : morales@hack.gr
//** date : 2005-06-25
//*******************************************************
class PWImage {
//instantiate class
//$filename : the path+filename of the written png file
//$string : the text that you want to have in the image
//$fact : a magnification factor. play with values>2
//$bcol : the background colour, R, G, B (0-255)
//$fcol : the foreground colour, R, G, B (0-255)
function PWImage($filename, $string, $fact, $bcol, $fcol) {
$font = 5;
$cosrate = rand(10,19);
$sinrate = rand(10,18);
//functions to extract RGB values from combined 24bit color value
function getR($col) {return (($col >> 8) >> 8) % 256;}
function getG($col) {return ($col >> 8) % 256;}
function getB($col) {return $col % 256;}
}
//**********************************************
//*************** example use ******************
//**********************************************
$pw = new PWImage("temp1.png", "some pass", 2, array(0, 0, 0), array(255, 128, 200));
$pw = new PWImage("temp2.png", "WEBERDEV", 4, array(255, 255, 255), array(0, 0, 0));
$pw = new PWImage("temp3.png", "9df2ceA", 3, array(0, 0, 0), array(255, 228, 250));
$pw = new PWImage("temp4.png", "abcdef_g", 1.8, array(0, 0, 0), array(0, 255, 255));