Skip to content
This repository has been archived by the owner on Oct 13, 2019. It is now read-only.

edlinklater/silverstripe-recaptcha

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reCAPTCHA FormField Module

Build Status

Introduction

Provides a FormField which allows form to validate for non-bot submissions using Google's reCAPTCHA service

Maintainer Contact

  • Ingo Schommer (Nickname: ischommer, chillu) <ingo (at) silverstripe (dot) com>

Requirements

  • SilverStripe framework 3.1 or newer
  • curl PHP module
  • Requires spamprotection module

Installation

  • Copy the recaptcha directory into your main SilverStripe webroot
  • Run ?flush=1

This should go in your mysite/_config.php. You can get an free API key at https://www.google.com/recaptcha

RecaptchaField::$public_api_key = '<publickey>';
RecaptchaField::$private_api_key = '<privatekey>';

If using on a site requiring a proxy server for outgoing traffic then you can set these additional
options in your `mysite/_config.php`. 

RecaptchaField::$proxy_server = "<proxy address>";
RecaptchaField::$proxy_auth = "<proxy_username>:<proxy_password>";

Usage

As a Standalone Field

If you want to use reCAPTCHA field by itself, you can simply just include it as a field in your form.

$recaptchaField = new RecaptchaField('MyCaptcha');
$recaptchaField->options = array('theme' => 'light'); // optional

See reCAPTCHA docs for more configuration options.

Integration with spamprotection module

This requires the spamprotection module to be installed, see its documentation for details. You can use this field to protect any built informs on your website, including user comments in the [[:modules:blog]] module.

Configuration example in mysite/_config/spamprotection.yml

---
name: spamprotection
---
FormSpamProtectionExtension:
  default_spam_protector: RecaptchaProtector

Then once you have setup this config you will need to include the spam protector field as per the instructions on the spamprotection page.

Known issues:

Problems with page doctype XHTML

reCAPTCHA current does not work if the page doctype is XHTML. The API returns Javascript which uses "document.write", which is not supported in XHTML. A work-around is to always use the no-script version of the module (modify the relevant lines in RecaptchaField.php), or to switch your webpage's doctype to HTML 4. See: http://www.w3schools.com/tags/tag_DOCTYPE.asp

About

SilverStripe module for ReCaptcha spam protection service

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%