magento-hackathon / HoneySpam

Spam protection module for customer registration, product review form and contact form.
Open Software License 3.0
102 stars 36 forks source link

Enable Honeypot Hidden Field - Not working #69

Closed addison74 closed 3 years ago

addison74 commented 3 years ago

Here are the steps to reproduce this issue:

  1. Go to backend and change "Enable Hidden Honeypot Field" from Yes to No.

  2. Visit the URL /customer/account/create/ and look into the source code. The input text box related to honeypot is still there.

At first glance it seems that regardless of the chosen value in backend, this field will appear in the source code.

addison74 commented 3 years ago

I have checked the pages where the extension adds the template honeypot.phtml based on the layout file (customer account, review). In fact, this option "Enable Honeypot Hidden Field" is not related to inserting or not the input text box in the frontend, but to processing the form by extension. The input text box still exists in the frontend regardless of the option.

Either the name of the option is changed to be clear, or a change is made by which, depending on the option, the field in the source code of the page is entered or not. I would suggest using in config.xml in all blocks related to honeypot.phtml file this condition:

ifconfig="hackathon/honeyspam/enableHoneypotName"
addison74 commented 3 years ago

Here is my proposal for config.xml file content:

<?xml version="1.0"?>
<!--
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category  Hackathon
 * @package   Hackathon_HoneySpam
 * @author    Andreas Emer <honeyspam@emdec.de>
 * @author    Fabian Blechschmidt <hackathon@fabian-blechschmidt.de>
 * @author    Sascha Wohlgemuth <sascha.wohlgemuth@gmail.com>
 * @author    Bastian Ike <bastian.ike@gmail.com>
 * @author    Peter Ukener <peterukener@gmail.com>
 * @copyright 2012 Magento Hackathon
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @link      http://www.magento-hackathon.de/
 */
-->
<layout>
    <default>
        <reference name="head">
            <action method="addJs" ifconfig="hackathon/honeyspam/enableHoneypotName">
                <script>hackathon/HoneySpam/honeyspam.js</script>
            </action>
        </reference>
        <!-- base/default theme -->
        <block type="hackathon_honeyspam/honeypot"
                     name="honeyspam.honeypot"
                     template="hackathon/honeyspam/honeypot.phtml"/>
        <reference name="left.newsletter">
          <block type="core/text_list"
                       name="newsletter.form.fields.before"
                       as="form_fields_before"
                       translate="label">
            <action method="append" ifconfig="hackathon/honeyspam/enableHoneypotName">
              <block>honeyspam.honeypot</block>
            </action>
          </block>
        </reference>
        <!-- rwd/default theme -->
        <reference name="footer.newsletter">
          <block type="core/text_list"
                       name="newsletter.form.fields.before"
                       as="form_fields_before"
                       translate="label">
            <action method="append" ifconfig="hackathon/honeyspam/enableHoneypotName">
              <block>honeyspam.honeypot</block>
            </action>
          </block>
        </reference>
        <!-- default/modern theme -->
        <reference name="newsletter">
          <block type="core/text_list"
                       name="newsletter.form.fields.before"
                       as="form_fields_before"
                       translate="label">
            <action method="append" ifconfig="hackathon/honeyspam/enableHoneypotName">
              <block>honeyspam.honeypot</block>
            </action>
          </block>
        </reference>  
    </default>

    <customer_account_create>
      <block type="hackathon_honeyspam/honeypot"
                   name="honeyspam.honeypot"
                   template="hackathon/honeyspam/honeypot.phtml"/>
      <reference name="form.additional.info">
        <action method="append" ifconfig="hackathon/honeyspam/enableHoneypotName">
          <block>honeyspam.honeypot</block>
        </action>
      </reference>
    </customer_account_create>

    <customer_account_forgotpassword>
      <block type="hackathon_honeyspam/honeypot"
                   name="honeyspam.honeypot"
                   template="hackathon/honeyspam/honeypot.phtml"/>
      <reference name="form.additional.info">
        <action method="append" ifconfig="hackathon/honeyspam/enableHoneypotName">
          <block>honeyspam.honeypot</block>
        </action>
      </reference>
    </customer_account_forgotpassword>

    <review_product_list>
      <block type="hackathon_honeyspam/honeypot"
                   name="honeyspam.honeypot"
                   template="hackathon/honeyspam/honeypot.phtml"/>
      <reference name="product.review.form.fields.before">
        <action method="append" ifconfig="hackathon/honeyspam/enableHoneypotName">
          <block>honeyspam.honeypot</block>
        </action>
      </reference>
    </review_product_list>

    <contacts_index_index>
      <block type="hackathon_honeyspam/honeypot"
                   name="honeyspam.honeypot"
                   template="hackathon/honeyspam/honeypot.phtml"/>
      <reference name="contactForm">
        <block type="core/text_list"
                     name="contacts.form.fields.before"
                     as="form_fields_before"
                     translate="label">
          <action method="append" ifconfig="hackathon/honeyspam/enableHoneypotName">
            <block>honeyspam.honeypot</block>
          </action>
        </block>
      </reference>
    </contacts_index_index>

    <hackathon_honeyspam_error_index>
        <reference name="content">
            <block type="core/template"
                   name="honeyspam.error"
                   template="hackathon/honeyspam/error.phtml"/>
        </reference>
    </hackathon_honeyspam_error_index>
</layout>