Dextrous_Addcaptcha - Version 1.1.0

Version Notes

Stable version to add captcha on contact us page.

Download this release

Release Info

Developer Hemant kumar sharma
Extension Dextrous_Addcaptcha
Version 1.1.0
Comparing to
See all releases


Version 1.1.0

app/code/local/Dextrous/Addcaptcha/Model/Observer.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dextrous_Addcaptcha_Model_Observer
3
+ {
4
+ public function checkContacts($observer){
5
+ $formId = 'contacts';
6
+ $captchaModel = Mage::helper('captcha')->getCaptcha($formId);
7
+ if ($captchaModel->isRequired()) {
8
+ $controller = $observer->getControllerAction();
9
+ $word = $this->_getCaptchaString($controller->getRequest(), $formId);
10
+ if (!$captchaModel->isCorrect($word)) {
11
+ Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));
12
+ $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
13
+ $url = Mage::getUrl('contacts');
14
+ $controller->getResponse()->setRedirect($url);
15
+ }
16
+ }
17
+ return $this;
18
+ }
19
+ /**
20
+ * Get Captcha String
21
+ *
22
+ * @param Varien_Object $request
23
+ * @param string $formId
24
+ * @return string
25
+ */
26
+ protected function _getCaptchaString($request, $formId)
27
+ {
28
+ $captchaParams = $request->getPost(Mage_Captcha_Helper_Data::INPUT_NAME_FIELD_VALUE);
29
+ return $captchaParams[$formId];
30
+ }
31
+ }
app/code/local/Dextrous/Addcaptcha/etc/config.xml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dextrous_Addcaptcha>
5
+ <version>1.1.0</version>
6
+ </Dextrous_Addcaptcha>
7
+ </modules>
8
+ <frontend>
9
+ <layout>
10
+ <updates>
11
+ <addcaptcha>
12
+ <file>dextrous_addcaptcha.xml</file>
13
+ </addcaptcha>
14
+ </updates>
15
+ </layout>
16
+ </frontend>
17
+ <global>
18
+ <models>
19
+ <addcaptcha>
20
+ <class>Dextrous_Addcaptcha_Model</class>
21
+ </addcaptcha>
22
+ </models>
23
+ <events>
24
+ <controller_action_predispatch_contacts_index_post>
25
+ <observers>
26
+ <addcaptcha>
27
+ <class>addcaptcha/observer</class>
28
+ <method>checkContacts</method>
29
+ </addcaptcha>
30
+ </observers>
31
+ </controller_action_predispatch_contacts_index_post>
32
+ </events>
33
+ </global>
34
+ <default>
35
+ <captcha>
36
+ <frontend>
37
+ <areas>
38
+ <contacts>
39
+ <label>Contacts Page</label>
40
+ </contacts>
41
+ </areas>
42
+ </frontend>
43
+ </captcha>
44
+ <customer>
45
+ <captcha>
46
+ <always_for>
47
+ <contacts>1</contacts>
48
+ </always_for>
49
+ </captcha>
50
+ </customer>
51
+ </default>
52
+ </config>
app/design/frontend/base/default/layout/dextrous_addcaptcha.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <contacts_index_index>
4
+ <reference name="contactForm">
5
+ <action method="setTemplate"><template>addcaptcha/contacts/form.phtml</template></action>
6
+ <block type="core/text_list" name="form.additional.info">
7
+ <block type="captcha/captcha" name="captcha">
8
+ <reference name="head">
9
+ <action method="addJs"><file>mage/captcha.js</file></action>
10
+ </reference>
11
+ <action method="setFormId"><formId>contacts</formId></action>
12
+ <action method="setImgWidth"><width>230</width></action>
13
+ <action method="setImgHeight"><width>50</width></action>
14
+ </block>
15
+ </block>
16
+ </reference>
17
+ </contacts_index_index>
18
+ </layout>
app/design/frontend/base/default/template/addcaptcha/contacts/form.phtml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>
28
+ <div class="page-title">
29
+ <h1><?php echo Mage::helper('contacts')->__('Contact Us') ?></h1>
30
+ </div>
31
+ <form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
32
+ <div class="fieldset">
33
+ <h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
34
+ <ul class="form-list">
35
+ <li class="fields">
36
+ <div class="field">
37
+ <label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
38
+ <div class="input-box">
39
+ <input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
40
+ </div>
41
+ </div>
42
+ <div class="field">
43
+ <label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
44
+ <div class="input-box">
45
+ <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
46
+ </div>
47
+ </div>
48
+ </li>
49
+ <li>
50
+ <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label>
51
+ <div class="input-box">
52
+ <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="text" />
53
+ </div>
54
+ </li>
55
+ <li class="wide">
56
+ <label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label>
57
+ <div class="input-box">
58
+ <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
59
+ </div>
60
+ <?php echo $this->getChildHtml('form.additional.info'); ?>
61
+ </li>
62
+ </ul>
63
+ </div>
64
+ <div class="buttons-set">
65
+ <p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
66
+ <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
67
+ <button type="submit" title="<?php echo Mage::helper('contacts')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
68
+ </div>
69
+ </form>
70
+ <script type="text/javascript">
71
+ //<![CDATA[
72
+ var contactForm = new VarienForm('contactForm', true);
73
+ //]]>
74
+ </script>
app/etc/modules/Dextrous_Addcaptcha.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dextrous_Addcaptcha>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Dextrous_Addcaptcha>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Dextrous_Addcaptcha</name>
4
+ <version>1.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Add Default Magento Captcha On Contact Us Page.</summary>
10
+ <description>Add Captcha On Contact Us Page:&#xD;
11
+ &#xD;
12
+ This extension add default Magento captcha on 'Contact US' page and will protect 'Contact US' form from unwanted spambots..&#xD;
13
+ &#xD;
14
+ Key Features:-&#xD;
15
+ - Ability to Enable/Disable each block from admin configuration.&#xD;
16
+ &#xD;
17
+ To Use Extension Follow Below Instruction:-&#xD;
18
+ - Navigate 'System-&gt;Configuration'.&#xD;
19
+ - Select 'Customer Configuration' from Left Panel.&#xD;
20
+ - Select 'CAPTCHA' tab.&#xD;
21
+ - Set 'Enable CAPTCHA on Frontend' to 'Yes'.&#xD;
22
+ - Select 'Contacts Page' from multiselect drop-down for 'Forms'.&#xD;
23
+ - Save Configuration.</description>
24
+ <notes>Stable version to add captcha on contact us page.</notes>
25
+ <authors><author><name>Hemant kumar sharma</name><user>hemantkr</user><email>hemant7677@gmail.com</email></author></authors>
26
+ <date>2015-03-05</date>
27
+ <time>03:02:59</time>
28
+ <contents><target name="magelocal"><dir name="Dextrous"><dir name="Addcaptcha"><dir name="Model"><file name="Observer.php" hash="60c428209ec75f4f78edd4c24171641e"/></dir><dir name="etc"><file name="config.xml" hash="80edee11f7494962ae91387a6221309a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Dextrous_Addcaptcha.xml" hash="d504bff70a1186b6240b163cb8a403ac"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="dextrous_addcaptcha.xml" hash="a853ff77793485bd8ff56d2c4f32057f"/></dir><dir name="template"><dir name="addcaptcha"><dir name="contacts"><file name="form.phtml" hash="60aff60de2fbfdf8ebe2032a637535b4"/></dir></dir></dir></dir></dir></dir></target></contents>
29
+ <compatible/>
30
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.9.0.1</max></package></required></dependencies>
31
+ </package>