proxiblue-recaptcha - Version 1.2.3

Version Notes

Download this release

Release Info

Developer Lucas van Staden
Extension proxiblue-recaptcha
Version 1.2.3
Comparing to
See all releases


Version 1.2.3

app/code/community/ProxiBlue/ReCaptcha/Block/Captcha/Recaptcha.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The reCaptcha Block
5
+ *
6
+ * @category ProxiBlue
7
+ * @package ProxiBlue_reCaptcha
8
+ * @author Lucas van Staden (sales@proxiblue.com.au)
9
+ */
10
+ class ProxiBlue_ReCaptcha_Block_Captcha_Recaptcha extends Mage_Captcha_Block_Captcha_Zend {
11
+
12
+ protected $_template = 'captcha/recaptcha.phtml';
13
+
14
+ }
app/code/community/ProxiBlue/ReCaptcha/Helper/Data.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Captcha image type models
5
+ *
6
+ * @category ProxiBlue
7
+ * @package ProxiBlue_reCaptcha
8
+ * @author Lucas van Staden (sales@proxiblue.com.au)
9
+ */
10
+ class ProxiBlue_ReCaptcha_Helper_Data extends Mage_Captcha_Helper_Data {
11
+
12
+ /**
13
+ * The API server address
14
+ */
15
+ const RECAPTCHA_API_SERVER = "https://www.google.com";
16
+ const RECAPTCHA_API_PATH = "/recaptcha/api";
17
+ const RECAPTCHA_VERIFY_SERVER = "www.google.com";
18
+ const RECAPTCHA_VERIFY_PATH = "verify";
19
+ const RECAPTCHA_SITEVERIFY_PATH = "siteverify";
20
+
21
+ }
app/code/community/ProxiBlue/ReCaptcha/Model/Config/Lang.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Captcha image type models
5
+ *
6
+ * @category ProxiBlue
7
+ * @package ProxiBlue_reCaptcha
8
+ * @author Lucas van Staden (sales@proxiblue.com.au)
9
+ */
10
+ class ProxiBlue_ReCaptcha_Model_Config_Lang {
11
+
12
+ private $lang = array(array('value' => 'en', 'label' => 'English'),
13
+ array('value' => 'fr', 'label' => 'French'),
14
+ array('value' => 'de', 'label' => 'German'),
15
+ array('value' => 'nl', 'label' => 'Dutch'),
16
+ array('value' => 'pt', 'label' => 'Portuguese'),
17
+ array('value' => 'ru', 'label' => 'Russian'),
18
+ array('value' => 'es', 'label' => 'Spanish'),
19
+ array('value' => 'tr', 'label' => 'Turkish'),
20
+ );
21
+
22
+ public function toOptionArray() {
23
+ return $this->lang;
24
+ }
25
+
26
+ }
app/code/community/ProxiBlue/ReCaptcha/Model/Config/Themes.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Captcha image type models
5
+ *
6
+ * @category ProxiBlue
7
+ * @package ProxiBlue_reCaptcha
8
+ * @author Lucas van Staden (sales@proxiblue.com.au)
9
+ */
10
+ class ProxiBlue_ReCaptcha_Model_Config_Themes {
11
+
12
+ public function toOptionArray() {
13
+ return array(array('value' => 'clean', 'label' => 'Clean'),
14
+ array('value' => 'white', 'label' => 'White'),
15
+ array('value' => 'red', 'label' => 'Red'),
16
+ array('value' => 'blackglass', 'label' => 'Blackglass'),
17
+ array('value' => 'local', 'label' => 'Local'),
18
+ array('value' => 'New', 'label' => 'I am not a Robot')
19
+ );
20
+ }
21
+
22
+ }
app/code/community/ProxiBlue/ReCaptcha/Model/Observer.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Captcha Observer
5
+ *
6
+ * @category Mage
7
+ * @package Mage_Captcha
8
+ * @author Magento Core Team <core@magentocommerce.com>
9
+ */
10
+ class ProxiBlue_ReCaptcha_Model_Observer
11
+ {
12
+ /**
13
+ * Check Captcha On Contact Us
14
+ *
15
+ * @param Varien_Event_Observer $observer
16
+ *
17
+ * @return Mage_Captcha_Model_Observer
18
+ */
19
+ public function checkContact($observer)
20
+ {
21
+ $formId = 'user_contact';
22
+ $captchaModel = Mage::helper('captcha')->getCaptcha($formId);
23
+ if ($captchaModel->isRequired()) {
24
+ $controller = $observer->getControllerAction();
25
+ if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) {
26
+ Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));
27
+ // insert form data to session, allowing to re-populate the contact us form
28
+ $data = $controller->getRequest()->getPost();
29
+ Mage::getSingleton('customer/session')->setFormData($data);
30
+ $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
31
+ $controller->getResponse()->setRedirect(Mage::getUrl('*/*/'));
32
+ }
33
+ }
34
+
35
+ return $this;
36
+ }
37
+
38
+ /**
39
+ * Check Captcha On Product Reviews Page
40
+ *
41
+ * @param Varien_Event_Observer $observer
42
+ *
43
+ * @return Mage_Captcha_Model_Observer
44
+ */
45
+ public function checkReview($observer)
46
+ {
47
+ $formId = 'user_review';
48
+ $captchaModel = Mage::helper('captcha')->getCaptcha($formId);
49
+ if ($captchaModel->isRequired()) {
50
+ $controller = $observer->getControllerAction();
51
+ if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) {
52
+ Mage::getSingleton('core/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));
53
+ $data = $controller->getRequest()->getPost();
54
+ Mage::getSingleton('review/session')->setFormData($data);
55
+ if ($this->isOldMagento()) {
56
+ $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
57
+ if ($redirectUrl = Mage::getSingleton('review/session')->getRedirectUrl(true)) {
58
+ $controller->getResponse()->setRedirect($redirectUrl);
59
+
60
+ return $this;
61
+ }
62
+ $controller->getResponse()->setRedirect($this->_getRefererUrl($controller));
63
+ } else {
64
+ //invalidate the formkey, which will force the controller to redirect back to referer
65
+ $controller->getRequest()->setParam('form_key', 'Incorrect CAPTCHA.');
66
+ }
67
+ }
68
+ }
69
+
70
+ return $this;
71
+ }
72
+
73
+ /**
74
+ * Test if this is an older magento
75
+ *
76
+ * @return boolean
77
+ */
78
+ public function isOldMagento()
79
+ {
80
+ $isEE = Mage::helper('core')->isModuleEnabled('Enterprise_Enterprise');
81
+ $magentoVersion = Mage::getVersionInfo();
82
+ if ($magentoVersion['minor'] < 9 || ($isEE && $magentoVersion['minor'] < 13)) {
83
+ return true;
84
+ }
85
+
86
+ return false;
87
+ }
88
+
89
+ /**
90
+ * Get Captcha String
91
+ *
92
+ * @param Varien_Object $request
93
+ * @param string $formId
94
+ *
95
+ * @return string
96
+ */
97
+ protected function _getCaptchaString($request, $formId)
98
+ {
99
+ $captchaParams = $request->getPost(Mage_Captcha_Helper_Data::INPUT_NAME_FIELD_VALUE);
100
+
101
+ return $captchaParams[$formId];
102
+ }
103
+
104
+ /**
105
+ * Identify referer url via all accepted methods (HTTP_REFERER, regular or base64-encoded request param)
106
+ * Compatibility with magento < 1.9
107
+ *
108
+ * @return string
109
+ */
110
+ protected function _getRefererUrl($controller)
111
+ {
112
+ $refererUrl = $controller->getRequest()->getServer('HTTP_REFERER');
113
+ if ($url = $controller->getRequest()->getParam(Mage_Core_Controller_Varien_Action::PARAM_NAME_REFERER_URL)) {
114
+ $refererUrl = $url;
115
+ }
116
+ if ($url = $controller->getRequest()->getParam(Mage_Core_Controller_Varien_Action::PARAM_NAME_BASE64_URL)) {
117
+ $refererUrl = Mage::helper('core')->urlDecodeAndEscape($url);
118
+ }
119
+ if ($url = $controller->getRequest()->getParam(Mage_Core_Controller_Varien_Action::PARAM_NAME_URL_ENCODED)) {
120
+ $refererUrl = Mage::helper('core')->urlDecodeAndEscape($url);
121
+ }
122
+
123
+ if (!$this->_isUrlInternal($refererUrl)) {
124
+ $refererUrl = Mage::app()->getStore()->getBaseUrl();
125
+ }
126
+
127
+ return $refererUrl;
128
+ }
129
+
130
+ /**
131
+ * Check url to be used as internal
132
+ * Compatibility with magento < 1.9
133
+ *
134
+ *
135
+ * @param string $url
136
+ *
137
+ * @return bool
138
+ */
139
+ protected function _isUrlInternal($url)
140
+ {
141
+ if (strpos($url, 'http') !== false) {
142
+ /**
143
+ * Url must start from base secure or base unsecure url
144
+ */
145
+ if ((strpos($url, Mage::app()->getStore()->getBaseUrl()) === 0)
146
+ || (strpos($url, Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true)) === 0)
147
+ ) {
148
+ return true;
149
+ }
150
+ }
151
+
152
+ return false;
153
+ }
154
+
155
+
156
+ }
app/code/community/ProxiBlue/ReCaptcha/Model/Recaptcha.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * The reCaptcha Model
6
+ *
7
+ * @category ProxiBlue
8
+ * @package ProxiBlue_reCaptcha
9
+ * @author Lucas van Staden (sales@proxiblue.com.au)
10
+ */
11
+ class ProxiBlue_ReCaptcha_Model_Recaptcha extends Mage_Captcha_Model_Zend implements Mage_Captcha_Model_Interface
12
+ {
13
+
14
+ /**
15
+ * Key in session for captcha code
16
+ */
17
+ const SESSION_WORD = 'word';
18
+
19
+
20
+ /**
21
+ * Helper Instance
22
+ *
23
+ * @var Mage_Captcha_Helper_Data
24
+ */
25
+ protected $_helper = null;
26
+
27
+
28
+ /**
29
+ * Captcha form id
30
+ *
31
+ * @var string
32
+ */
33
+ protected $_formId;
34
+ protected $_language = 'en';
35
+ protected $_theme = 'clean';
36
+ protected $_private_key = null;
37
+ protected $_public_key = null;
38
+
39
+
40
+ /**
41
+ * Get Block Name
42
+ *
43
+ * @return string
44
+ */
45
+ public function getBlockName()
46
+ {
47
+ return 'proxiblue_recaptcha/captcha_recaptcha';
48
+ }
49
+
50
+ /**
51
+ * Returns captcha helper
52
+ *
53
+ * @return Mage_Captcha_Helper_Data
54
+ */
55
+ protected function _getHelper()
56
+ {
57
+ if (empty($this->_helper)) {
58
+ $this->_helper = Mage::helper('proxiblue_recaptcha');
59
+ }
60
+
61
+ return $this->_helper;
62
+ }
63
+
64
+ public function generate()
65
+ {
66
+ $this->_language = $this->_getHelper()->getConfigNode('language');
67
+ $this->_theme = $this->_getHelper()->getConfigNode('theme');
68
+ $this->_private_key = $this->_getHelper()->getConfigNode('private_key');
69
+ $this->_public_key = $this->_getHelper()->getConfigNode('public_key');
70
+ }
71
+
72
+ public function getLanguage()
73
+ {
74
+ return $this->_language;
75
+ }
76
+
77
+ public function getTheme()
78
+ {
79
+ return $this->_theme;
80
+ }
81
+
82
+ public function getPrivateKey()
83
+ {
84
+ return $this->_private_key;
85
+ }
86
+
87
+ public function getPublicKey()
88
+ {
89
+ return $this->_public_key;
90
+ }
91
+
92
+ public function isCorrect($word)
93
+ {
94
+ try {
95
+ $request = Mage::app()->getRequest();
96
+ $this->generate();
97
+ // is this the new 'I am not a robot'?
98
+ if ($response = $request->getParam('g-recaptcha-response')) {
99
+ $path = ProxiBlue_ReCaptcha_Helper_Data::RECAPTCHA_SITEVERIFY_PATH;
100
+ $params = array('secret' => $this->_private_key,
101
+ 'response' => $response
102
+ );
103
+ $result = $this->_sendRequest($path, $params);
104
+ $response = json_decode($result);
105
+ if (is_object($response) && $response->success == true) {
106
+ return true;
107
+ }
108
+ } else {
109
+ $params = array('privatekey' => $this->_private_key,
110
+ 'challenge' => $request->getParam('recaptcha_challenge_field'),
111
+ 'response' => $request->getParam('recaptcha_response_field'),
112
+ );
113
+
114
+ $path = ProxiBlue_ReCaptcha_Helper_Data::RECAPTCHA_VERIFY_PATH;
115
+ $result = $this->_sendRequest($path, $params);
116
+ $answers = explode("\n", $result);
117
+ if (is_array($answers) && array_key_exists('0', $answers)) {
118
+ return (trim($answers[0]) == 'true') ? true : false;
119
+ }
120
+ }
121
+ } catch (Exception $e) {
122
+ Mage::log($e);
123
+ }
124
+
125
+ return false;
126
+ }
127
+
128
+ public function getUrl()
129
+ {
130
+ return
131
+ ProxiBlue_ReCaptcha_Helper_Data::RECAPTCHA_API_SERVER . ProxiBlue_ReCaptcha_Helper_Data::RECAPTCHA_API_PATH
132
+ . '/challenge?k=' . $this->_public_key;
133
+ }
134
+
135
+ private function _sendRequest($path, $params)
136
+ {
137
+ $httpRequest = new Zend_Http_Client(
138
+ ProxiBlue_ReCaptcha_Helper_Data::RECAPTCHA_API_SERVER
139
+ . '/'
140
+ . ProxiBlue_ReCaptcha_Helper_Data::RECAPTCHA_API_PATH
141
+ . '/'
142
+ . $path
143
+ );
144
+ $httpRequest->setParameterPost(array_merge(array('remoteip' => $_SERVER['REMOTE_ADDR']), $params));
145
+ $response = $httpRequest->request('POST');
146
+ if ($response->getStatus() != 200) {
147
+ mage::throwException('Bad response from cpatcha gateway. we got ' . $response->getStatus());
148
+ }
149
+
150
+ return $response->getBody();
151
+
152
+ }
153
+ }
app/code/community/ProxiBlue/ReCaptcha/etc/config.xml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ProxiBlue_ReCaptcha>
5
+ <version>1.2.3</version>
6
+ <depends>
7
+ <Mage_Captcha/>
8
+ </depends>
9
+ </ProxiBlue_ReCaptcha>
10
+ </modules>
11
+ <global>
12
+ <blocks>
13
+ <proxiblue_recaptcha>
14
+ <class>ProxiBlue_ReCaptcha_Block</class>
15
+ </proxiblue_recaptcha>
16
+ </blocks>
17
+ <helpers>
18
+ <proxiblue_recaptcha>
19
+ <class>ProxiBlue_ReCaptcha_Helper</class>
20
+ </proxiblue_recaptcha>
21
+ </helpers>
22
+ <models>
23
+ <proxiblue_recaptcha>
24
+ <class>ProxiBlue_ReCaptcha_Model</class>
25
+ </proxiblue_recaptcha>
26
+ <captcha>
27
+ <rewrite>
28
+ <recaptcha>ProxiBlue_ReCaptcha_Model_Recaptcha</recaptcha>
29
+ </rewrite>
30
+ </captcha>
31
+ </models>
32
+ <events>
33
+ <controller_action_predispatch_contacts_index_post>
34
+ <observers>
35
+ <captcha>
36
+ <class>proxiblue_recaptcha/observer</class>
37
+ <method>checkContact</method>
38
+ </captcha>
39
+ </observers>
40
+ </controller_action_predispatch_contacts_index_post>
41
+ <controller_action_predispatch_review_product_post>
42
+ <observers>
43
+ <captcha>
44
+ <class>proxiblue_recaptcha/observer</class>
45
+ <method>checkReview</method>
46
+ </captcha>
47
+ </observers>
48
+ </controller_action_predispatch_review_product_post>
49
+ </events>
50
+ </global>
51
+ <frontend>
52
+ <layout>
53
+ <updates>
54
+ <proxiblue_recaptcha>
55
+ <file>proxiblue_recaptcha.xml</file>
56
+ </proxiblue_recaptcha>
57
+ </updates>
58
+ </layout>
59
+ </frontend>
60
+ <default>
61
+ <admin>
62
+ <captcha>
63
+ <type>recaptcha</type>
64
+ <theme>clean</theme>
65
+ <language>en</language>
66
+ <mode>always</mode>
67
+ </captcha>
68
+ </admin>
69
+ <customer>
70
+ <captcha>
71
+ <type>recaptcha</type>
72
+ <theme>clean</theme>
73
+ <language>en</language>
74
+ <mode>always</mode>
75
+ </captcha>
76
+ </customer>
77
+ <captcha translate="label">
78
+ <frontend>
79
+ <areas>
80
+ <user_contact>
81
+ <label>Contact</label>
82
+ </user_contact>
83
+ <user_review>
84
+ <label>Reviews</label>
85
+ </user_review>
86
+ </areas>
87
+ </frontend>
88
+ </captcha>
89
+ </default>
90
+ </config>
app/code/community/ProxiBlue/ReCaptcha/etc/file-list.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /app/code/community/ProxiBlue/ReCaptcha
2
+ /app/etc/modules/ProxiBlue_ReCaptcha.xml
3
+ /app/design/adminhtml/default/default/template/captcha/recaptcha.phtml
4
+ /app/design/frontend/base/default/layout/proxiblue_recaptcha.xml
5
+ /app/design/frontend/base/default/template/captcha/recaptcha.phtml
6
+ /skin/frontend/base/default/recaptcha
app/code/community/ProxiBlue/ReCaptcha/etc/system.xml ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <admin>
5
+ <groups>
6
+ <captcha translate="label">
7
+ <fields>
8
+ <font>
9
+ <depends>
10
+ <type>zend</type>
11
+ </depends>
12
+ </font>
13
+ <timeout>
14
+ <depends>
15
+ <type>zend</type>
16
+ </depends>
17
+ </timeout>
18
+ <length>
19
+ <depends>
20
+ <type>zend</type>
21
+ </depends>
22
+ </length>
23
+ <symbols>
24
+ <depends>
25
+ <type>zend</type>
26
+ </depends>
27
+ </symbols>
28
+ <case_sensitive>
29
+ <depends>
30
+ <type>zend</type>
31
+ </depends>
32
+ </case_sensitive>
33
+ <public_key translate="label">
34
+ <label>Public Key</label>
35
+ <frontend_type>text</frontend_type>
36
+ <sort_order>10</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ <depends>
41
+ <type>recaptcha</type>
42
+ </depends>
43
+ </public_key>
44
+ <private_key translate="label">
45
+ <label>Private Key</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>11</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <depends>
52
+ <type>recaptcha</type>
53
+ </depends>
54
+ </private_key>
55
+ <theme translate="label">
56
+ <label>Recaptcha Theme</label>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>proxiblue_recaptcha/config_themes</source_model>
59
+ <sort_order>3</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
+ <depends>
64
+ <type>recaptcha</type>
65
+ </depends>
66
+ </theme>
67
+ <language translate="label">
68
+ <label>Language</label>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>proxiblue_recaptcha/config_lang</source_model>
71
+ <sort_order>4</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ <depends>
76
+ <type>recaptcha</type>
77
+ </depends>
78
+ </language>
79
+ </fields>
80
+ </captcha>
81
+ </groups>
82
+ </admin>
83
+ <customer>
84
+ <groups>
85
+ <captcha translate="label">
86
+ <fields>
87
+ <font>
88
+ <depends>
89
+ <type>zend</type>
90
+ </depends>
91
+ </font>
92
+ <timeout>
93
+ <depends>
94
+ <type>zend</type>
95
+ </depends>
96
+ </timeout>
97
+ <length>
98
+ <depends>
99
+ <type>zend</type>
100
+ </depends>
101
+ </length>
102
+ <symbols>
103
+ <depends>
104
+ <type>zend</type>
105
+ </depends>
106
+ </symbols>
107
+ <case_sensitive>
108
+ <depends>
109
+ <type>zend</type>
110
+ </depends>
111
+ </case_sensitive>
112
+ <public_key translate="label">
113
+ <label>Public Key</label>
114
+ <frontend_type>text</frontend_type>
115
+ <sort_order>10</sort_order>
116
+ <show_in_default>1</show_in_default>
117
+ <show_in_website>1</show_in_website>
118
+ <show_in_store>1</show_in_store>
119
+ <depends>
120
+ <type>recaptcha</type>
121
+ </depends>
122
+ </public_key>
123
+ <private_key translate="label">
124
+ <label>Private Key</label>
125
+ <frontend_type>text</frontend_type>
126
+ <sort_order>11</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ <depends>
131
+ <type>recaptcha</type>
132
+ </depends>
133
+ </private_key>
134
+ <theme translate="label">
135
+ <label>Recaptcha Theme</label>
136
+ <frontend_type>select</frontend_type>
137
+ <source_model>proxiblue_recaptcha/config_themes</source_model>
138
+ <sort_order>3</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>1</show_in_store>
142
+ <depends>
143
+ <type>recaptcha</type>
144
+ </depends>
145
+ </theme>
146
+ <language translate="label">
147
+ <label>Language</label>
148
+ <frontend_type>select</frontend_type>
149
+ <source_model>proxiblue_recaptcha/config_lang</source_model>
150
+ <sort_order>4</sort_order>
151
+ <show_in_default>1</show_in_default>
152
+ <show_in_website>1</show_in_website>
153
+ <show_in_store>1</show_in_store>
154
+ <depends>
155
+ <type>recaptcha</type>
156
+ </depends>
157
+ </language>
158
+ </fields>
159
+ </captcha>
160
+ </groups>
161
+ </customer>
162
+ </sections>
163
+ </config>
app/design/adminhtml/default/default/template/captcha/recaptcha.phtml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $captcha = $this->getCaptchaModel() ?>
2
+ <?php $theme = $captcha->getTheme(); ?>
3
+
4
+ <?php if ($theme == 'local'): ?>
5
+ <script>
6
+ var RecaptchaOptions = {
7
+ theme: 'custom',
8
+ lang: '<?php echo $captcha->getLanguage(); ?>',
9
+ custom_theme_widget: 'recaptcha_widget'
10
+ };
11
+ </script>
12
+ <div id="recaptcha_widget" class="group-select wide fieldset" style="display:none">
13
+ <div class="col2-set">
14
+ <div class="col-1" style="width: 310px; margin-right: 10px; background: transparent; border: 0px none;">
15
+ <div id="recaptcha_image" style="border: 1px solid #CCCCCC; margin-bottom: 10px;"></div>
16
+ <div style="text-align: left;">
17
+ <span class="recaptcha_only_if_image"><?php echo $this->__(
18
+ 'Type the image letters or numbers'
19
+ ); ?></span>
20
+ <span class="recaptcha_only_if_audio"><?php echo $this->__('Type what you hear'); ?></span>
21
+ <input type="text" id="recaptcha_response_field" name="recaptcha_response_field"
22
+ class="input-text required-entry"/>
23
+ </div>
24
+ </div>
25
+ <div class="col-2" style="float: left; width: 25px; background: transparent; border: 0px none;">
26
+ <div><a href="javascript:Recaptcha.reload()"><img
27
+ src="<?php echo $this->getSkinUrl('recaptcha/images/refresh.png'); ?>"
28
+ title="<?php echo $this->__('Load Another Image'); ?>"
29
+ alt="<?php echo $this->__('Load Another Image'); ?>"/></a></div>
30
+ <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')"><img
31
+ src="<?php echo $this->getSkinUrl('recaptcha/images/sound.png'); ?>"
32
+ title="<?php echo $this->__('Get an audio challenge'); ?>"
33
+ alt="<?php echo $this->__('Get an audio challenge'); ?>"/></a></div>
34
+ <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')"><img
35
+ src="<?php echo $this->getSkinUrl('recaptcha/images/text.png'); ?>"
36
+ title="<?php echo $this->__('Get a visual challenge'); ?>"
37
+ alt="<?php echo $this->__('Get a visual challenge'); ?>"/></a></div>
38
+ <div><a href="javascript:Recaptcha.showhelp()"><img
39
+ src="<?php echo $this->getSkinUrl('fontis/recaptcha/images/help.png'); ?>"
40
+ title="<?php echo $this->__('help'); ?>" alt="<?php echo $this->__('help'); ?>"/></a></div>
41
+ </div>
42
+ </div>
43
+
44
+ </div>
45
+ <?php elseif ($theme == 'New'): ?>
46
+ <script type="text/javascript">
47
+ var onloadCallback = function () {
48
+ grecaptcha.render('recaptcha_html_element', {
49
+ 'sitekey': '<?php echo $captcha->getPublicKey(); ?>'
50
+ });
51
+ };
52
+ </script>
53
+ <div id="recaptcha_html_element"></div>
54
+ <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
55
+ <?php else: ?>
56
+ <script type="text/javascript">
57
+ var RecaptchaOptions = {
58
+ lang: '<?php echo $captcha->getLanguage(); ?>',
59
+ theme: '<?php echo $theme ?>',
60
+ };
61
+ </script>
62
+ <script type="text/javascript" src="<?php echo $captcha->getUrl(); ?>"></script>
63
+ <?php endif; ?>
app/design/frontend/base/default/layout/proxiblue_recaptcha.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <contacts_index_index>
4
+ <reference name="contactForm">
5
+ <block type="captcha/captcha" name="recaptcha">
6
+ <action method="setFormId">
7
+ <formId>user_contact</formId>
8
+ </action>
9
+ <action method="setImgWidth">
10
+ <width>230</width>
11
+ </action>
12
+ <action method="setImgHeight">
13
+ <width>50</width>
14
+ </action>
15
+ </block>
16
+ </reference>
17
+ </contacts_index_index>
18
+ <review_product_list>
19
+ <reference name="product.review.form">
20
+ <block type="captcha/captcha" name="recaptcha">
21
+ <action method="setFormId">
22
+ <formId>user_review</formId>
23
+ </action>
24
+ <action method="setImgWidth">
25
+ <width>230</width>
26
+ </action>
27
+ <action method="setImgHeight">
28
+ <width>50</width>
29
+ </action>
30
+ </block>
31
+ </reference>
32
+ </review_product_list>
33
+ </layout>
app/design/frontend/base/default/template/captcha/recaptcha.phtml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $captcha = $this->getCaptchaModel() ?>
2
+ <?php $theme = $captcha->getTheme(); ?>
3
+
4
+ <?php if ($theme == 'local'): ?>
5
+ <script>
6
+ var RecaptchaOptions = {
7
+ theme: 'custom',
8
+ lang: '<?php echo $captcha->getLanguage(); ?>',
9
+ custom_theme_widget: 'recaptcha_widget'
10
+ };
11
+ </script>
12
+ <div id="recaptcha_widget" class="group-select wide fieldset" style="display:none">
13
+ <div class="col2-set">
14
+ <div class="col-1" style="width: 310px; margin-right: 10px; background: transparent; border: 0px none;">
15
+ <div id="recaptcha_image" style="border: 1px solid #CCCCCC; margin-bottom: 10px;"></div>
16
+ <div style="text-align: left;">
17
+ <span class="recaptcha_only_if_image"><?php echo $this->__(
18
+ 'Type the image letters or numbers'
19
+ ); ?></span>
20
+ <span class="recaptcha_only_if_audio"><?php echo $this->__('Type what you hear'); ?></span>
21
+ <input type="text" id="recaptcha_response_field" name="recaptcha_response_field"
22
+ class="input-text required-entry"/>
23
+ </div>
24
+ </div>
25
+ <div class="col-2" style="float: left; width: 25px; background: transparent; border: 0px none;">
26
+ <div><a href="javascript:Recaptcha.reload()"><img
27
+ src="<?php echo $this->getSkinUrl('recaptcha/images/refresh.png'); ?>"
28
+ title="<?php echo $this->__('Load Another Image'); ?>"
29
+ alt="<?php echo $this->__('Load Another Image'); ?>"/></a></div>
30
+ <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')"><img
31
+ src="<?php echo $this->getSkinUrl('recaptcha/images/sound.png'); ?>"
32
+ title="<?php echo $this->__('Get an audio challenge'); ?>"
33
+ alt="<?php echo $this->__('Get an audio challenge'); ?>"/></a></div>
34
+ <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')"><img
35
+ src="<?php echo $this->getSkinUrl('recaptcha/images/text.png'); ?>"
36
+ title="<?php echo $this->__('Get a visual challenge'); ?>"
37
+ alt="<?php echo $this->__('Get a visual challenge'); ?>"/></a></div>
38
+ <div><a href="javascript:Recaptcha.showhelp()"><img
39
+ src="<?php echo $this->getSkinUrl('fontis/recaptcha/images/help.png'); ?>"
40
+ title="<?php echo $this->__('help'); ?>" alt="<?php echo $this->__('help'); ?>"/></a></div>
41
+ </div>
42
+ </div>
43
+
44
+ </div>
45
+ <?php elseif ($theme == 'New'): ?>
46
+ <script type="text/javascript">
47
+ var onloadCallback = function () {
48
+ grecaptcha.render('recaptcha_html_element', {
49
+ 'sitekey': '<?php echo $captcha->getPublicKey(); ?>'
50
+ });
51
+ };
52
+ </script>
53
+ <div id="recaptcha_html_element"></div>
54
+ <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
55
+ <?php else: ?>
56
+ <script type="text/javascript">
57
+ var RecaptchaOptions = {
58
+ lang: '<?php echo $captcha->getLanguage(); ?>',
59
+ theme: '<?php echo $theme ?>',
60
+ };
61
+ </script>
62
+ <script type="text/javascript" src="<?php echo $captcha->getUrl(); ?>"></script>
63
+ <?php endif; ?>
app/etc/modules/ProxiBlue_ReCaptcha.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ProxiBlue_ReCaptcha>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends></depends>
8
+ </ProxiBlue_ReCaptcha>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?xml version="1.0"?>
2
+ <package><name>proxiblue-recaptcha</name><version>1.2.3</version><stability>stable</stability><license>Custom License</license><channel>community</channel><extends></extends><summary></summary><description></description><notes></notes><authors><author><name>Lucas van Staden</name><user>proxiblue</user><email>sales@proxiblue.com.au</email></author></authors><date>2015-11-20</date><time>1:09:32</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="ProxiBlue"><dir name="ReCaptcha"><dir name="Model"><file name="Observer.php" hash="d6c0bd87886171400c9604658a28cd10"/><file name="Recaptcha.php" hash="b5118a1f58cdfa423b95214f80c6a656"/><dir name="Config"><file name="Lang.php" hash="1e41d395691c2a9d7302e02b09534b90"/><file name="Themes.php" hash="99f3d851e48ee24ecb8d57acc5cbb0ac"/></dir></dir><dir name="etc"><file name="config.xml" hash="d6a5371bfd3b49db7aa43caf035c1a2d"/><file name="file-list.txt" hash="3e107c153e663ca019ed5e959616b57f"/><file name="system.xml" hash="99ee82fe9e88027a1391595f5662cfc0"/></dir><dir name="Helper"><file name="Data.php" hash="02588e1bf43e7189776ec459c4e2c546"/></dir><dir name="Block"><dir name="Captcha"><file name="Recaptcha.php" hash="55f93f4002c41dd511f6a6133af4daca"/></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="ProxiBlue_ReCaptcha.xml" hash="140179aff01e1af20cdb4f1bdbdc8ec3"/></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="proxiblue_recaptcha.xml" hash="96b6aafb35780cfa8ce1262556029834"/></dir><dir name="template"><dir name="captcha"><file name="recaptcha.phtml" hash="19e555548961c4b8578d9934f779ab03"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="captcha"><file name="recaptcha.phtml" hash="19e555548961c4b8578d9934f779ab03"/></dir></dir></dir></dir></dir></dir></dir><dir name="skin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="recaptcha"><dir name="images"><file name="help.png" hash="c3812c74bc524179f4ccf5d2db7b3cbf"/><file name="refresh.png" hash="6b95778460f660aa7c08f47d244780a7"/><file name="sound.png" hash="8158cd1e7493e88be977a0be37d73aaf"/><file name="text.png" hash="dfcf6dcfd81693487e5642fc8e735dd6"/></dir></dir></dir></dir></dir></dir></target></contents></package>
skin/frontend/base/default/recaptcha/images/help.png ADDED
Binary file
skin/frontend/base/default/recaptcha/images/refresh.png ADDED
Binary file
skin/frontend/base/default/recaptcha/images/sound.png ADDED
Binary file
skin/frontend/base/default/recaptcha/images/text.png ADDED
Binary file