Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' of https://github.com/joomla/joomla-cms into b…
…atchoptimizations
- Loading branch information
Showing
20 changed files
with
414 additions
and
5 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
administrator/components/com_admin/sql/updates/mysql/3.4.0-2014-12-04.sql
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,2 @@ | ||
INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES | ||
(452, 'plg_captcha_nocaptcha', 'plugin', 'nocaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"light"}', '', '', 0, '0000-00-00 00:00:00', 0, 0); |
2 changes: 2 additions & 0 deletions
2
administrator/components/com_admin/sql/updates/postgresql/3.4.0-2014-12-04.sql
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,2 @@ | ||
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES | ||
(452, 'plg_captcha_nocaptcha', 'plugin', 'nocaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"light"}', '', '', 0, '1970-01-01 00:00:00', 0, 0); |
6 changes: 6 additions & 0 deletions
6
administrator/components/com_admin/sql/updates/sqlazure/3.4.0-2014-12-04.sql
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,6 @@ | ||
SET IDENTITY_INSERT [#__extensions] ON; | ||
|
||
INSERT [#__extensions] ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state]) | ||
SELECT 452, 'plg_captcha_nocaptcha', 'plugin', 'nocaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"light"}', '', '', 0, '1900-01-01 00:00:00', 0, 0; | ||
|
||
SET IDENTITY_INSERT [#__extensions] OFF; |
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
23 changes: 23 additions & 0 deletions
23
administrator/language/en-GB/en-GB.plg_captcha_nocaptcha.ini
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,23 @@ | ||
; Joomla! Project | ||
; Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. | ||
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_CAPTCHA_NOCAPTCHA_XML_DESCRIPTION="This CAPTCHA plugin uses the reCAPTCHA service to prevent spammers. To get a site and secret key for your domain, go to <a href="_QQ_"http://www.google.com/recaptcha"_QQ_" target="_QQ_"_blank"_QQ_">http://www.google.com/recaptcha</a>. To use this for new account registration, go to Options in the User Manager and select Captcha - NoCAPTCHA as the Captcha." | ||
PLG_CAPTCHA_NOCAPTCHA="Captcha - NoCAPTCHA" | ||
|
||
; Params | ||
PLG_NOCAPTCHA_PUBLIC_KEY_LABEL="Site key" | ||
PLG_NOCAPTCHA_PUBLIC_KEY_DESC="Used in the JavaScript code that is served to your users. See the plugin description for instructions on getting a site key." | ||
PLG_NOCAPTCHA_PRIVATE_KEY_LABEL="Secret key" | ||
PLG_NOCAPTCHA_PRIVATE_KEY_DESC="Used in the communication between your server and the reCAPTCHA server. Be sure to keep it a secret. See the plugin description for instructions on getting a secret key." | ||
PLG_NOCAPTCHA_THEME_LABEL="Theme" | ||
PLG_NOCAPTCHA_THEME_DESC="Defines which theme to use for NoCAPTCHA." | ||
PLG_NOCAPTCHA_THEME_LIGHT="Light" | ||
PLG_NOCAPTCHA_THEME_DARK="Dark" | ||
|
||
; Error messages | ||
PLG_NOCAPTCHA_ERROR_NO_PRIVATE_KEY="The NoCAPTCHA plugin needs a secret key to be set in its parameters. Please contact a site administrator." | ||
PLG_NOCAPTCHA_ERROR_NO_PUBLIC_KEY="The NoCAPTCHA plugin needs a site key to be set in its parameters. Please contact a site administrator." | ||
PLG_NOCAPTCHA_ERROR_NOT_SET="Please complete the security question." | ||
PLG_NOCAPTCHA_ERROR_NO_IP="For security reasons, you must pass the remote ip address to NoCAPTCHA" |
7 changes: 7 additions & 0 deletions
7
administrator/language/en-GB/en-GB.plg_captcha_nocaptcha.sys.ini
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,7 @@ | ||
; Joomla! Project | ||
; Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved. | ||
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_CAPTCHA_NOCAPTCHA_XML_DESCRIPTION="This CAPTCHA plugin uses the reCAPTCHA service to prevent spammers. To get a site and secret key for your domain, go to <a href="_QQ_"http://www.google.com/recaptcha"_QQ_" target="_QQ_"_blank"_QQ_">http://www.google.com/recaptcha</a>. To use this for new account registration, go to Options in the User Manager and select Captcha - NoCAPTCHA as the Captcha." | ||
PLG_CAPTCHA_NOCAPTCHA="Captcha - NoCAPTCHA" |
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
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<!DOCTYPE html><title></title> |
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,141 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Plugin | ||
* @subpackage Captcha | ||
* | ||
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* NoCaptcha Plugin. | ||
* Based on the official recaptcha library( https://developers.google.com/recaptcha/docs/php ) | ||
* | ||
* @since 3.4 | ||
*/ | ||
class PlgCaptchaNocaptcha extends JPlugin | ||
{ | ||
/** | ||
* Load the language file on instantiation. | ||
* | ||
* @var boolean | ||
* @since 3.4 | ||
*/ | ||
protected $autoloadLanguage = true; | ||
|
||
/** | ||
* Initialise the captcha | ||
* | ||
* @param string $id The id of the field. | ||
* | ||
* @return boolean True on success, false otherwise | ||
* | ||
* @since 3.4 | ||
*/ | ||
public function onInit($id = 'dynamic_recaptcha_1') | ||
{ | ||
$document = JFactory::getDocument(); | ||
$app = JFactory::getApplication(); | ||
|
||
JHtml::_('jquery.framework'); | ||
|
||
$public_key = $this->params->get('public_key', ''); | ||
$theme = $this->params->get('theme', 'light'); | ||
|
||
if ($public_key == null || $public_key == '') | ||
{ | ||
throw new Exception(JText::_('PLG_NOCAPTCHA_ERROR_NO_PUBLIC_KEY')); | ||
} | ||
|
||
$file = $app->isSSLConnection() ? 'https' : 'http'; | ||
$file .= '://www.google.com/recaptcha/api.js?hl=' . JFactory::getLanguage() | ||
->getTag() . '&onload=onloadCallback&render=explicit'; | ||
|
||
JHtml::_('script', $file, true, true); | ||
|
||
$document->addScriptDeclaration('var onloadCallback = function() {' | ||
. 'grecaptcha.render("' . $id . '", {sitekey: "' . $public_key . '", theme: "' . $theme . '"});' | ||
. '}' | ||
); | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Gets the challenge HTML | ||
* | ||
* @param string $name The name of the field. | ||
* @param string $id The id of the field. | ||
* @param string $class The class of the field. This should be passed as | ||
* e.g. 'class="required"'. | ||
* | ||
* @return string The HTML to be embedded in the form. | ||
* | ||
* @since 3.4 | ||
*/ | ||
public function onDisplay($name, $id = 'dynamic_recaptcha_1', $class = '') | ||
{ | ||
return '<div id="' . $id . '" ' . $class . '></div>'; | ||
} | ||
|
||
/** | ||
* Calls an HTTP POST function to verify if the user's guess was correct | ||
* | ||
* @param string $code Answer provided by user. | ||
* | ||
* @return True if the answer is correct, false otherwise | ||
* | ||
* @since 3.4 | ||
*/ | ||
public function onCheckAnswer($code) | ||
{ | ||
$input = JFactory::getApplication()->input; | ||
$privatekey = $this->params->get('private_key'); | ||
$remoteip = $input->server->get('REMOTE_ADDR', '', 'string'); | ||
$response = $input->get('g-recaptcha-response', '', 'string'); | ||
|
||
// Check for Private Key | ||
if (empty($privatekey)) | ||
{ | ||
$this->_subject->setError(JText::_('PLG_NOCAPTCHA_ERROR_NO_PRIVATE_KEY')); | ||
|
||
return false; | ||
} | ||
|
||
// Check for IP | ||
if (empty($remoteip)) | ||
{ | ||
$this->_subject->setError(JText::_('PLG_NOCAPTCHA_ERROR_NO_IP')); | ||
|
||
return false; | ||
} | ||
|
||
// Discard spam submissions | ||
if ($response == null || strlen($response) == 0) | ||
{ | ||
$this->_subject->setError(JText::_('PLG_NOCAPTCHA_ERROR_EMPTY_SOLUTION')); | ||
|
||
return false; | ||
} | ||
|
||
require_once 'recaptchalib.php'; | ||
|
||
$reCaptcha = new JReCaptcha($privatekey); | ||
$response = $reCaptcha->verifyResponse($remoteip, $response); | ||
|
||
if ( !isset($response->success) || !$response->success) | ||
{ | ||
// @todo use exceptions here | ||
foreach ($response->errorCodes as $error) | ||
{ | ||
$this->_subject->setError($error); | ||
} | ||
|
||
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,55 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<extension version="3.1" type="plugin" group="captcha"> | ||
<name>plg_captcha_nocaptcha</name> | ||
<version>3.0.0</version> | ||
<creationDate>December 2014</creationDate> | ||
<author>Joomla! Project</author> | ||
<authorEmail>admin@joomla.org</authorEmail> | ||
<authorUrl>www.joomla.org</authorUrl> | ||
<copyright>Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.</copyright> | ||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> | ||
<description>PLG_CAPTCHA_NOCAPTCHA_XML_DESCRIPTION</description> | ||
<files> | ||
<filename | ||
plugin="nocaptcha">nocaptcha.php</filename> | ||
</files> | ||
<config> | ||
<fields name="params"> | ||
<fieldset name="basic"> | ||
<field | ||
name="public_key" | ||
type="text" | ||
default="" | ||
label="PLG_NOCAPTCHA_PUBLIC_KEY_LABEL" | ||
description="PLG_NOCAPTCHA_PUBLIC_KEY_DESC" | ||
required="true" | ||
filter="string" | ||
size="50" /> | ||
|
||
<field | ||
name="private_key" | ||
type="text" | ||
default="" | ||
label="PLG_NOCAPTCHA_PRIVATE_KEY_LABEL" | ||
description="PLG_NOCAPTCHA_PRIVATE_KEY_DESC" | ||
required="true" | ||
filter="string" | ||
size="50" /> | ||
|
||
<field | ||
name="theme" | ||
type="list" | ||
default="dark" | ||
label="PLG_NOCAPTCHA_THEME_LABEL" | ||
description="PLG_NOCAPTCHA_THEME_DESC" | ||
required="true" | ||
filter=""> | ||
<option | ||
value="light">PLG_NOCAPTCHA_THEME_LIGHT</option> | ||
<option | ||
value="dark">PLG_NOCAPTCHA_THEME_DARK</option> | ||
</field> | ||
</fieldset> | ||
</fields> | ||
</config> | ||
</extension> |
Oops, something went wrong.