Skip to content

Commit

Permalink
Added Invisible reCAPTCHA support for Denim theme
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Dec 2, 2017
1 parent 1effd9d commit 8aaad51
Show file tree
Hide file tree
Showing 30 changed files with 1,482 additions and 1,001 deletions.
6 changes: 6 additions & 0 deletions language/japanese_utf-8.php
Expand Up @@ -2019,6 +2019,12 @@
'DESC' => '新しい順に'
);

$LANG_statuscodes = array(
0 => 'Normal',
1 => 'Refreshing',
10 => 'Archive'
);

$LANG_trackbackcodes = array(
0 => 'トラックバックを受け付ける',
-1 => 'トラックバックを受け付けない'
Expand Down
4 changes: 2 additions & 2 deletions plugins/calendar/templates/default/submitevent.thtml
@@ -1,7 +1,7 @@
{# begin {templatelocation} #}

{explanation}
<form class="form-theme uk-form" action="{site_url}{submit_url}" method="post">
<form class="form-theme uk-form" id="submit_event_form" action="{site_url}{submit_url}" method="post">
<div class="form-description">{lang_title}:</div>
<div class="form-field"><input type="text" size="48" maxlength="128" name="title"{xhtml}></div>
<div class="clear-left"></div>
Expand Down Expand Up @@ -99,7 +99,7 @@
<input type="hidden" name="type" value="calendar"{xhtml}>
<input type="hidden" name="calendar_type" value="{mode}"{xhtml}>
<input type="hidden" name="hour_mode" value="{hour_mode}"{xhtml}>
<input type="submit" value="{lang_submit}"{xhtml}>
<button type="submit" value="{lang_submit}" class="g-recaptcha"{!if invisible_recaptcha}{invisible_recaptcha}{!endif}>lang_submit</button>
{hidden_fields}
</div>
<div class="clear-left"></div>
Expand Down
4 changes: 2 additions & 2 deletions plugins/calendar/templates/denim/submitevent.thtml
@@ -1,7 +1,7 @@
{# begin {templatelocation} #}

{explanation}
<form class="form-theme uk-form" action="{site_url}{submit_url}" method="post">
<form class="form-theme uk-form" id="submit_event_form" action="{site_url}{submit_url}" method="post">
<div class="form-description">{lang_title}:</div>
<div class="form-field"><input type="text" size="48" maxlength="128" name="title"{xhtml}></div>
<div class="clear-left"></div>
Expand Down Expand Up @@ -99,7 +99,7 @@
<input type="hidden" name="type" value="calendar"{xhtml}>
<input type="hidden" name="calendar_type" value="{mode}"{xhtml}>
<input type="hidden" name="hour_mode" value="{hour_mode}"{xhtml}>
<button type="submit" value="{lang_submit}" class="uk-button uk-button-primary">{lang_submit}</button>
<button type="submit" value="{lang_submit}" class="uk-button uk-button-primary g-recaptcha"{!if invisible_recaptcha}{invisible_recaptcha}{!endif}>{lang_submit}</button>
{hidden_fields}
</div>
<div class="clear-left"></div>
Expand Down
2 changes: 1 addition & 1 deletion plugins/links/templates/default/submitlink.thtml
Expand Up @@ -19,7 +19,7 @@
<div class="submit">
<input type="hidden" name="mode" value="{lang_submit}"{xhtml}>
<input type="hidden" name="type" value="links"{xhtml}>
<input type="submit" value="{lang_submit}" class="submit"{xhtml}>
<button type="submit" value="{lang_submit}" class="submit g-recaptcha"{!if invisible_recaptcha}{invisible_recaptcha}{!endif}></button>
</div>
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion plugins/links/templates/denim/submitlink.thtml
Expand Up @@ -19,7 +19,7 @@
<div class="submit">
<input type="hidden" name="mode" value="{lang_submit}"{xhtml}>
<input type="hidden" name="type" value="links"{xhtml}>
<button type="submit" value="{lang_submit}" class="uk-button">{lang_submit}</button>
<button type="submit" value="{lang_submit}" class="uk-button g-recaptcha"{!if invisible_recaptcha}{invisible_recaptcha}{!endif}>{lang_submit}</button>
</div>
</div>
</form>
Expand Down
10 changes: 7 additions & 3 deletions plugins/recaptcha/README.md
@@ -1,7 +1,7 @@
# Install/Uninstall/Upgrade instruction for the Geeklog reCAPTCHA plugin

* Repository: https://github.com/mystralkk/recaptcha
* Version: 1.1.4
* Version: 1.2.0
* License: GPL v2 or later

## What is reCAPTCHA?
Expand All @@ -10,8 +10,7 @@ ReCAPTCHA(R) is a free anti-bot service providing powerful CAPTCHA(Completely Au

## System Requirements

* Geeklog-1.6.0+
* PHP-5.3.2+. Maybe PHP-5-3.0 or PHP-5.3.1 will do, but I am not sure.
* Geeklog-2.2.0+

## INSTALL

Expand Down Expand Up @@ -41,6 +40,11 @@ In the following descriptions

| Version | Date(YYYY-MM-DD) |Description |
|:-------:|-----------------:|------------------------------------------------------------------------------------|
| 1.2.0 | 2017-12-02 |* Added support for Invisible reCAPTCHA. |
| 1.1.6 | 2017-11-28 |* Added support for Login Form. |
| | |* Added support for Forget Password Form. |
| | |* Added support for the demo mode introduced in Geeklog 2.2.0. |
| 1.1.5 | 2017-04-12 |* Fixed a bug where reCAPTCHA failed to check for input when $_RECAPTCHA_CONF['logging'] is set to off. |
| 1.1.4 | 2017-01-18 |* Small bug fix. |
| 1.1.3 | 2016-08-12 |* Replaced COM_siteHeader and COM_siteFooter with COM_createHTMLDocument. |
| 1.1.2 | 2016-02-20 |* Modified to use reCAPTCHA v1.1.2 library. |
Expand Down
99 changes: 51 additions & 48 deletions plugins/recaptcha/autoinstall.php
Expand Up @@ -31,66 +31,69 @@
// +---------------------------------------------------------------------------+

if (stripos($_SERVER['PHP_SELF'], basename(__FILE__)) !== false) {
die('This file cannot be used on its own!');
die('This file cannot be used on its own!');
}

/**
* Plugin autoinstall function
*
* @param string $pi_name Plugin name
* @return array Plugin information
*/
function plugin_autoinstall_recaptcha($pi_name) {
global $_CONF, $_RECAPTCHA_CONF;
* Plugin autoinstall function
*
* @param string $pi_name Plugin name
* @return array Plugin information
*/
function plugin_autoinstall_recaptcha($pi_name)
{
global $_CONF, $_RECAPTCHA_CONF;

// IF demo mode (since GL 2.2.0) is in effect, return no valid information
if (isset($_CONF['demo_mode']) && $_CONF['demo_mode']) {
return array();
}

require_once dirname(__FILE__) . '/config.php';
// IF demo mode (since GL 2.2.0) is in effect, return no valid information
if (isset($_CONF['demo_mode']) && $_CONF['demo_mode']) {
return array();
}

return array(
'info' => array(
'pi_name' => 'recaptcha',
'pi_display_name' => 'reCAPTCHA',
'pi_version' => $_RECAPTCHA_CONF['pi_version'],
'pi_gl_version' => $_RECAPTCHA_CONF['gl_version'],
'pi_homepage' => $_RECAPTCHA_CONF['pi_url'],
),
'groups' => $_RECAPTCHA_CONF['GROUPS'],
'features' => $_RECAPTCHA_CONF['FEATURES'],
'mappings' => $_RECAPTCHA_CONF['MAPPINGS'],
'tables' => array(),
);
require_once __DIR__ . '/config.php';

return array(
'info' => array(
'pi_name' => 'recaptcha',
'pi_display_name' => 'reCAPTCHA',
'pi_version' => $_RECAPTCHA_CONF['pi_version'],
'pi_gl_version' => $_RECAPTCHA_CONF['gl_version'],
'pi_homepage' => $_RECAPTCHA_CONF['pi_url'],
),
'groups' => $_RECAPTCHA_CONF['GROUPS'],
'features' => $_RECAPTCHA_CONF['FEATURES'],
'mappings' => $_RECAPTCHA_CONF['MAPPINGS'],
'tables' => array(),
);
}

/**
* Load plugin configuration from database
*
* @param string $pi_name Plugin name
* @return boolean true on success, otherwise false
* @see plugin_initconfig_recaptcha
*/
function plugin_load_configuration_recaptcha($pi_name) {
global $_CONF;

$base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';

require_once $_CONF['path_system'] . 'classes/config.class.php';
require_once $base_path . 'install_defaults.php';
* Load plugin configuration from database
*
* @param string $pi_name Plugin name
* @return bool true on success, otherwise false
* @see plugin_initconfig_recaptcha
*/
function plugin_load_configuration_recaptcha($pi_name)
{
require_once __DIR__ . '/install_defaults.php';

return plugin_initconfig_recaptcha();
}

/**
* Checks if the plugin is compatible with this Geeklog version
*
* @param string $pi_name Plugin name
* @return boolean true: plugin compatible; false: not compatible
*/
function plugin_compatible_with_this_version_recaptcha($pi_name) {
global $_CONF;
* Checks if the plugin is compatible with this Geeklog version
*
* @param string $pi_name Plugin name
* @return bool true: plugin compatible; false: not compatible
*/
function plugin_compatible_with_this_version_recaptcha($pi_name)
{
global $_RECAPTCHA_CONF;

require_once __DIR__ . '/config.php';

$geeklogVersion = preg_replace('/[^0-9.]/', '', VERSION);

return version_compare(PHP_VERSION, '5.3.0', '>=');
return version_compare(PHP_VERSION, '5.3.0', '>=') &&
version_compare($geeklogVersion, $_RECAPTCHA_CONF['gl_version'], '>=');
}
4 changes: 2 additions & 2 deletions plugins/recaptcha/config.php
Expand Up @@ -37,8 +37,8 @@
$_RECAPTCHA_CONF = array();

// Plugin info
$_RECAPTCHA_CONF['pi_version'] = '1.1.6'; // Plugin Version
$_RECAPTCHA_CONF['gl_version'] = '1.8.0'; // GL Version plugin for
$_RECAPTCHA_CONF['pi_version'] = '1.2.0'; // Plugin Version
$_RECAPTCHA_CONF['gl_version'] = '2.2.0'; // GL Version plugin for
$_RECAPTCHA_CONF['pi_url'] = 'https://github.com/Geeklog-Plugins/recaptcha'; // Plugin Homepage
$_RECAPTCHA_CONF['GROUPS'] = array(
'reCAPTCHA Admin' => 'Users in this group can administer the ReCAPTCHA plugin',
Expand Down
44 changes: 24 additions & 20 deletions plugins/recaptcha/configuration_validation.php
Expand Up @@ -31,28 +31,32 @@
// +---------------------------------------------------------------------------+

if (stripos($_SERVER['PHP_SELF'], basename(__FILE__)) !== false) {
die('This file cannot be used on its own!');
die('This file cannot be used on its own!');
}

// reCAPTCHA Plugin Main Settings
$_CONF_VALIDATE['recaptcha'] = array(
'public_key' => array('rule' => 'stringOrEmpty'),
'private_key' => array('rule' => 'stringOrEmpty'),
'logging' => array('rule' => array('inList', array('0', '1'), true)),
'anonymous_only' => array('rule' => array('inList', array('0', '1'), true)),
'remoteusers' => array('rule' => array('inList', array('0', '1'), true)),
'enable_comment' => array('rule' => array('inList', array('0', '1'), true)),
'enable_contact' => array('rule' => array('inList', array('0', '1'), true)),
'enable_emailstory' => array('rule' => array('inList', array('0', '1'), true)),
'enable_forum' => array('rule' => array('inList', array('0', '1'), true)),
'enable_registration' => array('rule' => array('inList', array('0', '1'), true)),
'enable_mediagallery' => array('rule' => array('inList', array('0', '1'), true)),
'enable_rating' => array('rule' => array('inList', array('0', '1'), true)),
'enable_story' => array('rule' => array('inList', array('0', '1'), true)),
'enable_calendar' => array('rule' => array('inList', array('0', '1'), true)),
'enable_links' => array('rule' => array('inList', array('0', '1'), true)),

// Since reCAPTCHA v1.1.6
'enable_getpassword' => array('rule' => array('inList', array('0', '1'), true)),
'enable_loginform' => array('rule' => array('inList', array('0', '1'), true)),
'site_key' => array('rule' => 'stringOrEmpty'),
'secret_key' => array('rule' => 'stringOrEmpty'),
'invisible_site_key' => array('rule' => 'stringOrEmpty'),
'invisible_secret_key' => array('rule' => 'stringOrEmpty'),
'logging' => array('rule' => array('inList', array('0', '1'), true)),
'anonymous_only' => array('rule' => array('inList', array('0', '1'), true)),
'remoteusers' => array('rule' => array('inList', array('0', '1'), true)),

// '0' => Disabled, '1' => reCAPTCHA v2, '2' => Invisible reCAPTCHA
'enable_comment' => array('rule' => array('inList', array('0', '1', '2'), true)),
'enable_contact' => array('rule' => array('inList', array('0', '1', '2'), true)),
'enable_emailstory' => array('rule' => array('inList', array('0', '1', '2'), true)),
'enable_registration' => array('rule' => array('inList', array('0', '1', '2'), true)),
'enable_getpassword' => array('rule' => array('inList', array('0', '1', '2'), true)),
'enable_loginform' => array('rule' => array('inList', array('0', '1', '2'), true)),
'enable_story' => array('rule' => array('inList', array('0', '1', '2'), true)),
'enable_calendar' => array('rule' => array('inList', array('0', '1', '2'), true)),
'enable_links' => array('rule' => array('inList', array('0', '1', '2'), true)),

// The plugins below still don't support Invisible reCAPTCHA
'enable_forum' => array('rule' => array('inList', array('0', '1'), true)),
'enable_mediagallery' => array('rule' => array('inList', array('0', '1'), true)),
'enable_rating' => array('rule' => array('inList', array('0', '1'), true)),
);

0 comments on commit 8aaad51

Please sign in to comment.