-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b930d61
commit 6b2e037
Showing
4 changed files
with
105 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,65 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: elisa | ||
* Date: 03.01.18 | ||
* Time: 19:19 | ||
*/ | ||
* @package Joomla.Plugin | ||
* @subpackage Captcha | ||
* | ||
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
|
||
/** | ||
* Honeypot Plugin. | ||
*/ | ||
|
||
class PlgCaptchaHoneypot extends JPlugin | ||
{ | ||
|
||
/** | ||
* Displays the honeypot input field and adds style declaration to hide it | ||
* | ||
* @param string $this->params->get("fieldname") The name of the field. | ||
* | ||
* @return string The HTML to be embedded in the form. | ||
* | ||
* @since 2.5 | ||
*/ | ||
public function onDisplay() | ||
{ | ||
$doc = JFactory::getDocument(); | ||
/* $doc->addStyleDeclaration('body label[for="' . $this->params->get("fieldname") . '"], body label[for="jform_captcha"], body label[for="jform_captcha"] + span.optional, body #' . $this->params->get("fieldname") . ' {display: none; visibility: hidden; }');*/ | ||
return '<input id="' . $this->params->get("fieldname") . '" name="' . $this->params->get("fieldname") . '" size="40" type="text" />'; | ||
} | ||
|
||
|
||
/** | ||
* Verifies if the honeypot field is empty | ||
* | ||
* @param string $code Answer provided by user. | ||
* | ||
* @return True if the answer is correct, false otherwise | ||
* | ||
* @since 2.5 | ||
*/ | ||
public function onCheckAnswer() | ||
{ | ||
$input = JFactory::getApplication()->input; | ||
$honeypot = $this->params->get("fieldname"); | ||
$response = $input->get($honeypot, '', 'string'); | ||
$spam = ($response != ''); | ||
|
||
// Discard spam submissions | ||
if ($spam) | ||
{ | ||
$this->_subject->setError(JText::_('PLG_RECAPTCHA_ERROR_HONEYPOT')); | ||
|
||
return false; | ||
} | ||
|
||
return true; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<extension version="3.9" type="plugin" group="captcha" method="upgrade"> | ||
<name>plg_captcha_honeypot</name> | ||
<version>3.9.0</version> | ||
<creationDate>January 2018</creationDate> | ||
<author>Joomla! Project</author> | ||
<authorEmail>admin@joomla.org</authorEmail> | ||
<authorUrl>www.joomla.org</authorUrl> | ||
<copyright>Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.</copyright> | ||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> | ||
<description>PLG_CAPTCHA_HONEYPOT_XML_DESCRIPTION</description> | ||
|
||
<files> | ||
<filename plugin="honeypot">honeypot.php</filename> | ||
</files> | ||
<languages> | ||
<language tag="en-GB">language/en-GB.plg_captcha_honeypot.ini</language> | ||
<language tag="en-GB">language/en-GB.plg_captcha_honeypot.sys.ini</language> | ||
</languages> | ||
<config> | ||
<fields name="params"> | ||
<fieldset name="basic"> | ||
|
||
<field | ||
name="fieldname" | ||
label="PLG_CAPTCHA_HONEYPOT_FIELDNAME_LABEL" | ||
description="PLG_CAPTCHA_HONEYPOT_FIELDNAME_DESC" | ||
type="text" | ||
default="repeatmail" | ||
/> | ||
</fieldset> | ||
</fields> | ||
</config> | ||
</extension> |