开发者

Is there a free PHP library that can be used for captcha

In the our website, we adopt reCAPTCHA to prevent spam. However, our clients complain that the validation is too 开发者_开发知识库complicated. I also agree that the reCAPTCHA is way too complicated for a regular person to read. It is especially hard for people who don't know English.

I found that the CAPTCHA function of mail.yahoo.com is reasonable and I don't know whether or not I can use it for free like reCAPTCHA.

Thank you

Update

I think my original idea is to find a free PHP library that can be used for captcha. I just need some simple way to do the captcha rather than make my clients feel it is so difficult even for a real human to solve the words.


Most hosts allow GD image manipulation for PHP. Its actually really easy to learn, and you could make your own captcha script in 10 or 20 minutes. That is, if you already know PHP.

This is a pretty simple script example: linky

Example:

Is there a free PHP library that can be used for captcha

Code:

<?php
/*
Author: Simon Jarvis
Modified: Azmisov
Copyright: 2006 Simon Jarvis
License: GPL2
Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php
*/

//OPTIONS
$dwidth = 260;
$dheight = 90;
$dcharacters = 6;
//https://fontlibrary.org/en/font/jellee-typeface
$font = './jellee_roman.ttf';
$possible = '234679ABCDEHJLMNPTUVWXY';

//CODE
session_start();
function generateCode($characters) {
    global $possible;
    $code = '';
    $len = strlen($possible)-1;
    for($i=0; $i<$characters; $i++)
        $code .= substr($possible, mt_rand(0, $len), 1);
    return $code;
}
function createCaptcha($width,$height,$characters) {
    global $font;
    $code = generateCode($characters);
    $_SESSION['captcha'] = $code;
    //font size will be 75% of the image height
    $font_size = $height * 0.4;
    $image = imagecreate($width, $height) or die('Cannot initialize new GD image stream');
    //set the colours
    $background_color = imagecolorallocate($image, 20, 58, 78);
    $text_color = imagecolorallocate($image, 74, 143, 200);
    $noise_color = imagecolorallocate($image, 100, 120, 200);
    //generate random dots in background
    for( $i=0; $i<($width*$height)/3; $i++)
        imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
    //generate random lines in background
    for($i=0; $i<($width*$height)/150; $i++)
        imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
    //create textbox and add text
    $textbox = imagettfbbox($font_size, 0, $font, $code) or die('Error in imagettfbbox function');
    $x = ($width - $textbox[4])/2;
    $y = ($height - $textbox[5])/2;
    imagettftext($image, $font_size, 0, $x, $y, $text_color, $font , $code) or die('Error in imagettftext function');
    //generate random dots/lines in foreground
    for($i=0; $i<2; $i++)
        imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
    for( $i=0; $i<40; $i++)
        imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 3, 3, $noise_color);
    //Apply filters
    imagefilter($image, IMG_FILTER_CONTRAST, 1);
    imagefilter($image, IMG_FILTER_EMBOSS);
    imagefilter($image, IMG_FILTER_EDGEDETECT);
    imagefilter($image, IMG_FILTER_NEGATE);
    /* output captcha image to browser */
    header('Content-Type: image/jpeg');
    imagejpeg($image);
    imagedestroy($image);
} 
createCaptcha($width,$height,$characters); 
?>


I'd recommend one more place: phpclasses.org, in this site, you can find all sort of PHP resources. I had to use a captcha and found it there. I downloaded it, but lost the link tough, sorry :(

Anyways, looking for a captcha class there won't take more than 5 minutes.

Try this url

Best regards, David!


I built a simple captcha class based on GD. It even has a math mode if images are to hard for your users.

http://github.com/Xeoncross/micromvc/blob/v2.0.0/modules/core/classes/captcha.php


I'm not sure if there are any classes yet for this, but instead of a CAPTCHA, you could keep a collection of anti-bot questions like "Is fire hot or cold?" and use those instead of images. That method is becoming increasingly popular in web apps.

Edit: like this! http://textcaptcha.com/


Microsoft's ASIRRA, it's just pictures of cats and dogs and you have to select all the cats.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜