[nycphp-talk] Old subject new day - Pear Captcha
Rolan Yang
rolan at omnistep.com
Sat Jun 14 08:37:16 EDT 2008
y2rob at aol.com wrote:
> hello rolan,
> so did you make any code change or just had freetype2 installed?
>
> ~rob
>
> ps - thanks for replying to my post :)
>
Unfortunately, I was in a rush to get it done and didn't take notes. I
do remember now that the true type fonts were not installed on the
machine either so I copied one over from a windows machine. Here's a
list of pear stuff installed:
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.1 stable
Console_Getopt 1.2 stable
Image_Text 0.6.0beta beta
PEAR 1.4.9 stable
Text_CAPTCHA 0.3.1 alpha
Text_Figlet 1.0.0 stable
Text_Password 1.1.0 stable
XML_RPC 1.4.8 stable
Here's a snippet of code that works (for me):
<?php
require_once 'Text/CAPTCHA.php';
session_start();
$captcha = Text_CAPTCHA::factory('Image');
$options = array('font_size'=>'20',
'font_path'=>'/home/webdir/',
'font_file'=>'VERDANA.TTF');
$captcha->init(150, 60,NULL,$options);
$image = $captcha->getCAPTCHAAsJPEG();
file_put_contents('captcha.jpg', $image);
$_SESSION['captcha_phrase'] = $captcha->getPhrase();
?>
The captcha has succeeded in stopping any futher spam from hitting my
clients comment board. I've read, however, that something as simple as a
fixed image and a request to retype the displayed word is sufficient
(http://www.codinghorror.com/blog/archives/000712.html)
~Rolan
More information about the talk
mailing list