Fontis_Recaptcha - Version 1.0.0

Version Notes

Still requires functionality to save form data when incorrect reCAPTCHA is entered.

Download this release

Release Info

Developer Magento Core Team
Extension Fontis_Recaptcha
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Fontis/Recaptcha/Helper/Data.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Recaptcha Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * This code has been adopted from the reCAPTCHA module available at:
16
+ * http://recaptcha.net
17
+ * The original reCAPTCHA module was written by:
18
+ * Mike Crawford
19
+ * Ben Maurer
20
+ *
21
+ * @category Fontis
22
+ * @package Fontis_Recaptcha
23
+ * @author Denis Margetic
24
+ * @author Chris Norton
25
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ */
28
+ class Fontis_Recaptcha_Helper_Data extends Mage_Core_Helper_Abstract
29
+ {
30
+ const RECAPTCHA_API_SERVER = "http://api.recaptcha.net";
31
+ const RECAPTCHA_API_SECURE_SERVER = "https://api-secure.recaptcha.net";
32
+ const RECAPTCHA_VERIFY_SERVER = "api-verify.recaptcha.net";
33
+
34
+ /**
35
+ * Encodes the given data into a query string format
36
+ * @param $data - array of string elements to be encoded
37
+ * @return string - encoded request
38
+ */
39
+ function _recaptcha_qsencode ($data)
40
+ {
41
+ $req = "";
42
+ foreach ( $data as $key => $value )
43
+ $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
44
+
45
+ // Cut the last '&'
46
+ $req=substr($req,0,strlen($req)-1);
47
+ return $req;
48
+ }
49
+
50
+ /**
51
+ * Submits an HTTP POST to a reCAPTCHA server
52
+ * @param string $host
53
+ * @param string $path
54
+ * @param array $data
55
+ * @param int port
56
+ * @return array response
57
+ */
58
+ function _recaptcha_http_post($host, $path, $data, $port = 80)
59
+ {
60
+ $req = $this->_recaptcha_qsencode ($data);
61
+
62
+ $http_request = "POST $path HTTP/1.0\r\n";
63
+ $http_request .= "Host: $host\r\n";
64
+ $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
65
+ $http_request .= "Content-Length: " . strlen($req) . "\r\n";
66
+ $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
67
+ $http_request .= "\r\n";
68
+ $http_request .= $req;
69
+
70
+ $response = '';
71
+ if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
72
+ die ('Could not open socket');
73
+ }
74
+
75
+ fwrite($fs, $http_request);
76
+
77
+ while ( !feof($fs) )
78
+ $response .= fgets($fs, 1160); // One TCP-IP packet
79
+ fclose($fs);
80
+ $response = explode("\r\n\r\n", $response, 2);
81
+
82
+ return $response;
83
+ }
84
+
85
+ /**
86
+ * Gets the challenge HTML (javascript and non-javascript version).
87
+ * This is called from the browser, and the resulting reCAPTCHA HTML widget
88
+ * is embedded within the HTML form it was called from.
89
+ * @param string $pubkey A public key for reCAPTCHA
90
+ * @param string $error The error given by reCAPTCHA (optional, default is null)
91
+ * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
92
+
93
+ * @return string - The HTML to be embedded in the user's form.
94
+ */
95
+ function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
96
+ {
97
+ if ($pubkey == null || $pubkey == '') {
98
+ die ("To use reCAPTCHA you must get an API key from <a href='http://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>");
99
+ }
100
+
101
+ if ($use_ssl) {
102
+ $server = self::RECAPTCHA_API_SECURE_SERVER;
103
+ } else {
104
+ $server = self::RECAPTCHA_API_SERVER;
105
+ }
106
+
107
+ $errorpart = "";
108
+ if ($error) {
109
+ $errorpart = "&amp;error=" . $error;
110
+ }
111
+ return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
112
+
113
+ <noscript>
114
+ <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
115
+ <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
116
+ <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
117
+ </noscript>';
118
+ }
119
+
120
+ /**
121
+ * Calls an HTTP POST function to verify if the user's guess was correct
122
+ * @param string $privkey
123
+ * @param string $remoteip
124
+ * @param string $challenge
125
+ * @param string $response
126
+ * @param array $extra_params an array of extra variables to post to the server
127
+ * @return ReCaptchaResponse
128
+ */
129
+ function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
130
+ {
131
+ if ($privkey == null || $privkey == '') {
132
+ die ("To use reCAPTCHA you must get an API key from <a href='http://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>");
133
+ }
134
+
135
+ if ($remoteip == null || $remoteip == '') {
136
+ die ("For security reasons, you must pass the remote ip to reCAPTCHA");
137
+ }
138
+
139
+ //discard spam submissions
140
+ if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
141
+ return false;
142
+ }
143
+
144
+ $response = $this->_recaptcha_http_post (self::RECAPTCHA_VERIFY_SERVER, "/verify", array ( 'privatekey' => $privkey,
145
+ 'remoteip' => $remoteip,
146
+ 'challenge' => $challenge,
147
+ 'response' => $response
148
+ ) + $extra_params
149
+ );
150
+
151
+ $answers = explode ("\n", $response [1]);
152
+
153
+ if (trim ($answers [0]) == 'true') {
154
+ return true;
155
+ }
156
+ return false;
157
+ }
158
+
159
+ /**
160
+ * gets a URL where the user can sign up for reCAPTCHA. If your application
161
+ * has a configuration page where you enter a key, you should provide a link
162
+ * using this function.
163
+ * @param string $domain The domain where the page is hosted
164
+ * @param string $appname The name of your application
165
+ */
166
+ function recaptcha_get_signup_url ($domain = null, $appname = null)
167
+ {
168
+ return "http://recaptcha.net/api/getkey?" . $this->_recaptcha_qsencode (array ('domain' => $domain, 'app' => $appname));
169
+ }
170
+
171
+ function _recaptcha_aes_pad($val)
172
+ {
173
+ $block_size = 16;
174
+ $numpad = $block_size - (strlen ($val) % $block_size);
175
+ return str_pad($val, strlen ($val) + $numpad, chr($numpad));
176
+ }
177
+ }
178
+ ?>
app/code/community/Fontis/Recaptcha/Model/Source/Recaptchatheme.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Recaptcha Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Recaptcha
17
+ * @author Denis Margetic
18
+ * @author Chris Norton
19
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class Fontis_Recaptcha_Model_Source_Recaptchatheme
24
+ {
25
+ public function toOptionArray()
26
+ {
27
+ return array(array('value' => 'clean', 'label' => 'Clean'),
28
+ array('value' => 'white', 'label' => 'White'),
29
+ array('value' => 'red', 'label' => 'Red'),
30
+ array('value' => 'blackglass', 'label' => 'Blackglass'),
31
+ );
32
+ }
33
+ }
app/code/community/Fontis/Recaptcha/controllers/AccountController.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Recaptcha Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Recaptcha
17
+ * @author Denis Margetic
18
+ * @author Chris Norton
19
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ include_once "Mage/Customer/controllers/AccountController.php";
23
+
24
+ class Fontis_Recaptcha_AccountController extends Mage_Customer_AccountController
25
+ {
26
+ public function createPostAction()
27
+ {
28
+ if (Mage::getStoreConfig("customer/recaptcha/enabled")) { // check that recaptcha is actually enabled
29
+ // get private key from system configuration
30
+ $privatekey = Mage::getStoreConfig("admin/recaptcha/private_key");
31
+ // check response
32
+ $resp = Mage::helper("recaptcha")->recaptcha_check_answer( $privatekey,
33
+ $_SERVER["REMOTE_ADDR"],
34
+ $_POST["recaptcha_challenge_field"],
35
+ $_POST["recaptcha_response_field"]
36
+ );
37
+ if ($resp == true) { // if recaptcha response is correct, follow core functionality
38
+ if ($this->_getSession()->isLoggedIn()) {
39
+ $this->_redirect('*/*/');
40
+ return;
41
+ }
42
+ if ($this->getRequest()->isPost()) {
43
+ $errors = array();
44
+ $customer = Mage::getModel('customer/customer')->setId(null);
45
+ foreach (Mage::getConfig()->getFieldset('customer_account') as $code=>$node) {
46
+ if ($node->is('create') && ($value = $this->getRequest()->getParam($code)) !== null) {
47
+ $customer->setData($code, $value);
48
+ }
49
+ }
50
+ if ($this->getRequest()->getParam('is_subscribed', false)) {
51
+ $customer->setIsSubscribed(1);
52
+ }
53
+ $customer->getGroupId();
54
+ if ($this->getRequest()->getPost('create_address')) {
55
+ $address = Mage::getModel('customer/address')
56
+ ->setData($this->getRequest()->getPost())
57
+ ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
58
+ ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false))
59
+ ->setId(null);
60
+ $customer->addAddress($address);
61
+ $errors = $address->validate();
62
+ if (!is_array($errors)) {
63
+ $errors = array();
64
+ }
65
+ }
66
+ try {
67
+ $validationCustomer = $customer->validate();
68
+ if (is_array($validationCustomer)) {
69
+ $errors = array_merge($validationCustomer, $errors);
70
+ }
71
+ $validationResult = count($errors) == 0;
72
+
73
+ if (true === $validationResult) {
74
+ $customer->save();
75
+ if ($customer->isConfirmationRequired()) {
76
+ $customer->sendNewAccountEmail('confirmation', $this->_getSession()->getBeforeAuthUrl());
77
+ $this->_getSession()->addSuccess($this->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.',
78
+ Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail()))
79
+ );
80
+ $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
81
+ return;
82
+ } else {
83
+ $this->_getSession()->setCustomerAsLoggedIn($customer);
84
+ $url = $this->_welcomeCustomer($customer);
85
+ $this->_redirectSuccess($url);
86
+ return;
87
+ }
88
+ } else {
89
+ $this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
90
+ if (is_array($errors)) {
91
+ foreach ($errors as $errorMessage) {
92
+ $this->_getSession()->addError($errorMessage);
93
+ }
94
+ } else {
95
+ $this->_getSession()->addError($this->__('Invalid customer data'));
96
+ }
97
+ }
98
+ } catch (Mage_Core_Exception $e) {
99
+ $this->_getSession()->addError($e->getMessage())
100
+ ->setCustomerFormData($this->getRequest()->getPost());
101
+ } catch (Exception $e) {
102
+ $this->_getSession()->setCustomerFormData($this->getRequest()->getPost())
103
+ ->addException($e, $this->__('Can\'t save customer'));
104
+ }
105
+ }
106
+ $this->_redirectError(Mage::getUrl('*/*/create', array('_secure'=>true)));
107
+ }else{ // if recaptcha response is incorrect, reload the page
108
+ $this->_redirectReferer();
109
+ return;
110
+ }
111
+ } else { // if recaptcha is not enabled, use core function alone
112
+ parent::sendmailAction();
113
+ }
114
+ }
115
+ }
116
+ ?>
app/code/community/Fontis/Recaptcha/controllers/ContactsController.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Recaptcha Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Recaptcha
17
+ * @author Denis Margetic
18
+ * @author Chris Norton
19
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ include_once "Mage/Contacts/controllers/IndexController.php";
23
+
24
+ class Fontis_Recaptcha_ContactsController extends Mage_Contacts_IndexController
25
+ {
26
+ public function postAction()
27
+ {
28
+ if (Mage::getStoreConfig("sendfriend/recaptcha/enabled")) { // check that recaptcha is actually enabled
29
+ // get private key from system configuration
30
+ $privatekey = Mage::getStoreConfig("admin/recaptcha/private_key");
31
+ // check response
32
+ $resp = Mage::helper("recaptcha")->recaptcha_check_answer( $privatekey,
33
+ $_SERVER["REMOTE_ADDR"],
34
+ $_POST["recaptcha_challenge_field"],
35
+ $_POST["recaptcha_response_field"]
36
+ );
37
+ if ($resp == true) { // if recaptcha response is correct, follow core functionality
38
+ $post = $this->getRequest()->getPost();
39
+ if ( $post ) {
40
+ $translate = Mage::getSingleton('core/translate');
41
+ /* @var $translate Mage_Core_Model_Translate */
42
+ $translate->setTranslateInline(false);
43
+ try {
44
+ $postObject = new Varien_Object();
45
+ $postObject->setData($post);
46
+ $error = false;
47
+ if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {
48
+ $error = true;
49
+ }
50
+ if (!Zend_Validate::is(trim($post['comment']) , 'NotEmpty')) {
51
+ $error = true;
52
+ }
53
+ if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
54
+ $error = true;
55
+ }
56
+ if ($error) {
57
+ throw new Exception();
58
+ }
59
+ $mailTemplate = Mage::getModel('core/email_template');
60
+ /* @var $mailTemplate Mage_Core_Model_Email_Template */
61
+ $mailTemplate->setDesignConfig(array('area' => 'frontend'))
62
+ ->setReplyTo($post['email'])
63
+ ->sendTransactional( Mage::getStoreConfig('contacts/email/email_template'),
64
+ Mage::getStoreConfig('contacts/email/sender_email_identity'),
65
+ Mage::getStoreConfig('contacts/email/recipient_email'),
66
+ null,
67
+ array('data' => $postObject)
68
+ );
69
+ if (!$mailTemplate->getSentSuccess()) {
70
+ throw new Exception();
71
+ }
72
+ $translate->setTranslateInline(true);
73
+ Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
74
+ $this->_redirect('*/*/');
75
+ return;
76
+ } catch (Exception $e) {
77
+ $translate->setTranslateInline(true);
78
+ Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
79
+ $this->_redirect('*/*/');
80
+ return;
81
+ }
82
+ } else {
83
+ $this->_redirect('*/*/');
84
+ }
85
+ }else{ // if recaptcha response is incorrect, reload the page
86
+ $this->_redirectReferer();
87
+ return;
88
+ }
89
+ } else { // if recaptcha is not enabled, use core function alone
90
+ parent::sendmailAction();
91
+ }
92
+ }
93
+ }
94
+ ?>
app/code/community/Fontis/Recaptcha/controllers/ProductController.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Recaptcha Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Recaptcha
17
+ * @author Denis Margetic
18
+ * @author Chris Norton
19
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ include_once "Mage/Sendfriend/controllers/ProductController.php";
23
+
24
+ class Fontis_Recaptcha_ProductController extends Mage_Sendfriend_ProductController
25
+ {
26
+ public function sendmailAction()
27
+ {
28
+ if (Mage::getStoreConfig("sendfriend/recaptcha/enabled")) { // check that recaptcha is actually enabled
29
+ // get private key from system configuration
30
+ $privatekey = Mage::getStoreConfig("admin/recaptcha/private_key");
31
+ // check response
32
+ $resp = Mage::helper("recaptcha")->recaptcha_check_answer( $privatekey,
33
+ $_SERVER["REMOTE_ADDR"],
34
+ $_POST["recaptcha_challenge_field"],
35
+ $_POST["recaptcha_response_field"]
36
+ );
37
+ if ($resp == true) { // if recaptcha response is correct, follow core functionality
38
+ $product = $this->_initProduct();
39
+ $sendToFriendModel = $this->_initSendToFriendModel();
40
+ $data = $this->getRequest()->getPost();
41
+ if (!$product || !$product->isVisibleInCatalog() || !$data) {
42
+ $this->_forward('noRoute');
43
+ return;
44
+ }
45
+ $categoryId = $this->getRequest()->getParam('cat_id', null);
46
+ if ($categoryId && $category = Mage::getModel('catalog/category')->load($categoryId)) {
47
+ Mage::register('current_category', $category);
48
+ }
49
+ $sendToFriendModel->setSender($this->getRequest()->getPost('sender'));
50
+ $sendToFriendModel->setRecipients($this->getRequest()->getPost('recipients'));
51
+ $sendToFriendModel->setIp(Mage::getSingleton('log/visitor')->getRemoteAddr());
52
+ $sendToFriendModel->setProduct($product);
53
+ try {
54
+ $validateRes = $sendToFriendModel->validate();
55
+ if (true === $validateRes) {
56
+ $sendToFriendModel->send();
57
+ Mage::getSingleton('catalog/session')->addSuccess($this->__('Link to a friend was sent.'));
58
+ $this->_redirectSuccess($product->getProductUrl());
59
+ return;
60
+ } else {
61
+ Mage::getSingleton('catalog/session')->setFormData($data);
62
+ if (is_array($validateRes)) {
63
+ foreach ($validateRes as $errorMessage) {
64
+ Mage::getSingleton('catalog/session')->addError($errorMessage);
65
+ }
66
+ } else {
67
+ Mage::getSingleton('catalog/session')->addError($this->__('Some problems with data.'));
68
+ }
69
+ }
70
+ } catch (Mage_Core_Exception $e) {
71
+ Mage::getSingleton('catalog/session')->addError($e->getMessage());
72
+ } catch (Exception $e) {
73
+ Mage::getSingleton('catalog/session')
74
+ ->addException($e, $this->__('Some emails were not sent'));
75
+ echo $e->getTraceAsString();
76
+ }
77
+ $this->_redirectError(Mage::getURL('*/*/send',array('id'=>$product->getId())));
78
+ } else { // if recaptcha response is incorrect, reload the page
79
+ $this->_redirectReferer();
80
+ return;
81
+ }
82
+ } else { // if recaptcha is not enabled, use core function alone
83
+ parent::sendmailAction();
84
+ }
85
+ }
86
+ }
87
+ ?>
app/code/community/Fontis/Recaptcha/etc/config.xml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Fontis Recaptcha Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Fontis
17
+ * @package Fontis_Recaptcha
18
+ * @author Denis Margetic
19
+ * @author Chris Norton
20
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <modules>
26
+ <Fontis_Recaptcha>
27
+ <version>1.0.0</version>
28
+ </Fontis_Recaptcha>
29
+ </modules>
30
+ <global>
31
+ <models>
32
+ <fontis_recaptcha>
33
+ <class>Fontis_Recaptcha_Model</class>
34
+ </fontis_recaptcha>
35
+ </models>
36
+ <routers>
37
+ <sendfriend>
38
+ <rewrite>
39
+ <product>
40
+ <to>recaptcha/product</to>
41
+ </product>
42
+ </rewrite>
43
+ </sendfriend>
44
+ <customer>
45
+ <rewrite>
46
+ <account>
47
+ <actions>
48
+ <create>
49
+ <to>recaptcha/account/create</to>
50
+ </create>
51
+ </actions>
52
+ </account>
53
+ </rewrite>
54
+ </customer>
55
+ <contacts>
56
+ <rewrite>
57
+ <index>
58
+ <to>recaptcha/contacts</to>
59
+ </index>
60
+ </rewrite>
61
+ </contacts>
62
+ </routers>
63
+ <helpers>
64
+ <recaptcha>
65
+ <class>Fontis_Recaptcha_Helper</class>
66
+ </recaptcha>
67
+ </helpers>
68
+ </global>
69
+ <frontend>
70
+ <routers>
71
+ <recaptcha>
72
+ <use>standard</use>
73
+ <args>
74
+ <module>Fontis_Recaptcha</module>
75
+ <frontName>recaptcha</frontName>
76
+ </args>
77
+ </recaptcha>
78
+ </routers>
79
+ <layout>
80
+ <updates>
81
+ <recaptcha module="Fontis_Recaptcha">
82
+ <file>fontis_recaptcha.xml</file>
83
+ </recaptcha>
84
+ </updates>
85
+ </layout>
86
+ </frontend>
87
+ <default>
88
+ <admin>
89
+ <recaptcha>
90
+ <public_key></public_key>
91
+ <private_key></private_key>
92
+ <recaptcha_theme>clean</recaptcha_theme>
93
+ </recaptcha>
94
+ </admin>
95
+ <sendfriend>
96
+ <recaptcha>
97
+ <enabled>1</enabled>
98
+ </recaptcha>
99
+ </sendfriend>
100
+ <contacts>
101
+ <recaptcha>
102
+ <enabled>1</enabled>
103
+ </recaptcha>
104
+ </contacts>
105
+ <customer>
106
+ <recaptcha>
107
+ <enabled>1</enabled>
108
+ </recaptcha>
109
+ </customer>
110
+ </default>
111
+ </config>
app/code/community/Fontis/Recaptcha/etc/system.xml ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Fontis Recaptcha Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Fontis
17
+ * @package Fontis_Recaptcha
18
+ * @author Denis Margetic
19
+ * @author Chris Norton
20
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <sections>
26
+ <admin>
27
+ <groups>
28
+ <recaptcha translate="label">
29
+ <label>Recaptcha Settings</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>5</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
+ <fields>
36
+ <public_key translate="label">
37
+ <label>Public Key</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>2</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ </public_key>
43
+ <private_key translate="label">
44
+ <label>Private Key</label>
45
+ <frontend_type>text</frontend_type>
46
+ <sort_order>3</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ </private_key>
50
+ <recaptcha_theme translate="label">
51
+ <label>Recaptcha Theme</label>
52
+ <frontend_type>select</frontend_type>
53
+ <source_model>fontis_recaptcha/source_recaptchatheme</source_model>
54
+ <sort_order>1</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ </recaptcha_theme>
58
+ </fields>
59
+ </recaptcha>
60
+ </groups>
61
+ </admin>
62
+ <sendfriend>
63
+ <groups>
64
+ <recaptcha translate="label">
65
+ <label>Email to a Friend Recaptcha</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>5</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ <fields>
72
+ <enabled translate="label">
73
+ <label>Enabled</label>
74
+ <frontend_type>select</frontend_type>
75
+ <source_model>adminhtml/system_config_source_yesno</source_model>
76
+ <sort_order>1</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ </enabled>
80
+ </fields>
81
+ </recaptcha>
82
+ </groups>
83
+ </sendfriend>
84
+ <customer>
85
+ <groups>
86
+ <recaptcha translate="label">
87
+ <label>Create New Account Recaptcha</label>
88
+ <frontend_type>text</frontend_type>
89
+ <sort_order>55</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ <fields>
94
+ <enabled translate="label">
95
+ <label>Enabled</label>
96
+ <frontend_type>select</frontend_type>
97
+ <source_model>adminhtml/system_config_source_yesno</source_model>
98
+ <sort_order>1</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ </enabled>
102
+ </fields>
103
+ </recaptcha>
104
+ </groups>
105
+ </customer>
106
+ <contacts>
107
+ <groups>
108
+ <recaptcha translate="label">
109
+ <label>Contact Us Recaptcha</label>
110
+ <frontend_type>text</frontend_type>
111
+ <sort_order>50</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ <fields>
116
+ <enabled translate="label">
117
+ <label>Enabled</label>
118
+ <frontend_type>select</frontend_type>
119
+ <source_model>adminhtml/system_config_source_yesno</source_model>
120
+ <sort_order>1</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>1</show_in_website>
123
+ </enabled>
124
+ </fields>
125
+ </recaptcha>
126
+ </groups>
127
+ </contacts>
128
+ </sections>
129
+ </config>
app/design/frontend/default/default/layout/fontis_recaptcha.xml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Fontis Recaptcha Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Fontis
17
+ * @package Fontis_Recaptcha
18
+ * @author Denis Margetic
19
+ * @author Chris Norton
20
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+ -->
24
+ <layout version="0.1.0">
25
+ <recaptcha_product_send>
26
+ <reference name="root">
27
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
28
+ </reference>
29
+ <reference name="head">
30
+ <action method="addJs"><script>varien/product.js</script></action>
31
+ </reference>
32
+ <reference name="content">
33
+ <block type="sendfriend/send" name="sendfriend.fontis.send" template="fontis/recaptcha/send.phtml" />
34
+ </reference>
35
+ </recaptcha_product_send>
36
+ <recaptcha_contacts_index>
37
+ <reference name="root">
38
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
39
+ <action method="setHeaderTitle" translate="title" module="contacts"><title>Contact Us</title></action>
40
+ </reference>
41
+ <reference name="content">
42
+ <block type="core/template" name="contactForm" template="fontis/recaptcha/form.phtml"/>
43
+ </reference>
44
+ </recaptcha_contacts_index>
45
+ <recaptcha_account_create>
46
+ <remove name="right"/>
47
+ <remove name="left"/>
48
+ <reference name="root">
49
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
50
+ </reference>
51
+ <reference name="content">
52
+ <block type="customer/form_register" name="customer_form_register" template="fontis/recaptcha/register.phtml"/>
53
+ </reference>
54
+ </recaptcha_account_create>
55
+ </layout>
app/design/frontend/default/default/template/fontis/recaptcha/form.phtml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Recaptcha Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Recaptcha
17
+ * @author Denis Margetic
18
+ * @author Chris Norton
19
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
24
+ <div class="page-head">
25
+ <h3><?php echo Mage::helper('contacts')->__('Contact Us') ?></h3>
26
+ </div>
27
+ <form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
28
+ <fieldset class="group-select">
29
+ <h4 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h4>
30
+ <ul>
31
+ <li>
32
+ <div class="input-box">
33
+ <label for="name"><?php echo Mage::helper('contacts')->__('Name') ?> <span class="required">*</span></label><br />
34
+ <input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserName()) ?>" class="required-entry input-text" type="text" />
35
+ </div>
36
+
37
+ <div class="input-box">
38
+ <label for="email"><?php echo Mage::helper('contacts')->__('Email') ?> <span class="required">*</span></label><br />
39
+ <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text" />
40
+ </div>
41
+
42
+ <div class="clear"></div>
43
+
44
+ <div class="input-box">
45
+ <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label><br />
46
+ <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="text" />
47
+ </div>
48
+
49
+ <div class="clear"></div>
50
+
51
+ <div class="input-box">
52
+ <label for="comment"><?php echo Mage::helper('contacts')->__('Comment') ?></label><br />
53
+ <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" style="height:150px;width:525px;" cols="50" rows="5"></textarea>
54
+ </div>
55
+ </li>
56
+ </ul>
57
+ </fieldset>
58
+
59
+ <?php // recaptcha
60
+ if (Mage::getStoreConfig("contacts/recaptcha/enabled")) {
61
+ // set the recaptcha theme based on preferences
62
+ echo '<script> var RecaptchaOptions = { theme : \'';
63
+ echo Mage::getStoreConfig("admin/recaptcha/recaptcha_theme");
64
+ echo '\' }; </script>';
65
+ // show the recaptcha form
66
+ $publickey = Mage::getStoreConfig("admin/recaptcha/public_key");
67
+ echo Mage::helper("recaptcha")->recaptcha_get_html($publickey);
68
+ }
69
+ ?>
70
+
71
+ <div class="button-set">
72
+ <p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
73
+ <button class="form-button" type="submit"><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></button>
74
+ </div>
75
+ </form>
76
+ <script type="text/javascript">
77
+ var contactForm = new VarienForm('contactForm', true);
78
+ </script>
app/design/frontend/default/default/template/fontis/recaptcha/register.phtml ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Recaptcha Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Recaptcha
17
+ * @author Denis Margetic
18
+ * @author Chris Norton
19
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * Create account form template
26
+ *
27
+ * @see Mage_Customer_Block_Form_Register
28
+ */
29
+ ?>
30
+ <div class="page-head">
31
+ <h3><?php echo $this->__('Create an Account') ?></h3>
32
+ </div>
33
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
34
+ <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
35
+ <fieldset class="group-select wide">
36
+ <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
37
+ <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
38
+ <h4 class="legend"><?php echo $this->__('Personal Information') ?></h4>
39
+ <ul>
40
+ <li>
41
+ <?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->toHtml() ?>
42
+ </li>
43
+ <li>
44
+ <div class="input-box">
45
+ <label for="email_address"><?php echo $this->__('Email Address') ?> <span class="required">*</span></label><br/>
46
+ <input type="text" name="email" id="email_address" value="<?php echo $this->htmlEscape($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry input-text" />
47
+ </div>
48
+ </li>
49
+ <?php if ($this->isNewsletterEnabled()): ?>
50
+ <li>
51
+ <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 ?> />
52
+ <label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
53
+ </li>
54
+ <?php endif ?>
55
+ <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
56
+ <?php if ($_dob->isEnabled()): ?>
57
+ <li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
58
+ <?php endif ?>
59
+ <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
60
+ <?php if ($_taxvat->isEnabled()): ?>
61
+ <li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
62
+ <?php endif ?>
63
+ </ul>
64
+ </fieldset>
65
+ <?php if($this->getShowAddressFields()): ?>
66
+ <input type="hidden" name="create_address" value="1" />
67
+ <fieldset class="group-select wide">
68
+ <h4 class="legend"><?php echo $this->__('Address Information') ?></h4>
69
+ <ul>
70
+ <li>
71
+ <div class="input-box">
72
+ <label for="company"><?php echo $this->__('Company') ?></label><br />
73
+ <input type="text" name="company" id="company" value="<?php echo $this->htmlEscape($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" />
74
+ </div>
75
+ <div class="input-box">
76
+ <label for="lastname"><?php echo $this->__('Telephone') ?> <span class="required">*</span></label><br />
77
+ <input type="text" name="telephone" id="telephone" value="<?php echo $this->htmlEscape($this->getFormData()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="required-entry input-text" />
78
+ </div>
79
+ </li>
80
+ <li>
81
+ <label for="street_1"><?php echo $this->__('Street Address') ?> <span class="required">*</span></label><br />
82
+ <input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getFormData()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="required-entry input-text" />
83
+ </li>
84
+ <?php for ($_i=2, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++): ?>
85
+ <li>
86
+ <input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getFormData()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address '.$_i) ?>" id="street_<?php echo $_i?>" class="input-text" />
87
+ <?php endfor ?>
88
+ </li>
89
+ <li>
90
+ <div class="input-box">
91
+ <label for="city"><?php echo $this->__('City') ?> <span class="required">*</span></label><br />
92
+ <input type="text" name="city" value="<?php echo $this->htmlEscape($this->getFormData()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="required-entry input-text" id="city" />
93
+ </div>
94
+ <div class="input-box">
95
+ <label for="region_id"><?php echo $this->__('State/Province') ?> <span class="required">*</span></label><br />
96
+ <select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none">
97
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
98
+ </select>
99
+ <script type="text/javascript">
100
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
101
+ </script>
102
+ <input type="text" id="region" name="region" value="<?php echo $this->htmlEscape($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none" />
103
+ </div>
104
+ </li>
105
+ <li>
106
+ <div class="input-box">
107
+ <label for="zip"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br/>
108
+ <input type="text" name="postcode" value="<?php echo $this->htmlEscape($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="validate-zip-international required-entry input-text" />
109
+ </div>
110
+ <div class="input-box">
111
+ <label for="country"><?php echo $this->__('Country') ?> <span class="required">*</span></label><br/>
112
+ <?php echo $this->getCountryHtmlSelect() ?>
113
+ </div>
114
+ </li>
115
+ </ul>
116
+ </fieldset>
117
+ <input type="hidden" name="default_billing" value="1" />
118
+ <input type="hidden" name="default_shipping" value="1" />
119
+ <?php endif; ?>
120
+ <fieldset class="group-select wide">
121
+ <h4 class="legend"><?php echo $this->__('Login Information') ?></h4>
122
+ <ul>
123
+ <li>
124
+ <div class="input-box">
125
+ <label for="password"><?php echo $this->__('Password') ?> <span class="required">*</span></label><br/>
126
+ <input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="required-entry validate-password input-text" />
127
+ </div>
128
+ <div class="input-box">
129
+ <label for="confirmation"><?php echo $this->__('Confirm Password') ?> <span class="required">*</span></label><br />
130
+ <input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="required-entry validate-cpassword input-text" />
131
+ </div>
132
+ </li>
133
+ </ul>
134
+ </fieldset>
135
+
136
+ <?php // recaptcha
137
+ if (Mage::getStoreConfig("customer/recaptcha/enabled")) {
138
+ // set the recaptcha theme based on preferences
139
+ echo '<script> var RecaptchaOptions = { theme : \'';
140
+ echo Mage::getStoreConfig("admin/recaptcha/recaptcha_theme");
141
+ echo '\' }; </script>';
142
+ // show the recaptcha form
143
+ $publickey = Mage::getStoreConfig("admin/recaptcha/public_key");
144
+ echo Mage::helper("recaptcha")->recaptcha_get_html($publickey);
145
+ }
146
+ ?>
147
+
148
+ <div class="button-set">
149
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
150
+ <a href="<?php echo $this->getBackUrl() ?>" class="left">&laquo; <?php echo $this->__('Back') ?></a>
151
+ <button class="form-button" type="submit"><span><?php echo $this->__('Submit') ?></span></button>
152
+ </div>
153
+ </form>
154
+ <script type="text/javascript">
155
+ //<![CDATA[
156
+ var dataForm = new VarienForm('form-validate', true);
157
+ <?php if($this->getShowAddressFields()): ?>
158
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
159
+ <?php endif; ?>
160
+ //]]>
161
+ </script>
app/design/frontend/default/default/template/fontis/recaptcha/send.phtml ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Recaptcha Extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Recaptcha
17
+ * @author Denis Margetic
18
+ * @author Chris Norton
19
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Send to friend form
25
+ *
26
+ * @see Mage_Sendfriend_Block_Index
27
+ */
28
+ ?>
29
+
30
+ <script type="text/javascript">
31
+ i=0;
32
+ var recipCount = 1;
33
+ var maxRecip = <?php echo $this->getMaxRecipients() ?>;
34
+ function remove_recipient(i){
35
+ $('recipients_name'+i).up(2).remove();
36
+ recipCount--;
37
+ if(recipCount<maxRecip && maxRecip != 0) {
38
+ $('add_recipient_button').show();
39
+ $('max_recipient_message').hide();
40
+ }
41
+ return false;
42
+ }
43
+
44
+ function add_recipient(){
45
+ ul = $('recipients_options');
46
+ var li_mail = Element.extend(document.createElement("LI"));
47
+ li_mail.addClassName('addElement');
48
+ li_mail.innerHTML = '<div align="right"><a href="delete_email" onclick="remove_recipient('+i+');return false"><img src="<?php echo $this->getSkinUrl('images/list_remove_btn.gif') ?>" alt="<?php echo $this->__('Remove Email') ?>"/><\/a><\/div>'
49
+ li_mail.innerHTML += '<div class="left"><label for="recipients_name"><?php echo $this->__('Name:') ?> <span class="required">*<\/span><\/label><br /><div style="width:250px"><input name="recipients[name][]" type="text" class="input-text required-entry" id="recipients_name'+i+'" style="width:250px;" /><\/div><br /><br /><\/div>';
50
+ li_mail.innerHTML += '<div class="right"><label for="recipients_email"><?php echo $this->__('Email Address:') ?><span class="required">*<\/span><\/label><br /><div style="width:250px"><input name="recipients[email][]" value="" title="<?php echo $this->__('Email Address') ?>" id="recipients_email'+i+'" type="text" class="input-text required-entry validate-email" style="width:250px;" /><\/div><\/div>';
51
+ i++;
52
+ recipCount++;
53
+ if(recipCount>=maxRecip && maxRecip != 0) {
54
+ $('add_recipient_button').hide();
55
+ $('max_recipient_message').show();
56
+ }
57
+
58
+ ul.appendChild(li_mail);
59
+ }
60
+ </script>
61
+
62
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
63
+ <div class="page-head">
64
+ <h3><?php echo $this->__('Email to a Friend') ?></h3>
65
+ </div>
66
+ <form action="<?php echo $this->getUrl('*/*/sendmail', array('id'=>$this->getProductId(), 'cat_id'=>$this->getCategoryId())) ?>" method="post" id="product_sendtofriend_form">
67
+ <div class="col-1 login-box">
68
+ <div class="col-1 registered-users">
69
+ <div class="content ">
70
+ <div>
71
+ <h4><?php echo $this->__('Sender:') ?></h4>
72
+ <ul class="form-list" id="sender_options">
73
+ <li>
74
+ <div class="left">
75
+ <label for="sender_name"><?php echo $this->__('Name:') ?> <span class="required">*</span></label><br/>
76
+ <div style="width:250px"><input name="sender[name]" value="<?php echo $this->htmlEscape($this->getUserName()) ?>" title="<?php echo $this->__('Name') ?>" id="sender_name" type="text" class="input-text required-entry" style="width:250px;" /></div>
77
+ </div>
78
+ <div class="right">
79
+ <label for="sender_email"><?php echo $this->__('Email:') ?> <span class="required">*</span></label><br/>
80
+ <div style="width:250px"><input name="sender[email]" value="<?php echo $this->htmlEscape($this->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" id="sender_email" type="text" class="input-text required-entry validate-email" style="width:250px;" /></div>
81
+ </div>
82
+ </li>
83
+ <li>
84
+ <label for="sender_message"><?php echo $this->__('Message:') ?> <span class="required">*</span></label><br/>
85
+ <textarea name="sender[message]" class="input-text required-entry" id="sender_message" cols="3" rows="3" style="width:100%;height:100px"><?php echo $this->htmlEscape($this->getFormData()->getData('sender/message'))?></textarea>
86
+ </li>
87
+
88
+ </ul>
89
+ </div>
90
+
91
+ <div>
92
+ <div>
93
+ <br />
94
+ <h4><?php echo $this->__('Recipient:') ?></h4>
95
+ <ul class="form-list" id="recipients_options">
96
+ <li>
97
+ <div class="left">
98
+ <label for="recipients_name"><?php echo $this->__('Name:') ?> <span class="required">*</span></label><br/>
99
+ <div style="width:250px"><input name="recipients[name][]" type="text" class="input-text required-entry" id="recipients_name" style="width:250px;" /></div><br /><br />
100
+ </div>
101
+ <div class="right">
102
+ <label for="recipients_email"><?php echo $this->__('Email Address:') ?> <span class="required">*</span></label><br/>
103
+ <div style="width:250px"><input name="recipients[email][]" value="" title="<?php echo $this->__('Email Address') ?>" id="recipients_email" type="text" class="input-text required-entry validate-email" style="width:250px;" /></div>
104
+ </div>
105
+ </li>
106
+ </ul>
107
+ <div id="max_recipient_message" style="display:none">
108
+ <?php if ($this->getMaxRecipients()): ?>
109
+ <?php echo $this->__('Maximum %d email addresses allowed.', $this->getMaxRecipients()) ?>
110
+ <?php endif; ?>
111
+ </div>
112
+ <?php if (1 < $this->getMaxRecipients()): ?>
113
+ <div id="add_recipient_button">
114
+ <button class="form-button" onclick="add_recipient();" type="button"><span><?php echo $this->__('Add Recipient') ?></span></button>
115
+ </div>
116
+ <?php endif; ?>
117
+ </div>
118
+ </div>
119
+ <div style="clear:both"></div>
120
+
121
+ </div>
122
+
123
+ <?php // recaptcha
124
+ if (Mage::getStoreConfig("sendfriend/recaptcha/enabled")) {
125
+ // set the recaptcha theme based on preferences
126
+ echo '<script> var RecaptchaOptions = { theme : \'';
127
+ echo Mage::getStoreConfig("admin/recaptcha/recaptcha_theme");
128
+ echo '\' }; </script>';
129
+ // show the recaptcha form
130
+ $publickey = Mage::getStoreConfig("admin/recaptcha/public_key");
131
+ echo Mage::helper("recaptcha")->recaptcha_get_html($publickey);
132
+ }
133
+ ?>
134
+
135
+ <div class="button-set">
136
+ <button class="form-button right" type="submit"><span><?php echo $this->__('Send email') ?></span></button>
137
+ </div>
138
+ </div>
139
+ </div>
140
+ </form>
141
+ <script type="text/javascript">
142
+ var productSendtofriendForm = new VarienForm('product_sendtofriend_form');
143
+ productSendtofriendForm.submit = function() {
144
+ if(this.validator.validate()) {
145
+ this.form.submit();
146
+ }
147
+ }.bind(productSendtofriendForm);
148
+ </script>
app/etc/modules/Fontis_Recaptcha.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Fontis Recaptcha Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Fontis
17
+ * @package Fontis_Recaptcha
18
+ * @author Denis Margetic
19
+ * @author Chris Norton
20
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <modules>
26
+ <Fontis_Recaptcha>
27
+ <active>true</active>
28
+ <codePool>community</codePool>
29
+ </Fontis_Recaptcha>
30
+ </modules>
31
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Fontis_Recaptcha</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Adds reCAPTCHA to 'Send Email to a Friend', 'Contact Us' and 'New Account' forms.</summary>
10
+ <description>Adds reCAPTCHA to 'Send Email to a Friend', 'Contact Us' and 'New Account' forms.</description>
11
+ <notes>Still requires functionality to save form data when incorrect reCAPTCHA is entered.</notes>
12
+ <authors><author><name>Chris Norton</name><user>auto-converted</user><email>chris.norton@fontis.com.au</email></author></authors>
13
+ <date>2009-04-17</date>
14
+ <time>07:18:53</time>
15
+ <contents><target name="magecommunity"><dir name="Fontis"><dir name="Recaptcha"><dir name="controllers"><file name="AccountController.php" hash="2629a3409c8d5115432d4900bcbcd44f"/><file name="ContactsController.php" hash="c04f3df6b4440f016d4677778709dc13"/><file name="ProductController.php" hash="ae10c19d4115e0eab0d3570084a2c05c"/></dir><dir name="etc"><file name="config.xml" hash="dcc978ebb3215d92b28432661aaa3890"/><file name="system.xml" hash="15797157254b3516ae025fda86cca5e3"/></dir><dir name="Helper"><file name="Data.php" hash="d73a2b15052d0a20c8224ddb1b56b4b7"/></dir><dir name="Model"><dir name="Source"><file name="Recaptchatheme.php" hash="362f8164db8e42e114d868b6fe01c83d"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="fontis_recaptcha.xml" hash="99677f78ba9ea31200389438d11fcf2d"/></dir><dir name="template"><dir name="fontis"><dir name="recaptcha"><file name="form.phtml" hash="0e7d3db186077d9984e990cff518ff97"/><file name="register.phtml" hash="e731fb6b8ab7b7b2e54d715c1b42393f"/><file name="send.phtml" hash="8e290d988d68b89cabb753b8a8d2f514"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Fontis_Recaptcha.xml" hash="6dced08415213c892d9414a5eefc49b7"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>