Skip to content

Commit

Permalink
Merge pull request #1 from fitorec/master
Browse files Browse the repository at this point in the history
Supported for cakephp 2.x
  • Loading branch information
tbsmcd committed Oct 9, 2012
2 parents 14699e3 + c22d007 commit b3033a2
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .gitignore
@@ -1,2 +1,2 @@
vendors/recaptchalib.php
config/key.php
Vendor/recaptchalib.php
Config/key.php
File renamed without changes.
@@ -1,5 +1,9 @@
<?php
class RecaptchaComponent extends Object {
App::uses('Component', 'Controller');

class RecaptchaComponent extends Component {


function startup(&$controller) {
$modelClass = $controller->modelClass;
if (!empty($controller->params['form']['recaptcha_challenge_field']) && !empty($controller->params['form']['recaptcha_response_field'])) {
Expand All @@ -11,3 +15,4 @@ function startup(&$controller) {

}
}

@@ -1,6 +1,7 @@
<?php
class ValidationBehavior extends ModelBehavior {
function beforeValidate(&$model) {
die(' probando funcion de validacion ');
$model->validate['recaptcha_response_field'] = array(
'checkRecaptcha' => array(
'rule' => array('checkRecaptcha', 'recaptcha_challenge_field'),
Expand Down
50 changes: 39 additions & 11 deletions README
@@ -1,32 +1,60 @@
Quick start guide.
================================================================================

1. Get reCAPTCHA key.
http://www.google.com/recaptcha
--------------------------------------------------------------------------------
- <http://www.google.com/recaptcha>

2. Setting.
Download recaptchalib.php.
And put it in recaptcha_plugin/vendors.
http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest
--------------------------------------------------------------------------------
- Download `recaptchalib.php` from:
- <http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest>
- And put it in `/app/Plugin/Recaptcha/Vendor/`


3. Config.
Insert keys in recaptcha_plugin/config/key.php .
--------------------------------------------------------------------------------
Insert keys in /app/Plugin/Recaptcha/Config/key.php.
```php
<?php
$config = array(
'Recaptcha' => array(
'Public' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'Private' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
),
);
```

Loadding the Plugin in `/app/Config/bootstrap.php` insert

```php
<?php
CakePlugin::load('Recaptcha');
```


4. Controller.
public $components = array('RecaptchaPlugin.Recaptcha');
public $helpers = array('RecaptchaPlugin.Recaptcha');
--------------------------------------------------------------------------------
```php
<?php
public $components = array('Recaptcha.Recaptcha');
public $helpers = array('Recaptcha.Recaptcha');
```

5. View.
Inside <form> tags:
--------------------------------------------------------------------------------
Inside `<form>` tags:
```php
<?php

echo $this->Recaptcha->show();
echo $this->Recaptcha->error();
```

If you want to use reCAPTCHA theme, you should write like this:
> echo $this->Recaptcha->show('white');
Possible values:'red'|'white'|'blackglass'|'clean';
Default value: 'red';
```php
<?php echo $this->Recaptcha->show('white'); ?>
```

**Possible values**: 'red' | 'white' | 'blackglass' | 'clean';
**Default value**: 'red';
60 changes: 60 additions & 0 deletions README.ES.md
@@ -0,0 +1,60 @@
Guia rápida de uso
================================================================================

1. Obten una clave reCAPTCHA.
--------------------------------------------------------------------------------
- <http://www.google.com/recaptcha>

2. Setting.
--------------------------------------------------------------------------------
- Download `recaptchalib.php` from:
- <http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest>
- And put it in `/app/Plugin/Recaptcha/Vendor/`


3. Config.
--------------------------------------------------------------------------------
Insert keys in /app/Plugin/Recaptcha/Config/key.php.
```php
<?php
$config = array(
'Recaptcha' => array(
'Public' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'Private' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
),
);
```

Loadding the Plugin in `/app/Config/bootstrap.php` insert

```php
<?php
CakePlugin::load('Recaptcha');
```


4. Controller.
--------------------------------------------------------------------------------
```php
<?php
public $components = array('Recaptcha.Recaptcha');
public $helpers = array('Recaptcha.Recaptcha');
```

5. View.
--------------------------------------------------------------------------------
Inside `<form>` tags:
```php
<?php

echo $this->Recaptcha->show();
echo $this->Recaptcha->error();
```

If you want to use reCAPTCHA theme, you should write like this:
```php
<?php echo $this->Recaptcha->show('white'); ?>
```

**Possible values**: 'red' | 'white' | 'blackglass' | 'clean';
**Default value**: 'red';
File renamed without changes.
@@ -1,12 +1,12 @@
<?php
class RecaptchaHelper extends Helper {
class RecaptchaHelper extends AppHelper {
public $helpers = array('Form');

function show($theme = null) {
if (empty($theme) || !in_array($theme, array('red', 'white', 'blackglass', 'clean'))) {
$theme = 'red';
}
App::import('Vendor', 'RecaptchaPlugin.recaptchalib');
App::import('Vendor', 'Recaptcha.recaptchalib');
Configure::load('RecaptchaPlugin.key');
$publickey = Configure::read('Recaptcha.Public');
$html = '<script type="text/javascript">var RecaptchaOptions = {theme : \'' . $theme . '\'};</script>';
Expand Down

0 comments on commit b3033a2

Please sign in to comment.