Version Notes
First preview release
Download this release
Release Info
Developer | Magento Core Team |
Extension | Sellry_Humanfriendlycaptcha |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Sellry/Humanfriendlycaptcha/Block/Adminhtml/System/Config/Fieldset/Hint.php +114 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Block/Core/Text/List.php +92 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Block/Customer/Form/Register.php +59 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Block/Humanfriendlycaptcha.php +45 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Block/Newsletter/Subscribe.php +59 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Block/Review/Form.php +59 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Block/System/Config/Form/Field/Pages.php +42 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Helper/Data.php +76 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Helper/Recaptcha.php +55 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Model/Humanfriendlycaptcha.php +61 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Model/Observer.php +61 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Model/System/Config/Backend/Pages.php +33 -0
- app/code/community/Sellry/Humanfriendlycaptcha/Model/System/Config/Source/Forms.php +53 -0
- app/code/community/Sellry/Humanfriendlycaptcha/controllers/IndexController.php +41 -0
- app/code/community/Sellry/Humanfriendlycaptcha/etc/config.xml +141 -0
- app/code/community/Sellry/Humanfriendlycaptcha/etc/system.xml +119 -0
- app/code/community/Sellry/Humanfriendlycaptcha/sql/humanfriendlycaptcha_setup/mysql4-install-1.0.0.php +43 -0
- app/design/adminhtml/default/default/template/sellry/humanfriendlycaptcha/system/config/fieldset/hint.phtml +61 -0
- app/design/frontend/default/default/layout/sellry_humanfriendlycaptcha.xml +35 -0
- app/design/frontend/default/default/template/sellry/humanfriendlycaptcha/humanfriendlycaptcha.phtml +41 -0
- js/sellry/humanfriendlycaptcha.js +37 -0
- lib/AYAH.php +461 -0
- package.xml +22 -0
app/code/community/Sellry/Humanfriendlycaptcha/Block/Adminhtml/System/Config/Fieldset/Hint.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Block_Adminhtml_System_Config_Fieldset_Hint
|
31 |
+
extends Mage_Adminhtml_Block_Abstract
|
32 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
33 |
+
{
|
34 |
+
protected $_template = 'sellry/humanfriendlycaptcha/system/config/fieldset/hint.phtml';
|
35 |
+
|
36 |
+
protected $_dataUrl = 'http://sellry.com/magento-extensions/index.php';
|
37 |
+
|
38 |
+
public function __construct() {
|
39 |
+
parent::__construct();
|
40 |
+
|
41 |
+
$this->setMainHeading(Mage::helper('humanfriendlycaptcha')->__('So You ARE a Human! by <a href="%s" target="_new">sellry</a>', "http://sellry.com/magento-extensions?utm_source=".Mage::getBaseUrl()."&utm_medium=developer-link&utm_campaign=HumanFriendlyCaptcha&utm_content=".$this->getModuleVersion()));
|
42 |
+
$this->setCallToActionMessage(Mage::helper('humanfriendlycaptcha')->__('Need help with this extension? Let us know.'));
|
43 |
+
$this->setLogoImage('http://sellry.com/magento-extensions/logo.jpg');
|
44 |
+
|
45 |
+
$this->getModuleData();
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function isConnected()
|
51 |
+
{
|
52 |
+
$helper = Mage::helper('humanfriendlycaptcha');
|
53 |
+
return (bool)($helper->getScoringKey() && $helper->getPublisherKey());
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Render fieldset html
|
58 |
+
*
|
59 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
63 |
+
{
|
64 |
+
return $this->toHtml();
|
65 |
+
}
|
66 |
+
|
67 |
+
public function getModuleVersion()
|
68 |
+
{
|
69 |
+
return (string) Mage::getConfig()->getNode('modules/Sellry_Humanfriendlycaptcha/version');
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getModuleData()
|
73 |
+
{
|
74 |
+
$modulesArray = (array)Mage::getConfig()->getNode('modules')->children();
|
75 |
+
$aux = (array_key_exists('Enterprise_Enterprise', $modulesArray))? 'EE' : 'CE' ;
|
76 |
+
|
77 |
+
$data = array(
|
78 |
+
'module' => 'Humanfriendlycaptcha',
|
79 |
+
'version' => $this->getModuleVersion(),
|
80 |
+
'magento_version' => Mage::getVersion(),
|
81 |
+
'magento_edition' => $aux,
|
82 |
+
'locale' => Mage::app()->getLocale()->getLocaleCode()
|
83 |
+
);
|
84 |
+
|
85 |
+
$client = new Varien_Http_Client($this->_dataUrl);
|
86 |
+
$client->setMethod(Varien_Http_Client::POST);
|
87 |
+
$client->setParameterPost('data', Mage::helper('core')->jsonEncode($data));
|
88 |
+
|
89 |
+
try{
|
90 |
+
$response = $client->request();
|
91 |
+
if ($response->isSuccessful()) {
|
92 |
+
$body = $response->getBody();
|
93 |
+
$requestData = Mage::helper('core')->jsonDecode($body);
|
94 |
+
if(!$requestData['error']) {
|
95 |
+
foreach($requestData['result'] as $key => $value) {
|
96 |
+
$this->setData($key, $value);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
} catch (Exception $e) {
|
101 |
+
Mage::log($e->getMessage());
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
public function getLatestDownloadUrl()
|
106 |
+
{
|
107 |
+
return "http://sellry.com/magento-extensions/human-friendly-captcha?utm_source=".Mage::getBaseUrl()."&utm_medium=download-link&utm_campaign=HumanFriendlyCaptcha&utm_content=".$this->getModuleVersion();
|
108 |
+
}
|
109 |
+
|
110 |
+
public function getCallToActionUrl()
|
111 |
+
{
|
112 |
+
return "http://sellry.com/contact?&utm_source=".Mage::getBaseUrl()."&utm_medium=support-link&utm_campaign=HumanFriendlyCaptcha&utm_content=".$this->getModuleVersion();
|
113 |
+
}
|
114 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Block/Core/Text/List.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Block_Core_Text_List extends Mage_Core_Block_Text_List
|
31 |
+
{
|
32 |
+
protected function _toHtml()
|
33 |
+
{
|
34 |
+
$html = parent::_toHtml();
|
35 |
+
$helper = Mage::helper('humanfriendlycaptcha');
|
36 |
+
$shouldCheck = false;
|
37 |
+
if($helper->isEnabled() && $this->getBlockAlias() == 'content') {
|
38 |
+
$activeOnThisPage = false;
|
39 |
+
|
40 |
+
$pages = unserialize($helper->getPages());
|
41 |
+
$currentUrl = parse_url(Mage::helper('core/url')->getCurrentUrl());
|
42 |
+
$currentUrl = trim($currentUrl['path'], '/');
|
43 |
+
foreach($pages as $page) {
|
44 |
+
if(isset($page['page'])) {
|
45 |
+
$url = parse_url($page['page']);
|
46 |
+
if($currentUrl == trim($url['path'], '/')) {
|
47 |
+
$activeOnThisPage = true;
|
48 |
+
break;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
$forms = explode(',',$helper->getMagentoForms());
|
54 |
+
if(stristr($currentUrl, 'contacts') && in_array('contact', $forms)) //small hack just for the contact page
|
55 |
+
$activeOnThisPage = true;
|
56 |
+
|
57 |
+
if($activeOnThisPage && !(stristr($html, 'ayah'))) {
|
58 |
+
$formIds = array();
|
59 |
+
preg_match("/var\s*([a-zA-Z0-9\_]*)[\s\=|new]*VarienForm\(['|\"](.[^'|\"]*)['|\"][\s\,a-z]*\)/si", $html, $formData);
|
60 |
+
if(count($formData) > 2)
|
61 |
+
{
|
62 |
+
$shouldCheck = true;
|
63 |
+
$varienVar = $formData[1];
|
64 |
+
$formId = $formData[2];
|
65 |
+
$matches = array();
|
66 |
+
$helper->runMatch($formId, $html, $matches, true);
|
67 |
+
if(count($matches)) {
|
68 |
+
foreach($matches[0] as $match) {
|
69 |
+
$ayahCode = $helper->getCode($formId, $varienVar);
|
70 |
+
$html = str_replace($match, $match.$ayahCode, $html);
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
else {
|
75 |
+
$formId = '[a-zA-Z0-9\-\_]*';
|
76 |
+
$matches = array();
|
77 |
+
$helper->runMatch($formId, $html, $matches, true);
|
78 |
+
if(count($matches)) {
|
79 |
+
$shouldCheck = true;
|
80 |
+
foreach($matches[0] as $match) {
|
81 |
+
$ayahCode = $helper->getCode();
|
82 |
+
$html = str_replace($match, $match.$ayahCode, $html);
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
Mage::getSingleton('core/session')->setShouldCheckCaptcha($shouldCheck);
|
89 |
+
|
90 |
+
return $html;
|
91 |
+
}
|
92 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Block/Customer/Form/Register.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Block_Customer_Form_Register extends Mage_Customer_Block_Form_Register
|
31 |
+
{
|
32 |
+
protected function _toHtml() {
|
33 |
+
$html = parent::_toHtml();
|
34 |
+
|
35 |
+
$helper = Mage::helper('humanfriendlycaptcha');
|
36 |
+
$shouldCheck = false;
|
37 |
+
if($helper->isEnabled()) {
|
38 |
+
$magentoForms = explode(',', $helper->getMagentoForms());
|
39 |
+
|
40 |
+
if(in_array('customer_register', $magentoForms)) {
|
41 |
+
preg_match("/var\s*([a-zA-Z0-9\_]*)[\s\=|new]*VarienForm\(['|\"](.[^'|\"]*)['|\"][\s\,a-z]*\)/si", $html, $formData);
|
42 |
+
if(count($formData) > 2)
|
43 |
+
{
|
44 |
+
$shouldCheck = true;
|
45 |
+
$varienVar = $formData[1];
|
46 |
+
$formId = $formData[2];
|
47 |
+
$matches = array();
|
48 |
+
$helper->runMatch($formId, $html, $matches);
|
49 |
+
if(count($matches)) {
|
50 |
+
$ayahCode = $helper->getCode($formId, $varienVar);
|
51 |
+
$html = str_replace($matches[0], $matches[0].$ayahCode, $html);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
Mage::getSingleton('core/session')->setShouldCheckCaptcha($shouldCheck);
|
57 |
+
return $html;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Block/Humanfriendlycaptcha.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Block_Humanfriendlycaptcha extends Mage_Core_Block_Template
|
31 |
+
{
|
32 |
+
protected function _construct()
|
33 |
+
{
|
34 |
+
parent::_construct();
|
35 |
+
$this->setTemplate('sellry/humanfriendlycaptcha/humanfriendlycaptcha.phtml');
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getCode(){
|
39 |
+
$code = '';
|
40 |
+
if (Mage::helper('humanfriendlycaptcha')->isEnabled()) {
|
41 |
+
$code = Mage::getSingleton('humanfriendlycaptcha/humanfriendlycaptcha')->getCode();
|
42 |
+
}
|
43 |
+
return $code;
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Block/Newsletter/Subscribe.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Block_Newsletter_Subscribe extends Mage_Newsletter_Block_Subscribe
|
31 |
+
{
|
32 |
+
protected function _toHtml() {
|
33 |
+
$html = parent::_toHtml();
|
34 |
+
|
35 |
+
$helper = Mage::helper('humanfriendlycaptcha');
|
36 |
+
$shouldCheck = false;
|
37 |
+
if($helper->isEnabled()) {
|
38 |
+
$magentoForms = explode(',', $helper->getMagentoForms());
|
39 |
+
|
40 |
+
if(in_array('newsletter', $magentoForms)) {
|
41 |
+
preg_match("/var\s*([a-zA-Z0-9\_]*)[\s\=|new]*VarienForm\(['|\"](.[^'|\"]*)['|\"][\s\,a-z]*\)/si", $html, $formData);
|
42 |
+
if(count($formData) > 2)
|
43 |
+
{
|
44 |
+
$shouldCheck = true;
|
45 |
+
$varienVar = $formData[1];
|
46 |
+
$formId = $formData[2];
|
47 |
+
$matches = array();
|
48 |
+
$helper->runMatch($formId, $html, $matches);
|
49 |
+
if(count($matches) && !(stristr($html, 'ayah'))) {
|
50 |
+
$ayahCode = $helper->getCode($formId, $varienVar);
|
51 |
+
$html = str_replace($matches[0], $matches[0].$ayahCode, $html);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
Mage::getSingleton('core/session')->setShouldCheckCaptcha($shouldCheck);
|
57 |
+
return $html;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Block/Review/Form.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Block_Review_Form extends Mage_Review_Block_Form
|
31 |
+
{
|
32 |
+
protected function _toHtml() {
|
33 |
+
$html = parent::_toHtml();
|
34 |
+
|
35 |
+
$helper = Mage::helper('humanfriendlycaptcha');
|
36 |
+
$shouldCheck = false;
|
37 |
+
if($helper->isEnabled()) {
|
38 |
+
$magentoForms = explode(',', $helper->getMagentoForms());
|
39 |
+
|
40 |
+
if(in_array('review_form', $magentoForms)) {
|
41 |
+
preg_match("/var\s*([a-zA-Z0-9\_]*)[\s\=|new]*VarienForm\(['|\"](.[^'|\"]*)['|\"][\s\,a-z]*\)/si", $html, $formData);
|
42 |
+
if(count($formData) > 2)
|
43 |
+
{
|
44 |
+
$shouldCheck = true;
|
45 |
+
$varienVar = $formData[1];
|
46 |
+
$formId = $formData[2];
|
47 |
+
$matches = array();
|
48 |
+
$helper->runMatch($formId, $html, $matches);
|
49 |
+
if(count($matches) && !(stristr($html, 'ayah'))) {
|
50 |
+
$ayahCode = $helper->getCode($formId, $varienVar);
|
51 |
+
$html = str_replace($matches[0], $matches[0].$ayahCode, $html);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
Mage::getSingleton('core/session')->setShouldCheckCaptcha($shouldCheck);
|
57 |
+
return $html;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Block/System/Config/Form/Field/Pages.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Block_System_Config_Form_Field_Pages extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
31 |
+
{
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
$this->addColumn('page', array(
|
35 |
+
'label' => Mage::helper('humanfriendlycaptcha')->__('Page link'),
|
36 |
+
'style' => 'width:360px',
|
37 |
+
));
|
38 |
+
$this->_addAfter = false;
|
39 |
+
$this->_addButtonLabel = Mage::helper('humanfriendlycaptcha')->__('Add Page');
|
40 |
+
parent::__construct();
|
41 |
+
}
|
42 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Helper/Data.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Helper_Data extends Mage_Core_Helper_Abstract
|
31 |
+
{
|
32 |
+
|
33 |
+
public function isEnabled() {
|
34 |
+
return (bool)Mage::getStoreConfig('sellry_humanfriendlycaptcha/general/enabled',Mage::app()->getStore());
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getScoringKey() {
|
38 |
+
return Mage::getStoreConfig('sellry_humanfriendlycaptcha/general/scoring_key',Mage::app()->getStore());
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getPublisherKey() {
|
42 |
+
return Mage::getStoreConfig('sellry_humanfriendlycaptcha/general/publisher_key',Mage::app()->getStore());
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getErrorMessage() {
|
46 |
+
return Mage::getStoreConfig('sellry_humanfriendlycaptcha/general/error_message',Mage::app()->getStore());
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getPages() {
|
50 |
+
return Mage::getStoreConfig('sellry_humanfriendlycaptcha/general/pages',Mage::app()->getStore());
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getMagentoForms() {
|
54 |
+
return Mage::getStoreConfig('sellry_humanfriendlycaptcha/general/magento_forms',Mage::app()->getStore());
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getCode($formId = null, $varienVar = null){
|
58 |
+
return Mage::app()->getLayout()->createBlock('humanfriendlycaptcha/humanfriendlycaptcha')
|
59 |
+
->setFormId($formId)
|
60 |
+
->setVarienVar($varienVar)
|
61 |
+
->toHtml();
|
62 |
+
}
|
63 |
+
|
64 |
+
public function score(){
|
65 |
+
return Mage::getSingleton('humanfriendlycaptcha/humanfriendlycaptcha')->score();
|
66 |
+
}
|
67 |
+
|
68 |
+
public function runMatch($formId, $html, &$matches, $all = false)
|
69 |
+
{
|
70 |
+
$regex = "/(<form[a-zA-Z0-9\s\=\'\"\.\:\/\-\_\\?\;\&\%\#\!\(\)\+\,\|\]\[\}\{\~]*id=['|\"]".$formId."['|\"][a-zA-Z0-9\s\=\'\"\.\:\/\-\_\\?\;\&\%\#\!\(\)\+\,\|\]\[\}\{\~]*>)/si";
|
71 |
+
if($all)
|
72 |
+
preg_match_all($regex, $html, $matches);
|
73 |
+
else
|
74 |
+
preg_match($regex, $html, $matches);
|
75 |
+
}
|
76 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Helper/Recaptcha.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Helper_Recaptcha extends Fishpig_Wordpress_Helper_Recaptcha {
|
31 |
+
|
32 |
+
public function getRecaptchaHtml() {
|
33 |
+
return $this->_getDataHelper()->getCode();
|
34 |
+
}
|
35 |
+
|
36 |
+
public function isEnabled() {
|
37 |
+
return $this->_getDataHelper()->isEnabled();
|
38 |
+
}
|
39 |
+
|
40 |
+
public function isValidValue($challenge, $response, $graceful = false) {
|
41 |
+
return $this->_getDataHelper()->score();
|
42 |
+
}
|
43 |
+
/**
|
44 |
+
*
|
45 |
+
* @return Sellry_Humanfriendlycaptcha_Helper_Data
|
46 |
+
*/
|
47 |
+
protected function _getDataHelper(){
|
48 |
+
return Mage::helper('humanfriendlycaptcha');
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getCaptchaErrorMessage() {
|
52 |
+
return $this->_getDataHelper()->getErrorMessage();
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Model/Humanfriendlycaptcha.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Model_Humanfriendlycaptcha extends Mage_Core_Model_Abstract
|
31 |
+
{
|
32 |
+
protected $_ayah;
|
33 |
+
|
34 |
+
protected function _construct()
|
35 |
+
{
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getCode(){
|
39 |
+
return $this->getAyah()->getPublisherHTML(array('onsubmit' => 'submitFirst'));
|
40 |
+
}
|
41 |
+
|
42 |
+
public function score(){
|
43 |
+
return $this->getAyah()->scoreResult();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
*
|
48 |
+
* @return AYAH
|
49 |
+
*/
|
50 |
+
public function getAyah(){
|
51 |
+
if (!$this->_ayah) {
|
52 |
+
$this->_ayah = new AYAH(array(
|
53 |
+
'scoring_key' => Mage::getStoreConfig('sellry_humanfriendlycaptcha/general/scoring_key'),
|
54 |
+
'publisher_key' => Mage::getStoreConfig('sellry_humanfriendlycaptcha/general/publisher_key'),
|
55 |
+
));
|
56 |
+
}
|
57 |
+
return $this->_ayah;
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Model/Observer.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Model_Observer extends Mage_Core_Controller_Front_Action
|
31 |
+
{
|
32 |
+
public function submitObserver($observer) {
|
33 |
+
/* @var $request Mage_Core_Controller_Request_Http */
|
34 |
+
if(Mage::helper('humanfriendlycaptcha')->isEnabled() && Mage::getSingleton('core/session')->getShouldCheckCaptcha()) {
|
35 |
+
$action = $observer->getControllerAction();
|
36 |
+
$request = $action->getRequest();
|
37 |
+
if ($request->isPost()) {
|
38 |
+
$api = Mage::getSingleton('humanfriendlycaptcha/humanfriendlycaptcha');
|
39 |
+
if (!$api->score()){
|
40 |
+
$session = Mage::getSingleton('customer/session');
|
41 |
+
$session->addError(Mage::helper('humanfriendlycaptcha')->getErrorMessage());
|
42 |
+
$action->getResponse()->setRedirect(Mage::getUrl($this->_getRedirectUrl($action), array('_secure' => true)));
|
43 |
+
$action->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
Mage::getSingleton('core/session')->unsShouldCheckCaptcha();
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _getRedirectUrl($action) {
|
52 |
+
switch (true) {
|
53 |
+
case ($action instanceof Mage_Customer_AccountController):
|
54 |
+
return '*/*/create';
|
55 |
+
case ($action instanceof Mage_Review_ProductController):
|
56 |
+
return '*/*/list/id/'.$action->getRequest()->getParam('id');
|
57 |
+
default:
|
58 |
+
return '*/*/*';
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Model/System/Config/Backend/Pages.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Model_System_Config_Backend_Pages extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
|
31 |
+
{
|
32 |
+
protected $_eventPrefix = 'sellry_humanfriendlycaptcha_config_backend_pages';
|
33 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/Model/System/Config/Source/Forms.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_Model_System_Config_Source_Forms
|
31 |
+
{
|
32 |
+
public function toOptionArray()
|
33 |
+
{
|
34 |
+
return array(
|
35 |
+
array(
|
36 |
+
'label' => 'Contact form',
|
37 |
+
'value' => 'contact'
|
38 |
+
),
|
39 |
+
array(
|
40 |
+
'label' => 'Customer Registration form',
|
41 |
+
'value' => 'customer_register'
|
42 |
+
),
|
43 |
+
array(
|
44 |
+
'label' => 'Newsletter Subscription form',
|
45 |
+
'value' => 'newsletter'
|
46 |
+
),
|
47 |
+
array(
|
48 |
+
'label' => 'Product Review form',
|
49 |
+
'value' => 'review_form'
|
50 |
+
),
|
51 |
+
);
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/controllers/IndexController.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Sellry_Humanfriendlycaptcha_IndexController extends Mage_Core_Controller_Front_Action
|
31 |
+
{
|
32 |
+
public function indexAction()
|
33 |
+
{
|
34 |
+
echo 'Inside Sellry_Humanfriendlycaptcha_IndexController::indexAction()'; exit;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function testAction()
|
38 |
+
{
|
39 |
+
echo 'Inside Sellry_Humanfriendlycaptcha_IndexController::testAction()'; exit;
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Sellry/Humanfriendlycaptcha/etc/config.xml
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
-->
|
29 |
+
<config>
|
30 |
+
<modules>
|
31 |
+
<Sellry_Humanfriendlycaptcha>
|
32 |
+
<version>1.0.0</version>
|
33 |
+
</Sellry_Humanfriendlycaptcha>
|
34 |
+
</modules>
|
35 |
+
<global>
|
36 |
+
<blocks>
|
37 |
+
<humanfriendlycaptcha>
|
38 |
+
<class>Sellry_Humanfriendlycaptcha_Block</class>
|
39 |
+
</humanfriendlycaptcha>
|
40 |
+
<core>
|
41 |
+
<rewrite>
|
42 |
+
<text_list>Sellry_Humanfriendlycaptcha_Block_Core_Text_List</text_list>
|
43 |
+
</rewrite>
|
44 |
+
</core>
|
45 |
+
<customer>
|
46 |
+
<rewrite>
|
47 |
+
<form_register>Sellry_Humanfriendlycaptcha_Block_Customer_Form_Register</form_register>
|
48 |
+
</rewrite>
|
49 |
+
</customer>
|
50 |
+
<newsletter>
|
51 |
+
<rewrite>
|
52 |
+
<subscribe>Sellry_Humanfriendlycaptcha_Block_Newsletter_Subscribe</subscribe>
|
53 |
+
</rewrite>
|
54 |
+
</newsletter>
|
55 |
+
<review>
|
56 |
+
<rewrite>
|
57 |
+
<form>Sellry_Humanfriendlycaptcha_Block_Review_Form</form>
|
58 |
+
</rewrite>
|
59 |
+
</review>
|
60 |
+
</blocks>
|
61 |
+
<helpers>
|
62 |
+
<humanfriendlycaptcha>
|
63 |
+
<class>Sellry_Humanfriendlycaptcha_Helper</class>
|
64 |
+
</humanfriendlycaptcha>
|
65 |
+
<wordpress>
|
66 |
+
<rewrite>
|
67 |
+
<recaptcha>Sellry_Humanfriendlycaptcha_Helper_Recaptcha</recaptcha>
|
68 |
+
</rewrite>
|
69 |
+
</wordpress>
|
70 |
+
</helpers>
|
71 |
+
<models>
|
72 |
+
<humanfriendlycaptcha>
|
73 |
+
<class>Sellry_Humanfriendlycaptcha_Model</class>
|
74 |
+
</humanfriendlycaptcha>
|
75 |
+
</models>
|
76 |
+
</global>
|
77 |
+
<frontend>
|
78 |
+
<layout>
|
79 |
+
<updates>
|
80 |
+
<Sellry_Humanfriendlycaptcha>
|
81 |
+
<file>sellry_humanfriendlycaptcha.xml</file>
|
82 |
+
</Sellry_Humanfriendlycaptcha>
|
83 |
+
</updates>
|
84 |
+
</layout>
|
85 |
+
<events>
|
86 |
+
<controller_action_predispatch_customer_account_createpost>
|
87 |
+
<observers>
|
88 |
+
<hfc_customer_account_create_observer>
|
89 |
+
<type>singleton</type>
|
90 |
+
<class>humanfriendlycaptcha/observer</class>
|
91 |
+
<method>submitObserver</method>
|
92 |
+
</hfc_customer_account_create_observer>
|
93 |
+
</observers>
|
94 |
+
</controller_action_predispatch_customer_account_createpost>
|
95 |
+
<controller_action_predispatch_review_product_post>
|
96 |
+
<observers>
|
97 |
+
<hfc_customer_account_create_observer>
|
98 |
+
<type>singleton</type>
|
99 |
+
<class>humanfriendlycaptcha/observer</class>
|
100 |
+
<method>submitObserver</method>
|
101 |
+
</hfc_customer_account_create_observer>
|
102 |
+
</observers>
|
103 |
+
</controller_action_predispatch_review_product_post>
|
104 |
+
</events>
|
105 |
+
</frontend>
|
106 |
+
<adminhtml>
|
107 |
+
<acl>
|
108 |
+
<resources>
|
109 |
+
<all>
|
110 |
+
<title>Allow Everything</title>
|
111 |
+
</all>
|
112 |
+
<admin>
|
113 |
+
<children>
|
114 |
+
<system>
|
115 |
+
<children>
|
116 |
+
<config>
|
117 |
+
<children>
|
118 |
+
<sellry_humanfriendlycaptcha translate="label" module="humanfriendlycaptcha">
|
119 |
+
<title>Configure Human Friendly CAPTCHA</title>
|
120 |
+
<sort_order>50</sort_order>
|
121 |
+
</sellry_humanfriendlycaptcha>
|
122 |
+
</children>
|
123 |
+
</config>
|
124 |
+
</children>
|
125 |
+
</system>
|
126 |
+
</children>
|
127 |
+
</admin>
|
128 |
+
</resources>
|
129 |
+
</acl>
|
130 |
+
</adminhtml>
|
131 |
+
<default>
|
132 |
+
<sellry_humanfriendlycaptcha>
|
133 |
+
<general>
|
134 |
+
<enabled>0</enabled>
|
135 |
+
<error_message>Hmmm... we weren't able to recognize you as human.</error_message>
|
136 |
+
<magento_forms>contact,customer_register,newsletter</magento_forms>
|
137 |
+
</general>
|
138 |
+
</sellry_humanfriendlycaptcha>
|
139 |
+
</default>
|
140 |
+
|
141 |
+
</config>
|
app/code/community/Sellry/Humanfriendlycaptcha/etc/system.xml
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
-->
|
29 |
+
<config>
|
30 |
+
<sections>
|
31 |
+
<sellry_humanfriendlycaptcha translate="label" module="humanfriendlycaptcha">
|
32 |
+
<label>Human-Friendly Captcha</label>
|
33 |
+
<tab>customer</tab>
|
34 |
+
<frontend_type>text</frontend_type>
|
35 |
+
<sort_order>10</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>1</show_in_store>
|
39 |
+
<groups>
|
40 |
+
<hint>
|
41 |
+
<frontend_model>humanfriendlycaptcha/adminhtml_system_config_fieldset_hint</frontend_model>
|
42 |
+
<sort_order>0</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
</hint>
|
47 |
+
<general translate='label'>
|
48 |
+
<label>General configuration</label>
|
49 |
+
<frontend_type>text</frontend_type>
|
50 |
+
<sort_order>10</sort_order>
|
51 |
+
<show_in_default>1</show_in_default>
|
52 |
+
<show_in_website>1</show_in_website>
|
53 |
+
<show_in_store>1</show_in_store>
|
54 |
+
<fields>
|
55 |
+
<enabled>
|
56 |
+
<label>Enable PlayThru CAPTCHA</label>
|
57 |
+
<frontend_type>select</frontend_type>
|
58 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
59 |
+
<sort_order>10</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 |
+
</enabled>
|
64 |
+
<publisher_key>
|
65 |
+
<label>Publisher Key</label>
|
66 |
+
<comment>Look for this in the areyouahuman.com dashboard.</comment>
|
67 |
+
<frontend_type>text</frontend_type>
|
68 |
+
<sort_order>20</sort_order>
|
69 |
+
<show_in_default>1</show_in_default>
|
70 |
+
<show_in_website>1</show_in_website>
|
71 |
+
<show_in_store>1</show_in_store>
|
72 |
+
</publisher_key>
|
73 |
+
<scoring_key>
|
74 |
+
<label>Scoring Key</label>
|
75 |
+
<comment>This is also in the areyouahuman.com dashboard.</comment>
|
76 |
+
<frontend_type>text</frontend_type>
|
77 |
+
<sort_order>30</sort_order>
|
78 |
+
<show_in_default>1</show_in_default>
|
79 |
+
<show_in_website>1</show_in_website>
|
80 |
+
<show_in_store>1</show_in_store>
|
81 |
+
</scoring_key>
|
82 |
+
<error_message>
|
83 |
+
<label>Error message</label>
|
84 |
+
<comment>Visitors see this if they don't complete the PlayThru.</comment>
|
85 |
+
<frontend_type>text</frontend_type>
|
86 |
+
<sort_order>40</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>1</show_in_website>
|
89 |
+
<show_in_store>1</show_in_store>
|
90 |
+
</error_message>
|
91 |
+
<magento_forms>
|
92 |
+
<label>Magento forms to protect</label>
|
93 |
+
<comment>Select Magento forms you want PlayThru to protect. Our recommended options are selected by default.</comment>
|
94 |
+
<frontend_type>multiselect</frontend_type>
|
95 |
+
<source_model>humanfriendlycaptcha/system_config_source_forms</source_model>
|
96 |
+
<sort_order>50</sort_order>
|
97 |
+
<show_in_default>1</show_in_default>
|
98 |
+
<show_in_website>1</show_in_website>
|
99 |
+
<show_in_store>1</show_in_store>
|
100 |
+
</magento_forms>
|
101 |
+
<pages>
|
102 |
+
<label>Additional forms to protect</label>
|
103 |
+
<comment>Type other URLs containing forms you want protected and CAPTCHA should appear magically on them!
|
104 |
+
Note: This feature doesn't work for all forms. If after you've added a URL and tried submitting your form, the CAPTCHA does not appear, follow the instructions on sellry.com/ayah to manually add CAPTCHA support to your form(s).
|
105 |
+
</comment>
|
106 |
+
<frontend_model>humanfriendlycaptcha/system_config_form_field_pages</frontend_model>
|
107 |
+
<backend_model>humanfriendlycaptcha/system_config_backend_pages</backend_model>
|
108 |
+
<sort_order>60</sort_order>
|
109 |
+
<show_in_default>1</show_in_default>
|
110 |
+
<show_in_website>1</show_in_website>
|
111 |
+
<show_in_store>1</show_in_store>
|
112 |
+
</pages>
|
113 |
+
</fields>
|
114 |
+
</general>
|
115 |
+
</groups>
|
116 |
+
</sellry_humanfriendlycaptcha>
|
117 |
+
</sections>
|
118 |
+
|
119 |
+
</config>
|
app/code/community/Sellry/Humanfriendlycaptcha/sql/humanfriendlycaptcha_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
|
30 |
+
$installer = $this;
|
31 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
32 |
+
|
33 |
+
$installer->startSetup();
|
34 |
+
|
35 |
+
//Use {$this->getTable('humanfriendlycaptcha_humanfriendlycaptcha')} for table name
|
36 |
+
|
37 |
+
$installer->run("
|
38 |
+
|
39 |
+
//Add your SQL here...
|
40 |
+
|
41 |
+
");
|
42 |
+
|
43 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/template/sellry/humanfriendlycaptcha/system/config/fieldset/hint.phtml
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<style>
|
31 |
+
.sellry-notice {padding:15px 10px 10px 20px; border:1px solid #ccc; background:#f9fcec; margin:0 0 10px;}
|
32 |
+
.sellry-notice .logo {width:155px; float:left; margin:0 10px 0 0;}
|
33 |
+
.sellry-notice .notice {float:left;}
|
34 |
+
.sellry-notice .notice h4 {color:#6e6e6e; }
|
35 |
+
.sellry-notice .notice span, strong {color:#a09991;}
|
36 |
+
.sellry-notice .notice span,
|
37 |
+
.sellry-notice .notice strong,
|
38 |
+
.sellry-notice .notice a {line-height:20px;}
|
39 |
+
</style>
|
40 |
+
<div class='sellry-notice'>
|
41 |
+
<div class="logo">
|
42 |
+
<img src="<?php echo $this->getLogoImage() ?>" />
|
43 |
+
</div>
|
44 |
+
<div class="notice">
|
45 |
+
<h4>
|
46 |
+
<?php echo $this->getMainHeading() ?>
|
47 |
+
</h4>
|
48 |
+
<?php if($this->getLatestVersion() && $this->getModuleVersion() != $this->getLatestVersion()): ?>
|
49 |
+
<span><?php echo $this->__('Version: <strong>%s</strong> (this version is out of date)', $this->getModuleVersion()) ?></span>
|
50 |
+
<a href="<?php echo $this->getLatestDownloadUrl() ?>" target="_new"><?php echo $this->__('Download an updated version.') ?></a>
|
51 |
+
<?php else: ?>
|
52 |
+
<span><?php echo $this->__('Version: <strong>%s</strong> (this is the latest).', $this->getModuleVersion()) ?></span>
|
53 |
+
<?php endif; ?>
|
54 |
+
<?php if(!$this->isConnected()): ?>
|
55 |
+
<br/>
|
56 |
+
<?php echo $this->__("<strong>You're not connected to PlayThru yet.</strong> <a href='%s' target='_new'>Get a free account now.</a>", 'http://portal.areyouahuman.com/signup/basic'); ?>
|
57 |
+
<?php endif; ?>
|
58 |
+
<h4><a href="<?php echo $this->getCallToActionUrl() ?>" target="_new"><?php echo $this->getCallToActionMessage() ?></a><h4>
|
59 |
+
</div>
|
60 |
+
<div class="clear"></div>
|
61 |
+
</div>
|
app/design/frontend/default/default/layout/sellry_humanfriendlycaptcha.xml
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
-->
|
29 |
+
<layout version="0.1.0">
|
30 |
+
<default>
|
31 |
+
<reference name="head">
|
32 |
+
<action method="addJs"><script>sellry/humanfriendlycaptcha.js</script></action>
|
33 |
+
</reference>
|
34 |
+
</default>
|
35 |
+
</layout>
|
app/design/frontend/default/default/template/sellry/humanfriendlycaptcha/humanfriendlycaptcha.phtml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* So You ARE a Human! by Sellry
|
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 |
+
* 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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* Humanfriendlycaptcha
|
22 |
+
*
|
23 |
+
* @category Sellry
|
24 |
+
* @package Sellry_Humanfriendlycaptcha
|
25 |
+
* @copyright Copyright (c) 2013 Sellry (http://sellry.com)
|
26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
27 |
+
* @author Michael Bower <sales@sellry.com>
|
28 |
+
*/
|
29 |
+
/*
|
30 |
+
* @var $this Sellry_Humanfriendlycaptcha_Block_Humanfriendlycaptcha
|
31 |
+
*/
|
32 |
+
?>
|
33 |
+
|
34 |
+
<?php echo $this->getCode(); ?>
|
35 |
+
<?php if($this->getFormId() && $this->getVarienVar()): ?>
|
36 |
+
<script type="text/javascript">
|
37 |
+
document.observe("dom:loaded", function(){
|
38 |
+
validators['<?php echo $this->getFormId() ?>'] = <?php echo $this->getVarienVar() ?>;
|
39 |
+
});
|
40 |
+
</script>
|
41 |
+
<?php endif; ?>
|
js/sellry/humanfriendlycaptcha.js
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* Here we will store references to all the VarienForm variables for the forms
|
3 |
+
* that we will use AYAH on
|
4 |
+
* @type Array
|
5 |
+
*/
|
6 |
+
var validators = new Array();
|
7 |
+
|
8 |
+
/*
|
9 |
+
* The modified submit function
|
10 |
+
* @param null|Event event
|
11 |
+
* @returns {Boolean}
|
12 |
+
*/
|
13 |
+
function validateSubmit(event) {
|
14 |
+
var target = event ? $(event.target) : $(this);
|
15 |
+
if(!validators[target.id].validator.validate()) {
|
16 |
+
$('ayahLayer').remove();
|
17 |
+
$('ayahLayerBlock').remove();
|
18 |
+
return false;
|
19 |
+
}
|
20 |
+
|
21 |
+
this._submit();
|
22 |
+
}
|
23 |
+
|
24 |
+
document.observe("dom:loaded", function(){
|
25 |
+
if(window.HTMLElement){
|
26 |
+
/* DOM-compliant Browsers */
|
27 |
+
HTMLFormElement.prototype._submit = HTMLFormElement.prototype.submit;
|
28 |
+
HTMLFormElement.prototype.submit = validateSubmit;
|
29 |
+
} else {
|
30 |
+
/* IE does not expose it's HTMLElement object or its children
|
31 |
+
Let the document load so all forms are accounted for */
|
32 |
+
for(var i=0; i<document.forms.length; i++){
|
33 |
+
document.forms[i]._submit= document.forms[i].submit;
|
34 |
+
document.forms[i].submit = validateSubmit;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
});
|
lib/AYAH.php
ADDED
@@ -0,0 +1,461 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Are You A Human
|
4 |
+
* PHP Integration Library
|
5 |
+
*
|
6 |
+
* @version 1.1.4
|
7 |
+
*
|
8 |
+
* - Documentation and latest version
|
9 |
+
* http://portal.areyouahuman.com/help
|
10 |
+
* - Get an AYAH Publisher Key
|
11 |
+
* https://portal.areyouahuman.com
|
12 |
+
* - Discussion group
|
13 |
+
* http://getsatisfaction.com/areyouahuman
|
14 |
+
*
|
15 |
+
* Copyright (c) 2011 AYAH LLC -- http://www.areyouahuman.com
|
16 |
+
*
|
17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23 |
+
* THE SOFTWARE.
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
class AYAH {
|
28 |
+
protected $ayah_publisher_key;
|
29 |
+
protected $ayah_scoring_key;
|
30 |
+
protected $ayah_web_service_host;
|
31 |
+
protected $session_secret;
|
32 |
+
|
33 |
+
protected $__debug_mode = FALSE;
|
34 |
+
protected $__message_buffer = array();
|
35 |
+
protected $__version_number = '1.1.4';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Constructor
|
39 |
+
* If the session secret exists in input, it grabs it
|
40 |
+
* @param $params associative array with keys publisher_key, scoring_key, web_service_host
|
41 |
+
*
|
42 |
+
*/
|
43 |
+
public function __construct($params = array())
|
44 |
+
{
|
45 |
+
// Try to load the ayah_config.php file.
|
46 |
+
if ( ! $this->__load_config_file())
|
47 |
+
{
|
48 |
+
$this->__log("DEBUG", __FUNCTION__, "The ayah_config.php file is missing.");
|
49 |
+
}
|
50 |
+
|
51 |
+
if(array_key_exists("session_secret", $_REQUEST)) {
|
52 |
+
$this->session_secret = $_REQUEST["session_secret"];
|
53 |
+
}
|
54 |
+
|
55 |
+
// Set them to defaults
|
56 |
+
$this->ayah_publisher_key = "";
|
57 |
+
$this->ayah_scoring_key = "";
|
58 |
+
$this->ayah_web_service_host = "ws.areyouahuman.com";
|
59 |
+
|
60 |
+
// If the constants exist, override with those
|
61 |
+
if (defined('AYAH_PUBLISHER_KEY')) {
|
62 |
+
$this->ayah_publisher_key = AYAH_PUBLISHER_KEY;
|
63 |
+
}
|
64 |
+
|
65 |
+
if (defined('AYAH_SCORING_KEY')) {
|
66 |
+
$this->ayah_scoring_key = AYAH_SCORING_KEY;
|
67 |
+
}
|
68 |
+
|
69 |
+
if (defined('AYAH_WEB_SERVICE_HOST')) {
|
70 |
+
$this->ayah_web_service_host = AYAH_WEB_SERVICE_HOST;
|
71 |
+
}
|
72 |
+
|
73 |
+
// Lastly grab the parameters input and save them
|
74 |
+
foreach (array_keys($params) as $key) {
|
75 |
+
if (in_array($key, array("publisher_key", "scoring_key", "web_service_host"))) {
|
76 |
+
$variable = "ayah_" . $key;
|
77 |
+
$this->$variable = $params[$key];
|
78 |
+
} else {
|
79 |
+
$this->__log("ERROR", __FUNCTION__, "Unrecognized key for constructor param: '$key'");
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
// Generate some warnings if a foot shot is coming
|
84 |
+
if ($this->ayah_publisher_key == "") {
|
85 |
+
$this->__log("ERROR", __FUNCTION__, "Warning: Publisher key is not defined. This won't work.");
|
86 |
+
}
|
87 |
+
else
|
88 |
+
{
|
89 |
+
$this->__log("DEBUG", __FUNCTION__, "Publisher key: '$this->ayah_publisher_key'");
|
90 |
+
}
|
91 |
+
|
92 |
+
if ($this->ayah_scoring_key == "") {
|
93 |
+
$this->__log("ERROR", __FUNCTION__, "Warning: Scoring key is not defined. This won't work.");
|
94 |
+
}
|
95 |
+
else
|
96 |
+
{
|
97 |
+
$this->__log("DEBUG", __FUNCTION__, "Scoring key: '$this->ayah_scoring_key'");
|
98 |
+
}
|
99 |
+
|
100 |
+
if ($this->ayah_web_service_host == "") {
|
101 |
+
$this->__log("ERROR", __FUNCTION__, "Warning: Web service host is not defined. This won't work.");
|
102 |
+
}
|
103 |
+
else
|
104 |
+
{
|
105 |
+
$this->__log("DEBUG", __FUNCTION__, "AYAH Webservice host: '$this->ayah_web_service_host'");
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Returns the markup for the PlayThru
|
111 |
+
*
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
public function getPublisherHTML($config = array())
|
115 |
+
{
|
116 |
+
// Initialize.
|
117 |
+
$session_secret = "";
|
118 |
+
$fields = array('config' => $config);
|
119 |
+
$webservice_url = '/ws/setruntimeoptions/' . $this->ayah_publisher_key;
|
120 |
+
|
121 |
+
// If necessary, process the config data.
|
122 |
+
if ( ! empty($config))
|
123 |
+
{
|
124 |
+
// Log it.
|
125 |
+
$this->__log("DEBUG", __FUNCTION__, "Setting runtime options...config data='".implode(",", $config)."'");
|
126 |
+
|
127 |
+
// Add the gameid to the options url.
|
128 |
+
if (array_key_exists("gameid", $config))
|
129 |
+
{
|
130 |
+
$webservice_url .= '/' . $config['gameid'];
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
// Call the webservice and get the response.
|
135 |
+
$resp = $this->doHttpsPostReturnJSONArray($this->ayah_web_service_host, $webservice_url, $fields);
|
136 |
+
if ($resp)
|
137 |
+
{
|
138 |
+
// Get the session secret from the response.
|
139 |
+
$session_secret = $resp->session_secret;
|
140 |
+
|
141 |
+
// Build the url to the AYAH webservice.
|
142 |
+
$url = 'https://'; // The AYAH webservice API requires https.
|
143 |
+
$url.= $this->ayah_web_service_host; // Add the host.
|
144 |
+
$url.= "/ws/script/"; // Add the path to the API script.
|
145 |
+
$url.= urlencode($this->ayah_publisher_key); // Add the encoded publisher key.
|
146 |
+
$url.= (empty($session_secret))? "" : "/".$session_secret; // If set, add the session_secret.
|
147 |
+
|
148 |
+
// Build and return the needed HTML code.
|
149 |
+
return "<div id='AYAH'></div><script src='". $url ."' type='text/javascript' language='JavaScript'></script>";
|
150 |
+
}
|
151 |
+
else
|
152 |
+
{
|
153 |
+
// Build and log a detailed message.
|
154 |
+
$url = "https://".$this->ayah_web_service_host.$webservice_url;
|
155 |
+
$message = "Unable to connect to the AYAH webservice server. url='$url'";
|
156 |
+
$this->__log("ERROR", __FUNCTION__, $message);
|
157 |
+
|
158 |
+
// Build and display a helpful message to the site user.
|
159 |
+
$style = "padding: 10px; border: 1px solid #EED3D7; background: #F2DEDE; color: #B94A48;";
|
160 |
+
$message = "Unable to load the <i>Are You a Human</i> PlayThru™. Please contact the site owner to report the problem.";
|
161 |
+
echo "<p style=\"$style\">$message</p>\n";
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Check whether the user is a human
|
167 |
+
* Wrapper for the scoreGame API call
|
168 |
+
*
|
169 |
+
* @return boolean
|
170 |
+
*/
|
171 |
+
public function scoreResult() {
|
172 |
+
$result = false;
|
173 |
+
if ($this->session_secret) {
|
174 |
+
$fields = array(
|
175 |
+
'session_secret' => urlencode($this->session_secret),
|
176 |
+
'scoring_key' => $this->ayah_scoring_key
|
177 |
+
);
|
178 |
+
$resp = $this->doHttpsPostReturnJSONArray($this->ayah_web_service_host, "/ws/scoreGame", $fields);
|
179 |
+
if ($resp) {
|
180 |
+
$result = ($resp->status_code == 1);
|
181 |
+
}
|
182 |
+
}
|
183 |
+
else
|
184 |
+
{
|
185 |
+
$this->__log("ERROR", __FUNCTION__, "Unable to score the result. Please check that your ayah_config.php file contains your correct publisher key and scoring key.");
|
186 |
+
}
|
187 |
+
|
188 |
+
return $result;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Records a conversion
|
193 |
+
* Called on the goal page that A and B redirect to
|
194 |
+
* A/B Testing Specific Function
|
195 |
+
*
|
196 |
+
* @return boolean
|
197 |
+
*/
|
198 |
+
public function recordConversion() {
|
199 |
+
// Build the url to the AYAH webservice..
|
200 |
+
$url = 'https://'; // The AYAH webservice API requires https.
|
201 |
+
$url.= $this->ayah_web_service_host; // Add the host.
|
202 |
+
$url.= "/ws/recordConversion/"; // Add the path to the API script.
|
203 |
+
$url.= urlencode($this->ayah_publisher_key); // Add the encoded publisher key.
|
204 |
+
|
205 |
+
if( isset( $this->session_secret ) ){
|
206 |
+
return '<iframe style="border: none;" height="0" width="0" src="' . $url . '"></iframe>';
|
207 |
+
} else {
|
208 |
+
$this->__log("ERROR", __FUNCTION__, 'AYAH Conversion Error: No Session Secret');
|
209 |
+
return FALSE;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Do a HTTPS POST, return some JSON decoded as array (Internal function)
|
215 |
+
* @param $host hostname
|
216 |
+
* @param $path path
|
217 |
+
* @param $fields associative array of fields
|
218 |
+
* return JSON decoded data structure or empty data structure
|
219 |
+
*/
|
220 |
+
protected function doHttpsPostReturnJSONArray($hostname, $path, $fields) {
|
221 |
+
$result = $this->doHttpsPost($hostname, $path, $fields);
|
222 |
+
|
223 |
+
if ($result) {
|
224 |
+
$result = $this->doJSONArrayDecode($result);
|
225 |
+
} else {
|
226 |
+
$this->__log("ERROR", __FUNCTION__, "Post to https://$hostname$path returned no result.");
|
227 |
+
$result = array();
|
228 |
+
}
|
229 |
+
|
230 |
+
return $result;
|
231 |
+
}
|
232 |
+
|
233 |
+
// Internal function; does an HTTPS post
|
234 |
+
protected function doHttpsPost($hostname, $path, $fields) {
|
235 |
+
$result = "";
|
236 |
+
// URLencode the post string
|
237 |
+
$fields_string = "";
|
238 |
+
foreach($fields as $key=>$value) {
|
239 |
+
if (is_array($value)) {
|
240 |
+
if ( ! empty($value)) {
|
241 |
+
foreach ($value as $k => $v) {
|
242 |
+
$fields_string .= $key . '['. $k .']=' . $v . '&';
|
243 |
+
}
|
244 |
+
} else {
|
245 |
+
$fields_string .= $key . '=&';
|
246 |
+
}
|
247 |
+
} else {
|
248 |
+
$fields_string .= $key.'='.$value.'&';
|
249 |
+
}
|
250 |
+
}
|
251 |
+
rtrim($fields_string,'&');
|
252 |
+
|
253 |
+
// cURL or something else
|
254 |
+
if (function_exists('curl_init'))
|
255 |
+
{
|
256 |
+
// Build the cURL url.
|
257 |
+
$curl_url = "https://" . $hostname . $path;
|
258 |
+
|
259 |
+
// Log it.
|
260 |
+
$this->__log("DEBUG", __FUNCTION__, "Using cURl: url='$curl_url', fields='$fields_string'");
|
261 |
+
|
262 |
+
// Initialize cURL session.
|
263 |
+
if ($ch = curl_init($curl_url))
|
264 |
+
{
|
265 |
+
// Set the cURL options.
|
266 |
+
curl_setopt($ch, CURLOPT_POST, count($fields));
|
267 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
|
268 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
269 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
270 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
271 |
+
|
272 |
+
// Execute the cURL request.
|
273 |
+
$result = curl_exec($ch);
|
274 |
+
|
275 |
+
// Close the curl session.
|
276 |
+
curl_close($ch);
|
277 |
+
}
|
278 |
+
else
|
279 |
+
{
|
280 |
+
// Log it.
|
281 |
+
$this->__log("DEBUG", __FUNCTION__, "Unable to initialize cURL: url='$curl_url'");
|
282 |
+
}
|
283 |
+
}
|
284 |
+
else
|
285 |
+
{
|
286 |
+
$this->__log("DEBUG", __FUNCTION__, "No cURL support....using fsockopen()");
|
287 |
+
|
288 |
+
// Build a header
|
289 |
+
$http_request = "POST $path HTTP/1.1\r\n";
|
290 |
+
$http_request .= "Host: $hostname\r\n";
|
291 |
+
$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
|
292 |
+
$http_request .= "Content-Length: " . strlen($fields_string) . "\r\n";
|
293 |
+
$http_request .= "User-Agent: AreYouAHuman/PHP " . $this->get_version_number() . "\r\n";
|
294 |
+
$http_request .= "Connection: Close\r\n";
|
295 |
+
$http_request .= "\r\n";
|
296 |
+
$http_request .= $fields_string ."\r\n";
|
297 |
+
|
298 |
+
$result = '';
|
299 |
+
$errno = $errstr = "";
|
300 |
+
$fs = fsockopen("ssl://" . $hostname, 443, $errno, $errstr, 10);
|
301 |
+
if( false == $fs ) {
|
302 |
+
$this->__log("ERROR", __FUNCTION__, "Could not open socket");
|
303 |
+
} else {
|
304 |
+
fwrite($fs, $http_request);
|
305 |
+
while (!feof($fs)) {
|
306 |
+
$result .= fgets($fs, 4096);
|
307 |
+
}
|
308 |
+
|
309 |
+
$result = explode("\r\n\r\n", $result, 2);
|
310 |
+
$result = $result[1];
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
// Log the result.
|
315 |
+
$this->__log("DEBUG", __FUNCTION__, "result='$result'");
|
316 |
+
|
317 |
+
// Return the result.
|
318 |
+
return $result;
|
319 |
+
}
|
320 |
+
|
321 |
+
// Internal function: does a JSON decode of the string
|
322 |
+
protected function doJSONArrayDecode($string) {
|
323 |
+
$result = array();
|
324 |
+
|
325 |
+
if (function_exists("json_decode")) {
|
326 |
+
try {
|
327 |
+
$result = json_decode( $string);
|
328 |
+
} catch (Exception $e) {
|
329 |
+
$this->__log("ERROR", __FUNCTION__, "Exception when calling json_decode: " . $e->getMessage());
|
330 |
+
$result = null;
|
331 |
+
}
|
332 |
+
} elseif (file_Exists("json.php")) {
|
333 |
+
require_once('json.php');
|
334 |
+
$json = new Services_JSON();
|
335 |
+
$result = $json->decode($string);
|
336 |
+
|
337 |
+
if (!is_array($result)) {
|
338 |
+
$this->__log("ERROR", __FUNCTION__, "Expected array; got something else: $result");
|
339 |
+
$result = array();
|
340 |
+
}
|
341 |
+
} else {
|
342 |
+
$this->__log("ERROR", __FUNCTION__, "No JSON decode function available.");
|
343 |
+
}
|
344 |
+
|
345 |
+
return $result;
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Get the current debug mode (TRUE or FALSE)
|
350 |
+
*
|
351 |
+
* @return boolean
|
352 |
+
*/
|
353 |
+
public function debug_mode($mode=null)
|
354 |
+
{
|
355 |
+
// Set it if the mode is passed.
|
356 |
+
if (null !== $mode)
|
357 |
+
{
|
358 |
+
$this->__debug_mode = $mode;
|
359 |
+
|
360 |
+
// Display a message if debug_mode is TRUE.
|
361 |
+
if ($mode)
|
362 |
+
{
|
363 |
+
$version_number = $this->get_version_number();
|
364 |
+
$this->__log("DEBUG", "", "Debug mode is now on. (ayah.php version=$version_number)");
|
365 |
+
|
366 |
+
// Flush the buffer.
|
367 |
+
$this->__flush_message_buffer();
|
368 |
+
}
|
369 |
+
}
|
370 |
+
|
371 |
+
// If necessary, set the default.
|
372 |
+
if ( ! isset($this->__debug_mode) or (null == $this->__debug_mode)) $this->__debug_mode = FALSE;
|
373 |
+
|
374 |
+
// Return TRUE or FALSE.
|
375 |
+
return ($this->__debug_mode)? TRUE : FALSE;
|
376 |
+
}
|
377 |
+
|
378 |
+
/**
|
379 |
+
* Get the current version number
|
380 |
+
*
|
381 |
+
* @return string
|
382 |
+
*/
|
383 |
+
public function get_version_number()
|
384 |
+
{
|
385 |
+
return (isset($this->__version_number))? $this->__version_number : FALSE;
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Load the config file.
|
390 |
+
*
|
391 |
+
* @return boolean
|
392 |
+
*/
|
393 |
+
private function __load_config_file()
|
394 |
+
{
|
395 |
+
// Initialize.
|
396 |
+
$name = 'ayah_config.php';
|
397 |
+
$locations = array(
|
398 |
+
'./',
|
399 |
+
dirname(__FILE__)."/",
|
400 |
+
);
|
401 |
+
|
402 |
+
// Look for the config file in each location.
|
403 |
+
foreach ($locations as $location)
|
404 |
+
{
|
405 |
+
if (file_exists($location.$name))
|
406 |
+
{
|
407 |
+
require_once($location.$name);
|
408 |
+
return TRUE;
|
409 |
+
}
|
410 |
+
}
|
411 |
+
|
412 |
+
// Could not find the config file.
|
413 |
+
return FALSE;
|
414 |
+
}
|
415 |
+
|
416 |
+
/**
|
417 |
+
* Log a message
|
418 |
+
*
|
419 |
+
* @return null
|
420 |
+
*/
|
421 |
+
private function __log($type, $function, $message)
|
422 |
+
{
|
423 |
+
// Add a prefix to the message.
|
424 |
+
$message = __CLASS__ . "::$function: " . $message;
|
425 |
+
|
426 |
+
// Is it an error message?
|
427 |
+
if (FALSE !== stripos($type, "error"))
|
428 |
+
{
|
429 |
+
error_log($message);
|
430 |
+
}
|
431 |
+
|
432 |
+
// Build the full message.
|
433 |
+
$message_style = "padding: 10px; border: 1px solid #EED3D7; background: #F2DEDE; color: #B94A48;";
|
434 |
+
$full_message = "<p style=\"$message_style\"><strong>$type:</strong> $message</p>\n";
|
435 |
+
|
436 |
+
// Output to the screen too?
|
437 |
+
if ($this->debug_mode())
|
438 |
+
{
|
439 |
+
echo "$full_message";
|
440 |
+
}
|
441 |
+
else
|
442 |
+
{
|
443 |
+
// Add the message to the buffer in case we need it later.
|
444 |
+
$this->__message_buffer[] = $full_message;
|
445 |
+
}
|
446 |
+
}
|
447 |
+
|
448 |
+
private function __flush_message_buffer()
|
449 |
+
{
|
450 |
+
// Flush the buffer.
|
451 |
+
if ( ! empty($this->__message_buffer))
|
452 |
+
{
|
453 |
+
foreach ($this->__message_buffer as $buffered_message)
|
454 |
+
{
|
455 |
+
// Print the buffered message.
|
456 |
+
echo "$buffered_message";
|
457 |
+
}
|
458 |
+
}
|
459 |
+
}
|
460 |
+
}
|
461 |
+
|
package.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Sellry_Humanfriendlycaptcha</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>Protect your Magento form submissions from spammers with CAPTCHAs that humans can actually understand.</summary>
|
10 |
+
<description>Robots are getting smarter even as CAPTCHAs become less and less intelligible. This extension installs human-friendly CAPTCHA onto your Magento forms. Choose from standard Magento forms you want to protect, or add pages by URL that need protection.
|
11 |
+
|
12 |
+
Works with the following CAPTCHAs:
|
13 |
+
|
14 |
+
Are You a Human</description>
|
15 |
+
<notes>First preview release</notes>
|
16 |
+
<authors><author><name>Sellry</name><user>auto-converted</user><email>sales@sellry.com</email></author></authors>
|
17 |
+
<date>2013-12-12</date>
|
18 |
+
<time>18:53:28</time>
|
19 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="sellry"><dir name="humanfriendlycaptcha"><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="4ffda31ed5a854e6d03df65fda40eeab"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="sellry_humanfriendlycaptcha.xml" hash="f62470104a87239680cca79be096d98c"/></dir><dir name="template"><dir name="sellry"><dir name="humanfriendlycaptcha"><file name="humanfriendlycaptcha.phtml" hash="8e8c779d1f4261c8b7354f127d4c5180"/></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="sellry"><file name="humanfriendlycaptcha.js" hash="8f71fd680038cf42f29a257f1aff86e9"/></dir></dir></target><target name="magecommunity"><dir name="Sellry"><dir name="Humanfriendlycaptcha"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="ece13d217b1ebfe0e36ba6fccc776e93"/></dir></dir></dir></dir><dir name="Core"><dir name="Text"><file name="List.php" hash="14dfceedfff6897587044d6a1d03347b"/></dir></dir><dir name="Customer"><dir name="Form"><file name="Register.php" hash="e5a69c958ec9dbbf3acdb3a03fb87e83"/></dir></dir><dir name="Newsletter"><file name="Subscribe.php" hash="a511133a5ef347cf96b72014effa5d43"/></dir><dir name="Review"><file name="Form.php" hash="e19dbd18afed68e0920145e60a1c87f9"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Pages.php" hash="625a666baf27f37e590bc5f7737cc926"/></dir></dir></dir></dir><file name="Humanfriendlycaptcha.php" hash="8412803f2df929af4cd91dc47112db49"/></dir><dir name="controllers"><file name="IndexController.php" hash="86db65a7958c5f55bdd591ce3a098099"/></dir><dir name="etc"><file name="config.xml" hash="b81396a765670564f7111e145628e72f"/><file name="system.xml" hash="93c17ac2da194b937c8d9288e74ba2ab"/></dir><dir name="Helper"><file name="Data.php" hash="732e6ffaa3ef704147d49186ffd2164f"/><file name="Recaptcha.php" hash="10d0dff1e96048acc379e6f1ffd418d5"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Pages.php" hash="fdc321fb336eba011139898148b91e80"/></dir><dir name="Source"><file name="Forms.php" hash="026e2cd45ce1c8a13c4f0d23b6d95fa9"/></dir></dir></dir><file name="Humanfriendlycaptcha.php" hash="4591ab13d33f39175b4efb2f14c2daa3"/><file name="Observer.php" hash="ba3341c6c6776d96cf613622c9c7bc3c"/></dir><dir name="sql"><dir name="humanfriendlycaptcha_setup"><file name="mysql4-install-1.0.0.php" hash="2ce8c8ee2a56cb462ed62d289a0e6e77"/></dir></dir></dir></dir></target><target name="magelib"><dir name="."><file name="AYAH.php" hash="198ddd78f6b3b5161eb1a3c9d2c602e2"/></dir></target></contents>
|
20 |
+
<compatible/>
|
21 |
+
<dependencies/>
|
22 |
+
</package>
|