Skip to content

Commit

Permalink
Merge branch 'feature/integrate-recaptcha-plugin'
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Dec 2, 2017
2 parents cde5e9f + 63215f9 commit c5384e0
Show file tree
Hide file tree
Showing 54 changed files with 3,291 additions and 46 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
55 changes: 55 additions & 0 deletions plugins/recaptcha/README.md
@@ -0,0 +1,55 @@
# Install/Uninstall/Upgrade instruction for the Geeklog reCAPTCHA plugin

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

## What is reCAPTCHA?

ReCAPTCHA(R) is a free anti-bot service providing powerful CAPTCHA(Completely Automated Public Turing test to tell Computers and Humans Apart). This plugin makes it easy to use reCAPTCHA with Geeklog.

## System Requirements

* Geeklog-2.2.0+

## INSTALL

In the following descriptions

* <geeklog_dir> is the directory where the system config.php file resides
* <admin> is the directory where the administration files reside (usually, under <public_html>)

1. Uncompress the recaptcha plugin archive while in the <geeklog_dir>/plugins directory. The archive will create a directory called recaptcha in the plugins directory.
2. Create the admin directory. Under your <admin>/plugins/ directory, create a directory called recaptcha.
3. Change to your <geeklog_dir>/plugins/recaptcha/ directory. Copy the files in the admin directory to the <admin>/plugins/recaptcha/ directory your created in step 2.
4. Log in to your Geeklog as a root user, go to the plugin editor and click on reCAPTCHA. If the install failed, examine Geeklog system errorlog for possible problems.
5. **Important**: Set up API keys. Go to the Configuration and enter reCAPTCHA API Public Key and Private Key that you can get at [https://www.google.com/recaptcha/admin/create](https://www.google.com/recaptcha/admin/create). **It is not until you set the API keys that you can use reCAPTCHA service.**

## UNINSTALL

1. Log in to your Geeklog web site as a root user, go to the plugin editor and click on reCAPTCHA. If the unstall failed, examine Geeklog system errorlog for possible problems.
2. Delete the two plugin directories created in the install process: <geeklog-dir>/plugins/recaptcha/ and <admin>/plugins/recaptcha/.

## UPGRADE

1. Log in to your Geeklog web site as a root user, go to the plugin editor and disable the reCAPTCHA plugin.
2. Uncompress the recaptcha plugin archive and upload the resulting files as you did when you installed the plugin.
3. Go to the plugin editor and Enable the reCAPTCHA plugin. Then, upgrade the plugin.

## REVISION HISTORY

| 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. |
| 1.1.0 | 2015-07-03 |* Upgraded to Google reCAPTCHA v2. |
| | |* Added an error code to a log file(logs/recaptch.log) entry. Patch provided by Tom.|
| 1.0.1 | 2014-01-26 |* Added a <div> tag to enclose the reCAPTCHA code. Patch provided by Tom. |
| | |* Changed to write log entries into "logs/recaptch.log". Patch provided by Tom. |
| 1.0.0 | 2014-01-24 |* Initial release |
99 changes: 99 additions & 0 deletions plugins/recaptcha/autoinstall.php
@@ -0,0 +1,99 @@
<?php

// +---------------------------------------------------------------------------+
// | reCAPTCHA Plugin for Geeklog - The Ultimate Weblog |
// +---------------------------------------------------------------------------+
// | geeklog/plugins/recaptcha/autoinstall.php |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2014-2017 mystral-kk - geeklog AT mystral-kk DOT net |
// | |
// | Based on the CAPTCHA Plugin by Ben |
// | - ben AT geeklog DOT fr |
// | Based on the original CAPTCHA Plugin by Mark R. Evans |
// | - mark AT glfusion DOT org |
// | Constructed with the Universal Plugin |
// +---------------------------------------------------------------------------+
// | |
// | This program is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public License |
// | as published by the Free Software Foundation; either version 2 |
// | of the License, or (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+

if (stripos($_SERVER['PHP_SELF'], basename(__FILE__)) !== false) {
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;

// 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 __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 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 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', '>=') &&
version_compare($geeklogVersion, $_RECAPTCHA_CONF['gl_version'], '>=');
}
57 changes: 57 additions & 0 deletions plugins/recaptcha/config.php
@@ -0,0 +1,57 @@
<?php

// +---------------------------------------------------------------------------+
// | reCAPTCHA Plugin for Geeklog - The Ultimate Weblog |
// +---------------------------------------------------------------------------+
// | geeklog/plugins/recaptcha/config.php |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2014-2017 mystral-kk - geeklog AT mystral-kk DOT net |
// | |
// | Based on the CAPTCHA Plugin by Ben |
// | - ben AT geeklog DOT fr |
// | Based on the original CAPTCHA Plugin by Mark R. Evans |
// | - mark AT glfusion DOT org |
// | Constructed with the Universal Plugin |
// +---------------------------------------------------------------------------+
// | |
// | This program is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public License |
// | as published by the Free Software Foundation; either version 2 |
// | of the License, or (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+

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

$_RECAPTCHA_CONF = array();

// Plugin info
$_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',
);
$_RECAPTCHA_CONF['FEATURES'] = array(
'recaptcha.edit' => 'Access to reCAPTCHA editor',
);
$_RECAPTCHA_CONF['MAPPINGS'] = array(
'recaptcha.edit' => array('reCAPTCHA Admin'),
);

// Items the reCAPTCHA plugin supports
$_RECAPTCHA_CONF['supported_items'] = array(
'comment', 'story', 'registration', 'loginform', 'getpassword', 'contact',
'emailstory', 'forum', 'mediagallery', 'rating', 'links', 'calendar',
);
62 changes: 62 additions & 0 deletions plugins/recaptcha/configuration_validation.php
@@ -0,0 +1,62 @@
<?php

// +---------------------------------------------------------------------------+
// | reCAPTCHA Plugin for Geeklog - The Ultimate Weblog |
// +---------------------------------------------------------------------------+
// | geeklog/plugins/recaptcha/autoinstall.php |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2014-2017 mystral-kk - geeklog AT mystral-kk DOT net |
// | |
// | Based on the CAPTCHA Plugin by Ben |
// | - ben AT geeklog DOT fr |
// | Based on the original CAPTCHA Plugin by Mark R. Evans |
// | - mark AT glfusion DOT org |
// | Constructed with the Universal Plugin |
// +---------------------------------------------------------------------------+
// | |
// | This program is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public License |
// | as published by the Free Software Foundation; either version 2 |
// | of the License, or (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+

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

// reCAPTCHA Plugin Main Settings
$_CONF_VALIDATE['recaptcha'] = array(
'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 c5384e0

Please sign in to comment.