`
dcj3sjt126com
  • 浏览: 1830622 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

开源免费的验证码解决方案 openCaptcha和reCaptcha

    博客分类:
  • PHP
 
阅读更多

 

Open Captcha

Captchas remain the most effective, universal method of preventing automated spam currently available on the web. While services like akismetand linksleeve provide valuable protection, they are dependent upon widespread adoption to be successful. When used correctly, captchas just work.

 

The Problems With Current Captcha Integration
  1. Captchas require special system configurations / modules (like PHP's GD) that, in most cases, cannot be installed without root access.
  2. Even with the proper system configuration, programming image creation scripts can be difficult and time consuming.
  3. Captchas must be changed with some frequency to prevent cracking.

 

How Does OpenCaptcha Solve These Issues
  1. It requires no special configurations or modules, it is a simple web service.
  2. Basic installation is cut-and-paste, and requires no ability to program image manipuation scripts
  3. New fonts, image algorithms, and distortions applied weekly.

 

How To Install OpenCaptcha
Installation happens to be quite easy with OpenCaptcha, there are really only 3 steps.
  1. On the form page, dynamically create a filename (http://www.opencaptcha.com/img/{random}.jpgx and print to the screen both an >img< and an >input value={image name}< tag including that name 
    Tips
    • Use the current timestamp and your domain name as the random number { 200705041231mydomainname.jpgx }
    • Add -{height}-{width} to specify the size { 200705041231mydomainname-80-240.jpgx will make a 80px tall and 240px wide image }
  2. On the form page, add a text field for the user to enter the Captcha code
  3. On the processing page, check to see if http://www.opencaptcha.com/validate.php?img={imageName}&ans={users Answer} returns the word "pass" or "fail"
Below is a really simple sample PHP code. 

Example PHP Integration 
Login Page
<?
if($_GET['opencaptcha']=='failed') { echo "<script>alert('You Did Not Fill In The Security Code Correctly');</script>";}
$date = date("Ymd");
$rand = rand(0,9999999999999);
$height = "80";
$width  = "240";
$img    = "$date$rand-$height-$width.jpgx";
echo "<input type='hidden' name='img' value='$img'>";
echo "<a href='http://www.opencaptcha.com'><img src='http://www.opencaptcha.com/img/$img' height='$height' alt='captcha' width='$width' border='0' /></a><br />";
echo "<input type=text name=code value='Enter The Code' size='35' />";
?>
 
Processing Page
<?
if(file_get_contents("http://www.opencaptcha.com/validate.php?ans=".$_POST['code']."&img=".$_POST['img'])=='pass') {
  // CONTINUE LOGIN
} else {
  header("LOCATION: ".$_SERVER['HTTP_REFERER']."?opencaptcha=failed");
}
?>
 
Thats it. There is no API, no special configurations or modules and, best of all, you get a powerful, free, highly randomized captcha.
====================================================================================================

reCAPTCHA计划是由卡内基梅隆大学所发展的系统,主要目的是利用CAPTCHA技术来帮助典籍数位化的进行,这个计划将由书本扫描下来无法准确的被光学文字辨识技术识别的文字显示在CAPTCHA问题中,让人类在回答CAPTCHA问题时用人脑加以识别。reCAPTCHA正数位化纽约时报的扫描存档,目前已经完成20年份的资料,并希望在2010年完成110年份的资料。

为了验证人类所输入的文字是正确的,而不是随意输入,有两个字会被显示出来;一个是光学文字辨识软体无法辨别的字,另一个是一个已经知道正确答案的 字。如果使用者正确的回答出已知正确答案的字,那么就假设所输入的另一个光学辨识软体无法辨识的字是认真的检视后被输入而非随便输入

reCAPTCHA 问题的所需的文字图片,首先会由 reCAPTCHA 计划网站利用 Javascript API 取得, 在终端使用者回答问题后,伺服器再连回 reCAPTCHA 计划的主机验证使用者的输入是否正确。 reCAPTCHA 计划提供了许多程式语言的函式库,让整合 reCAPTCHA 服务到现有程式的过程可以轻松些。除非有较大的频宽需求,否则 reCAPTCHA 原则上是一个免费的服务。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics