diff --git a/README.md b/README.md index 90c5f9f..04445ed 100644 --- a/README.md +++ b/README.md @@ -275,54 +275,19 @@ The core functionality can easily be used to produce spam. The process is that an account is created, then a product is added, then spam is generated via the share functionality, with spam messages in the message field. Adding reCaptcha allows you to block this. -* Enable in admin under Customer Configuration by selecting 'Wishlist Sharing' in available forms list -* Unfortunately the core wishlist sharing form does not have an after form elements block, so you will need to adjust your form to display the captcha. - Edit the wishlist sharing form located here: - - app/design/frontend/[rwd|base|your package]/[default|your theme]/template/wishlist/sharing.phtml - - place the following line into the form, anywhere within the `````` tag +** Magento introduced wishlist capctha from 1.9.4, or with SUPEE 10975 ** - +The custom wishlist recaptcha code of this module was removed, favouring the core functionality. +If you require wishlist recapctha in pre 1.9.4 without SUPEE-10975, install version 2.0.1 - Entered values will be retained upon incorrect captcha entry - Product Email a Friend Captcha ------------------------------ -The core functionality can easily be used to produce spam. -The process is that an account is created, then a product is Emailed to a Friend, then spam is generated via the send functionality, with spam messages in the message field. -Adding reCaptcha allows you to block this. - -* Enable in admin under Customer Configuration by selecting 'Email a Friend' in available forms list - -Unfortunately the core Send a Friend form does not have an after form elements block, so you will need to adjust your form to display the captcha. -Additionally, the form allows you to add/remove recipients by adding/removing more recipient rows. -Some changes need to be made to the base form (copy to your own theme folder) to accommodate this functionality, else the recipients will be lost upon incorrect captcha. - -The changes are done to retain the core add/remove functionality of the form. -Since these changes are fairly big, I have provided a diff which you can apply, and for reference there is also a gist with the complete form ready to use (if you have no custom changes in your theme for the ```sendfiend/send.phtml``` template, you can simply just place the provided gist file to your theme as the template ```sendfiend\send.phtml```) - -[Full file](https://gist.github.com/ProxiBlue/bff88b184c9c0e44997ff6ae05468b01) -[diff](https://gist.github.com/ProxiBlue/fdf28f9bf8b678e9aa30c475d681f974) - -####Explaining the changes: - -[recipients counter](https://gist.github.com/ProxiBlue/bff88b184c9c0e44997ff6ae05468b01#file-gistfile1-txt-L35) -This change pre-sets the counter used to add new recipients. By default this is 0, since no recipients are initially present - -[pre propulate set receipients](https://gist.github.com/ProxiBlue/bff88b184c9c0e44997ff6ae05468b01#file-gistfile1-txt-L108) Injects the already defined recipients back into the form, after any failed captcha - -[inject captcha form](https://gist.github.com/ProxiBlue/bff88b184c9c0e44997ff6ae05468b01#file-gistfile1-txt-L102) ads the reCaptcha form to the display - - - -Entered values will be retained upon incorrect captcha entry +** Magento introduced capctha from 1.9.4, or with SUPEE 10975 ** +The custom recaptcha code of this module was removed, favouring the core functionality. +If you require recapctha in pre 1.9.4 without SUPEE-10975, install version 2.0.1 Newsletter Subscribe Captcha ---------------------------- diff --git a/app/code/community/ProxiBlue/ReCaptcha/Model/Observer.php b/app/code/community/ProxiBlue/ReCaptcha/Model/Observer.php index b2c1488..e662775 100644 --- a/app/code/community/ProxiBlue/ReCaptcha/Model/Observer.php +++ b/app/code/community/ProxiBlue/ReCaptcha/Model/Observer.php @@ -160,71 +160,6 @@ protected function _isUrlInternal($url) return false; } - /** - * Check Captcha On Whislist Sharing - * - * @param Varien_Event_Observer $observer - * - * @return Mage_Captcha_Model_Observer - */ - public function checkWishlist($observer) - { - $formId = 'user_wishlist'; - $captchaModel = Mage::helper('captcha')->getCaptcha($formId); - if ($captchaModel->isRequired()) { - $controller = $observer->getControllerAction(); - if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) { - $request = $controller->getRequest(); - $isAjax = $request->getParam('json'); - // insert form data to session, allowing to re-populate the contact us form - $data = $controller->getRequest()->getPost(); - Mage::getSingleton('wishlist/session')->setData('sharing_form', $data); - $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true); - if($isAjax) { - $controller->getResponse()->setBody(Zend_Json::encode(array('error'=>Mage::helper('captcha')->__('Incorrect CAPTCHA.')))); - } else { - Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.')); - $controller->getResponse()->setRedirect(Mage::getUrl('*/*/share')); - } - } - } - - return $this; - } - - /** - * Check Captcha On Send to Friend - * - * @param Varien_Event_Observer $observer - * - * @return Mage_Captcha_Model_Observer - */ - public function checkSendFriend($observer) - { - $formId = 'product_sendtofriend'; - $captchaModel = Mage::helper('captcha')->getCaptcha($formId); - if ($captchaModel->isRequired()) { - $controller = $observer->getControllerAction(); - if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) { - $request = $controller->getRequest(); - $isAjax = $request->getParam('json'); - // insert form data to session, allowing to re-populate the contact us form - $data = $controller->getRequest()->getPost(); - $productId = (int)$controller->getRequest()->getParam('id'); - $catId = (int)$controller->getRequest()->getParam('cat_id'); - Mage::getSingleton('catalog/session')->setData('sendfriend_form_data', $data); - $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true); - if($isAjax) { - $controller->getResponse()->setBody(Zend_Json::encode(array('error'=>Mage::helper('captcha')->__('Incorrect CAPTCHA.')))); - } else { - Mage::getSingleton('catalog/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.')); - $controller->getResponse()->setRedirect(Mage::getUrl('*/*/send',array('id' => $productId, 'cat_id' => $catId))); - } - } - } - return $this; - } - /** * Check Captcha On newsletter Subscribe * diff --git a/app/code/community/ProxiBlue/ReCaptcha/Model/Recaptcha.php b/app/code/community/ProxiBlue/ReCaptcha/Model/Recaptcha.php index 1d59021..40a9671 100755 --- a/app/code/community/ProxiBlue/ReCaptcha/Model/Recaptcha.php +++ b/app/code/community/ProxiBlue/ReCaptcha/Model/Recaptcha.php @@ -11,13 +11,6 @@ class ProxiBlue_ReCaptcha_Model_Recaptcha extends Mage_Captcha_Model_Zend implements Mage_Captcha_Model_Interface { - /** - * @var array - * - * normally recaptcha will not show for logged in users. Form ids listed here will also appear when logged in - * - */ - protected $_alwaysShow = array('user_wishlist', 'product_sendtofriend'); /** * Key in session for captcha code */ @@ -203,10 +196,6 @@ public function isRequired($login = null) return false; } - if (in_array($this->_formId, $this->_alwaysShow)) { - return true; - } - return ($this->_isShowAlways() || $this->_isOverLimitAttempts($login) || $this->getSession()->getData($this->_getFormIdKey('show_captcha')) ); diff --git a/app/code/community/ProxiBlue/ReCaptcha/etc/config.xml b/app/code/community/ProxiBlue/ReCaptcha/etc/config.xml index 574c087..bcd8cc7 100755 --- a/app/code/community/ProxiBlue/ReCaptcha/etc/config.xml +++ b/app/code/community/ProxiBlue/ReCaptcha/etc/config.xml @@ -2,7 +2,7 @@ - 2.0.1 + 2.1.0 @@ -46,22 +46,6 @@ - - - - proxiblue_recaptcha/observer - checkWishlist - - - - - - - proxiblue_recaptcha/observer - checkSendFriend - - - @@ -139,12 +123,6 @@ - - - - - -