定制 htmlwebfan/nocaptcha 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

htmlwebfan/nocaptcha

最新稳定版本:v1.0.1

Composer 安装命令:

composer require htmlwebfan/nocaptcha

包简介

Generates and verifies a NoCaptcha field in forms HTML forms with PHP.

README 文档

README

Latest Version Software License

Are you a robot? Introducing "No Captcha reCaptcha".

This PHP package allows you to render a form field in a form and then verify the response from Google on your server. The package supports psr-4.

reCAPTCHA from Google

Install

To get the latest version of nocaptcha simply require it in your composer.json file.

"htmlwebfan/nocaptcha": "dev-master"

You'll then need to run composer install to download it and have the autoloader updated.

Usage

Overview

  1. Configure NoCaptcha
  2. Display the nocaptcha filed on the form
  3. When the form is posted to your processor script, verify that the nocaptcha response is valid

Configure

Open the Config.php file and set the constants with the the sitekey and the secret values you got from Google Google

Display

// form_page.php

// Instantiate a NoCaptcha object and initialize it with the Config 
// object containing your keys
$nb = new NoCaptcha(new Config);  

// Generate the HTML code for your nocaptcha form field
$nb->generateField();

// When the user successfully completes the turing test, Google will set a 
// g-recaptcha-response on your form that will be posted to your processing script

Verify captcha from the server

// processor_script.php

// The value Google gave you on the form when the user completed the test
$r = $_POST['g-recaptcha-response']; 

// Do not forget to filter your input here, I have not done so here in order 
// to keep the example simple
$em = $_POST['email'];

$nobot = new NoCaptcha(new Config);
$nobot->setResponse($r);
$v = $nobot->verify();

// verify() returns a stdCalss Object with a success property with a value of 1
// Any other value means the verification failed. The class has a debug() method 
// for troubleshooting failures like so:

$nobot->debug()

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email nocaptcha@htmlwebfan.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 28
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-17