Skip to content

Commit 4e53e75

Browse files
committed
Add nocaptcha (reCAPTCHA 2) module
1 parent a7d644f commit 4e53e75

File tree

14 files changed

+542
-0
lines changed

14 files changed

+542
-0
lines changed

nocaptcha/.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# For more information about the properties used in this file,
2+
# please see the EditorConfig documentation:
3+
# http://editorconfig.org
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 4
9+
indent_style = space
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[{*.yml,package.json}]
14+
indent_size = 2
15+
16+
# The indent size used in the package.json file cannot be changed:
17+
# https://github.com/npm/npm/pull/3180#issuecomment-16336516

nocaptcha/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.gitignore export-ignore

nocaptcha/.scrutinizer.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
inherit: true
2+
3+
checks:
4+
php:
5+
verify_property_names: true
6+
verify_argument_usable_as_reference: true
7+
verify_access_scope_valid: true
8+
useless_calls: true
9+
use_statement_alias_conflict: true
10+
variable_existence: true
11+
unused_variables: true
12+
unused_properties: true
13+
unused_parameters: true
14+
unused_methods: true
15+
unreachable_code: true
16+
too_many_arguments: true
17+
sql_injection_vulnerabilities: true
18+
simplify_boolean_return: true
19+
side_effects_or_types: true
20+
security_vulnerabilities: true
21+
return_doc_comments: true
22+
return_doc_comment_if_not_inferrable: true
23+
require_scope_for_properties: true
24+
require_scope_for_methods: true
25+
require_php_tag_first: true
26+
psr2_switch_declaration: true
27+
psr2_class_declaration: true
28+
property_assignments: true
29+
prefer_while_loop_over_for_loop: true
30+
precedence_mistakes: true
31+
precedence_in_conditions: true
32+
phpunit_assertions: true
33+
php5_style_constructor: true
34+
parse_doc_comments: true
35+
parameter_non_unique: true
36+
parameter_doc_comments: true
37+
param_doc_comment_if_not_inferrable: true
38+
optional_parameters_at_the_end: true
39+
one_class_per_file: true
40+
no_unnecessary_if: true
41+
no_trailing_whitespace: true
42+
no_property_on_interface: true
43+
no_non_implemented_abstract_methods: true
44+
no_error_suppression: true
45+
no_duplicate_arguments: true
46+
no_commented_out_code: true
47+
newline_at_end_of_file: true
48+
missing_arguments: true
49+
method_calls_on_non_object: true
50+
instanceof_class_exists: true
51+
foreach_traversable: true
52+
fix_line_ending: true
53+
fix_doc_comments: true
54+
duplication: true
55+
deprecated_code_usage: true
56+
deadlock_detection_in_loops: true
57+
code_rating: true
58+
closure_use_not_conflicting: true
59+
catch_class_exists: true
60+
blank_line_after_namespace_declaration: false
61+
avoid_multiple_statements_on_same_line: true
62+
avoid_duplicate_types: true
63+
avoid_conflicting_incrementers: true
64+
avoid_closing_tag: true
65+
assignment_of_null_return: true
66+
argument_type_checks: true
67+
68+
filter:
69+
paths: [code/*, tests/*]

nocaptcha/CHANGELOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Change Log
2+
3+
## [0.2.0](https://github.com/UndefinedOffset/silverstripe-nocaptcha/tree/0.2.0) (2016-09-30)
4+
[Full Changelog](https://github.com/UndefinedOffset/silverstripe-nocaptcha/compare/0.1.5...0.2.0)
5+
6+
**Merged pull requests:**
7+
8+
- Cant have a blank title for nocatpcha fields [\#23](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/23) ([Leapfrognz](https://github.com/Leapfrognz))
9+
- Added standard Scrutinizer config [\#22](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/22) ([helpfulrobot](https://github.com/helpfulrobot))
10+
- Added german translation [\#21](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/21) ([sebastiand](https://github.com/sebastiand))
11+
- Added captcha size parameter [\#20](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/20) ([jeffwhitfield](https://github.com/jeffwhitfield))
12+
- Added standard .gitattributes file [\#17](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/17) ([helpfulrobot](https://github.com/helpfulrobot))
13+
- Added standard .editorconfig file [\#15](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/15) ([helpfulrobot](https://github.com/helpfulrobot))
14+
- DOCS Updated versions [\#14](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/14) ([camfindlay](https://github.com/camfindlay))
15+
16+
## [0.1.5](https://github.com/UndefinedOffset/silverstripe-nocaptcha/tree/0.1.5) (2015-10-01)
17+
[Full Changelog](https://github.com/UndefinedOffset/silverstripe-nocaptcha/compare/0.1.4...0.1.5)
18+
19+
**Closed issues:**
20+
21+
- Test master against 3.2 core? [\#12](https://github.com/UndefinedOffset/silverstripe-nocaptcha/issues/12)
22+
23+
**Merged pull requests:**
24+
25+
- Update for 3.2 core and spamprotection compatibility [\#13](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/13) ([camfindlay](https://github.com/camfindlay))
26+
27+
## [0.1.4](https://github.com/UndefinedOffset/silverstripe-nocaptcha/tree/0.1.4) (2015-09-08)
28+
[Full Changelog](https://github.com/UndefinedOffset/silverstripe-nocaptcha/compare/0.1.3...0.1.4)
29+
30+
**Closed issues:**
31+
32+
- Captcha could not be validated. [\#8](https://github.com/UndefinedOffset/silverstripe-nocaptcha/issues/8)
33+
34+
**Merged pull requests:**
35+
36+
- Added Callbck Function Check [\#11](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/11) ([thezenmonkey](https://github.com/thezenmonkey))
37+
- Added example for setting field labels [\#6](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/6) ([jonom](https://github.com/jonom))
38+
39+
## [0.1.3](https://github.com/UndefinedOffset/silverstripe-nocaptcha/tree/0.1.3) (2015-02-20)
40+
[Full Changelog](https://github.com/UndefinedOffset/silverstripe-nocaptcha/compare/0.1.2...0.1.3)
41+
42+
**Closed issues:**
43+
44+
- Adding nocaptcha field to page php [\#5](https://github.com/UndefinedOffset/silverstripe-nocaptcha/issues/5)
45+
46+
## [0.1.2](https://github.com/UndefinedOffset/silverstripe-nocaptcha/tree/0.1.2) (2014-12-16)
47+
[Full Changelog](https://github.com/UndefinedOffset/silverstripe-nocaptcha/compare/0.1.1...0.1.2)
48+
49+
**Merged pull requests:**
50+
51+
- Ensure JS is run in the correct order for all browsers. [\#4](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/4) ([DarrenInwood](https://github.com/DarrenInwood))
52+
53+
## [0.1.1](https://github.com/UndefinedOffset/silverstripe-nocaptcha/tree/0.1.1) (2014-12-09)
54+
[Full Changelog](https://github.com/UndefinedOffset/silverstripe-nocaptcha/compare/0.1.0...0.1.1)
55+
56+
**Closed issues:**
57+
58+
- Just Comments [\#1](https://github.com/UndefinedOffset/silverstripe-nocaptcha/issues/1)
59+
60+
**Merged pull requests:**
61+
62+
- FIX: Validator::validationError\(\) calls weren't being passed a $messageT... [\#3](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/3) ([christopherdarling](https://github.com/christopherdarling))
63+
- \_t namespace should be NocaptchaField [\#2](https://github.com/UndefinedOffset/silverstripe-nocaptcha/pull/2) ([christopherdarling](https://github.com/christopherdarling))
64+
65+
## [0.1.0](https://github.com/UndefinedOffset/silverstripe-nocaptcha/tree/0.1.0) (2014-12-04)

nocaptcha/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2015, Ed Chipman
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
Redistributions in binary form must reproduce the above copyright notice, this
11+
list of conditions and the following disclaimer in the documentation and/or
12+
other materials provided with the distribution.
13+
14+
Neither the name of Ed Chipman nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

nocaptcha/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Nocaptcha
2+
=================
3+
A spam protector and form field using the new Google's reCAPTCHA 2 aka [No Captcha](http://googleonlinesecurity.blogspot.ca/2014/12/are-you-robot-introducing-no-captcha.html).
4+
5+
## Requirements
6+
* SilverStripe 3.x
7+
* [SilverStripe Spam Protection 2.x](https://github.com/silverstripe/silverstripe-spamprotection/)
8+
* PHP CURL
9+
10+
## Installation
11+
* Download the module from [here](https://github.com/UndefinedOffset/silverstripe-nocaptcha/archive/master.zip)
12+
* Extract the downloaded archive into your site root so that the destination folder is called nocaptcha, opening the extracted folder should contain _config.php in the root along with other files/folders
13+
* Run dev/build?flush=all to regenerate the manifest
14+
15+
If you prefer you may also install using composer:
16+
```
17+
composer require undefinedoffset/silverstripe-nocaptcha
18+
```
19+
20+
After installing the module via composer or manual install you must set the spam protector to NocaptchaProtector, this needs to be set in your site's config file normally this is mysite/_config/config.yml.
21+
```yml
22+
FormSpamProtectionExtension:
23+
default_spam_protector: NocaptchaProtector
24+
```
25+
26+
27+
## Configuration
28+
There are multiple configuration options for the field, you must set the site_key and the secret_key which you can get from the [reCAPTCHA page](https://www.google.com/recaptcha). These configuration options must be added to your site's yaml config typically this is mysite/_config/config.yml.
29+
```yml
30+
NocaptchaField:
31+
site_key: "YOUR_SITE_KEY" #Your site key (required)
32+
secret_key: "YOUR_SECRET_KEY" #Your secret key (required)
33+
verify_ssl: true #Allows you to disable php-curl's SSL peer verification by setting this to false (optional, defaults to true)
34+
default_theme: "light" #Default theme color (optional, light or dark, defaults to light)
35+
default_type: "image" #Default captcha type (optional, image or audio, defaults to image)
36+
default_size: "normal" #Default size (optional, normal or compact, defaults to normal)
37+
proxy_server: "" #Your proxy server address (optional)
38+
proxy_auth: "" #Your proxy server authentication information (optional)
39+
```
40+
41+
## Adding field labels
42+
If you want to add a field label or help text to the Captcha field you can do so like this:
43+
```php
44+
$form->enableSpamProtection()
45+
->fields()->fieldByName('Captcha')
46+
->setTitle("Spam protection")
47+
->setDescription("Please tick the box to prove you're a human and help us stop spam.");
48+
```
49+
50+
## Reporting an issue
51+
When you're reporting an issue please ensure you specify what version of SilverStripe you are using i.e. 3.1.3, 3.2beta, master etc. Also be sure to include any JavaScript or PHP errors you receive, for PHP errors please ensure you include the full stack trace. Also please include how you produced the issue. You may also be asked to provide some of the classes to aid in re-producing the issue. Stick with the issue, remember that you seen the issue not the maintainer of the module so it may take allot of questions to arrive at a fix or answer.

nocaptcha/_config.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
define('NOCAPTCHA_BASE', basename(dirname(__FILE__)));
3+
?>

0 commit comments

Comments
 (0)