Version Notes
None
Download this release
Release Info
Developer | Nikita Nautiyal |
Extension | nrgsignupformrecaptcha |
Version | 1.1.0 |
Comparing to | |
See all releases |
Version 1.1.0
- app/code/community/Tri/SignupFormCaptcha/Helper/Data.php +4 -0
- app/code/community/Tri/SignupFormCaptcha/Model/System/Config/Source/Dropdown/Lang.php +40 -0
- app/code/community/Tri/SignupFormCaptcha/Model/System/Config/Source/Dropdown/Theme.php +24 -0
- app/code/community/Tri/SignupFormCaptcha/controllers/AccountController.php +93 -0
- app/code/community/Tri/SignupFormCaptcha/etc/config.xml +91 -0
- app/code/community/Tri/SignupFormCaptcha/etc/system.xml +157 -0
- app/design/frontend/base/default/layout/signupformcaptcha.xml +11 -0
- app/design/frontend/base/default/template/signupformcaptcha/form.phtml +176 -0
- app/etc/modules/Tri_SignupFormCaptcha.xml +10 -0
- app/locale/en_US/Tri_SignupFormCaptcha.csv +8 -0
- lib/reCaptcha/recaptchalib.php +240 -0
- package.xml +18 -0
app/code/community/Tri/SignupFormCaptcha/Helper/Data.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Tri_SignupFormCaptcha_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
app/code/community/Tri/SignupFormCaptcha/Model/System/Config/Source/Dropdown/Lang.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Tri_SignupFormCaptcha_Model_System_Config_Source_Dropdown_Lang {
|
4 |
+
public function toOptionArray() {
|
5 |
+
return array(
|
6 |
+
array(
|
7 |
+
'value' => 'en',
|
8 |
+
'label' => 'English (default)',
|
9 |
+
),
|
10 |
+
array(
|
11 |
+
'value' => 'nl',
|
12 |
+
'label' => 'Dutch',
|
13 |
+
),
|
14 |
+
array(
|
15 |
+
'value' => 'fr',
|
16 |
+
'label' => 'French',
|
17 |
+
),
|
18 |
+
array(
|
19 |
+
'value' => 'de',
|
20 |
+
'label' => 'German',
|
21 |
+
),
|
22 |
+
array(
|
23 |
+
'value' => 'pt',
|
24 |
+
'label' => 'Portuguese',
|
25 |
+
),
|
26 |
+
array(
|
27 |
+
'value' => 'ru',
|
28 |
+
'label' => 'Russian',
|
29 |
+
),
|
30 |
+
array(
|
31 |
+
'value' => 'es',
|
32 |
+
'label' => 'Spanish',
|
33 |
+
),
|
34 |
+
array(
|
35 |
+
'value' => 'tr',
|
36 |
+
'label' => 'Turkish',
|
37 |
+
),
|
38 |
+
);
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Tri/SignupFormCaptcha/Model/System/Config/Source/Dropdown/Theme.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Tri_SignupFormCaptcha_Model_System_Config_Source_Dropdown_Theme {
|
4 |
+
public function toOptionArray() {
|
5 |
+
return array(
|
6 |
+
array(
|
7 |
+
'value' => 'red',
|
8 |
+
'label' => 'Red (default)',
|
9 |
+
),
|
10 |
+
array(
|
11 |
+
'value' => 'white',
|
12 |
+
'label' => 'White',
|
13 |
+
),
|
14 |
+
array(
|
15 |
+
'value' => 'blackglass',
|
16 |
+
'label' => 'Blackglass',
|
17 |
+
),
|
18 |
+
array(
|
19 |
+
'value' => 'clean',
|
20 |
+
'label' => 'Clean',
|
21 |
+
),
|
22 |
+
);
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Tri/SignupFormCaptcha/controllers/AccountController.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once(Mage::getBaseDir('app') . DS .'code'. DS .'core'. DS .'Mage'. DS .'Customer'. DS .'controllers'. DS .'AccountController.php');
|
4 |
+
|
5 |
+
class Tri_SignupFormCaptcha_AccountController extends Mage_Customer_AccountController {
|
6 |
+
const XML_PATH_CFC_ENABLED = 'tri_options/general/enabled';
|
7 |
+
const XML_PATH_CFC_PUBLIC_KEY = 'tri_options/general/public_key';
|
8 |
+
const XML_PATH_CFC_PRIVATE_KEY = 'tri_options/general/private_key';
|
9 |
+
const XML_PATH_CFC_THEME = 'tri_options/general/theme';
|
10 |
+
const XML_PATH_CFC_LANG = 'tri_options/general/lang';
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
public function preDispatch() {
|
15 |
+
parent::preDispatch();
|
16 |
+
}
|
17 |
+
public function createAction() {
|
18 |
+
$this->loadLayout();
|
19 |
+
$this->getLayout()->getBlock('customer_form_register')->setFormAction(Mage::getUrl('*/ */post'));
|
20 |
+
|
21 |
+
if (Mage::getStoreConfigFlag(self::XML_PATH_CFC_ENABLED)) {
|
22 |
+
|
23 |
+
require_once(Mage::getBaseDir('lib') . DS .'reCaptcha'. DS .'recaptchalib.php');
|
24 |
+
|
25 |
+
|
26 |
+
$publickey = Mage::getStoreConfig(self::XML_PATH_CFC_PUBLIC_KEY);
|
27 |
+
$captcha_code = recaptcha_get_html($publickey);
|
28 |
+
|
29 |
+
$theme = Mage::getStoreConfig(self::XML_PATH_CFC_THEME);
|
30 |
+
if (strlen($theme) == 0 || !in_array($theme, array('red', 'white', 'blackglass', 'clean'))) {
|
31 |
+
$theme = 'red';
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
$lang = Mage::getStoreConfig(self::XML_PATH_CFC_LANG);
|
36 |
+
if (strlen($lang) == 0 || !in_array($lang, array('en', 'nl', 'fr', 'de', 'pt', 'ru', 'es', 'tr'))) {
|
37 |
+
$lang = 'en';
|
38 |
+
}
|
39 |
+
|
40 |
+
$captcha_code = str_replace('?k=', '?hl='. $lang .'&k=', $captcha_code);
|
41 |
+
|
42 |
+
$this->getLayout()->getBlock('customer_form_register')->setCaptchaCode($captcha_code)
|
43 |
+
->setCaptchaTheme($theme)
|
44 |
+
->setCaptchaLang($lang);
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->_initLayoutMessages('customer/session');
|
48 |
+
$this->_initLayoutMessages('catalog/session');
|
49 |
+
$this->renderLayout();
|
50 |
+
}
|
51 |
+
public function createPostAction() {
|
52 |
+
|
53 |
+
if (Mage::getStoreConfigFlag(self::XML_PATH_CFC_ENABLED)) {
|
54 |
+
|
55 |
+
try {
|
56 |
+
|
57 |
+
$post = $this->getRequest()->getPost();
|
58 |
+
$formData = new Varien_Object();
|
59 |
+
$formData->setData($post);
|
60 |
+
Mage::getSingleton('core/session')->setData('customer_form_register', $formData);
|
61 |
+
|
62 |
+
if ($post) {
|
63 |
+
|
64 |
+
require_once(Mage::getBaseDir('lib') . DS .'reCaptcha'. DS .'recaptchalib.php');
|
65 |
+
|
66 |
+
|
67 |
+
$privatekey = Mage::getStoreConfig(self::XML_PATH_CFC_PRIVATE_KEY);
|
68 |
+
$remote_addr = $this->getRequest()->getServer('REMOTE_ADDR');
|
69 |
+
$captcha = recaptcha_check_answer($privatekey, $remote_addr, $post["recaptcha_challenge_field"], $post["recaptcha_response_field"]);
|
70 |
+
|
71 |
+
if (!$captcha->is_valid) {
|
72 |
+
throw new Exception($this->__("The reCAPTCHA wasn't entered correctly. Go back and try it again."), 1);
|
73 |
+
}
|
74 |
+
|
75 |
+
Mage::getSingleton('core/session')->unsetData('customer_form_register');
|
76 |
+
}
|
77 |
+
else {
|
78 |
+
throw new Exception('', 1);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
catch (Exception $e) {
|
82 |
+
if (strlen($e->getMessage()) > 0) {
|
83 |
+
Mage::getSingleton('customer/session')->addError($this->__($e->getMessage()));
|
84 |
+
}
|
85 |
+
$this->_redirect('*/*/create');
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
parent::createPostAction();
|
92 |
+
}
|
93 |
+
}
|
app/code/community/Tri/SignupFormCaptcha/etc/config.xml
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Tri_SignupFormCaptcha>
|
6 |
+
<version>1.1.0</version>
|
7 |
+
<depends>
|
8 |
+
<Mage_Customer/>
|
9 |
+
</depends>
|
10 |
+
</Tri_SignupFormCaptcha>
|
11 |
+
</modules>
|
12 |
+
|
13 |
+
<global>
|
14 |
+
<blocks>
|
15 |
+
<signupformcaptcha>
|
16 |
+
<class>Tri_SignupFormCaptcha_Block</class>
|
17 |
+
</signupformcaptcha>
|
18 |
+
</blocks>
|
19 |
+
|
20 |
+
<models>
|
21 |
+
<signupformcaptcha>
|
22 |
+
<class>Tri_SignupFormCaptcha_Model</class>
|
23 |
+
</signupformcaptcha>
|
24 |
+
</models>
|
25 |
+
|
26 |
+
<helpers>
|
27 |
+
<signupformcaptcha>
|
28 |
+
<class>Tri_SignupFormCaptcha_Helper</class>
|
29 |
+
</signupformcaptcha>
|
30 |
+
</helpers>
|
31 |
+
</global>
|
32 |
+
|
33 |
+
<frontend>
|
34 |
+
<routers>
|
35 |
+
<customer>
|
36 |
+
<args>
|
37 |
+
<modules>
|
38 |
+
<signupformcaptcha before="Mage_Customer">Tri_SignupFormCaptcha</signupformcaptcha>
|
39 |
+
</modules>
|
40 |
+
</args>
|
41 |
+
</customer>
|
42 |
+
</routers>
|
43 |
+
<translate>
|
44 |
+
<modules>
|
45 |
+
<Tri_SignupFormCaptcha>
|
46 |
+
<files>
|
47 |
+
<default>Tri_SignupFormCaptcha.csv</default>
|
48 |
+
</files>
|
49 |
+
</Tri_SignupFormCaptcha>
|
50 |
+
</modules>
|
51 |
+
</translate>
|
52 |
+
<layout>
|
53 |
+
<updates>
|
54 |
+
<signupformcaptcha module="Tri_SignupFormCaptcha">
|
55 |
+
<file>signupformcaptcha.xml</file>
|
56 |
+
</signupformcaptcha>
|
57 |
+
</updates>
|
58 |
+
</layout>
|
59 |
+
</frontend>
|
60 |
+
|
61 |
+
<adminhtml>
|
62 |
+
<acl>
|
63 |
+
<resources>
|
64 |
+
<admin>
|
65 |
+
<children>
|
66 |
+
<system>
|
67 |
+
<children>
|
68 |
+
<config>
|
69 |
+
<children>
|
70 |
+
<tri_options>
|
71 |
+
<title>Tri Signup Form Captcha Section</title>
|
72 |
+
</tri_options>
|
73 |
+
</children>
|
74 |
+
</config>
|
75 |
+
</children>
|
76 |
+
</system>
|
77 |
+
</children>
|
78 |
+
</admin>
|
79 |
+
</resources>
|
80 |
+
</acl>
|
81 |
+
<translate>
|
82 |
+
<modules>
|
83 |
+
<Tri_SignupFormCaptcha>
|
84 |
+
<files>
|
85 |
+
<default>Tri_SignupFormCaptcha.csv</default>
|
86 |
+
</files>
|
87 |
+
</Tri_SignupFormCaptcha>
|
88 |
+
</modules>
|
89 |
+
</translate>
|
90 |
+
</adminhtml>
|
91 |
+
</config>
|
app/code/community/Tri/SignupFormCaptcha/etc/system.xml
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!-- <config>
|
4 |
+
<tabs>
|
5 |
+
<tri translate="label">
|
6 |
+
<label>tri</label>
|
7 |
+
<sort_order>1</sort_order>
|
8 |
+
</tri>
|
9 |
+
<sections>
|
10 |
+
<tri translate="label" module="adminhtml">
|
11 |
+
<label>SignUpCaptcha</label>
|
12 |
+
<tab>tri</tab>
|
13 |
+
<sort_order>1</sort_order>
|
14 |
+
<show_in_default>1</show_in_default>
|
15 |
+
<show_in_website>1</show_in_website>
|
16 |
+
<show_in_store>1</show_in_store>
|
17 |
+
<groups>
|
18 |
+
<general translate="label comment">
|
19 |
+
<label>Signup Form Captcha</label>
|
20 |
+
<frontend_type>text</frontend_type>
|
21 |
+
<sort_order>100</sort_order>
|
22 |
+
<show_in_default>1</show_in_default>
|
23 |
+
<show_in_website>1</show_in_website>
|
24 |
+
<show_in_store>1</show_in_store>
|
25 |
+
<fields>
|
26 |
+
<enabled translate="label comment">
|
27 |
+
<label>Enable Captcha</label>
|
28 |
+
<frontend_type>select</frontend_type>
|
29 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
30 |
+
<backend_model>contacts/system_config_backend_links</backend_model>
|
31 |
+
<sort_order>10</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
</enabled>
|
36 |
+
<public_key translate="label comment">
|
37 |
+
<label>Public Key</label>
|
38 |
+
<comment>You got this from the signup page: https://www.google.com/recaptcha/admin/create</comment>
|
39 |
+
<frontend_type>text</frontend_type>
|
40 |
+
<sort_order>20</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>1</show_in_store>
|
44 |
+
</public_key>
|
45 |
+
<private_key translate="label comment">
|
46 |
+
<label>Private Key</label>
|
47 |
+
<comment>You got this from the signup page: https://www.google.com/recaptcha/admin/create</comment>
|
48 |
+
<frontend_type>text</frontend_type>
|
49 |
+
<sort_order>30</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
</private_key>
|
54 |
+
<theme translate="label comment">
|
55 |
+
<label>reCaptcha Theme</label>
|
56 |
+
<comment>Customizing the Look of reCAPTCHA</comment>
|
57 |
+
<frontend_type>select</frontend_type>
|
58 |
+
<source_model>contactsformcaptcha/system_config_source_dropdown_theme</source_model>
|
59 |
+
<sort_order>40</sort_order>
|
60 |
+
<show_in_default>1</show_in_default>
|
61 |
+
<show_in_website>1</show_in_website>
|
62 |
+
<show_in_store>1</show_in_store>
|
63 |
+
</theme>
|
64 |
+
<lang translate="label comment">
|
65 |
+
<label>reCaptcha Language</label>
|
66 |
+
<comment>Which language is used in the reCaptcha interface</comment>
|
67 |
+
<frontend_type>select</frontend_type>
|
68 |
+
<source_model>contactsformcaptcha/system_config_source_dropdown_lang</source_model>
|
69 |
+
<sort_order>50</sort_order>
|
70 |
+
<show_in_default>1</show_in_default>
|
71 |
+
<show_in_website>1</show_in_website>
|
72 |
+
<show_in_store>1</show_in_store>
|
73 |
+
</lang>
|
74 |
+
</fields>
|
75 |
+
</general>
|
76 |
+
</groups>
|
77 |
+
</tri>
|
78 |
+
</sections>
|
79 |
+
</config> -->
|
80 |
+
|
81 |
+
<config>
|
82 |
+
<tabs>
|
83 |
+
<tri translate="label" module="signupformcaptcha">
|
84 |
+
<label>Tri Captcha</label>
|
85 |
+
<sort_order>200</sort_order>
|
86 |
+
</tri>
|
87 |
+
</tabs>
|
88 |
+
<sections>
|
89 |
+
<tri_options translate="label" module="signupformcaptcha">
|
90 |
+
<label>Sign Up Captcha</label>
|
91 |
+
<tab>tri</tab>
|
92 |
+
<sort_order>10</sort_order>
|
93 |
+
<show_in_default>1</show_in_default>
|
94 |
+
<show_in_website>1</show_in_website>
|
95 |
+
<show_in_store>1</show_in_store>
|
96 |
+
<groups>
|
97 |
+
<general translate="label comment">
|
98 |
+
<label>General</label>
|
99 |
+
<sort_order>50</sort_order>
|
100 |
+
<show_in_default>1</show_in_default>
|
101 |
+
<show_in_website>1</show_in_website>
|
102 |
+
<show_in_store>1</show_in_store>
|
103 |
+
<fields>
|
104 |
+
<enabled translate="label comment">
|
105 |
+
<label>Enable Captcha</label>
|
106 |
+
<frontend_type>select</frontend_type>
|
107 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
108 |
+
<backend_model>contacts/system_config_backend_links</backend_model>
|
109 |
+
<sort_order>10</sort_order>
|
110 |
+
<show_in_default>1</show_in_default>
|
111 |
+
<show_in_website>1</show_in_website>
|
112 |
+
<show_in_store>1</show_in_store>
|
113 |
+
</enabled>
|
114 |
+
<public_key translate="label comment">
|
115 |
+
<label>Public Key</label>
|
116 |
+
<comment>You got this from the signup page: https://www.google.com/recaptcha/admin/create</comment>
|
117 |
+
<frontend_type>text</frontend_type>
|
118 |
+
<sort_order>20</sort_order>
|
119 |
+
<show_in_default>1</show_in_default>
|
120 |
+
<show_in_website>1</show_in_website>
|
121 |
+
<show_in_store>1</show_in_store>
|
122 |
+
</public_key>
|
123 |
+
<private_key translate="label comment">
|
124 |
+
<label>Private Key</label>
|
125 |
+
<comment>You got this from the signup page: https://www.google.com/recaptcha/admin/create</comment>
|
126 |
+
<frontend_type>text</frontend_type>
|
127 |
+
<sort_order>30</sort_order>
|
128 |
+
<show_in_default>1</show_in_default>
|
129 |
+
<show_in_website>1</show_in_website>
|
130 |
+
<show_in_store>1</show_in_store>
|
131 |
+
</private_key>
|
132 |
+
<theme translate="label comment">
|
133 |
+
<label>reCaptcha Theme</label>
|
134 |
+
<comment>Customizing the Look of reCAPTCHA</comment>
|
135 |
+
<frontend_type>select</frontend_type>
|
136 |
+
<source_model>signupformcaptcha/system_config_source_dropdown_theme</source_model>
|
137 |
+
<sort_order>40</sort_order>
|
138 |
+
<show_in_default>1</show_in_default>
|
139 |
+
<show_in_website>1</show_in_website>
|
140 |
+
<show_in_store>1</show_in_store>
|
141 |
+
</theme>
|
142 |
+
<lang translate="label comment">
|
143 |
+
<label>reCaptcha Language</label>
|
144 |
+
<comment>Which language is used in the reCaptcha interface</comment>
|
145 |
+
<frontend_type>select</frontend_type>
|
146 |
+
<source_model>signupformcaptcha/system_config_source_dropdown_lang</source_model>
|
147 |
+
<sort_order>50</sort_order>
|
148 |
+
<show_in_default>1</show_in_default>
|
149 |
+
<show_in_website>1</show_in_website>
|
150 |
+
<show_in_store>1</show_in_store>
|
151 |
+
</lang>
|
152 |
+
</fields>
|
153 |
+
</general>
|
154 |
+
</groups>
|
155 |
+
</tri_options>
|
156 |
+
</sections>
|
157 |
+
</config>
|
app/design/frontend/base/default/layout/signupformcaptcha.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
|
3 |
+
<layout version="0.1.0">
|
4 |
+
<customer_account_create>
|
5 |
+
<reference name="content">
|
6 |
+
<reference name="customer_form_register">
|
7 |
+
<action method="setTemplate"><template>signupformcaptcha/form.phtml</template></action>
|
8 |
+
</reference>
|
9 |
+
</reference>
|
10 |
+
</customer_account_create>
|
11 |
+
</layout>
|
app/design/frontend/base/default/template/signupformcaptcha/form.phtml
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="account-create">
|
2 |
+
<div class="page-title">
|
3 |
+
<h1><?php echo $this->__('Create an Account') ?></h1>
|
4 |
+
</div>
|
5 |
+
<?php echo $this->getChildHtml('form_fields_before')?>
|
6 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
7 |
+
<script type="text/javascript">
|
8 |
+
//<![CDATA[
|
9 |
+
var RecaptchaOptions = {
|
10 |
+
theme : '<?php echo $this->getCaptchaTheme(); ?>',
|
11 |
+
lang : '<?php echo $this->getCaptchaLang(); ?>',
|
12 |
+
};
|
13 |
+
//]]>
|
14 |
+
</script>
|
15 |
+
<?php /* Extensions placeholder */ ?>
|
16 |
+
<?php echo $this->getChildHtml('customer.form.register.extra')?>
|
17 |
+
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
|
18 |
+
<div class="fieldset">
|
19 |
+
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
|
20 |
+
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
|
21 |
+
<h2 class="legend"><?php echo $this->__('Personal Information') ?></h2>
|
22 |
+
<ul class="form-list">
|
23 |
+
<li class="fields">
|
24 |
+
<?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
|
25 |
+
</li>
|
26 |
+
<li>
|
27 |
+
<label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
28 |
+
<div class="input-box">
|
29 |
+
<input type="text" name="email" id="email_address" value="<?php echo $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
|
30 |
+
</div>
|
31 |
+
</li>
|
32 |
+
<?php if ($this->isNewsletterEnabled()): ?>
|
33 |
+
<li class="control">
|
34 |
+
<div class="input-box">
|
35 |
+
<input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed"<?php if($this->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox" />
|
36 |
+
</div>
|
37 |
+
<label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
|
38 |
+
<?php /* Extensions placeholder */ ?>
|
39 |
+
<?php echo $this->getChildHtml('customer.form.register.newsletter')?>
|
40 |
+
</li>
|
41 |
+
<?php endif ?>
|
42 |
+
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
|
43 |
+
<?php if ($_dob->isEnabled()): ?>
|
44 |
+
<li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
|
45 |
+
<?php endif ?>
|
46 |
+
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
|
47 |
+
<?php if ($_taxvat->isEnabled()): ?>
|
48 |
+
<li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
|
49 |
+
<?php endif ?>
|
50 |
+
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
|
51 |
+
<?php if ($_gender->isEnabled()): ?>
|
52 |
+
<li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
|
53 |
+
<?php endif ?>
|
54 |
+
</ul>
|
55 |
+
</div>
|
56 |
+
<?php if($this->getShowAddressFields()): ?>
|
57 |
+
<div class="fieldset">
|
58 |
+
<input type="hidden" name="create_address" value="1" />
|
59 |
+
<h2 class="legend"><?php echo $this->__('Address Information') ?></h2>
|
60 |
+
<ul class="form-list">
|
61 |
+
<li class="fields">
|
62 |
+
<div class="field">
|
63 |
+
<label for="company"><?php echo $this->__('Company') ?></label>
|
64 |
+
<div class="input-box">
|
65 |
+
<input type="text" name="company" id="company" value="<?php echo $this->escapeHtml($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
|
66 |
+
</div>
|
67 |
+
</div>
|
68 |
+
<div class="field">
|
69 |
+
<label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
70 |
+
<div class="input-box">
|
71 |
+
<input type="text" name="telephone" id="telephone" value="<?php echo $this->escapeHtml($this->getFormData()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" />
|
72 |
+
</div>
|
73 |
+
</div>
|
74 |
+
</li>
|
75 |
+
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
|
76 |
+
<li class="wide">
|
77 |
+
<label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
|
78 |
+
<div class="input-box">
|
79 |
+
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>" />
|
80 |
+
</div>
|
81 |
+
</li>
|
82 |
+
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
|
83 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
84 |
+
<li class="wide">
|
85 |
+
<div class="input-box">
|
86 |
+
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
|
87 |
+
</div>
|
88 |
+
</li>
|
89 |
+
<?php endfor; ?>
|
90 |
+
<li class="fields">
|
91 |
+
<div class="field">
|
92 |
+
<label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
93 |
+
<div class="input-box">
|
94 |
+
<input type="text" name="city" value="<?php echo $this->escapeHtml($this->getFormData()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
<div class="field">
|
98 |
+
<label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
99 |
+
<div class="input-box">
|
100 |
+
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
|
101 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
102 |
+
</select>
|
103 |
+
<script type="text/javascript">
|
104 |
+
//<![CDATA[
|
105 |
+
$('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
|
106 |
+
//]]>
|
107 |
+
</script>
|
108 |
+
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
|
109 |
+
</div>
|
110 |
+
</div>
|
111 |
+
</li>
|
112 |
+
<li class="fields">
|
113 |
+
<div class="field">
|
114 |
+
<label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
115 |
+
<div class="input-box">
|
116 |
+
<input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
<div class="field">
|
120 |
+
<label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
121 |
+
<div class="input-box">
|
122 |
+
<?php echo $this->getCountryHtmlSelect() ?>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
</li>
|
126 |
+
</ul>
|
127 |
+
<input type="hidden" name="default_billing" value="1" />
|
128 |
+
<input type="hidden" name="default_shipping" value="1" />
|
129 |
+
</div>
|
130 |
+
<?php endif; ?>
|
131 |
+
<div class="fieldset">
|
132 |
+
<h2 class="legend"><?php echo $this->__('Login Information') ?></h2>
|
133 |
+
<ul class="form-list">
|
134 |
+
<li class="fields">
|
135 |
+
<div class="field">
|
136 |
+
<label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
|
137 |
+
<div class="input-box">
|
138 |
+
<input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
|
139 |
+
</div>
|
140 |
+
</div>
|
141 |
+
<div class="field">
|
142 |
+
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
|
143 |
+
<div class="input-box">
|
144 |
+
<input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
|
145 |
+
</div>
|
146 |
+
</div>
|
147 |
+
</li>
|
148 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
149 |
+
|
150 |
+
</div>
|
151 |
+
|
152 |
+
|
153 |
+
|
154 |
+
<div class="input-box">
|
155 |
+
<?php echo $this->getCaptchaCode(); ?>
|
156 |
+
</div>
|
157 |
+
|
158 |
+
</ul>
|
159 |
+
<div class="buttons-set">
|
160 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
161 |
+
<p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>" class="back-link"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
162 |
+
<button type="submit" title="<?php echo $this->__('Submit') ?>" class="button"><span><span><?php echo $this->__('Submit') ?></span></span></button>
|
163 |
+
</div>
|
164 |
+
</form>
|
165 |
+
<script type="text/javascript">
|
166 |
+
//<![CDATA[
|
167 |
+
var dataForm = new VarienForm('form-validate', true);
|
168 |
+
<?php if($this->getShowAddressFields()): ?>
|
169 |
+
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
|
170 |
+
<?php endif; ?>
|
171 |
+
//]]>
|
172 |
+
</script>
|
173 |
+
</div>
|
174 |
+
|
175 |
+
|
176 |
+
|
app/etc/modules/Tri_SignupFormCaptcha.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Tri_SignupFormCaptcha>
|
6 |
+
<active>true</active>
|
7 |
+
<codePool>community</codePool>
|
8 |
+
</Tri_SignupFormCaptcha>
|
9 |
+
</modules>
|
10 |
+
</config>
|
app/locale/en_US/Tri_SignupFormCaptcha.csv
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Contacts Form Captcha","Signup Form Captcha"
|
2 |
+
"Enable Captcha","Enable Captcha"
|
3 |
+
"Public Key","Public Key"
|
4 |
+
"Private Key","Private Key"
|
5 |
+
"reCaptcha Theme","reCaptcha Theme"
|
6 |
+
"reCaptcha Language","reCaptcha Language"
|
7 |
+
"You got this from the signup page: https://www.google.com/recaptcha/admin/create","You got this from the signup page: https://www.google.com/recaptcha/admin/create"
|
8 |
+
"The reCAPTCHA wasn't entered correctly. Go back and try it again.","The reCAPTCHA wasn't entered correctly. Go back and try it again."
|
lib/reCaptcha/recaptchalib.php
ADDED
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
|
3 |
+
define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
|
4 |
+
define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Encodes the given data into a query string format
|
8 |
+
* @param $data - array of string elements to be encoded
|
9 |
+
* @return string - encoded request
|
10 |
+
*/
|
11 |
+
function _recaptcha_qsencode ($data) {
|
12 |
+
$req = "";
|
13 |
+
foreach ( $data as $key => $value )
|
14 |
+
$req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
|
15 |
+
|
16 |
+
// Cut the last '&'
|
17 |
+
$req=substr($req,0,strlen($req)-1);
|
18 |
+
return $req;
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Submits an HTTP POST to a reCAPTCHA server
|
25 |
+
* @param string $host
|
26 |
+
* @param string $path
|
27 |
+
* @param array $data
|
28 |
+
* @param int port
|
29 |
+
* @return array response
|
30 |
+
*/
|
31 |
+
function _recaptcha_http_post($host, $path, $data, $port = 80) {
|
32 |
+
|
33 |
+
$req = _recaptcha_qsencode ($data);
|
34 |
+
|
35 |
+
$http_request = "POST $path HTTP/1.0\r\n";
|
36 |
+
$http_request .= "Host: $host\r\n";
|
37 |
+
$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
|
38 |
+
$http_request .= "Content-Length: " . strlen($req) . "\r\n";
|
39 |
+
$http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
|
40 |
+
$http_request .= "\r\n";
|
41 |
+
$http_request .= $req;
|
42 |
+
|
43 |
+
$response = '';
|
44 |
+
if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
|
45 |
+
die ('Could not open socket');
|
46 |
+
}
|
47 |
+
|
48 |
+
fwrite($fs, $http_request);
|
49 |
+
|
50 |
+
while ( !feof($fs) )
|
51 |
+
$response .= fgets($fs, 1160); // One TCP-IP packet
|
52 |
+
fclose($fs);
|
53 |
+
$response = explode("\r\n\r\n", $response, 2);
|
54 |
+
|
55 |
+
return $response;
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Gets the challenge HTML (javascript and non-javascript version).
|
62 |
+
* This is called from the browser, and the resulting reCAPTCHA HTML widget
|
63 |
+
* is embedded within the HTML form it was called from.
|
64 |
+
* @param string $pubkey A public key for reCAPTCHA
|
65 |
+
* @param string $error The error given by reCAPTCHA (optional, default is null)
|
66 |
+
* @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
|
67 |
+
* @return string - The HTML to be embedded in the user's form.
|
68 |
+
*/
|
69 |
+
function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
|
70 |
+
{
|
71 |
+
if ($pubkey == null || $pubkey == '') {
|
72 |
+
die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
|
73 |
+
}
|
74 |
+
|
75 |
+
if ($use_ssl) {
|
76 |
+
$server = RECAPTCHA_API_SECURE_SERVER;
|
77 |
+
} else {
|
78 |
+
$server = RECAPTCHA_API_SERVER;
|
79 |
+
}
|
80 |
+
|
81 |
+
$errorpart = "";
|
82 |
+
if ($error) {
|
83 |
+
$errorpart = "&error=" . $error;
|
84 |
+
}
|
85 |
+
return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
|
86 |
+
|
87 |
+
<noscript>
|
88 |
+
<iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
|
89 |
+
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
|
90 |
+
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
|
91 |
+
</noscript>';
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
|
97 |
+
/**
|
98 |
+
* A ReCaptchaResponse is returned from recaptcha_check_answer()
|
99 |
+
*/
|
100 |
+
class ReCaptchaResponse {
|
101 |
+
var $is_valid;
|
102 |
+
var $error;
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Calls an HTTP POST function to verify if the user's guess was correct
|
108 |
+
* @param string $privkey
|
109 |
+
* @param string $remoteip
|
110 |
+
* @param string $challenge
|
111 |
+
* @param string $response
|
112 |
+
* @param array $extra_params an array of extra variables to post to the server
|
113 |
+
* @return ReCaptchaResponse
|
114 |
+
*/
|
115 |
+
function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
|
116 |
+
{
|
117 |
+
if ($privkey == null || $privkey == '') {
|
118 |
+
die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
|
119 |
+
}
|
120 |
+
|
121 |
+
if ($remoteip == null || $remoteip == '') {
|
122 |
+
die ("For security reasons, you must pass the remote ip to reCAPTCHA");
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
|
127 |
+
//discard spam submissions
|
128 |
+
if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
|
129 |
+
$recaptcha_response = new ReCaptchaResponse();
|
130 |
+
$recaptcha_response->is_valid = false;
|
131 |
+
$recaptcha_response->error = 'incorrect-captcha-sol';
|
132 |
+
return $recaptcha_response;
|
133 |
+
}
|
134 |
+
|
135 |
+
$response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
|
136 |
+
array (
|
137 |
+
'privatekey' => $privkey,
|
138 |
+
'remoteip' => $remoteip,
|
139 |
+
'challenge' => $challenge,
|
140 |
+
'response' => $response
|
141 |
+
) + $extra_params
|
142 |
+
);
|
143 |
+
|
144 |
+
$answers = explode ("\n", $response [1]);
|
145 |
+
$recaptcha_response = new ReCaptchaResponse();
|
146 |
+
|
147 |
+
if (trim ($answers [0]) == 'true') {
|
148 |
+
$recaptcha_response->is_valid = true;
|
149 |
+
}
|
150 |
+
else {
|
151 |
+
$recaptcha_response->is_valid = false;
|
152 |
+
$recaptcha_response->error = $answers [1];
|
153 |
+
}
|
154 |
+
return $recaptcha_response;
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* gets a URL where the user can sign up for reCAPTCHA. If your application
|
160 |
+
* has a configuration page where you enter a key, you should provide a link
|
161 |
+
* using this function.
|
162 |
+
* @param string $domain The domain where the page is hosted
|
163 |
+
* @param string $appname The name of your application
|
164 |
+
*/
|
165 |
+
function recaptcha_get_signup_url ($domain = null, $appname = null) {
|
166 |
+
return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname));
|
167 |
+
}
|
168 |
+
|
169 |
+
function _recaptcha_aes_pad($val) {
|
170 |
+
$block_size = 16;
|
171 |
+
$numpad = $block_size - (strlen ($val) % $block_size);
|
172 |
+
return str_pad($val, strlen ($val) + $numpad, chr($numpad));
|
173 |
+
}
|
174 |
+
|
175 |
+
/* Mailhide related code */
|
176 |
+
|
177 |
+
function _recaptcha_aes_encrypt($val,$ky) {
|
178 |
+
if (! function_exists ("mcrypt_encrypt")) {
|
179 |
+
die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");
|
180 |
+
}
|
181 |
+
$mode=MCRYPT_MODE_CBC;
|
182 |
+
$enc=MCRYPT_RIJNDAEL_128;
|
183 |
+
$val=_recaptcha_aes_pad($val);
|
184 |
+
return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
|
185 |
+
}
|
186 |
+
|
187 |
+
|
188 |
+
function _recaptcha_mailhide_urlbase64 ($x) {
|
189 |
+
return strtr(base64_encode ($x), '+/', '-_');
|
190 |
+
}
|
191 |
+
|
192 |
+
/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */
|
193 |
+
function recaptcha_mailhide_url($pubkey, $privkey, $email) {
|
194 |
+
if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) {
|
195 |
+
die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
|
196 |
+
"you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
|
197 |
+
}
|
198 |
+
|
199 |
+
|
200 |
+
$ky = pack('H*', $privkey);
|
201 |
+
$cryptmail = _recaptcha_aes_encrypt ($email, $ky);
|
202 |
+
|
203 |
+
return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail);
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* gets the parts of the email to expose to the user.
|
208 |
+
* eg, given johndoe@example,com return ["john", "example.com"].
|
209 |
+
* the email is then displayed as john...@example.com
|
210 |
+
*/
|
211 |
+
function _recaptcha_mailhide_email_parts ($email) {
|
212 |
+
$arr = preg_split("/@/", $email );
|
213 |
+
|
214 |
+
if (strlen ($arr[0]) <= 4) {
|
215 |
+
$arr[0] = substr ($arr[0], 0, 1);
|
216 |
+
} else if (strlen ($arr[0]) <= 6) {
|
217 |
+
$arr[0] = substr ($arr[0], 0, 3);
|
218 |
+
} else {
|
219 |
+
$arr[0] = substr ($arr[0], 0, 4);
|
220 |
+
}
|
221 |
+
return $arr;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Gets html to display an email address given a public an private key.
|
226 |
+
* to get a key, go to:
|
227 |
+
*
|
228 |
+
* http://www.google.com/recaptcha/mailhide/apikey
|
229 |
+
*/
|
230 |
+
function recaptcha_mailhide_html($pubkey, $privkey, $email) {
|
231 |
+
$emailparts = _recaptcha_mailhide_email_parts ($email);
|
232 |
+
$url = recaptcha_mailhide_url ($pubkey, $privkey, $email);
|
233 |
+
|
234 |
+
return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
|
235 |
+
"' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]);
|
236 |
+
|
237 |
+
}
|
238 |
+
|
239 |
+
|
240 |
+
?>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>nrgsignupformrecaptcha</name>
|
4 |
+
<version>1.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL v1.1.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>reCaptcha for sign up page</summary>
|
10 |
+
<description>reCaptcha for sign up page</description>
|
11 |
+
<notes>None</notes>
|
12 |
+
<authors><author><name>Nikita Nautiyal</name><user>nautiyal_nikita</user><email>nautiyal.nikita@gmail.com</email></author></authors>
|
13 |
+
<date>2013-11-19</date>
|
14 |
+
<time>10:36:31</time>
|
15 |
+
<contents><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="signupformcaptcha.xml" hash="0c22a6ae3e96fa7e95bae04691e99095"/></dir><dir name="template"><dir name="signupformcaptcha"><file name="form.phtml" hash="32dd0c1f18ca5619deb4bf4162b37f69"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Tri_SignupFormCaptcha.xml" hash="81f77d0bc38c9424be2d699486c8875f"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Tri_SignupFormCaptcha.csv" hash="1dbfb4db2a75c4403f42a84875b18c29"/></dir></target><target name="magelib"><dir name="reCaptcha"><file name="recaptchalib.php" hash="46a45855390608a518f0cb1da69025e9"/></dir></target><target name="magecommunity"><dir name="Tri"><dir name="SignupFormCaptcha"><dir name="Helper"><file name="Data.php" hash="cdd9774c9ca0fdc4a897a210f08a2ee6"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Dropdown"><file name="Lang.php" hash="c1193bcb16d302f29cd4f92a2a3b1a0c"/><file name="Theme.php" hash="1acbb3912cc72946513058a4e9eb9765"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AccountController.php" hash="41a20afb789afa4118e0aeb258a4bcca"/></dir><dir name="etc"><file name="config.xml" hash="7be0bf180330c1b702cf8e73f1d8e218"/><file name="system.xml" hash="cd4422851470abaa0c402dbf1e6e5114"/></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0</min><max>1.8</max></package></required></dependencies>
|
18 |
+
</package>
|