Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# reCAPTCHA

## Installation
1. Get reCAPTCHA API keys from http://recaptcha.net/whyrecaptcha.html
1. Get reCAPTCHA API keys from https://www.google.com/recaptcha/intro/index.html
2. Upload the 'recaptcha' folder in this archive to your Symphony 'extensions' folder.
3. Enable it at System > Extensions.
4. Go to System > Preferences and enter your reCAPTCHA private/public API key pair.
5. Add the "reCAPTCHA Verification" filter rule to your Event via Blueprints > Events
6. Save the Event.
7. Add "reCAPTCHA: Public Key" Data Source to your page.
8. Add the following line to your form:
8. Add the following script to your site:

```HTML
<script type="text/javascript" src="http://api.recaptcha.net/challenge?k={/data/recaptcha}"></script>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
```
8. Add the following html where you want your recaptcha to appear:

See http://recaptcha.net/apidocs/captcha/client.html for information about customisation of the reCAPTCHA box.
```HTML
<div class="g-recaptcha" data-sitekey="{/data/recaptcha}"></div>
```

See https://developers.google.com/recaptcha/intro for additional reCAPTCHA information / customization.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"google/recaptcha": "~1.1"
}
}
64 changes: 64 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 17 additions & 25 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@

Class extension_recaptcha extends Extension{

public function about(){
return array('name' => 'reCAPTCHA',
'version' => '1.0',
'release-date' => '2008-05-07',
'author' => array( 'name' => 'Symphony Team',
'website' => 'http://symphony21.com',
'email' => '[email protected]'),
'description' => 'This is an event that uses the reCAPTCHA service to help prevent spam.'
);
}

public function getSubscribedDelegates(){
return array(
array(
Expand Down Expand Up @@ -64,11 +53,11 @@ public function appendPreferences($context){

$div = new XMLElement('div', NULL, array('class' => 'group'));
$label = Widget::Label('Public Key');
$label->appendChild(Widget::Input('settings[recaptcha][public-key]', General::Sanitize($this->_Parent->Configuration->get('public-key', 'recaptcha'))));
$label->appendChild(Widget::Input('settings[recaptcha][public-key]', General::Sanitize(Symphony::Configuration()->get('public-key', 'recaptcha'))));
$div->appendChild($label);

$label = Widget::Label('Private Key');
$label->appendChild(Widget::Input('settings[recaptcha][private-key]', General::Sanitize($this->_Parent->Configuration->get('private-key', 'recaptcha'))));
$label->appendChild(Widget::Input('settings[recaptcha][private-key]', General::Sanitize(Symphony::Configuration()->get('private-key', 'recaptcha'))));
$div->appendChild($label);

$group->appendChild($div);
Expand Down Expand Up @@ -99,30 +88,33 @@ public function processEventData($context){
if(!in_array('recaptcha', $context['event']->eParamFILTERS)) return;


include_once(EXTENSIONS . '/recaptcha/lib/recaptchalib.php');
$resp = recaptcha_check_answer($this->getPrivateKey(),
$_SERVER['REMOTE_ADDR'],
$_POST['recaptcha_challenge_field'],
$_POST['recaptcha_response_field']);
include_once(EXTENSIONS . '/recaptcha/vendor/autoload.php');

$recaptcha = new \ReCaptcha\ReCaptcha(Symphony::Configuration()->get('private-key', 'recaptcha'));
$resp = $recaptcha->verify($_POST['g-captcha-response'], $_SERVER['REMOTE_ADDR']);

// $resp = recaptcha_check_answer($this->getPrivateKey(),
// $_SERVER['REMOTE_ADDR'],
// $_POST['recaptcha_challenge_field'],
// $_POST['recaptcha_response_field']);

$success = $resp->isSuccess();

$context['messages'][] = array('recaptcha', $resp->is_valid, (!$resp->is_valid ? 'Challenge words entered were invalid.' : NULL));
$context['messages'][] = array('recaptcha', $success, (!$success ? 'Challenge words entered were invalid.' : NULL));

}

public function uninstall(){
//ConfigurationAccessor::remove('recaptcha');
$this->_Parent->Configuration->remove('recaptcha');
Symphony::Configuration()->remove('recaptcha');
$this->_Parent->saveConfig();
}

public function getPublicKey(){
//return ConfigurationAccessor::get('public-key', 'recaptcha');
return $this->_Parent->Configuration->get('public-key', 'recaptcha');
return Symphony::Configuration()->get('public-key', 'recaptcha');
}

public function getPrivateKey(){
//return ConfigurationAccessor::get('private-key', 'recaptcha');
return $this->_Parent->Configuration->get('private-key', 'recaptcha');
return Symphony::Configuration()->get('private-key', 'recaptcha');
}

}
Expand Down
5 changes: 4 additions & 1 deletion extension.meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension id="recaptcha" status="unmaintained" xmlns="http://symphony-cms.com/schemas/extension/1.0">
<extension id="recaptcha" status="released" xmlns="http://symphony-cms.com/schemas/extension/1.0">
<name>reCAPTCHA</name>
<description>reCAPTCHA spam prevention</description>
<repo type="github">https://github.com/symphonists/recaptcha</repo>
Expand All @@ -14,6 +14,9 @@
</author>
</authors>
<releases>
<release version="2.0.0" date="2016-06-03">
- Update to new Google reCaptcha Code
</release>
<release version="1.0.1" date="2012-05-17" />
</releases>
</extension>
7 changes: 0 additions & 7 deletions lib/README

This file was deleted.

Loading