From 0f06de60bf5dacf0548517a7c6d00e3b98c18334 Mon Sep 17 00:00:00 2001 From: Kenji ITO Date: Thu, 30 Nov 2017 07:22:52 +0900 Subject: [PATCH 1/7] Added reCAPTCHA plugin --- plugins/recaptcha/INSTALL | 1 + plugins/recaptcha/README.md | 51 ++ plugins/recaptcha/autoinstall.php | 96 ++++ plugins/recaptcha/config.php | 57 +++ .../recaptcha/configuration_validation.php | 58 +++ plugins/recaptcha/form_id_mapping.php | 16 + plugins/recaptcha/functions.inc | 484 ++++++++++++++++++ plugins/recaptcha/install_defaults.php | 133 +++++ plugins/recaptcha/install_updates.php | 54 ++ plugins/recaptcha/language/english.php | 84 +++ .../language/french_france_utf-8.php | 84 +++ plugins/recaptcha/language/japanese_utf-8.php | 84 +++ plugins/recaptcha/vendor/LICENSE | 29 ++ .../recaptcha/vendor/ReCaptcha/ReCaptcha.php | 98 ++++ .../vendor/ReCaptcha/RequestMethod.php | 42 ++ .../vendor/ReCaptcha/RequestMethod/Curl.php | 74 +++ .../ReCaptcha/RequestMethod/CurlPost.php | 88 ++++ .../vendor/ReCaptcha/RequestMethod/Post.php | 70 +++ .../vendor/ReCaptcha/RequestMethod/Socket.php | 104 ++++ .../ReCaptcha/RequestMethod/SocketPost.php | 121 +++++ .../vendor/ReCaptcha/RequestParameters.php | 103 ++++ .../recaptcha/vendor/ReCaptcha/Response.php | 102 ++++ plugins/recaptcha/vendor/autoload.php | 38 ++ .../admin/plugins/recaptcha/docs/docstyle.css | 161 ++++++ .../recaptcha/docs/english/config.html | 100 ++++ .../recaptcha/docs/english/install.html | 129 +++++ .../recaptcha/docs/japanese/config.html | 100 ++++ .../recaptcha/docs/japanese/install.html | 130 +++++ .../plugins/recaptcha/images/recaptcha.png | Bin 0 -> 2050 bytes public_html/admin/plugins/recaptcha/index.php | 64 +++ 30 files changed, 2755 insertions(+) create mode 100644 plugins/recaptcha/INSTALL create mode 100644 plugins/recaptcha/README.md create mode 100644 plugins/recaptcha/autoinstall.php create mode 100644 plugins/recaptcha/config.php create mode 100644 plugins/recaptcha/configuration_validation.php create mode 100644 plugins/recaptcha/form_id_mapping.php create mode 100644 plugins/recaptcha/functions.inc create mode 100644 plugins/recaptcha/install_defaults.php create mode 100644 plugins/recaptcha/install_updates.php create mode 100644 plugins/recaptcha/language/english.php create mode 100644 plugins/recaptcha/language/french_france_utf-8.php create mode 100644 plugins/recaptcha/language/japanese_utf-8.php create mode 100644 plugins/recaptcha/vendor/LICENSE create mode 100644 plugins/recaptcha/vendor/ReCaptcha/ReCaptcha.php create mode 100644 plugins/recaptcha/vendor/ReCaptcha/RequestMethod.php create mode 100644 plugins/recaptcha/vendor/ReCaptcha/RequestMethod/Curl.php create mode 100644 plugins/recaptcha/vendor/ReCaptcha/RequestMethod/CurlPost.php create mode 100644 plugins/recaptcha/vendor/ReCaptcha/RequestMethod/Post.php create mode 100644 plugins/recaptcha/vendor/ReCaptcha/RequestMethod/Socket.php create mode 100644 plugins/recaptcha/vendor/ReCaptcha/RequestMethod/SocketPost.php create mode 100644 plugins/recaptcha/vendor/ReCaptcha/RequestParameters.php create mode 100644 plugins/recaptcha/vendor/ReCaptcha/Response.php create mode 100644 plugins/recaptcha/vendor/autoload.php create mode 100644 public_html/admin/plugins/recaptcha/docs/docstyle.css create mode 100644 public_html/admin/plugins/recaptcha/docs/english/config.html create mode 100644 public_html/admin/plugins/recaptcha/docs/english/install.html create mode 100644 public_html/admin/plugins/recaptcha/docs/japanese/config.html create mode 100644 public_html/admin/plugins/recaptcha/docs/japanese/install.html create mode 100644 public_html/admin/plugins/recaptcha/images/recaptcha.png create mode 100644 public_html/admin/plugins/recaptcha/index.php diff --git a/plugins/recaptcha/INSTALL b/plugins/recaptcha/INSTALL new file mode 100644 index 000000000..ea809b3b5 --- /dev/null +++ b/plugins/recaptcha/INSTALL @@ -0,0 +1 @@ +Please see README.md and admin/docs/(english|japanese)/install.html. diff --git a/plugins/recaptcha/README.md b/plugins/recaptcha/README.md new file mode 100644 index 000000000..410c67ec6 --- /dev/null +++ b/plugins/recaptcha/README.md @@ -0,0 +1,51 @@ +# Install/Uninstall/Upgrade instruction for the Geeklog reCAPTCHA plugin + +* Repository: https://github.com/mystralkk/recaptcha +* Version: 1.1.4 +* 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-1.6.0+ +* PHP-5.3.2+. Maybe PHP-5-3.0 or PHP-5.3.1 will do, but I am not sure. + +## INSTALL + +In the following descriptions + +* is the directory where the system config.php file resides +* is the directory where the administration files reside (usually, under ) + +1. Uncompress the recaptcha plugin archive while in the /plugins directory. The archive will create a directory called recaptcha in the plugins directory. +2. Create the admin directory. Under your /plugins/ directory, create a directory called recaptcha. +3. Change to your /plugins/recaptcha/ directory. Copy the files in the admin directory to the /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: /plugins/recaptcha/ and /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.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
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 | diff --git a/plugins/recaptcha/autoinstall.php b/plugins/recaptcha/autoinstall.php new file mode 100644 index 000000000..dc8811d45 --- /dev/null +++ b/plugins/recaptcha/autoinstall.php @@ -0,0 +1,96 @@ + 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'; + + 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; + + return version_compare(PHP_VERSION, '5.3.0', '>='); +} diff --git a/plugins/recaptcha/config.php b/plugins/recaptcha/config.php new file mode 100644 index 000000000..bc95a9387 --- /dev/null +++ b/plugins/recaptcha/config.php @@ -0,0 +1,57 @@ + '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', +); diff --git a/plugins/recaptcha/configuration_validation.php b/plugins/recaptcha/configuration_validation.php new file mode 100644 index 000000000..007cc0ea4 --- /dev/null +++ b/plugins/recaptcha/configuration_validation.php @@ -0,0 +1,58 @@ + 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)), +); diff --git a/plugins/recaptcha/form_id_mapping.php b/plugins/recaptcha/form_id_mapping.php new file mode 100644 index 000000000..9ede285e3 --- /dev/null +++ b/plugins/recaptcha/form_id_mapping.php @@ -0,0 +1,16 @@ + 'commentform', + 'contact' => 'contactuserform', + 'emailstory' => 'contactauthorform', + 'forum' => '', + 'registration' => 'registrationform', + 'mediagallery' => '', + 'rating' => '', + 'story' => 'submitstory', + 'calendar' => 'submiteventform', + 'links' => 'submitlink', + 'getpassword' => 'getpasswordform', +); diff --git a/plugins/recaptcha/functions.inc b/plugins/recaptcha/functions.inc new file mode 100644 index 000000000..7733a8bb2 --- /dev/null +++ b/plugins/recaptcha/functions.inc @@ -0,0 +1,484 @@ +' . $pi_name . '!'; + } + + $admin_url = $_CONF['site_admin_url'] . '/plugins/recaptcha/index.php'; + $icon_url = plugin_geticon_recaptcha(); + + return array($pi_name, $admin_url, $icon_url); + } else { + return null; + } +} + +/** +* Returns the administrative option for this plugin +* +* @return array Array containing (plugin name, plugin admin url, # of items +* in plugin or '') +*/ +function plugin_getadminoption_recaptcha() { + global $_CONF, $_TABLES; + + if (SEC_hasRights('recaptcha.edit')) { + $pi_name = RECAPTCHA_str('admin'); + + if (!RECAPTCHA_isEnabled()) { + $pi_name = '' . $pi_name . '!'; + } + + $admin_url = $_CONF['site_admin_url'] . '/plugins/recaptcha/index.php'; + $num_items = ''; + return array($pi_name, $admin_url, $num_items); + } else { + return null; + } +} + +/** +* Returns the version for this plugin +* +* @return string plugin version no +*/ +function plugin_chkVersion_recaptcha() { + global $_RECAPTCHA_CONF; + + return $_RECAPTCHA_CONF['pi_version']; +} + +/** +* Upgrades the plugin +* +* @return boolean true (= success) +*/ +function plugin_upgrade_recaptcha() { + global $_CONF, $_TABLES, $_RECAPTCHA_CONF; + + $sql = "SELECT pi_version " + . "FROM {$_TABLES['plugins']} " + . "WHERE (pi_name = 'recaptcha') "; + $result = DB_query($sql); + $A = DB_fetchArray($result); + $pi_version = $A['pi_version']; // Version info stored in database + + // Does upgrading + while (version_compare($pi_version, $_RECAPTCHA_CONF['pi_version']) < 0) { + switch ($pi_version) { + case '1.0.0': + case '1.0.1': + case '1.1.0': + case '1.1.1': + case '1.1.2': + case '1.1.3': + case '1.1.4': + case '1.1.5': + require_once dirname(__FILE__) . '/install_updates.php'; + recaptcha_update_ConfValues_1_1_5(); + $pi_version = '1.1.6'; + break; + + default: + $pi_version = $_RECAPTCHA_CONF['pi_version']; + break; + } + } + + // Updates plugin info + $sql = "UPDATE {$_TABLES['plugins']} SET pi_version = '{$_RECAPTCHA_CONF['pi_version']}' " + . "WHERE (pi_name = 'recaptcha') "; + $result = DB_query($sql); + COM_errorLog("reCAPTCHA plugin was successfully updated to version {$_RECAPTCHA_CONF['pi_version']}."); + + return true; +} + +/** +* Automatic uninstall function for plugins +* +* @return array +*/ +function plugin_autouninstall_recaptcha() { + global $_RECAPTCHA_CONF; + + return array ( + 'tables' => array(), + 'groups' => array('reCAPTCHA Admin'), + 'features' => $_RECAPTCHA_CONF['FEATURES'], + 'php_blocks' => array(), + 'vars' => array() + ); +} + +/** +* Returns the URL to a given document +*/ +function plugin_getdocumentationurl_recaptcha($file) { + global $_CONF; + + $lang = COM_getLanguageName(); + $path = $_CONF['path_html'] . 'admin/plugins/recaptcha/docs/' . $lang . '/' + . $file . '.html'; + clearstatcache(); + + if (!file_exists($path)) { + $lang = 'english'; + } + + $retval = $_CONF['site_admin_url'] . '/plugins/recaptcha/docs/' . $lang . '/' + . $file . '.html'; + + return $retval; +} + +/** +* Provides text for a Configuration tooltip +* +* @param string $id Id of config value +* @return mixed Text to use regular tooltip, null to use config +* tooltip hack, or empty string when not available +*/ +function plugin_getconfigtooltip_recaptcha($id) { + // Use config tooltip hack where tooltip is read from the config documentation + return null; +} + +/** +* Callback function to add HTML text for reCAPTCHA +* +* @param string $type +* @param object $template a reference to a Template class object +* @return void +*/ +function plugin_templatesetvars_recaptcha($type, &$template) { + global $_RECAPTCHA_CONF; + + if (RECAPTCHA_isEnabled() && RECAPTCHA_requireCaptcha($type)) { + $lang = RECAPTCHA_getLangCode(); + $captcha = '
' + . ''; +; + } else { + $captcha = ''; + } + + $template->set_var('captcha', $captcha); +} + +/** +* Callback function to check the code entered by a user +* +* @param (not used in this function) +* @param object $template a reference to a Template class object +* @return string empty = success +*/ +function plugin_commentPreSave_recaptcha($uid, $title, $comment, $sid, $pid, $type, $postmode) { + return plugin_itemPreSave_recaptcha('comment', ''); +} + +/** +* Callback function to check the code entered by a user +* +* @param string $type item type +* @param object $template a reference to a Template class object +* @return string empty = success +*/ +function plugin_itemPreSave_recaptcha($type, $content = '') { + global $_RECAPTCHA_CONF; + + $msg = ''; + + if (RECAPTCHA_isEnabled() && RECAPTCHA_requireCaptcha($type)) { + if (is_callable('curl_init')) { + $recaptcha = new \ReCaptcha\ReCaptcha($_RECAPTCHA_CONF['private_key'], new \ReCaptcha\RequestMethod\CurlPost()); + } elseif (@ini_get('allow_url_fopen')) { + $recaptcha = new \ReCaptcha\ReCaptcha($_RECAPTCHA_CONF['private_key'], new \ReCaptcha\RequestMethod\Post()); + } else { + $recaptcha = new \ReCaptcha\ReCaptcha($_RECAPTCHA_CONF['private_key'], new \ReCaptcha\RequestMethod\SocketPost()); + } + + $resp = $recaptcha->verify(@$_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); + + if (!$resp->isSuccess()) { + $msg = implode(', ', $resp->getErrorCodes()); + + if ($_RECAPTCHA_CONF['logging']) { + $entry = sprintf( + RECAPTCHA_str('entry_error', true), + $type, + $_SERVER['REMOTE_ADDR'], + $msg + ); + $entry = RECAPTCHA_esc($entry); + RECAPTCHA_errorLog($entry); + } + } + } + + return $msg; +} + +/** +* Writes an entry into a log file +* +* @param string $logEntry +* @param int $override +*/ +function RECAPTCHA_errorLog($logEntry, $override = 0) { + global $_CONF, $_RECAPTCHA_CONF; + + if (!isset($_RECAPTCHA_CONF['logging'])) { + $_RECAPTCHA_CONF['logging'] = 0; + } + + if (($_RECAPTCHA_CONF['logging'] != 1) && ($override == 0)) { + return; + } + + if (!empty($logEntry)) { + $timestamp = date('Y-m-d H:i:s'); + $logfile = $_CONF['path_log'] . 'recaptcha.log'; + $entry = "{$timestamp} - {$logEntry} \n"; + + if (($file = @fopen($logfile, 'a')) !== false) { + fputs($file, "$timestamp - $logEntry \n"); + fclose($file); + } else { + COM_errorLog(__FUNCTION__ . ': cannot open "' . $logfile . '"'); + } + } +} + +/** +* Loads config info with config.class.php +*/ +function RECAPTCHA_loadConfig() { + global $_CONF, $_RECAPTCHA_CONF; + + $config = config::get_instance(); + + if ($config->group_exists('recaptcha')) { + $_RECAPTCHA_CONF = array_merge($_RECAPTCHA_CONF, $config->get_config('recaptcha')); + } else { + COM_errorLog(__FUNCTION__ . ': cannot load configuration. Using default setiings instead'); + require_once 'install_defaults.php'; + $_RECAPTCHA_CONF = $_RC_DEFAULT; + } +} + +/** +* Returns a string escaped for HTML output +*/ +function RECAPTCHA_esc($str) { + global $_CONF; + + static $encoding = null; + + if ($encoding === null) { + $encoding = is_callable('COM_getCharset') + ? COM_getCharset() + : $_CONF['default_charset']; + } + + if (version_compare(PHP_VERSION, '5.2.3') >= 0) { + return htmlspecialchars($str, ENT_QUOTES, $encoding, false); + } else { + return str_replace( + array('&&', '&<', '&>', '&"', '&''), + array('&', '<:', '>', '"', '''), + htmlspecialchars($str, ENT_QUOTES, $encoding) + ); + } +} + +/** +* Returns a lang var +*/ +function RECAPTCHA_str($index, $noesc = false) { + global $LANG_RECAPTCHA; + + if (isset($LANG_RECAPTCHA[$index])) { + return $noesc ? $LANG_RECAPTCHA[$index] : RECAPTCHA_esc($LANG_RECAPTCHA[$index]); + } else { + COM_errorLog(__FUNCTION__ . ': undefined index: "' . $index . '"'); + return '(undefined)'; + } +} + +/** +* Returns if the current type of item requires reCAPTCHA +* +* @param string $type item type +* @return boolean true = requires reCAPTCHA +*/ +function RECAPTCHA_requireCaptcha($type) { + global $_RECAPTCHA_CONF, $_USER; + + if (!RECAPTCHA_isEnabled()) { + return false; + } + + if ((in_array($type, $_RECAPTCHA_CONF['supported_items']) && + ($_RECAPTCHA_CONF['enable_' . $type] == 0)) || + !in_array($type, $_RECAPTCHA_CONF['supported_items'])) { + return false; + } + + if (!isset($_USER['uid'])) { + $_USER['uid'] = 1; + } + + if (($_RECAPTCHA_CONF['anonymous_only'] && ($_USER['uid'] < 2)) || + ($_RECAPTCHA_CONF['anonymous_only'] == 0) || + (($_RECAPTCHA_CONF['remoteusers'] == 1) && SEC_inGroup('Remote Users'))) { + return true; + } + + return false; +} + +/** +* Returns if the plugin is ready to work +* +* @return boolean true = OK +*/ +function RECAPTCHA_isEnabled() { + global $_RECAPTCHA_CONF; + + return ($_RECAPTCHA_CONF['private_key'] !== '') && ($_RECAPTCHA_CONF['public_key'] !== ''); +} + +/** +* Return language codes used by Google +* +* @return string +* @link https://developers.google.com/recaptcha/docs/language +*/ +function RECAPTCHA_getLangCode() { + $mapping = array( + // GL language name => Google language code + 'afrikaans' => 'en', // Not supported by Google + 'bosnian' => 'en', // Not supported by Google + 'bulgarian' => 'bg', + 'catalan' => 'ca', + 'chinese_simplified' => 'zh-CN', + 'chinese_traditional' => 'zh-TW', + 'croatian' => 'hr', + 'czech' => 'cs', + 'danish' => 'da', + 'dutch' => 'nl', + 'english' => 'en', + 'estonian' => 'et', + 'farsi' => 'fa', + 'finnish' => 'fi', + 'french_canada' => 'fr-CA', + 'french_france' => 'fr', + 'german' => 'de', + 'german_formal' => 'de', + 'hebrew' => 'iw', + 'hellenic' => 'el', + 'indonesian' => 'id', + 'italian' => 'it', + 'japanese' => 'ja', + 'korean' => 'ko', + 'norwegian' => 'no', + 'polish' => 'pl', + 'portuguese' => 'pt', + 'portuguese_brazil' => 'pt-BR', + 'romanian' => 'ro', + 'russian' => 'ru', + 'serbian' => 'sr', + 'slovak' => 'sk', + 'slovenian' => 'sl', + 'spanish' => 'es', + 'spanish_argentina' => 'es-419', + 'swedish' => 'sv', + 'turkish' => 'tr', + 'ukrainian' => 'uk', + 'ukrainian_koi8-u' => 'uk', + ); + + $langName = COM_getLanguage(); + $langName = strtolower($langName); + $langName = str_replace('_utf-8', '', $langName); + + return isset($mapping[$langName]) ? $mapping[$langName] : 'en'; +} diff --git a/plugins/recaptcha/install_defaults.php b/plugins/recaptcha/install_defaults.php new file mode 100644 index 000000000..46f700238 --- /dev/null +++ b/plugins/recaptcha/install_defaults.php @@ -0,0 +1,133 @@ + '', + 'private_key' => '', + 'logging' => 0, + 'anonymous_only' => 0, + 'remoteusers' => 0, + 'enable_comment' => 1, + 'enable_contact' => 1, + 'enable_emailstory' => 1, + 'enable_forum' => 1, + 'enable_registration' => 1, + 'enable_loginform' => 1, + 'enable_getpassword' => 1, + 'enable_mediagallery' => 1, + 'enable_rating' => 1, + 'enable_story' => 1, + 'enable_calendar' => 1, + 'enable_links' => 1, +); + +/** +* Initializes reCAPTCHA plugin configuration +* +* Creates the database entries for the configuation if they don't already +* exist. Initial values will be taken from $_RECAPTCHA_DEFAULT +* if available (e.g. from an old config.php), uses $_RECAPTCHA_DEFAULT +* otherwise. +* +* @return boolean true: success; false: an error occurred +*/ +function plugin_initconfig_recaptcha() { + global $_RECAPTCHA_CONF, $_RECAPTCHA_DEFAULT; + + $c = config::get_instance(); + $me = 'recaptcha'; + $so = 10; + + if (!$c->group_exists($me)) { + // Subgroup = 0 + $sg = 0; + $c->add('sg_main', null, 'subgroup', $sg, 0, null, 0, true, $me, 0); + $c->add('tab_main', null, 'tab', $sg, 0, null, 0, true, $me, 0); + + // Fieldset = 0 + $fs = 0; + $c->add('fs_system', null, 'fieldset', $sg, $fs, null, 0, true, $me, 0); + $c->add('public_key', $_RECAPTCHA_DEFAULT['public_key'], 'text', $sg, $fs, null, $so, true, $me, 0); + $so += 10; + $c->add('private_key', $_RECAPTCHA_DEFAULT['private_key'], 'text', $sg, $fs, null, $so, true, $me, 0); + $so += 10; + $c->add('logging', $_RECAPTCHA_DEFAULT['logging'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + + // Subgroup = 0, Fieldset = 1 + $fs++; + $c->add('fs_integration', null, 'fieldset', $sg, $fs, null, 0, true, $me, 0); + $c->add('anonymous_only', $_RECAPTCHA_DEFAULT['anonymous_only'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('remoteusers', $_RECAPTCHA_DEFAULT['remoteusers'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_comment', $_RECAPTCHA_DEFAULT['enable_comment'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_contact', $_RECAPTCHA_DEFAULT['enable_contact'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_emailstory', $_RECAPTCHA_DEFAULT['enable_emailstory'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_forum', $_RECAPTCHA_DEFAULT['enable_forum'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_registration', $_RECAPTCHA_DEFAULT['enable_registration'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_mediagallery', $_RECAPTCHA_DEFAULT['enable_mediagallery'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_rating', $_RECAPTCHA_DEFAULT['enable_rating'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_story', $_RECAPTCHA_DEFAULT['enable_story'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_calendar', $_RECAPTCHA_DEFAULT['enable_calendar'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_links', $_RECAPTCHA_DEFAULT['enable_links'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + + // Subgroup = 1, Fieldset = 0 + require_once dirname(__FILE__) . '/install_updates.php'; + recaptcha_update_ConfValues_1_1_5(); + } + + return true; +} diff --git a/plugins/recaptcha/install_updates.php b/plugins/recaptcha/install_updates.php new file mode 100644 index 000000000..f55ba69b9 --- /dev/null +++ b/plugins/recaptcha/install_updates.php @@ -0,0 +1,54 @@ +add('enable_getpassword', $_RECAPTCHA_DEFAULT['enable_getpassword'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_loginform', $_RECAPTCHA_DEFAULT['enable_loginform'], 'select', $sg, $fs, 0, $so, true, $me, 0); + + return true; +} diff --git a/plugins/recaptcha/language/english.php b/plugins/recaptcha/language/english.php new file mode 100644 index 000000000..d4c7dc9ed --- /dev/null +++ b/plugins/recaptcha/language/english.php @@ -0,0 +1,84 @@ + 'reCAPTCHA', + 'admin' => 'reCAPTCHA', + 'entry_error' => 'An invalid reCAPTCHA string was entered in %1s - IP Address: %2s - Error Codes: %3s', // %1s = $type, %2s = $ip, %3s = $errorCode +); + +// Localization of the Admin Configuration UI +$LANG_configsections['recaptcha'] = array( + 'label' => 'reCAPTCHA', + 'title' => 'reCAPTCHA Configuration' +); + +$LANG_confignames['recaptcha'] = array( + 'public_key' => 'reCAPTCHA API Site Key', + 'private_key' => 'reCAPTCHA API Secret Key', + 'logging' => 'Log invalid reCAPTCHA attempts', + 'anonymous_only' => 'Anonymous Only', + 'remoteusers' => 'Force reCAPTCHA for all Remote Users', + 'enable_comment' => 'Enable Comment Support' , + 'enable_contact' => 'Enable Contact Support', + 'enable_emailstory' => 'Enable Email Story Support', + 'enable_forum' => 'Enable Forum Support', + 'enable_registration' => 'Enable Registration Support', + 'enable_loginform' => 'Enable Login Form Support', + 'enable_getpassword' => 'Enable Get Password Form Support', + 'enable_mediagallery' => 'Enable Media Gallery (Postcards) Support', + 'enable_rating' => 'Enable Rating Plugin Support', + 'enable_story' => 'Enable Story Support', + 'enable_calendar' => 'Enable Calendar Plugin Support', + 'enable_links' => 'Enable Links Plugin Support', +); + +$LANG_configsubgroups['recaptcha'] = array( + 'sg_main' => 'Main Settings', +); + +$LANG_tab['recaptcha'] = array( + 'tab_main' => 'reCAPTCHA Settings', +); + +$LANG_fs['recaptcha'] = array( + 'fs_system' => 'System', + 'fs_integration' => 'Integration', +); + +// Note: entries 0, 1, 9, and 12 are the same as in $LANG_configselects['Core'] +$LANG_configselects['recaptcha'] = array( + 0 => array('Yes' => 1, 'No' => 0), +); diff --git a/plugins/recaptcha/language/french_france_utf-8.php b/plugins/recaptcha/language/french_france_utf-8.php new file mode 100644 index 000000000..4e7c50506 --- /dev/null +++ b/plugins/recaptcha/language/french_france_utf-8.php @@ -0,0 +1,84 @@ + 'reCAPTCHA', + 'admin' => 'reCAPTCHA', + 'entry_error' => 'An invalid reCAPTCHA string was entered in %1s - IP Address: %2s - Error Codes: %3s', // %1s = $type, %2s = $ip, %3s = $errorCode +)); + +// Localization of the Admin Configuration UI +$LANG_configsections['recaptcha'] = array( + 'label' => 'reCAPTCHA', + 'title' => 'reCAPTCHA Configuration' +); + +$LANG_confignames['recaptcha'] = array( + 'public_key' => 'reCAPTCHA API Site Key', + 'private_key' => 'reCAPTCHA API Secret Key', + 'logging' => 'Log invalid reCAPTCHA attempts', + 'anonymous_only' => 'Anonymous Only', + 'remoteusers' => 'Force CAPTCHA for all Remote Users', + 'enable_comment' => 'Enable Comment Support', + 'enable_contact' => 'Enable Contact Support', + 'enable_emailstory' => 'Enable Email Story Support', + 'enable_forum' => 'Enable Forum Support', + 'enable_registration' => 'Enable Registration Support', + 'enable_loginform' => 'Enable Login Form Support', + 'enable_getpassword' => 'Enable Get Password Form Support', + 'enable_mediagallery' => 'Enable Media Gallery (Postcards) Support', + 'enable_rating' => 'Enable Rating Plugin Support', + 'enable_story' => 'Enable Story Support', + 'enable_calendar' => 'Enable Calendar Plugin Support', + 'enable_links' => 'Enable Links Plugin Support', +); + +$LANG_configsubgroups['recaptcha'] = array( + 'sg_main' => 'Main Settings' +); + +$LANG_tab['recaptcha'] = array( + 'tab_main' => 'General Captcha Settings' +); + +$LANG_fs['recaptcha'] = array( + 'fs_system' => 'System', + 'fs_integration' => 'Integration', +); + +// Note: entries 0 is the same as in $LANG_configselects['Core'] +$LANG_configselects['recaptcha'] = array( + 0 => array('Yes' => 1, 'No' => 0), +); diff --git a/plugins/recaptcha/language/japanese_utf-8.php b/plugins/recaptcha/language/japanese_utf-8.php new file mode 100644 index 000000000..f88ac2f69 --- /dev/null +++ b/plugins/recaptcha/language/japanese_utf-8.php @@ -0,0 +1,84 @@ + 'reCAPTCHA', + 'admin' => 'reCAPTCHA', + 'entry_error' => '%1sで無効な入力を検出しました。IPアドレス: %2s エラーコード: %3s', // %1s = $type, %2s = $ip, %3s = $errorCode +); + +// Localization of the Admin Configuration UI +$LANG_configsections['recaptcha'] = array( + 'label' => 'reCAPTCHA', + 'title' => 'reCAPTCHAの設定', +); + +$LANG_confignames['recaptcha'] = array( + 'public_key' => 'reCAPTCHA API Site Key', + 'private_key' => 'reCAPTCHA API Secret Key', + 'logging' => '無効な入力をログファイルに記録する', + 'anonymous_only' => 'ゲストユーザーに対してのみ使用する', + 'remoteusers' => 'リモートユーザー全員に強制する', + 'enable_comment' => 'コメントをサポートする' , + 'enable_contact' => 'メール送信をサポートする', + 'enable_emailstory' => '「記事をメールする」をサポートする', + 'enable_forum' => '掲示板プラグインをサポートする', + 'enable_registration' => 'ユーザー登録をサポートする', + 'enable_loginform' => 'ログインフォームをサポートする', + 'enable_getpassword' => 'パスワード再設定フォームをサポートする', + 'enable_mediagallery' => 'メディアギャラリープラグインをサポートする', + 'enable_rating' => 'レーティングプラグインをサポートする', + 'enable_story' => '記事投稿をサポートする', + 'enable_calendar' => 'カレンダープラグインをサポートする', + 'enable_links' => 'リンクプラグインをサポートする', +); + +$LANG_configsubgroups['recaptcha'] = array( + 'sg_main' => '主要設定' +); + +$LANG_tab['recaptcha'] = array( + 'tab_main' => 'reCAPTCHA設定', +); + +$LANG_fs['recaptcha'] = array( + 'fs_system' => 'システム', + 'fs_integration' => 'Geeklogへの統合', +); + +// Note: entries 0, 1, 9, and 12 are the same as in $LANG_configselects['Core'] +$LANG_configselects['recaptcha'] = array( + 0 => array('はい' => 1, 'いいえ' => 0), +); diff --git a/plugins/recaptcha/vendor/LICENSE b/plugins/recaptcha/vendor/LICENSE new file mode 100644 index 000000000..f6412328f --- /dev/null +++ b/plugins/recaptcha/vendor/LICENSE @@ -0,0 +1,29 @@ +Copyright 2014, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/plugins/recaptcha/vendor/ReCaptcha/ReCaptcha.php b/plugins/recaptcha/vendor/ReCaptcha/ReCaptcha.php new file mode 100644 index 000000000..c157dc9a3 --- /dev/null +++ b/plugins/recaptcha/vendor/ReCaptcha/ReCaptcha.php @@ -0,0 +1,98 @@ +secret = $secret; + + if (!is_null($requestMethod)) { + $this->requestMethod = $requestMethod; + } else { + $this->requestMethod = new RequestMethod\Post(); + } + } + + /** + * Calls the reCAPTCHA siteverify API to verify whether the user passes + * CAPTCHA test. + * + * @param string $response The value of 'g-recaptcha-response' in the submitted form. + * @param string $remoteIp The end user's IP address. + * @return Response Response from the service. + */ + public function verify($response, $remoteIp = null) + { + // Discard empty solution submissions + if (empty($response)) { + $recaptchaResponse = new Response(false, array('missing-input-response')); + return $recaptchaResponse; + } + + $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION); + $rawResponse = $this->requestMethod->submit($params); + return Response::fromJson($rawResponse); + } +} diff --git a/plugins/recaptcha/vendor/ReCaptcha/RequestMethod.php b/plugins/recaptcha/vendor/ReCaptcha/RequestMethod.php new file mode 100644 index 000000000..fc4dde59c --- /dev/null +++ b/plugins/recaptcha/vendor/ReCaptcha/RequestMethod.php @@ -0,0 +1,42 @@ +curl = $curl; + } else { + $this->curl = new Curl(); + } + } + + /** + * Submit the cURL request with the specified parameters. + * + * @param RequestParameters $params Request parameters + * @return string Body of the reCAPTCHA response + */ + public function submit(RequestParameters $params) + { + $handle = $this->curl->init(self::SITE_VERIFY_URL); + + $options = array( + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $params->toQueryString(), + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/x-www-form-urlencoded' + ), + CURLINFO_HEADER_OUT => false, + CURLOPT_HEADER => false, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_SSL_VERIFYPEER => true + ); + $this->curl->setoptArray($handle, $options); + + $response = $this->curl->exec($handle); + $this->curl->close($handle); + + return $response; + } +} diff --git a/plugins/recaptcha/vendor/ReCaptcha/RequestMethod/Post.php b/plugins/recaptcha/vendor/ReCaptcha/RequestMethod/Post.php new file mode 100644 index 000000000..01ab33b2d --- /dev/null +++ b/plugins/recaptcha/vendor/ReCaptcha/RequestMethod/Post.php @@ -0,0 +1,70 @@ + array( + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", + 'method' => 'POST', + 'content' => $params->toQueryString(), + // Force the peer to validate (not needed in 5.6.0+, but still works) + 'verify_peer' => true, + // Force the peer validation to use www.google.com + $peer_key => 'www.google.com', + ), + ); + $context = stream_context_create($options); + return file_get_contents(self::SITE_VERIFY_URL, false, $context); + } +} diff --git a/plugins/recaptcha/vendor/ReCaptcha/RequestMethod/Socket.php b/plugins/recaptcha/vendor/ReCaptcha/RequestMethod/Socket.php new file mode 100644 index 000000000..f51f1239a --- /dev/null +++ b/plugins/recaptcha/vendor/ReCaptcha/RequestMethod/Socket.php @@ -0,0 +1,104 @@ +handle = fsockopen($hostname, $port, $errno, $errstr, (is_null($timeout) ? ini_get("default_socket_timeout") : $timeout)); + + if ($this->handle != false && $errno === 0 && $errstr === '') { + return $this->handle; + } + return false; + } + + /** + * fwrite + * + * @see http://php.net/fwrite + * @param string $string + * @param int $length + * @return int | bool + */ + public function fwrite($string, $length = null) + { + return fwrite($this->handle, $string, (is_null($length) ? strlen($string) : $length)); + } + + /** + * fgets + * + * @see http://php.net/fgets + * @param int $length + * @return string + */ + public function fgets($length = null) + { + return fgets($this->handle, $length); + } + + /** + * feof + * + * @see http://php.net/feof + * @return bool + */ + public function feof() + { + return feof($this->handle); + } + + /** + * fclose + * + * @see http://php.net/fclose + * @return bool + */ + public function fclose() + { + return fclose($this->handle); + } +} diff --git a/plugins/recaptcha/vendor/ReCaptcha/RequestMethod/SocketPost.php b/plugins/recaptcha/vendor/ReCaptcha/RequestMethod/SocketPost.php new file mode 100644 index 000000000..47541215f --- /dev/null +++ b/plugins/recaptcha/vendor/ReCaptcha/RequestMethod/SocketPost.php @@ -0,0 +1,121 @@ +socket = $socket; + } else { + $this->socket = new Socket(); + } + } + + /** + * Submit the POST request with the specified parameters. + * + * @param RequestParameters $params Request parameters + * @return string Body of the reCAPTCHA response + */ + public function submit(RequestParameters $params) + { + $errno = 0; + $errstr = ''; + + if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) { + return self::BAD_REQUEST; + } + + $content = $params->toQueryString(); + + $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; + $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; + $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; + $request .= "Content-length: " . strlen($content) . "\r\n"; + $request .= "Connection: close\r\n\r\n"; + $request .= $content . "\r\n\r\n"; + + $this->socket->fwrite($request); + $response = ''; + + while (!$this->socket->feof()) { + $response .= $this->socket->fgets(4096); + } + + $this->socket->fclose(); + + if (0 !== strpos($response, 'HTTP/1.1 200 OK')) { + return self::BAD_RESPONSE; + } + + $parts = preg_split("#\n\s*\n#Uis", $response); + + return $parts[1]; + } +} diff --git a/plugins/recaptcha/vendor/ReCaptcha/RequestParameters.php b/plugins/recaptcha/vendor/ReCaptcha/RequestParameters.php new file mode 100644 index 000000000..cb66f26cf --- /dev/null +++ b/plugins/recaptcha/vendor/ReCaptcha/RequestParameters.php @@ -0,0 +1,103 @@ +secret = $secret; + $this->response = $response; + $this->remoteIp = $remoteIp; + $this->version = $version; + } + + /** + * Array representation. + * + * @return array Array formatted parameters. + */ + public function toArray() + { + $params = array('secret' => $this->secret, 'response' => $this->response); + + if (!is_null($this->remoteIp)) { + $params['remoteip'] = $this->remoteIp; + } + + if (!is_null($this->version)) { + $params['version'] = $this->version; + } + + return $params; + } + + /** + * Query string representation for HTTP request. + * + * @return string Query string formatted parameters. + */ + public function toQueryString() + { + return http_build_query($this->toArray(), '', '&'); + } +} diff --git a/plugins/recaptcha/vendor/ReCaptcha/Response.php b/plugins/recaptcha/vendor/ReCaptcha/Response.php new file mode 100644 index 000000000..111df978a --- /dev/null +++ b/plugins/recaptcha/vendor/ReCaptcha/Response.php @@ -0,0 +1,102 @@ +success = $success; + $this->errorCodes = $errorCodes; + } + + /** + * Is success? + * + * @return boolean + */ + public function isSuccess() + { + return $this->success; + } + + /** + * Get error codes. + * + * @return array + */ + public function getErrorCodes() + { + return $this->errorCodes; + } +} diff --git a/plugins/recaptcha/vendor/autoload.php b/plugins/recaptcha/vendor/autoload.php new file mode 100644 index 000000000..5a7ee94c3 --- /dev/null +++ b/plugins/recaptcha/vendor/autoload.php @@ -0,0 +1,38 @@ + */ +a[name] { + color: black; + background: transparent; +} + +a.wikipedia { + text-decoration: none; + color: black; + border-bottom: 1px dotted black; +} + +.geeklog { + background-color: yellow; +} + +.public { + background-color: #99ff00; +} + +.admin { + background-color: aqua; +} + +.new { + color: white; + font-weight: bold; + background-color: #3333ff; +} + +.fixed { + color: white; + font-weight: bold; + background-color: #ff0033; +} + +.code { + color: white; + background: black; + padding: 5px; +} diff --git a/public_html/admin/plugins/recaptcha/docs/english/config.html b/public_html/admin/plugins/recaptcha/docs/english/config.html new file mode 100644 index 000000000..caefb3a0f --- /dev/null +++ b/public_html/admin/plugins/recaptcha/docs/english/config.html @@ -0,0 +1,100 @@ + + + + + Geeklog reCAPTCHA plugin - Configuration + + + + + +

reCAPTCHA® Plugin Configuration

+ +

System

+ + + + + + + + + + + + + + + + + +
VariableDefault ValueDescription
public_key(empty)reCAPTCHA API Site Key. If you don't have one, please go to https://www.google.com/recaptcha/admin/create and sign up.
private_key(empty)reCAPTCHA API Secret Key. If you don't have one, please go to https://www.google.com/recaptcha/admin/create and sign up.
loggingNoIf you set this to Yes, reCAPTCHA plugin will log invalid reCAPTCHA attempts into the log file (recaptcha.log).
+ +

Integration

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VariableDefault ValueDescription
anonymous_onlyNoIf you set this to Yes, reCAPTCHA will be shown to anonymous users only.
remoteusersNoIf you set this to Yes, reCAPTCHA will be forced upon all Remote Users.
enable_commentYesIf you set this to Yes, reCAPTCHA will be enabled for comments.
enable_contactYesIf you set this to Yes, reCAPTCHA will be enabled for contact.
enable_emailstoryYesIf you set this to Yes, reCAPTCHA will be enabled for emailing a story.
enable_forumYesIf you set this to Yes, reCAPTCHA will be enabled for the Forum plugin.
enable_registrationYesIf you set this to Yes, reCAPTCHA will be enabled for user registration.
enable_mediagalleryYesIf you set this to Yes, reCAPTCHA will be enabled for the Mediagallery plugin.
enable_ratingYesIf you set this to Yes, reCAPTCHA will be enabled for the Rating plugin.
enable_storyYesIf you set this to Yes, reCAPTCHA will be enabled for submitting a story.
enable_calendarYesIf you set this to Yes, reCAPTCHA will be enabled for the Calendar plugin.
enable_linksYesIf you set this to Yes, reCAPTCHA will be enabled for the Links plugin.
enable_getpasswordYesIf you set this to Yes, reCAPTCHA will be enabled for Forget Password Form.
enable_loginfotmYesIf you set this to Yes, reCAPTCHA will be enabled for Login Form.
+ + + + + diff --git a/public_html/admin/plugins/recaptcha/docs/english/install.html b/public_html/admin/plugins/recaptcha/docs/english/install.html new file mode 100644 index 000000000..d48bd28e9 --- /dev/null +++ b/public_html/admin/plugins/recaptcha/docs/english/install.html @@ -0,0 +1,129 @@ + + + + + + + Geeklog reCAPTCHA plugin + + + +

Install/Uninstall/Upgrade instruction for the Geeklog reCAPTCHA plugin

+ +

What is reCAPTCHA?

+ +

ReCAPTCHA® is a free anti-bot service providing powerful CAPTCHA. This plugin makes it easy to use reCAPTCHA with Geeklog.

+ +

System Requirements

+ +
    +
  • Since v1.1.0, PHP-5.3.2 or later is required. Maybe PHP-5-3.0 or PHP-5.3.1 will do, but I am not sure.
  • +
  • Since v1.1.6, Geeklog 1.8.0 or newer is required.
  • +
+ +

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. +
  3. Create the admin directory. Under your <admin>/plugins/ directory, create a directory called recaptcha.
  4. +
  5. 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.
  6. +
  7. 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.
  8. +
  9. Important: Set up API keys. Go to the Configuration and enter reCAPTCHA API Site Key and Secret Key that you can get at https://www.google.com/recaptcha/admin/create. It is not until you set the API keys that you can use reCAPTCHA service.
  10. +
+ +

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. +
  3. Delete the two plugin directories created in the install process: <geeklog-dir>/plugins/recaptcha/ and <admin>/plugins/recaptcha/.
  4. +
+ +

UPGRADE

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

REVISION HISTORY

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VersionDate(YYYY-MM-DD)Description
1.1.62017-11-27 +
    +
  • Added support for Login Form.
  • +
  • Added support for Forget Password Form.
  • +
  • Added support for the demo mode intruduced in Geeklog 2.2.0.
  • +
+
1.1.52017-04-12 +
    +
  • Fixed a bug where reCAPTCHA failed to check for input when $_RECAPTCHA_CONF['logging'] is set to off.
  • +
+
1.1.42017-01-18 +
    +
  • Small bug fix.
  • +
+
1.1.32016-08-12 +
    +
  • Replaced COM_siteHeader and COM_siteFooter with COM_createHTMLDocument.
  • +
+
1.1.22016-02-20 +
    +
  • Upgraded reCAPTCHA library to v1.1.2.
  • +
+
1.1.02015-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.12014-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.02014-01-24Initial release.
+ + + + + diff --git a/public_html/admin/plugins/recaptcha/docs/japanese/config.html b/public_html/admin/plugins/recaptcha/docs/japanese/config.html new file mode 100644 index 000000000..44681ada8 --- /dev/null +++ b/public_html/admin/plugins/recaptcha/docs/japanese/config.html @@ -0,0 +1,100 @@ + + + + + Geeklog reCAPTCHAプラグインの設定 + + + + + +

reCAPTCHA®プラグインの設定

+ +

システム

+ + + + + + + + + + + + + + + + + +
項目(変数)デフォルト説明
public_key(未入力)reCAPTCHA APIのSite Keyを入力します。お持ちでない場合は、https://www.google.com/recaptcha/admin/createで登録して入手してください。
private_key(未入力)reCAPTCHA APIのSecret Keyを入力します。お持ちでない場合は、https://www.google.com/recaptcha/admin/createで登録して入手してください。
loggingいいえ「はい」にすると、reCAPTCHAは無効な入力をログファイル(recaptcha.log)に記録します。
+ +

Geeklogへの統合

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
項目(変数)デフォルト説明
anonymous_onlyいいえ「はい」にすると、reCAPTCHAはゲストユーザーに対してのみ表示されます。
remoteusersいいえ「はい」にすると、reCAPTCHAが全てのリモートユーザーに対して強制されるようになります。
enable_commentはい「はい」にすると、reCAPTCHAがコメントに対して有効になります。
enable_contactはい「はい」にすると、reCAPTCHAがメール送信に対して有効になります。
enable_emailstoryはい「はい」にすると、reCAPTCHAが「記事をメールする」に対して有効になります。
enable_forumはい「はい」にすると、reCAPTCHAが掲示板プラグインに対して有効になります。
enable_registrationはい「はい」にすると、reCAPTCHAがユーザー登録の際に有効になります。
enable_mediagalleryはい「はい」にすると、reCAPTCHAがメディアギャラリー(Mediagallery)プラグインに対して有効になります。
enable_ratingはい「はい」にすると、reCAPTCHAがレーティング(Rating)プラグインに対して有効になります。
enable_storyはい「はい」にすると、reCAPTCHAが記事を投稿する際に有効になります。
enable_calendarはい「はい」にすると、reCAPTCHAがカレンダープラグインに対して有効になります。
enable_linksはい「はい」にすると、reCAPTCHAがリンクプラグインに対して有効になります。
enable_getpasswordはい「はい」にすると、reCAPTCHAがパスワード再設定フォームに対して有効になります。
enable_loginfotmYes「はい」にすると、reCAPTCHAがログインフォームに対して有効になります。
+ + + + + diff --git a/public_html/admin/plugins/recaptcha/docs/japanese/install.html b/public_html/admin/plugins/recaptcha/docs/japanese/install.html new file mode 100644 index 000000000..61202e04c --- /dev/null +++ b/public_html/admin/plugins/recaptcha/docs/japanese/install.html @@ -0,0 +1,130 @@ + + + + + + + Geeklog reCAPTCHAプラグイン + + + +

Geeklog reCAPTCHAプラグインのインストール/アンインストール

+ +

reCAPTCHAとは

+ +

ReCAPTCHA®は強力なCAPTCHAを提供する無料の対ボットシステムです。このプラグインを使うことで、GeeklogでreCAPTCHAを簡単に利用できるようになります。

+ +

システム要件

+ +
    +
  • バージョン1.1.0以降、PHP-5.3.2が必要になりました。PHP-5-3.0やPHP-5.3.1でも動作すると思いますが、確認はしていません。
  • +
  • バージョン1.1.6以降、Geeklog 1.8.0以降が必要になりました。
  • +
+ +

インストール

+ +

以下の説明で、

+
    +
  • <geeklog_dir>は、システムのdb-config.php が存在するディレクトリ
  • +
  • <admin>は、管理者用ファイルが存在するディレクトリ(ふつうは、<public_html>ディレクトリの下)
  • +
+

を表しています。

+ +
    +
  1. recaptchaプラグインのアーカイブを<geeklog_dir>/pluginsディレクトリに展開します。recaptchaという名前のディレクトリができます。
  2. +
  3. adminディレクトリを作ります。<admin>/plugins/ ディレクトリの下にrecaptchaという名前のディレクトリを作ります。
  4. +
  5. <geeklog_dir>/plugins/recaptcha/ ディレクトリに移動します。adminディレクトリの内容を、2.で作成した <admin>/plugins/recaptcha/ ディレクトリにコピーします。
  6. +
  7. 管理者としてログインし、プラグインエディタからインストールを実行します。失敗した場合には、エラーログ(error.log)を調べてください。
  8. +
  9. 重要: APIキーを設定します。https://www.google.com/recaptcha/admin/createでサインアップして、APIキーを入手してください。取得したSite KeyとSecret Keyをコンフィギュレーションで設定して初めて、reCAPTCHAを使用できるようになります
  10. +
+ +

アンインストール

+ +
    +
  1. プラグインエディタから、recaptchaプラグインをアンインストールします。
  2. +
  3. インストールの過程で作成した2つのディレクトリ(<geeklog-dir>/plugins/recaptcha/と<admin>/plugins/recaptcha/ を削除します。
  4. +
+ +

アップグレード

+ +
    +
  1. 管理者としてサイトにログインしてから、プラグインエディタでreCAPTCHAプラグインを無効にします。
  2. +
  3. インストール時と同様に、recaptchaプラグインのアーカイブを展開してからサーバーにアップロードします。
  4. +
  5. プラグインエディタでreCAPTCHAを有効にしてから、アップグレードします。
  6. +
+ +

更新履歴

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
バージョン日付(YYYY-MM-DD)説明
1.1.62017-11-27 +
    +
  • パスワード再設定フォームをサポートしました。
  • +
  • ログインフォームをサポートしました。
  • +
  • Geeklog 2.2.0で導入されるデモモードをサポートしました。
  • +
+
1.1.52017-04-12 +
    +
  • $_RECAPTCHA_CONF['logging']がfalseの場合に入力判定に失敗していたバグを修正しました。
  • +
+
1.1.42017-01-18 +
    +
  • 軽微なバグを修正しました。
  • +
+
1.1.32016-08-12 +
    +
  • COM_siteHeaderとCOM_siteFooterをCOM_createHTMLDocumentに置き換えました。
  • +
+
1.1.22016-02-20 +
    +
  • reCAPTCHAのライブラリをv1.1.2にアップグレードしました。
  • +
+
1.1.02015-07-03 +
    +
  • Google reCAPTCHA v2にアップグレードしました。
  • +
  • ログファイルの項目にエラーコードを追加しました。パッチ提供はTomさんです。
  • +
+
1.0.12014-01-26 +
    +
  • reCAPTCHAのコードをくるむ<div>タグを追加しました。パッチ提供はTomさんです。
  • +
  • エラーログを"logs/recaptch.log"に書き込むようにしました。パッチ提供はTomさんです。
  • +
+
1.0.02014-01-24最初のリリースです。
+ + + + + diff --git a/public_html/admin/plugins/recaptcha/images/recaptcha.png b/public_html/admin/plugins/recaptcha/images/recaptcha.png new file mode 100644 index 0000000000000000000000000000000000000000..d27923202f687a7b053ed39fbe987b345727de55 GIT binary patch literal 2050 zcmV+d2>thoP)Dj=+|ykCnvM0`{fG_lE;XiSW$6W>ykw&}n9r++k^PN&mJAJggNk93-d zyySIy&c|J5ML=6MB$H+4%(vfn&i%ggJKwqI+<^lC?z=4CY3E%4E&vyR3%~{70{H#_ zXa(bWwO#;c(Tc|3avZnJ*-m3H{>s^g7sUazd0|Nbc%JvwheeFtymJ+P@yV@O*^#pI zzB*Khei%TUxPJSiSsR3yQYw}5B?Zt3#)^WyMPoU8vLG`neO4-}tkb+fygUbBGGmuz z)`kEq7Rz$FsV4!U+X^z9-Jb0Yh{iwKYOBDKk@}F-HP!$x7>At?B!IN^owGIwFpa79 z8;wC2M%_4XF#c|{Ufkxqzgn$!*9ziMJm*guy)dT5TO|8XQT$Y;*T+2-fXZOl7-lw) z*3>xw(jX}%iTy4r&WFt0oFSD?u*|&y(r0C7LSky_)Un>9aP`I&xIJ(k&YbOsF!Rdk=(p&NY6}z=GF$#o5Dvz1Ys?UsLn9u&=EjtdK!okk%MS6lxmrQDz}zGRjq9t zVZSJ^v_7Cc=+<`UWI;l5B7~cx2BWrZ8?|Iwo(@2x*Yh#kT&c{%J#c|rI` zs%6H(!r}rbE-M*T>kOq1fV_fS$vzt*V`A>1qqQo%P!$;yeUH{C7!A#JtjspGG_X0X zzZM@ifdTuyMla@I;iyOFzry+77AwP#t3G{|HC2-ZMfoiHS=rfu{a}isl9-YLI%C*~S`c0)(V4hux6!lR;xnWG3$abQ1Nr<@id zB1g4GV-V##{iZdhv&{e;sIs!TwXz(r*W6cznu4E6AJFK;sML(~!S)V2rb+&yV#6rf z>TKh9Go1ubQ&$Z|dkZki2OukV4^}Bd3sx!{{iZdFcFF!y22fH~%I363VM*~AmeF^W z%FtjHFPN~5-o^Lr^8XA#IfoB^(AwTQU4!+%!deE+n5*`-=7*%k-o&Cza^(17{A@7& zi=1k0Yl5=!eNbIn2`5e-gC8d(4DZay80|aV%hqb^ZJ3fdlW2?8ENh}3`$?s(0?xeA z4^8%_ansi52XRSBL%pYdI!#s0d*eng^l8O>@4~#Pt8aFSmjSj)XKeyFZGaHiDcKZ|oboU%$^X{H5h)+(Q zZft2}zYiVmgf?`3OHAyr+8~_AvjUYGzC|AvKDuvz>2&wu85?@w%irbvy4991^lM)M)w)Q*bgODta(BF8&_%0?GokKZ!P!Lhcg4^2Y(Z zfFkqt^;LKT2Ch~3`}-*r3O^|VkBFC-mp5H8iKnOM8eH>m%%!XMAiGyWRJstAYU_*m zx6oc59v*9d_^Mjmq|(L*Z`x#(_VZlG`9-Uc+03m-I3p`uzn1mv+ zdlveD0B&_$pR712XvXn{n%TV0A3Vq{OZ=Jq?UZwFKqJk+P5MOv91mw-@rJIyXn{uO zO_o}}D8Sr@OFs^n-DJn>@(aF7PC?^R=o8P%-=VZ#5MTlF&*#klx|DN*lirCH4*@Xe zkG-pH=3#uu-JPT6v2N8WZvFON`G?M%(A>?93qt({8lR`0&W}4Ozf9}oANjfcq->v~ zsWAYHgyjl}lIDx{n7oh#2#&oTkm*To)@m3w({-cn Date: Sat, 2 Dec 2017 19:35:49 +0900 Subject: [PATCH 2/7] Removed form_id_mappgin.php --- plugins/recaptcha/form_id_mapping.php | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 plugins/recaptcha/form_id_mapping.php diff --git a/plugins/recaptcha/form_id_mapping.php b/plugins/recaptcha/form_id_mapping.php deleted file mode 100644 index 9ede285e3..000000000 --- a/plugins/recaptcha/form_id_mapping.php +++ /dev/null @@ -1,16 +0,0 @@ - 'commentform', - 'contact' => 'contactuserform', - 'emailstory' => 'contactauthorform', - 'forum' => '', - 'registration' => 'registrationform', - 'mediagallery' => '', - 'rating' => '', - 'story' => 'submitstory', - 'calendar' => 'submiteventform', - 'links' => 'submitlink', - 'getpassword' => 'getpasswordform', -); From 8d22ffea8632e1f6131dd274a06e97beb4a07386 Mon Sep 17 00:00:00 2001 From: Kenji ITO Date: Sat, 2 Dec 2017 19:36:30 +0900 Subject: [PATCH 3/7] Fixed an incompatible bug --- plugins/spamx/SFS.Misc.class.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/plugins/spamx/SFS.Misc.class.php b/plugins/spamx/SFS.Misc.class.php index 691979595..284ebfd8d 100644 --- a/plugins/spamx/SFS.Misc.class.php +++ b/plugins/spamx/SFS.Misc.class.php @@ -31,14 +31,21 @@ class SFS extends BaseCommand { /** - * The execute method examines the Email address + * Here we do the work * - * @param string $email Email text to examine - * @return int 0: no spam, else: spam detected + * @param string $comment + * @param string $permanentLink (since GL 2.2.0) + * @param string $commentType (since GL 2.2.0) + * @param string $commentAuthor (since GL 2.2.0) + * @param string $commentAuthorEmail (since GL 2.2.0) + * @param string $commentAuthorURL (since GL 2.2.0) + * @return int either PLG_SPAM_NOT_FOUND, PLG_SPAM_FOUND or PLG_SPAM_UNSURE + * @note As for valid value for $commentType, see system/classes/Akismet.php */ - public function execute($email) + public function execute($comment, $permanentLink, $commentType = Geeklog\Akismet::COMMENT_TYPE_COMMENT, + $commentAuthor = null, $commentAuthorEmail = null, $commentAuthorURL = null) { - $this->result = $this->_process($email, $_SERVER['REMOTE_ADDR']); + $this->result = $this->_process($commentAuthorEmail, $_SERVER['REMOTE_ADDR']); return $this->result; } From c15cb31304147c7e08c527721060cda73fb6fdee Mon Sep 17 00:00:00 2001 From: Kenji ITO Date: Sat, 2 Dec 2017 19:36:59 +0900 Subject: [PATCH 4/7] Removed INSTALL --- plugins/recaptcha/INSTALL | 1 - 1 file changed, 1 deletion(-) delete mode 100644 plugins/recaptcha/INSTALL diff --git a/plugins/recaptcha/INSTALL b/plugins/recaptcha/INSTALL deleted file mode 100644 index ea809b3b5..000000000 --- a/plugins/recaptcha/INSTALL +++ /dev/null @@ -1 +0,0 @@ -Please see README.md and admin/docs/(english|japanese)/install.html. From 1effd9dff7fdc785ec0878700f3bdde795a0d2f5 Mon Sep 17 00:00:00 2001 From: Kenji ITO Date: Sat, 2 Dec 2017 19:37:37 +0900 Subject: [PATCH 5/7] Fixed a Resource class bug --- system/classes/Resource.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/system/classes/Resource.php b/system/classes/Resource.php index 8fe433042..0a271ad27 100644 --- a/system/classes/Resource.php +++ b/system/classes/Resource.php @@ -39,6 +39,7 @@ class Resource const DEFAULT_CACHE_LIFESPAN = 604800; // 1 week const JS_TAG_TEMPLATE = ''; + const EXTERNAL_JS_TAG_TEMPLATE = ''; // Default theme const DEFAULT_THEME = 'denim'; @@ -879,7 +880,7 @@ private function makeFileServerTag(array $files, $isCss = true) if ($success && !$this->debug) { $url = $this->config['site_url'] . '/r.php?k=' . $key; - $retval .= sprintf('', $url); + $retval .= sprintf(self::JS_TAG_TEMPLATE, $url); } else { // Somehow failed to save data into cache or debug mode is on $retval .= PHP_EOL; @@ -1105,7 +1106,7 @@ public function getHeader() usort($this->externalJsFiles['header'], array('\\Geeklog\\Resource', 'comparePriority')); foreach ($this->externalJsFiles['header'] as $jsFile) { - $retval .= sprintf(self::JS_TAG_TEMPLATE, $jsFile['file']) . PHP_EOL; + $retval .= sprintf(self::EXTERNAL_JS_TAG_TEMPLATE, $jsFile['file']) . PHP_EOL; } } @@ -1157,7 +1158,7 @@ public function getHeader() if ($this->debug) { $retval .= '' . PHP_EOL; } else { $code = implode(PHP_EOL, $this->jsBlocks['header']); $code = JSMin::minify($code); @@ -1185,7 +1186,7 @@ public function getFooter() usort($this->externalJsFiles['footer'], array('\\Geeklog\\Resource', 'comparePriority')); foreach ($this->externalJsFiles['footer'] as $jsFile) { - $retval .= sprintf('', $jsFile['file']) . PHP_EOL; + $retval .= sprintf(self::EXTERNAL_JS_TAG_TEMPLATE, $jsFile['file']) . PHP_EOL; } } From 8aaad51230d1757b2570c748cea168fc1eb80a77 Mon Sep 17 00:00:00 2001 From: Kenji ITO Date: Sat, 2 Dec 2017 20:27:35 +0900 Subject: [PATCH 6/7] Added Invisible reCAPTCHA support for Denim theme --- language/japanese_utf-8.php | 6 + .../templates/default/submitevent.thtml | 4 +- .../templates/denim/submitevent.thtml | 4 +- .../links/templates/default/submitlink.thtml | 2 +- .../links/templates/denim/submitlink.thtml | 2 +- plugins/recaptcha/README.md | 10 +- plugins/recaptcha/autoinstall.php | 99 +- plugins/recaptcha/config.php | 4 +- .../recaptcha/configuration_validation.php | 44 +- plugins/recaptcha/functions.inc | 945 +++++++++++------- plugins/recaptcha/install_defaults.php | 183 ++-- plugins/recaptcha/install_updates.php | 100 +- plugins/recaptcha/language/english.php | 60 +- .../language/french_france_utf-8.php | 64 +- plugins/recaptcha/language/japanese_utf-8.php | 62 +- .../recaptcha/docs/english/config.html | 198 ++-- .../recaptcha/docs/english/install.html | 218 ++-- .../recaptcha/docs/japanese/config.html | 191 ++-- .../recaptcha/docs/japanese/install.html | 205 ++-- public_html/admin/plugins/recaptcha/index.php | 33 +- .../layout/denim/comment/commentform.thtml | 6 +- .../denim/comment/commentform_advanced.thtml | 6 +- .../denim/profiles/contactauthorform.thtml | 2 +- .../denim/profiles/contactuserform.thtml | 2 +- .../layout/denim/submit/submitarticle.thtml | 5 +- .../denim/submit/submitarticle_advanced.thtml | 5 +- .../layout/denim/users/getpasswordform.thtml | 2 +- .../layout/denim/users/loginform.thtml | 2 +- .../layout/denim/users/registrationform.thtml | 2 +- public_html/submit.php | 17 +- 30 files changed, 1482 insertions(+), 1001 deletions(-) diff --git a/language/japanese_utf-8.php b/language/japanese_utf-8.php index fb0d6eacc..4ea739b0e 100644 --- a/language/japanese_utf-8.php +++ b/language/japanese_utf-8.php @@ -2019,6 +2019,12 @@ 'DESC' => '新しい順に' ); +$LANG_statuscodes = array( + 0 => 'Normal', + 1 => 'Refreshing', + 10 => 'Archive' +); + $LANG_trackbackcodes = array( 0 => 'トラックバックを受け付ける', -1 => 'トラックバックを受け付けない' diff --git a/plugins/calendar/templates/default/submitevent.thtml b/plugins/calendar/templates/default/submitevent.thtml index 741d50d61..f5a89dea2 100644 --- a/plugins/calendar/templates/default/submitevent.thtml +++ b/plugins/calendar/templates/default/submitevent.thtml @@ -1,7 +1,7 @@ {# begin {templatelocation} #} {explanation} -
+
{lang_title}:
@@ -99,7 +99,7 @@ - + {hidden_fields}
diff --git a/plugins/calendar/templates/denim/submitevent.thtml b/plugins/calendar/templates/denim/submitevent.thtml index 55ec352bd..5c9dc7fd3 100644 --- a/plugins/calendar/templates/denim/submitevent.thtml +++ b/plugins/calendar/templates/denim/submitevent.thtml @@ -1,7 +1,7 @@ {# begin {templatelocation} #} {explanation} - +
{lang_title}:
@@ -99,7 +99,7 @@ - + {hidden_fields}
diff --git a/plugins/links/templates/default/submitlink.thtml b/plugins/links/templates/default/submitlink.thtml index a7d4ca401..0e60d41c4 100644 --- a/plugins/links/templates/default/submitlink.thtml +++ b/plugins/links/templates/default/submitlink.thtml @@ -19,7 +19,7 @@
- +
diff --git a/plugins/links/templates/denim/submitlink.thtml b/plugins/links/templates/denim/submitlink.thtml index a91e541fc..420ee3f60 100644 --- a/plugins/links/templates/denim/submitlink.thtml +++ b/plugins/links/templates/denim/submitlink.thtml @@ -19,7 +19,7 @@
- +
diff --git a/plugins/recaptcha/README.md b/plugins/recaptcha/README.md index 410c67ec6..adc298d02 100644 --- a/plugins/recaptcha/README.md +++ b/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? @@ -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 @@ -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. | diff --git a/plugins/recaptcha/autoinstall.php b/plugins/recaptcha/autoinstall.php index dc8811d45..fa3ff4813 100644 --- a/plugins/recaptcha/autoinstall.php +++ b/plugins/recaptcha/autoinstall.php @@ -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'], '>='); } diff --git a/plugins/recaptcha/config.php b/plugins/recaptcha/config.php index bc95a9387..ac5d00a5c 100644 --- a/plugins/recaptcha/config.php +++ b/plugins/recaptcha/config.php @@ -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', diff --git a/plugins/recaptcha/configuration_validation.php b/plugins/recaptcha/configuration_validation.php index 007cc0ea4..ecc7419bc 100644 --- a/plugins/recaptcha/configuration_validation.php +++ b/plugins/recaptcha/configuration_validation.php @@ -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)), ); diff --git a/plugins/recaptcha/functions.inc b/plugins/recaptcha/functions.inc index 7733a8bb2..e4bae170b 100644 --- a/plugins/recaptcha/functions.inc +++ b/plugins/recaptcha/functions.inc @@ -31,454 +31,645 @@ // +---------------------------------------------------------------------------+ 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.'); } // Language file Include -$langfile = $_CONF['path'] . 'plugins/recaptcha/language/' . $_CONF['language'] . '.php'; +$langFile = __DIR__ . '/language/' . $_CONF['language'] . '.php'; clearstatcache(); -if (file_exists($langfile)) { - include_once $langfile; +if (file_exists($langFile)) { + include_once $langFile; } else { - include_once $_CONF['path'] . 'plugins/recaptcha/language/english.php'; + include_once __DIR__ . '/language/english.php'; } // Loads the plugin configuration global $_RECAPTCHA_CONF; -require_once $_CONF['path'] . 'plugins/recaptcha/config.php'; +require_once __DIR__ . '/config.php'; RECAPTCHA_loadConfig(); -require_once $_CONF['path'] . 'plugins/recaptcha/vendor/autoload.php'; +require_once __DIR__ . '/vendor/autoload.php'; // +---------------------------------------------------------------------------+ // | Geeklog Plugin API Implementations | // +---------------------------------------------------------------------------+ /** -* Returns a URL to icon -*/ -function plugin_geticon_recaptcha() { - global $_CONF; - - return $_CONF['site_admin_url'] . '/plugins/recaptcha/images/recaptcha.png'; + * Return a URL to icon + * + * @return string + */ +function plugin_geticon_recaptcha() +{ + global $_CONF; + + return $_CONF['site_admin_url'] . '/plugins/recaptcha/images/recaptcha.png'; } /** -* Puts an option for the plugin in the command and control block on moderation.php -* -* @return array Array containing (plugin name, admin url, url of plugin icon) -*/ -function plugin_cclabel_recaptcha() { - global $_CONF; - - if (SEC_hasRights('recaptcha.edit')) { - $pi_name = RECAPTCHA_str('admin'); - - if (!RECAPTCHA_isEnabled()) { - $pi_name = '' . $pi_name . '!'; - } - - $admin_url = $_CONF['site_admin_url'] . '/plugins/recaptcha/index.php'; - $icon_url = plugin_geticon_recaptcha(); - - return array($pi_name, $admin_url, $icon_url); - } else { - return null; - } + * Puts an option for the plugin in the command and control block on moderation.php + * + * @return array Array containing (plugin name, admin url, url of plugin icon) + */ +function plugin_cclabel_recaptcha() +{ + global $_CONF; + + if (SEC_hasRights('recaptcha.edit')) { + $pi_name = RECAPTCHA_str('admin'); + + if (!RECAPTCHA_isRecaptchaEnabled() && !RECAPTCHA_isInvisibleRecaptchaEnabled()) { + $pi_name = '' . $pi_name . '!'; + } + + $admin_url = $_CONF['site_admin_url'] . '/plugins/recaptcha/index.php'; + $icon_url = plugin_geticon_recaptcha(); + + return array($pi_name, $admin_url, $icon_url); + } else { + return array(); + } } /** -* Returns the administrative option for this plugin -* -* @return array Array containing (plugin name, plugin admin url, # of items -* in plugin or '') -*/ -function plugin_getadminoption_recaptcha() { - global $_CONF, $_TABLES; - - if (SEC_hasRights('recaptcha.edit')) { - $pi_name = RECAPTCHA_str('admin'); - - if (!RECAPTCHA_isEnabled()) { - $pi_name = '' . $pi_name . '!'; - } - - $admin_url = $_CONF['site_admin_url'] . '/plugins/recaptcha/index.php'; - $num_items = ''; - return array($pi_name, $admin_url, $num_items); - } else { - return null; - } + * Returns the administrative option for this plugin + * + * @return array Array containing (plugin name, plugin admin url, # of items in plugin or '') + */ +function plugin_getadminoption_recaptcha() +{ + global $_CONF; + + if (SEC_hasRights('recaptcha.edit')) { + $pi_name = RECAPTCHA_str('admin'); + + if (!RECAPTCHA_isRecaptchaEnabled() && !RECAPTCHA_isInvisibleRecaptchaEnabled()) { + $pi_name = '' . $pi_name . '!'; + } + + $admin_url = $_CONF['site_admin_url'] . '/plugins/recaptcha/index.php'; + $num_items = ''; + + return array($pi_name, $admin_url, $num_items); + } else { + return array(); + } } /** -* Returns the version for this plugin -* -* @return string plugin version no -*/ -function plugin_chkVersion_recaptcha() { - global $_RECAPTCHA_CONF; - - return $_RECAPTCHA_CONF['pi_version']; + * Returns the version for this plugin + * + * @return string plugin version no + */ +function plugin_chkVersion_recaptcha() +{ + global $_RECAPTCHA_CONF; + + return $_RECAPTCHA_CONF['pi_version']; } /** -* Upgrades the plugin -* -* @return boolean true (= success) -*/ -function plugin_upgrade_recaptcha() { - global $_CONF, $_TABLES, $_RECAPTCHA_CONF; - - $sql = "SELECT pi_version " - . "FROM {$_TABLES['plugins']} " - . "WHERE (pi_name = 'recaptcha') "; - $result = DB_query($sql); - $A = DB_fetchArray($result); - $pi_version = $A['pi_version']; // Version info stored in database - - // Does upgrading - while (version_compare($pi_version, $_RECAPTCHA_CONF['pi_version']) < 0) { - switch ($pi_version) { - case '1.0.0': - case '1.0.1': - case '1.1.0': - case '1.1.1': - case '1.1.2': - case '1.1.3': - case '1.1.4': - case '1.1.5': - require_once dirname(__FILE__) . '/install_updates.php'; - recaptcha_update_ConfValues_1_1_5(); - $pi_version = '1.1.6'; - break; - - default: - $pi_version = $_RECAPTCHA_CONF['pi_version']; - break; - } - } - - // Updates plugin info - $sql = "UPDATE {$_TABLES['plugins']} SET pi_version = '{$_RECAPTCHA_CONF['pi_version']}' " - . "WHERE (pi_name = 'recaptcha') "; - $result = DB_query($sql); - COM_errorLog("reCAPTCHA plugin was successfully updated to version {$_RECAPTCHA_CONF['pi_version']}."); - - return true; + * Upgrades the plugin + * + * @return bool true (= success) + */ +function plugin_upgrade_recaptcha() +{ + global $_TABLES, $_RECAPTCHA_CONF; + + $pluginVersionInDb = DB_getItem($_TABLES['plugins'], 'pi_version', "pi_name = 'recaptcha'"); + + // Does upgrading + while (version_compare($pluginVersionInDb, $_RECAPTCHA_CONF['pi_version'], '<')) { + switch ($pluginVersionInDb) { + case '1.0.0': + case '1.0.1': + case '1.1.0': + case '1.1.1': + case '1.1.2': + case '1.1.3': + case '1.1.4': + case '1.1.5': + require_once dirname(__FILE__) . '/install_updates.php'; + recaptcha_update_ConfValues_1_1_5(); + $pluginVersionInDb = '1.1.6'; + break; + + case '1.1.6': + require_once dirname(__FILE__) . '/install_updates.php'; + recaptcha_update_ConfValues_1_1_6(); + $pluginVersionInDb = '1.2.0'; + break; + + default: + $pluginVersionInDb = $_RECAPTCHA_CONF['pi_version']; + break; + } + } + + // Updates plugin info + $sql = "UPDATE {$_TABLES['plugins']} SET pi_version = '{$_RECAPTCHA_CONF['pi_version']}' " + . "WHERE (pi_name = 'recaptcha') "; + DB_query($sql); + COM_errorLog("reCAPTCHA plugin was successfully updated to version {$_RECAPTCHA_CONF['pi_version']}."); + + return true; } /** -* Automatic uninstall function for plugins -* -* @return array -*/ -function plugin_autouninstall_recaptcha() { - global $_RECAPTCHA_CONF; - - return array ( - 'tables' => array(), - 'groups' => array('reCAPTCHA Admin'), - 'features' => $_RECAPTCHA_CONF['FEATURES'], - 'php_blocks' => array(), - 'vars' => array() - ); + * Automatic uninstall function for plugins + * + * @return array + */ +function plugin_autouninstall_recaptcha() +{ + global $_RECAPTCHA_CONF; + + return array( + 'tables' => array(), + 'groups' => array('reCAPTCHA Admin'), + 'features' => $_RECAPTCHA_CONF['FEATURES'], + 'php_blocks' => array(), + 'vars' => array(), + ); } /** -* Returns the URL to a given document -*/ -function plugin_getdocumentationurl_recaptcha($file) { - global $_CONF; + * Return the URL to a given document + * + * @return string + */ +function plugin_getdocumentationurl_recaptcha($file) +{ + global $_CONF; + + $lang = COM_getLanguageName(); + $path = $_CONF['path_html'] . 'admin/plugins/recaptcha/docs/' . $lang . '/' . $file . '.html'; + clearstatcache(); + + if (!file_exists($path)) { + $lang = 'english'; + } - $lang = COM_getLanguageName(); - $path = $_CONF['path_html'] . 'admin/plugins/recaptcha/docs/' . $lang . '/' - . $file . '.html'; - clearstatcache(); + $retval = $_CONF['site_admin_url'] . '/plugins/recaptcha/docs/' . $lang . '/' . $file . '.html'; - if (!file_exists($path)) { - $lang = 'english'; - } + return $retval; +} - $retval = $_CONF['site_admin_url'] . '/plugins/recaptcha/docs/' . $lang . '/' - . $file . '.html'; +/** + * Provides text for a Configuration tooltip + * + * @param string $id Id of config value + * @return mixed Text to use regular tooltip, null to use config tooltip hack, or empty string + * when not available + */ +function plugin_getconfigtooltip_recaptcha($id) +{ + // Use config tooltip hack where tooltip is read from the config documentation + return null; +} - return $retval; +/** + * Callback function to add HTML text for reCAPTCHA + * + * @param string $type + * @param Template $template a reference to a Template class object + */ +function plugin_templatesetvars_recaptcha($type, &$template) +{ + global $_RECAPTCHA_CONF, $_SCRIPTS; + + if (RECAPTCHA_requireCaptcha($type)) { + $isInvisible = ($_RECAPTCHA_CONF['enable_' . $type] == 2); + + if ($isInvisible) { + $formId = RECAPTCHA_getFormId($type); + $code = <<setJavaScript($code, false, false); + } + + $_SCRIPTS->setJavaScriptFile( + 'recaptcha', + 'https://www.google.com/recaptcha/api.js?hl=' . RECAPTCHA_getLangCode(), + true + ); + + if ($isInvisible) { + // Invisible reCAPTCHA + $template->set_var( + 'invisible_recaptcha', + sprintf(' data-sitekey="%s" data-callback="%s"', $_RECAPTCHA_CONF['invisible_site_key'], 'onFormSubmit') + ); + $template->set_var('captcha', ''); + } else { + // reCAPTCHA v2 + $template->set_var('invisible_recaptcha', ''); + $captcha = '
'; + $template->set_var('captcha', $captcha); + } + } + +} + +/** + * Callback function to check the code entered by a user + * + * @param int $uid (not used in this function) + * @param string $title (not used in this function) + * @param string $comment (not used in this function) + * @param string $sid (not used in this function) + * @param int $pid (not used in this function) + * @param string $type (not used in this function) + * @param string $postMode (not used in this function) + * @return string empty = success + */ +function plugin_commentPreSave_recaptcha($uid, $title, $comment, $sid, $pid, $type, $postMode) +{ + return plugin_itemPreSave_recaptcha('comment', ''); } /** -* Provides text for a Configuration tooltip -* -* @param string $id Id of config value -* @return mixed Text to use regular tooltip, null to use config -* tooltip hack, or empty string when not available -*/ -function plugin_getconfigtooltip_recaptcha($id) { - // Use config tooltip hack where tooltip is read from the config documentation - return null; + * Callback function to check the code entered by a user + * + * @param string $type item type + * @param string $content + * @return string empty = success + */ +function plugin_itemPreSave_recaptcha($type, $content = '') +{ + global $_RECAPTCHA_CONF; + + $msg = ''; + + if (RECAPTCHA_requireCaptcha($type)) { + if ($_RECAPTCHA_CONF['enable_' . $type] == 1) { + $secretKey = $_RECAPTCHA_CONF['secret_key']; + } else { + $secretKey = $_RECAPTCHA_CONF['invisible_secret_key']; + } + + if (is_callable('curl_init')) { + $recaptcha = new \ReCaptcha\ReCaptcha($secretKey, new \ReCaptcha\RequestMethod\CurlPost()); + } elseif (@ini_get('allow_url_fopen')) { + $recaptcha = new \ReCaptcha\ReCaptcha($secretKey, new \ReCaptcha\RequestMethod\Post()); + } else { + $recaptcha = new \ReCaptcha\ReCaptcha($secretKey, new \ReCaptcha\RequestMethod\SocketPost()); + } + + $resp = $recaptcha->verify(@$_POST['g-recaptcha-response'], RECAPTCHA_getIP()); + + if (!$resp->isSuccess()) { + $msg = implode(', ', $resp->getErrorCodes()); + + if ($_RECAPTCHA_CONF['logging']) { + $entry = sprintf( + RECAPTCHA_str('entry_error', true), + $type, + $_SERVER['REMOTE_ADDR'], + $msg + ); + $entry = RECAPTCHA_esc($entry); + RECAPTCHA_errorLog($entry); + } + } + } + + return $msg; } /** -* Callback function to add HTML text for reCAPTCHA -* -* @param string $type -* @param object $template a reference to a Template class object -* @return void -*/ -function plugin_templatesetvars_recaptcha($type, &$template) { - global $_RECAPTCHA_CONF; - - if (RECAPTCHA_isEnabled() && RECAPTCHA_requireCaptcha($type)) { - $lang = RECAPTCHA_getLangCode(); - $captcha = '
' - . ''; -; - } else { - $captcha = ''; - } - - $template->set_var('captcha', $captcha); + * Writes an entry into a log file + * + * @param string $logEntry + * @param int $override + */ +function RECAPTCHA_errorLog($logEntry, $override = 0) +{ + global $_CONF, $_RECAPTCHA_CONF; + + if (!isset($_RECAPTCHA_CONF['logging'])) { + $_RECAPTCHA_CONF['logging'] = 0; + } + + if (($_RECAPTCHA_CONF['logging'] != 1) && ($override == 0)) { + return; + } + + if (!empty($logEntry)) { + $timestamp = date('Y-m-d H:i:s'); + $logfile = $_CONF['path_log'] . 'recaptcha.log'; + $entry = "{$timestamp} - {$logEntry} " . PHP_EOL; + $isSuccess = false; + + for ($i = 0; $i < 10; $i++) { + $isSuccess = (@file_put_contents($logfile, $entry, FILE_APPEND | LOCK_EX) !== false); + + if ($isSuccess) { + break; + } + } + + if (!$isSuccess) { + COM_errorLog(__FUNCTION__ . ': cannot open "' . $logfile . '"'); + } + } } /** -* Callback function to check the code entered by a user -* -* @param (not used in this function) -* @param object $template a reference to a Template class object -* @return string empty = success -*/ -function plugin_commentPreSave_recaptcha($uid, $title, $comment, $sid, $pid, $type, $postmode) { - return plugin_itemPreSave_recaptcha('comment', ''); + * Loads config info with config.class.php + */ +function RECAPTCHA_loadConfig() +{ + global $_RECAPTCHA_CONF, $_RECAPTCHA_DEFAULT, $_TABLES; + + $config = config::get_instance(); + + if ($config->group_exists('recaptcha')) { + $_RECAPTCHA_CONF = array_merge($_RECAPTCHA_CONF, $config->get_config('recaptcha')); + } else { + COM_errorLog(__FUNCTION__ . ': cannot load configuration. Using default settings instead'); + require_once __DIR__ . '/install_defaults.php'; + $_RECAPTCHA_CONF = $_RECAPTCHA_DEFAULT; + } + + // Silently update the plugin + $pi_version = DB_getItem($_TABLES['plugins'], 'pi_version', "pi_name = 'recaptcha'"); + + if (version_compare($pi_version, $_RECAPTCHA_CONF['pi_version'], '<')) { + plugin_upgrade_recaptcha(); + } } /** -* Callback function to check the code entered by a user -* -* @param string $type item type -* @param object $template a reference to a Template class object -* @return string empty = success -*/ -function plugin_itemPreSave_recaptcha($type, $content = '') { - global $_RECAPTCHA_CONF; - - $msg = ''; - - if (RECAPTCHA_isEnabled() && RECAPTCHA_requireCaptcha($type)) { - if (is_callable('curl_init')) { - $recaptcha = new \ReCaptcha\ReCaptcha($_RECAPTCHA_CONF['private_key'], new \ReCaptcha\RequestMethod\CurlPost()); - } elseif (@ini_get('allow_url_fopen')) { - $recaptcha = new \ReCaptcha\ReCaptcha($_RECAPTCHA_CONF['private_key'], new \ReCaptcha\RequestMethod\Post()); - } else { - $recaptcha = new \ReCaptcha\ReCaptcha($_RECAPTCHA_CONF['private_key'], new \ReCaptcha\RequestMethod\SocketPost()); - } - - $resp = $recaptcha->verify(@$_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); - - if (!$resp->isSuccess()) { - $msg = implode(', ', $resp->getErrorCodes()); - - if ($_RECAPTCHA_CONF['logging']) { - $entry = sprintf( - RECAPTCHA_str('entry_error', true), - $type, - $_SERVER['REMOTE_ADDR'], - $msg - ); - $entry = RECAPTCHA_esc($entry); - RECAPTCHA_errorLog($entry); - } - } - } - - return $msg; + * Returns a string escaped for HTML output + * + * @param string $str + * @return string + */ +function RECAPTCHA_esc($str) +{ + global $_CONF; + + static $encoding = null; + + if ($encoding === null) { + $encoding = is_callable('COM_getCharset') + ? COM_getCharset() + : $_CONF['default_charset']; + } + + if (version_compare(PHP_VERSION, '5.2.3') >= 0) { + return htmlspecialchars($str, ENT_QUOTES, $encoding, false); + } else { + return str_replace( + array('&&', '&<', '&>', '&"', '&''), + array('&', '<:', '>', '"', '''), + htmlspecialchars($str, ENT_QUOTES, $encoding) + ); + } } /** -* Writes an entry into a log file -* -* @param string $logEntry -* @param int $override -*/ -function RECAPTCHA_errorLog($logEntry, $override = 0) { - global $_CONF, $_RECAPTCHA_CONF; - - if (!isset($_RECAPTCHA_CONF['logging'])) { - $_RECAPTCHA_CONF['logging'] = 0; - } - - if (($_RECAPTCHA_CONF['logging'] != 1) && ($override == 0)) { - return; - } - - if (!empty($logEntry)) { - $timestamp = date('Y-m-d H:i:s'); - $logfile = $_CONF['path_log'] . 'recaptcha.log'; - $entry = "{$timestamp} - {$logEntry} \n"; - - if (($file = @fopen($logfile, 'a')) !== false) { - fputs($file, "$timestamp - $logEntry \n"); - fclose($file); - } else { - COM_errorLog(__FUNCTION__ . ': cannot open "' . $logfile . '"'); - } - } + * Return a lang var + * + * @param string $index + * @param bool $noEsc + * @return string + */ +function RECAPTCHA_str($index, $noEsc = false) +{ + global $LANG_RECAPTCHA; + + if (isset($LANG_RECAPTCHA[$index])) { + return $noEsc ? $LANG_RECAPTCHA[$index] : RECAPTCHA_esc($LANG_RECAPTCHA[$index]); + } else { + COM_errorLog(__FUNCTION__ . ': undefined index: "' . $index . '"'); + + return '(undefined)'; + } } /** -* Loads config info with config.class.php -*/ -function RECAPTCHA_loadConfig() { - global $_CONF, $_RECAPTCHA_CONF; - - $config = config::get_instance(); - - if ($config->group_exists('recaptcha')) { - $_RECAPTCHA_CONF = array_merge($_RECAPTCHA_CONF, $config->get_config('recaptcha')); - } else { - COM_errorLog(__FUNCTION__ . ': cannot load configuration. Using default setiings instead'); - require_once 'install_defaults.php'; - $_RECAPTCHA_CONF = $_RC_DEFAULT; - } + * Returns if the current type of item requires reCAPTCHA + * + * @param string $type item type + * @return bool true = requires reCAPTCHA + */ +function RECAPTCHA_requireCaptcha($type) +{ + global $_RECAPTCHA_CONF, $_USER; + + // This item is not supported + if (!in_array($type, $_RECAPTCHA_CONF['supported_items'])) { + return false; + } + + switch ($_RECAPTCHA_CONF['enable_' . $type]) { + case 0: + // Disabled for this item + return false; + + case 1: + // reCAPTCHA v2 enabled + if (!RECAPTCHA_isRecaptchaEnabled()) { + return false; + } + break; + + case 2: + // Invisible reCAPTCHA enabled + if (!RECAPTCHA_isInvisibleRecaptchaEnabled()) { + return false; + } + break; + + } + + if (!isset($_USER['uid'])) { + $_USER['uid'] = 1; + } + + if (($_RECAPTCHA_CONF['anonymous_only'] && ($_USER['uid'] < 2)) || + ($_RECAPTCHA_CONF['anonymous_only'] == 0) || + (($_RECAPTCHA_CONF['remoteusers'] == 1) && SEC_inGroup('Remote Users'))) { + return true; + } + + return false; } /** -* Returns a string escaped for HTML output -*/ -function RECAPTCHA_esc($str) { - global $_CONF; - - static $encoding = null; - - if ($encoding === null) { - $encoding = is_callable('COM_getCharset') - ? COM_getCharset() - : $_CONF['default_charset']; - } - - if (version_compare(PHP_VERSION, '5.2.3') >= 0) { - return htmlspecialchars($str, ENT_QUOTES, $encoding, false); - } else { - return str_replace( - array('&&', '&<', '&>', '&"', '&''), - array('&', '<:', '>', '"', '''), - htmlspecialchars($str, ENT_QUOTES, $encoding) - ); - } + * Returns if reCAPTCHA keys are set + * + * @return bool true = OK + */ +function RECAPTCHA_isRecaptchaEnabled() +{ + global $_RECAPTCHA_CONF; + + return ($_RECAPTCHA_CONF['secret_key'] !== '') && ($_RECAPTCHA_CONF['site_key'] !== ''); } /** -* Returns a lang var -*/ -function RECAPTCHA_str($index, $noesc = false) { - global $LANG_RECAPTCHA; - - if (isset($LANG_RECAPTCHA[$index])) { - return $noesc ? $LANG_RECAPTCHA[$index] : RECAPTCHA_esc($LANG_RECAPTCHA[$index]); - } else { - COM_errorLog(__FUNCTION__ . ': undefined index: "' . $index . '"'); - return '(undefined)'; - } + * Returns if Invisible reCAPTCHA keys are set + * + * @return bool true = OK + */ +function RECAPTCHA_isInvisibleRecaptchaEnabled() +{ + global $_RECAPTCHA_CONF; + + return ($_RECAPTCHA_CONF['invisible_site_key'] !== '') && ($_RECAPTCHA_CONF['invisible_secret_key'] !== ''); } /** -* Returns if the current type of item requires reCAPTCHA -* -* @param string $type item type -* @return boolean true = requires reCAPTCHA -*/ -function RECAPTCHA_requireCaptcha($type) { - global $_RECAPTCHA_CONF, $_USER; - - if (!RECAPTCHA_isEnabled()) { - return false; - } - - if ((in_array($type, $_RECAPTCHA_CONF['supported_items']) && - ($_RECAPTCHA_CONF['enable_' . $type] == 0)) || - !in_array($type, $_RECAPTCHA_CONF['supported_items'])) { - return false; - } - - if (!isset($_USER['uid'])) { - $_USER['uid'] = 1; - } - - if (($_RECAPTCHA_CONF['anonymous_only'] && ($_USER['uid'] < 2)) || - ($_RECAPTCHA_CONF['anonymous_only'] == 0) || - (($_RECAPTCHA_CONF['remoteusers'] == 1) && SEC_inGroup('Remote Users'))) { - return true; - } - - return false; + * Return language codes used by Google + * + * @return string + * @link https://developers.google.com/recaptcha/docs/language + */ +function RECAPTCHA_getLangCode() +{ + $mapping = array( + // GL language name => Google language code + 'afrikaans' => 'af', + 'bosnian' => 'en', // Not supported by Google + 'bulgarian' => 'bg', + 'catalan' => 'ca', + 'chinese_simplified' => 'zh-CN', + 'chinese_traditional' => 'zh-TW', + 'croatian' => 'hr', + 'czech' => 'cs', + 'danish' => 'da', + 'dutch' => 'nl', + 'english' => 'en', + 'estonian' => 'et', + 'farsi' => 'fa', + 'finnish' => 'fi', + 'french_canada' => 'fr-CA', + 'french_france' => 'fr', + 'german' => 'de', + 'german_formal' => 'de', + 'hebrew' => 'iw', + 'hellenic' => 'el', + 'indonesian' => 'id', + 'italian' => 'it', + 'japanese' => 'ja', + 'korean' => 'ko', + 'norwegian' => 'no', + 'polish' => 'pl', + 'portuguese' => 'pt', + 'portuguese_brazil' => 'pt-BR', + 'romanian' => 'ro', + 'russian' => 'ru', + 'serbian' => 'sr', + 'slovak' => 'sk', + 'slovenian' => 'sl', + 'spanish' => 'es', + 'spanish_argentina' => 'es-419', + 'swedish' => 'sv', + 'turkish' => 'tr', + 'ukrainian' => 'uk', + 'ukrainian_koi8-u' => 'uk', + ); + + $langName = COM_getLanguage(); + $langName = strtolower($langName); + $langName = str_replace('_utf-8', '', $langName); + + return isset($mapping[$langName]) ? $mapping[$langName] : 'en'; } /** -* Returns if the plugin is ready to work -* -* @return boolean true = OK -*/ -function RECAPTCHA_isEnabled() { - global $_RECAPTCHA_CONF; - - return ($_RECAPTCHA_CONF['private_key'] !== '') && ($_RECAPTCHA_CONF['public_key'] !== ''); + * Return IP address + * + * @return string + */ +function RECAPTCHA_getIP() +{ + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { + $ip = $_SERVER['HTTP_CLIENT_IP']; + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; + } else { + $ip = $_SERVER['REMOTE_ADDR']; + } + + return $ip; } /** -* Return language codes used by Google -* -* @return string -* @link https://developers.google.com/recaptcha/docs/language -*/ -function RECAPTCHA_getLangCode() { - $mapping = array( - // GL language name => Google language code - 'afrikaans' => 'en', // Not supported by Google - 'bosnian' => 'en', // Not supported by Google - 'bulgarian' => 'bg', - 'catalan' => 'ca', - 'chinese_simplified' => 'zh-CN', - 'chinese_traditional' => 'zh-TW', - 'croatian' => 'hr', - 'czech' => 'cs', - 'danish' => 'da', - 'dutch' => 'nl', - 'english' => 'en', - 'estonian' => 'et', - 'farsi' => 'fa', - 'finnish' => 'fi', - 'french_canada' => 'fr-CA', - 'french_france' => 'fr', - 'german' => 'de', - 'german_formal' => 'de', - 'hebrew' => 'iw', - 'hellenic' => 'el', - 'indonesian' => 'id', - 'italian' => 'it', - 'japanese' => 'ja', - 'korean' => 'ko', - 'norwegian' => 'no', - 'polish' => 'pl', - 'portuguese' => 'pt', - 'portuguese_brazil' => 'pt-BR', - 'romanian' => 'ro', - 'russian' => 'ru', - 'serbian' => 'sr', - 'slovak' => 'sk', - 'slovenian' => 'sl', - 'spanish' => 'es', - 'spanish_argentina' => 'es-419', - 'swedish' => 'sv', - 'turkish' => 'tr', - 'ukrainian' => 'uk', - 'ukrainian_koi8-u' => 'uk', - ); - - $langName = COM_getLanguage(); - $langName = strtolower($langName); - $langName = str_replace('_utf-8', '', $langName); - - return isset($mapping[$langName]) ? $mapping[$langName] : 'en'; + * Return the form id to which the user attaches Invisible reCAPTCHA + * + * @param string $type + * @return string + */ +function RECAPTCHA_getFormId($type) { + switch ($type) { + case 'comment': // OK + $formId = 'commentform'; + break; + + case 'story': // OK + $formId = 'submitstory'; + break; + + case 'registration': // OK + $formId = 'registrationform'; + break; + + case 'loginform': // OK + $formId = 'userloginform'; + break; + + case 'getpassword': // OK + $formId = 'getpasswordform'; + break; + + case 'contact': // OK + $formId = 'contactuserform'; + break; + + case 'emailstory': // OK + $formId = 'contactauthorform'; + break; + + case 'forum': + $formId = ''; + break; + + case 'mediagallery': + $formId = ''; + break; + + case 'rating': + $formId = ''; + break; + + case 'links': // OK + $formId = 'submitlink'; + break; + + case 'calendar': + $formId = 'submit_event_form'; + break; + + default: + $formId = ''; + } + + return $formId; } diff --git a/plugins/recaptcha/install_defaults.php b/plugins/recaptcha/install_defaults.php index 46f700238..d97f8011b 100644 --- a/plugins/recaptcha/install_defaults.php +++ b/plugins/recaptcha/install_defaults.php @@ -31,103 +31,116 @@ // +---------------------------------------------------------------------------+ 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 default settings -* -* Initial Installation Defaults used when loading the online configuration -* records. These settings are only used during the initial installation -* and not referenced any more once the plugin is installed -*/ + * reCAPTCHA default settings + * + * Initial Installation Defaults used when loading the online configuration + * records. These settings are only used during the initial installation + * and not referenced any more once the plugin is installed + */ global $_RECAPTCHA_DEFAULT; $_RECAPTCHA_DEFAULT = array( - 'public_key' => '', - 'private_key' => '', - 'logging' => 0, - 'anonymous_only' => 0, - 'remoteusers' => 0, - 'enable_comment' => 1, - 'enable_contact' => 1, - 'enable_emailstory' => 1, - 'enable_forum' => 1, - 'enable_registration' => 1, - 'enable_loginform' => 1, - 'enable_getpassword' => 1, - 'enable_mediagallery' => 1, - 'enable_rating' => 1, - 'enable_story' => 1, - 'enable_calendar' => 1, - 'enable_links' => 1, + 'site_key' => '', + 'secret_key' => '', + 'invisible_site_key' => '', + 'invisible_secret_key' => '', + + 'logging' => 0, + 'anonymous_only' => 0, + 'remoteusers' => 0, + + // 0 = disabled, 1 = reCAPTCHA v2, 2 = Invisible reCAPTCHA + 'enable_comment' => 1, + 'enable_contact' => 1, + 'enable_emailstory' => 1, + 'enable_forum' => 1, + 'enable_registration' => 1, + 'enable_loginform' => 1, + 'enable_getpassword' => 1, + 'enable_mediagallery' => 1, + 'enable_rating' => 1, + 'enable_story' => 1, + 'enable_calendar' => 1, + 'enable_links' => 1, ); /** -* Initializes reCAPTCHA plugin configuration -* -* Creates the database entries for the configuation if they don't already -* exist. Initial values will be taken from $_RECAPTCHA_DEFAULT -* if available (e.g. from an old config.php), uses $_RECAPTCHA_DEFAULT -* otherwise. -* -* @return boolean true: success; false: an error occurred -*/ -function plugin_initconfig_recaptcha() { - global $_RECAPTCHA_CONF, $_RECAPTCHA_DEFAULT; - - $c = config::get_instance(); - $me = 'recaptcha'; - $so = 10; + * Initializes reCAPTCHA plugin configuration + * + * Creates the database entries for the configuration if they don't already + * exist. Initial values will be taken from $_RECAPTCHA_DEFAULT + * if available (e.g. from an old config.php), uses $_RECAPTCHA_DEFAULT + * otherwise. + * + * @return bool true: success, false: an error occurred + */ +function plugin_initconfig_recaptcha() +{ + global $_RECAPTCHA_DEFAULT; - if (!$c->group_exists($me)) { - // Subgroup = 0 - $sg = 0; - $c->add('sg_main', null, 'subgroup', $sg, 0, null, 0, true, $me, 0); - $c->add('tab_main', null, 'tab', $sg, 0, null, 0, true, $me, 0); + $c = config::get_instance(); + $me = 'recaptcha'; + $so = 0; + $sg = 0; + $fs = 0; + $tab = 0; - // Fieldset = 0 - $fs = 0; - $c->add('fs_system', null, 'fieldset', $sg, $fs, null, 0, true, $me, 0); - $c->add('public_key', $_RECAPTCHA_DEFAULT['public_key'], 'text', $sg, $fs, null, $so, true, $me, 0); - $so += 10; - $c->add('private_key', $_RECAPTCHA_DEFAULT['private_key'], 'text', $sg, $fs, null, $so, true, $me, 0); - $so += 10; - $c->add('logging', $_RECAPTCHA_DEFAULT['logging'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; + if (!$c->group_exists($me)) { + // Subgroup = 0 + $c->add('sg_main', null, 'subgroup', $sg, $fs, null, $so, true, $me, $tab); + $c->add('tab_general', null, 'tab', $sg, $fs, null, $so, true, $me, $tab); - // Subgroup = 0, Fieldset = 1 - $fs++; - $c->add('fs_integration', null, 'fieldset', $sg, $fs, null, 0, true, $me, 0); - $c->add('anonymous_only', $_RECAPTCHA_DEFAULT['anonymous_only'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('remoteusers', $_RECAPTCHA_DEFAULT['remoteusers'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_comment', $_RECAPTCHA_DEFAULT['enable_comment'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_contact', $_RECAPTCHA_DEFAULT['enable_contact'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_emailstory', $_RECAPTCHA_DEFAULT['enable_emailstory'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_forum', $_RECAPTCHA_DEFAULT['enable_forum'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_registration', $_RECAPTCHA_DEFAULT['enable_registration'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_mediagallery', $_RECAPTCHA_DEFAULT['enable_mediagallery'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_rating', $_RECAPTCHA_DEFAULT['enable_rating'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_story', $_RECAPTCHA_DEFAULT['enable_story'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_calendar', $_RECAPTCHA_DEFAULT['enable_calendar'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_links', $_RECAPTCHA_DEFAULT['enable_links'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; + // Subgroup = 0, Fieldset = 0, Tab = 0 + $c->add('fs_system', null, 'fieldset', $sg, $fs, null, 0, true, $me, $tab); + $so += 10; + $c->add('site_key', $_RECAPTCHA_DEFAULT['site_key'], 'text', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('secret_key', $_RECAPTCHA_DEFAULT['secret_key'], 'text', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('invisible_site_key', $_RECAPTCHA_DEFAULT['inbisible_site_key'], 'text', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('invisible_secret_key', $_RECAPTCHA_DEFAULT['invisible_secret_key'], 'text', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('logging', $_RECAPTCHA_DEFAULT['logging'], 'select', $sg, $fs, 0, $so, true, $me, $tab); + $so += 10; + $c->add('anonymous_only', $_RECAPTCHA_DEFAULT['anonymous_only'], 'select', $sg, $fs, 0, $so, true, $me, $tab); + $so += 10; + $c->add('remoteusers', $_RECAPTCHA_DEFAULT['remoteusers'], 'select', $sg, $fs, 0, $so, true, $me, $tab); + $so += 10; - // Subgroup = 1, Fieldset = 0 - require_once dirname(__FILE__) . '/install_updates.php'; - recaptcha_update_ConfValues_1_1_5(); - } + // Subgroup = 0, Fieldset = 0, Tab = 1 + $tab++; + $c->add('tab_integration', null, 'tab', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('fs_integration', null, 'fieldset', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('enable_comment', $_RECAPTCHA_DEFAULT['enable_comment'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_contact', $_RECAPTCHA_DEFAULT['enable_contact'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_emailstory', $_RECAPTCHA_DEFAULT['enable_emailstory'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_forum', $_RECAPTCHA_DEFAULT['enable_forum'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_registration', $_RECAPTCHA_DEFAULT['enable_registration'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_getpassword', $_RECAPTCHA_DEFAULT['enable_getpassword'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_loginform', $_RECAPTCHA_DEFAULT['enable_loginform'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $c->add('enable_mediagallery', $_RECAPTCHA_DEFAULT['enable_mediagallery'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_rating', $_RECAPTCHA_DEFAULT['enable_rating'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_story', $_RECAPTCHA_DEFAULT['enable_story'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_calendar', $_RECAPTCHA_DEFAULT['enable_calendar'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_links', $_RECAPTCHA_DEFAULT['enable_links'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + } - return true; + return true; } diff --git a/plugins/recaptcha/install_updates.php b/plugins/recaptcha/install_updates.php index f55ba69b9..86e5ba2d3 100644 --- a/plugins/recaptcha/install_updates.php +++ b/plugins/recaptcha/install_updates.php @@ -31,24 +31,100 @@ // +---------------------------------------------------------------------------+ 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!'); } /** - * Update Configuration settings for reCAPTCHA plugin + * Update Configuration settings for reCAPTCHA plugin v1.1.5 * * @return bool true on success, false otherwise */ function recaptcha_update_ConfValues_1_1_5() { - $c = config::get_instance(); - $me = 'recaptcha'; - $sg = 0; - $fs = 1; - $so = 160; - $c->add('enable_getpassword', $_RECAPTCHA_DEFAULT['enable_getpassword'], 'select', $sg, $fs, 0, $so, true, $me, 0); - $so += 10; - $c->add('enable_loginform', $_RECAPTCHA_DEFAULT['enable_loginform'], 'select', $sg, $fs, 0, $so, true, $me, 0); - - return true; + global $_RECAPTCHA_DEFAULT; + + $c = config::get_instance(); + $me = 'recaptcha'; + $sg = 0; + $fs = 1; + $so = 160; + $c->add('enable_getpassword', $_RECAPTCHA_DEFAULT['enable_getpassword'], 'select', $sg, $fs, 0, $so, true, $me, 0); + $so += 10; + $c->add('enable_loginform', $_RECAPTCHA_DEFAULT['enable_loginform'], 'select', $sg, $fs, 0, $so, true, $me, 0); + + return true; +} + +/** + * Update Configuration settings for reCAPTCHA plugin v1.1.6 + * + * @return bool true on success, false otherwise + */ +function recaptcha_update_ConfValues_1_1_6() +{ + global $_RECAPTCHA_CONF, $_RECAPTCHA_DEFAULT, $_TABLES; + + // Delete old configuration values + $sql = "DELETE FROM {$_TABLES['conf_values']} WHERE group_name = 'recaptcha'"; + DB_query($sql); + + $c = config::get_instance(); + $me = 'recaptcha'; + $so = 0; + $sg = 0; + $fs = 0; + $tab = 0; + + // Subgroup = 0 + $c->add('sg_main', null, 'subgroup', $sg, $fs, null, $so, true, $me, $tab); + $c->add('tab_general', null, 'tab', $sg, $fs, null, $so, true, $me, $tab); + + // Subgroup = 0, Fieldset = 0, Tab = 0 + $c->add('fs_system', null, 'fieldset', $sg, $fs, null, 0, true, $me, $tab); + $so += 10; + $c->add('site_key', $_RECAPTCHA_CONF['public_key'], 'text', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('secret_key', $_RECAPTCHA_CONF['secret_key'], 'text', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('invisible_site_key', '', 'text', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('invisible_secret_key', '', 'text', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('logging', $_RECAPTCHA_CONF['logging'], 'select', $sg, $fs, 0, $so, true, $me, $tab); + $so += 10; + $c->add('anonymous_only', $_RECAPTCHA_CONF['anonymous_only'], 'select', $sg, $fs, 0, $so, true, $me, $tab); + $so += 10; + $c->add('remoteusers', $_RECAPTCHA_CONF['remoteusers'], 'select', $sg, $fs, 0, $so, true, $me, $tab); + $so += 10; + + // Subgroup = 0, Fieldset = 0, Tab = 1 + $tab++; + $c->add('tab_integration', null, 'tab', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('fs_integration', null, 'fieldset', $sg, $fs, null, $so, true, $me, $tab); + $so += 10; + $c->add('enable_comment', $_RECAPTCHA_CONF['enable_comment'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_contact', $_RECAPTCHA_CONF['enable_contact'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_emailstory', $_RECAPTCHA_CONF['enable_emailstory'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_forum', $_RECAPTCHA_CONF['enable_forum'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_registration', $_RECAPTCHA_CONF['enable_registration'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_getpassword', $_RECAPTCHA_CONF['enable_getpassword'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_loginform', $_RECAPTCHA_CONF['enable_loginform'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $c->add('enable_mediagallery', $_RECAPTCHA_CONF['enable_mediagallery'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_rating', $_RECAPTCHA_CONF['enable_rating'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_story', $_RECAPTCHA_CONF['enable_story'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_calendar', $_RECAPTCHA_CONF['enable_calendar'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + $so += 10; + $c->add('enable_links', $_RECAPTCHA_CONF['enable_links'], 'select', $sg, $fs, 2, $so, true, $me, $tab); + + return true; } diff --git a/plugins/recaptcha/language/english.php b/plugins/recaptcha/language/english.php index d4c7dc9ed..dbf6f8e06 100644 --- a/plugins/recaptcha/language/english.php +++ b/plugins/recaptcha/language/english.php @@ -30,55 +30,59 @@ // +---------------------------------------------------------------------------+ 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!'); } $LANG_RECAPTCHA = array( - 'plugin' => 'reCAPTCHA', - 'admin' => 'reCAPTCHA', - 'entry_error' => 'An invalid reCAPTCHA string was entered in %1s - IP Address: %2s - Error Codes: %3s', // %1s = $type, %2s = $ip, %3s = $errorCode + 'plugin' => 'reCAPTCHA', + 'admin' => 'reCAPTCHA', + 'entry_error' => 'An invalid reCAPTCHA string was entered in %1s - IP Address: %2s - Error Codes: %3s', // %1s = $type, %2s = $ip, %3s = $errorCode ); // Localization of the Admin Configuration UI $LANG_configsections['recaptcha'] = array( - 'label' => 'reCAPTCHA', - 'title' => 'reCAPTCHA Configuration' + 'label' => 'reCAPTCHA', + 'title' => 'reCAPTCHA Configuration', ); $LANG_confignames['recaptcha'] = array( - 'public_key' => 'reCAPTCHA API Site Key', - 'private_key' => 'reCAPTCHA API Secret Key', - 'logging' => 'Log invalid reCAPTCHA attempts', - 'anonymous_only' => 'Anonymous Only', - 'remoteusers' => 'Force reCAPTCHA for all Remote Users', - 'enable_comment' => 'Enable Comment Support' , - 'enable_contact' => 'Enable Contact Support', - 'enable_emailstory' => 'Enable Email Story Support', - 'enable_forum' => 'Enable Forum Support', - 'enable_registration' => 'Enable Registration Support', - 'enable_loginform' => 'Enable Login Form Support', - 'enable_getpassword' => 'Enable Get Password Form Support', - 'enable_mediagallery' => 'Enable Media Gallery (Postcards) Support', - 'enable_rating' => 'Enable Rating Plugin Support', - 'enable_story' => 'Enable Story Support', - 'enable_calendar' => 'Enable Calendar Plugin Support', - 'enable_links' => 'Enable Links Plugin Support', + 'site_key' => 'reCAPTCHA v2 Site Key', + 'secret_key' => 'reCAPTCHA v2 Secret Key', + 'invisible_site_key' => 'Invisible reCAPTCHA Site Key', + 'invisible_secret_key' => 'Invisible reCAPTCHA Secret Key', + 'logging' => 'Log invalid reCAPTCHA attempts', + 'anonymous_only' => 'Anonymous Only', + 'remoteusers' => 'Force reCAPTCHA for all Remote Users', + 'enable_comment' => 'Enable Comment Support', + 'enable_contact' => 'Enable Contact Support', + 'enable_emailstory' => 'Enable Email Story Support', + 'enable_forum' => 'Enable Forum Support', + 'enable_registration' => 'Enable Registration Support', + 'enable_loginform' => 'Enable Login Form Support', + 'enable_getpassword' => 'Enable Get Password Form Support', + 'enable_mediagallery' => 'Enable Media Gallery (Postcards) Support', + 'enable_rating' => 'Enable Rating Plugin Support', + 'enable_story' => 'Enable Story Support', + 'enable_calendar' => 'Enable Calendar Plugin Support', + 'enable_links' => 'Enable Links Plugin Support', ); $LANG_configsubgroups['recaptcha'] = array( - 'sg_main' => 'Main Settings', + 'sg_main' => 'Main Settings', ); $LANG_tab['recaptcha'] = array( - 'tab_main' => 'reCAPTCHA Settings', + 'tab_general' => 'reCAPTCHA Settings', + 'tab_integration' => 'Geeklog Integration', ); $LANG_fs['recaptcha'] = array( - 'fs_system' => 'System', - 'fs_integration' => 'Integration', + 'fs_system' => 'System', + 'fs_location' => 'Where to use reCAPTCHA', ); // Note: entries 0, 1, 9, and 12 are the same as in $LANG_configselects['Core'] $LANG_configselects['recaptcha'] = array( - 0 => array('Yes' => 1, 'No' => 0), + 0 => array('Yes' => 1, 'No' => 0), + 2 => array('Disabled' => 0, 'reCAPTCHA v2' => 1, 'Invisible reCAPTCHA' => 2), ); diff --git a/plugins/recaptcha/language/french_france_utf-8.php b/plugins/recaptcha/language/french_france_utf-8.php index 4e7c50506..35beb41d6 100644 --- a/plugins/recaptcha/language/french_france_utf-8.php +++ b/plugins/recaptcha/language/french_france_utf-8.php @@ -30,55 +30,59 @@ // +---------------------------------------------------------------------------| 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!'); } $LANG_RECAPTCHA = array( - 'plugin' => 'reCAPTCHA', - 'admin' => 'reCAPTCHA', - 'entry_error' => 'An invalid reCAPTCHA string was entered in %1s - IP Address: %2s - Error Codes: %3s', // %1s = $type, %2s = $ip, %3s = $errorCode -)); + 'plugin' => 'reCAPTCHA', + 'admin' => 'reCAPTCHA', + 'entry_error' => 'An invalid reCAPTCHA string was entered in %1s - IP Address: %2s - Error Codes: %3s', // %1s = $type, %2s = $ip, %3s = $errorCode +); // Localization of the Admin Configuration UI $LANG_configsections['recaptcha'] = array( - 'label' => 'reCAPTCHA', - 'title' => 'reCAPTCHA Configuration' + 'label' => 'reCAPTCHA', + 'title' => 'reCAPTCHA Configuration', ); $LANG_confignames['recaptcha'] = array( - 'public_key' => 'reCAPTCHA API Site Key', - 'private_key' => 'reCAPTCHA API Secret Key', - 'logging' => 'Log invalid reCAPTCHA attempts', - 'anonymous_only' => 'Anonymous Only', - 'remoteusers' => 'Force CAPTCHA for all Remote Users', - 'enable_comment' => 'Enable Comment Support', - 'enable_contact' => 'Enable Contact Support', - 'enable_emailstory' => 'Enable Email Story Support', - 'enable_forum' => 'Enable Forum Support', - 'enable_registration' => 'Enable Registration Support', - 'enable_loginform' => 'Enable Login Form Support', - 'enable_getpassword' => 'Enable Get Password Form Support', - 'enable_mediagallery' => 'Enable Media Gallery (Postcards) Support', - 'enable_rating' => 'Enable Rating Plugin Support', - 'enable_story' => 'Enable Story Support', - 'enable_calendar' => 'Enable Calendar Plugin Support', - 'enable_links' => 'Enable Links Plugin Support', + 'site_key' => 'reCAPTCHA v2 Site Key', + 'secret_key' => 'reCAPTCHA v2 Secret Key', + 'invisible_site_key' => 'Invisible reCAPTCHA Site Key', + 'invisible_secret_key' => 'Invisible reCAPTCHA Secret Key', + 'logging' => 'Log invalid reCAPTCHA attempts', + 'anonymous_only' => 'Anonymous Only', + 'remoteusers' => 'Force CAPTCHA for all Remote Users', + 'enable_comment' => 'Enable Comment Support', + 'enable_contact' => 'Enable Contact Support', + 'enable_emailstory' => 'Enable Email Story Support', + 'enable_forum' => 'Enable Forum Support', + 'enable_registration' => 'Enable Registration Support', + 'enable_loginform' => 'Enable Login Form Support', + 'enable_getpassword' => 'Enable Get Password Form Support', + 'enable_mediagallery' => 'Enable Media Gallery (Postcards) Support', + 'enable_rating' => 'Enable Rating Plugin Support', + 'enable_story' => 'Enable Story Support', + 'enable_calendar' => 'Enable Calendar Plugin Support', + 'enable_links' => 'Enable Links Plugin Support', ); $LANG_configsubgroups['recaptcha'] = array( - 'sg_main' => 'Main Settings' + 'sg_main' => 'Main Settings', ); $LANG_tab['recaptcha'] = array( - 'tab_main' => 'General Captcha Settings' + 'tab_general' => 'reCAPTCHA Settings', + 'tab_integration' => 'Geeklog Integration', ); $LANG_fs['recaptcha'] = array( - 'fs_system' => 'System', - 'fs_integration' => 'Integration', + 'fs_system' => 'System', + 'fs_location' => 'Where to use reCAPTCHA', ); -// Note: entries 0 is the same as in $LANG_configselects['Core'] +// Note: entries 0, 1, 9, and 12 are the same as in $LANG_configselects['Core'] $LANG_configselects['recaptcha'] = array( - 0 => array('Yes' => 1, 'No' => 0), + 0 => array('Yes' => 1, 'No' => 0), + 2 => array('Disabled' => 0, 'reCAPTCHA v2' => 1, 'Invisible reCAPTCHA' => 2), ); diff --git a/plugins/recaptcha/language/japanese_utf-8.php b/plugins/recaptcha/language/japanese_utf-8.php index f88ac2f69..8175a9a12 100644 --- a/plugins/recaptcha/language/japanese_utf-8.php +++ b/plugins/recaptcha/language/japanese_utf-8.php @@ -30,55 +30,59 @@ // +---------------------------------------------------------------------------| 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!'); } -$LANG_RECAPTCHA = array ( - 'plugin' => 'reCAPTCHA', - 'admin' => 'reCAPTCHA', - 'entry_error' => '%1sで無効な入力を検出しました。IPアドレス: %2s エラーコード: %3s', // %1s = $type, %2s = $ip, %3s = $errorCode +$LANG_RECAPTCHA = array( + 'plugin' => 'reCAPTCHA', + 'admin' => 'reCAPTCHA', + 'entry_error' => '%1sで無効な入力を検出しました。IPアドレス: %2s エラーコード: %3s', // %1s = $type, %2s = $ip, %3s = $errorCode ); // Localization of the Admin Configuration UI $LANG_configsections['recaptcha'] = array( - 'label' => 'reCAPTCHA', - 'title' => 'reCAPTCHAの設定', + 'label' => 'reCAPTCHA', + 'title' => 'reCAPTCHAの設定', ); $LANG_confignames['recaptcha'] = array( - 'public_key' => 'reCAPTCHA API Site Key', - 'private_key' => 'reCAPTCHA API Secret Key', - 'logging' => '無効な入力をログファイルに記録する', - 'anonymous_only' => 'ゲストユーザーに対してのみ使用する', - 'remoteusers' => 'リモートユーザー全員に強制する', - 'enable_comment' => 'コメントをサポートする' , - 'enable_contact' => 'メール送信をサポートする', - 'enable_emailstory' => '「記事をメールする」をサポートする', - 'enable_forum' => '掲示板プラグインをサポートする', - 'enable_registration' => 'ユーザー登録をサポートする', - 'enable_loginform' => 'ログインフォームをサポートする', - 'enable_getpassword' => 'パスワード再設定フォームをサポートする', - 'enable_mediagallery' => 'メディアギャラリープラグインをサポートする', - 'enable_rating' => 'レーティングプラグインをサポートする', - 'enable_story' => '記事投稿をサポートする', - 'enable_calendar' => 'カレンダープラグインをサポートする', - 'enable_links' => 'リンクプラグインをサポートする', + 'site_key' => 'reCAPTCHA v2 Site Key', + 'secret_key' => 'reCAPTCHA v2 Secret Key', + 'invisible_site_key' => 'Invisible reCAPTCHA Site Key', + 'invisible_secret_key' => 'Invisible reCAPTCHA Secret Key', + 'logging' => '無効な入力をログファイルに記録する', + 'anonymous_only' => 'ゲストユーザーに対してのみ使用する', + 'remoteusers' => 'リモートユーザー全員に強制する', + 'enable_comment' => 'コメントをサポートする', + 'enable_contact' => 'メール送信をサポートする', + 'enable_emailstory' => '「記事をメールする」をサポートする', + 'enable_forum' => '掲示板プラグインをサポートする', + 'enable_registration' => 'ユーザー登録をサポートする', + 'enable_loginform' => 'ログインフォームをサポートする', + 'enable_getpassword' => 'パスワード再設定フォームをサポートする', + 'enable_mediagallery' => 'メディアギャラリープラグインをサポートする', + 'enable_rating' => 'レーティングプラグインをサポートする', + 'enable_story' => '記事投稿をサポートする', + 'enable_calendar' => 'カレンダープラグインをサポートする', + 'enable_links' => 'リンクプラグインをサポートする', ); $LANG_configsubgroups['recaptcha'] = array( - 'sg_main' => '主要設定' + 'sg_main' => '主要設定', ); $LANG_tab['recaptcha'] = array( - 'tab_main' => 'reCAPTCHA設定', + 'tab_general' => 'reCAPTCHA設定', + 'tab_integration' => 'Geeklogへの統合', ); $LANG_fs['recaptcha'] = array( - 'fs_system' => 'システム', - 'fs_integration' => 'Geeklogへの統合', + 'fs_system' => 'システム', + 'fs_location' => '使用箇所', ); // Note: entries 0, 1, 9, and 12 are the same as in $LANG_configselects['Core'] $LANG_configselects['recaptcha'] = array( - 0 => array('はい' => 1, 'いいえ' => 0), + 0 => array('はい' => 1, 'いいえ' => 0), + 2 => array('無効' => 0, 'reCAPTCHA v2' => 1, 'Invisible reCAPTCHA' => 2), ); diff --git a/public_html/admin/plugins/recaptcha/docs/english/config.html b/public_html/admin/plugins/recaptcha/docs/english/config.html index caefb3a0f..a97a836ee 100644 --- a/public_html/admin/plugins/recaptcha/docs/english/config.html +++ b/public_html/admin/plugins/recaptcha/docs/english/config.html @@ -1,9 +1,9 @@ - - Geeklog reCAPTCHA plugin - Configuration - + + Geeklog reCAPTCHA plugin - Configuration + @@ -13,86 +13,134 @@

reCAPTCHA® Plugin Configuration

System

- - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VariableDefault ValueDescription
public_key(empty)reCAPTCHA API Site Key. If you don't have one, please go to https://www.google.com/recaptcha/admin/create and sign up.
private_key(empty)reCAPTCHA API Secret Key. If you don't have one, please go to https://www.google.com/recaptcha/admin/create and sign up.
loggingNoIf you set this to Yes, reCAPTCHA plugin will log invalid reCAPTCHA attempts into the log file (recaptcha.log).
VariableDefault ValueDescription
site_key(empty)reCAPTCHA API Site Key. If you don't have one, please go to https://www.google.com/recaptcha/admin/create + and sign up. +
secret_key(empty)reCAPTCHA API Secret Key. If you don't have one, please go to https://www.google.com/recaptcha/admin/create + and sign up. +
invisible_site_key(empty)Invisible reCAPTCHA API Site Key. If you don't have one, please go to https://www.google.com/recaptcha/admin/create + and sign up. +
invisible_secret_key(empty)Invisible reCAPTCHA API Secret Key. If you don't have one, please go to https://www.google.com/recaptcha/admin/create + and sign up. +
loggingNoIf you set this to Yes, reCAPTCHA plugin will log invalid reCAPTCHA attempts into the log file + (recaptcha.log). +

Integration

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VariableDefault ValueDescription
anonymous_onlyNoIf you set this to Yes, reCAPTCHA will be shown to anonymous users only.
remoteusersNoIf you set this to Yes, reCAPTCHA will be forced upon all Remote Users.
enable_commentYesIf you set this to Yes, reCAPTCHA will be enabled for comments.
enable_contactYesIf you set this to Yes, reCAPTCHA will be enabled for contact.
enable_emailstoryYesIf you set this to Yes, reCAPTCHA will be enabled for emailing a story.
enable_forumYesIf you set this to Yes, reCAPTCHA will be enabled for the Forum plugin.
enable_registrationYesIf you set this to Yes, reCAPTCHA will be enabled for user registration.
enable_mediagalleryYesIf you set this to Yes, reCAPTCHA will be enabled for the Mediagallery plugin.
enable_ratingYesIf you set this to Yes, reCAPTCHA will be enabled for the Rating plugin.
enable_storyYesIf you set this to Yes, reCAPTCHA will be enabled for submitting a story.
enable_calendarYesIf you set this to Yes, reCAPTCHA will be enabled for the Calendar plugin.
enable_linksYesIf you set this to Yes, reCAPTCHA will be enabled for the Links plugin.
enable_getpasswordYesIf you set this to Yes, reCAPTCHA will be enabled for Forget Password Form.
enable_loginfotmYesIf you set this to Yes, reCAPTCHA will be enabled for Login Form.
VariableDefault ValueDescription
anonymous_onlyNoIf you set this to Yes, reCAPTCHA will be shown to anonymous users only.
remoteusersNoIf you set this to Yes, reCAPTCHA will be forced upon all Remote Users.
enable_commentYesIf you set this to Yes, reCAPTCHA will be enabled for comments.
enable_contactYesIf you set this to Yes, reCAPTCHA will be enabled for contact.
enable_emailstoryYesIf you set this to Yes, reCAPTCHA will be enabled for emailing a story.
enable_forumYesIf you set this to Yes, reCAPTCHA will be enabled for the Forum plugin.
enable_registrationYesIf you set this to Yes, reCAPTCHA will be enabled for user registration.
enable_mediagalleryYesIf you set this to Yes, reCAPTCHA will be enabled for the Mediagallery plugin.
enable_ratingYesIf you set this to Yes, reCAPTCHA will be enabled for the Rating plugin.
enable_storyYesIf you set this to Yes, reCAPTCHA will be enabled for submitting a story.
enable_calendarYesIf you set this to Yes, reCAPTCHA will be enabled for the Calendar plugin.
enable_linksYesIf you set this to Yes, reCAPTCHA will be enabled for the Links plugin.
enable_getpasswordYesIf you set this to Yes, reCAPTCHA will be enabled for Forget Password Form.
enable_loginfotmYesIf you set this to Yes, reCAPTCHA will be enabled for Login Form.
diff --git a/public_html/admin/plugins/recaptcha/docs/english/install.html b/public_html/admin/plugins/recaptcha/docs/english/install.html index d48bd28e9..13249585b 100644 --- a/public_html/admin/plugins/recaptcha/docs/english/install.html +++ b/public_html/admin/plugins/recaptcha/docs/english/install.html @@ -1,10 +1,10 @@ - - - - Geeklog reCAPTCHA plugin + + + + Geeklog reCAPTCHA plugin @@ -12,117 +12,167 @@

Install/Uninstall/Upgrade instruction for the Geeklog reCAPTCHA plugin

What is reCAPTCHA?

-

ReCAPTCHA® is a free anti-bot service providing powerful CAPTCHA. This plugin makes it easy to use reCAPTCHA with Geeklog.

+

ReCAPTCHA® is a free anti-bot service providing powerful CAPTCHA. This + plugin makes it easy to use reCAPTCHA with Geeklog.

System Requirements

    -
  • Since v1.1.0, PHP-5.3.2 or later is required. Maybe PHP-5-3.0 or PHP-5.3.1 will do, but I am not sure.
  • -
  • Since v1.1.6, Geeklog 1.8.0 or newer is required.
  • +
  • Since v1.1.0, PHP-5.3.2 or later is required. Maybe PHP-5-3.0 or PHP-5.3.1 + will do, but I am not sure. +
  • +
  • Since v1.1.6, Geeklog 1.8.0 or newer is required.
  • +
  • Since v1.2.0, Geeklog 2.2.0 or newer is required.

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>)
  • +
  • <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. -
  3. Create the admin directory. Under your <admin>/plugins/ directory, create a directory called recaptcha.
  4. -
  5. 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.
  6. -
  7. 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.
  8. -
  9. Important: Set up API keys. Go to the Configuration and enter reCAPTCHA API Site Key and Secret Key that you can get at https://www.google.com/recaptcha/admin/create. It is not until you set the API keys that you can use reCAPTCHA service.
  10. +
  11. Uncompress the recaptcha plugin archive while in the <geeklog_dir>/plugins + directory. The archive will create a directory called recaptcha in the plugins directory. +
  12. +
  13. Create the admin directory. Under your <admin>/plugins/ directory, create a + directory called recaptcha. +
  14. +
  15. 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. +
  16. +
  17. 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. +
  18. +
  19. Important: Set up API keys. Go to the Configuration and + enter reCAPTCHA API Site Key and Secret Key that you can get at 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. -
  3. Delete the two plugin directories created in the install process: <geeklog-dir>/plugins/recaptcha/ and <admin>/plugins/recaptcha/.
  4. +
  5. 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. +
  6. +
  7. 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. -
  3. Uncompress the recaptcha plugin archive and upload the resulting files as you did when you installed the plugin.
  4. -
  5. Go to the plugin editor and Enable the reCAPTCHA plugin. Then, upgrade the plugin.
  6. +
  7. Log in to your Geeklog web site as a root user, go to the plugin editor and disable the reCAPTCHA plugin.
  8. +
  9. Uncompress the recaptcha plugin archive and upload the resulting files as you did when you installed the + plugin. +
  10. +
  11. Go to the plugin editor and Enable the reCAPTCHA plugin. Then, upgrade the plugin.

REVISION HISTORY

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VersionDate(YYYY-MM-DD)Description
1.1.62017-11-27 -
    -
  • Added support for Login Form.
  • -
  • Added support for Forget Password Form.
  • -
  • Added support for the demo mode intruduced in Geeklog 2.2.0.
  • -
-
1.1.52017-04-12 -
    -
  • Fixed a bug where reCAPTCHA failed to check for input when $_RECAPTCHA_CONF['logging'] is set to off.
  • -
-
1.1.42017-01-18 -
    -
  • Small bug fix.
  • -
-
1.1.32016-08-12 -
    -
  • Replaced COM_siteHeader and COM_siteFooter with COM_createHTMLDocument.
  • -
-
1.1.22016-02-20 -
    -
  • Upgraded reCAPTCHA library to v1.1.2.
  • -
-
1.1.02015-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.12014-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.02014-01-24Initial release.
VersionDate(YYYY-MM-DD)Description
1.2.02017-12-02 +
    +
  • Added support for Invisible reCAPTCHA.
  • +
  • Requires Geeklog 2.2.0.
  • +
+
1.1.62017-11-27 +
    +
  • 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.52017-04-12 +
    +
  • Fixed a bug where reCAPTCHA failed to check for input when $_RECAPTCHA_CONF['logging'] is set to + off. +
  • +
+
1.1.42017-01-18 +
    +
  • Small bug fix.
  • +
+
1.1.32016-08-12 +
    +
  • Replaced COM_siteHeader and COM_siteFooter with COM_createHTMLDocument.
  • +
+
1.1.22016-02-20 +
    +
  • Upgraded reCAPTCHA library to v1.1.2.
  • +
+
1.1.02015-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.12014-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.02014-01-24Initial release.
diff --git a/public_html/admin/plugins/recaptcha/docs/japanese/config.html b/public_html/admin/plugins/recaptcha/docs/japanese/config.html index 44681ada8..83cafdefe 100644 --- a/public_html/admin/plugins/recaptcha/docs/japanese/config.html +++ b/public_html/admin/plugins/recaptcha/docs/japanese/config.html @@ -1,9 +1,9 @@ - - Geeklog reCAPTCHAプラグインの設定 - + + Geeklog reCAPTCHAプラグインの設定 + @@ -13,86 +13,127 @@

reCAPTCHA®プラグインの設定

システム

- - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
項目(変数)デフォルト説明
public_key(未入力)reCAPTCHA APIのSite Keyを入力します。お持ちでない場合は、https://www.google.com/recaptcha/admin/createで登録して入手してください。
private_key(未入力)reCAPTCHA APIのSecret Keyを入力します。お持ちでない場合は、https://www.google.com/recaptcha/admin/createで登録して入手してください。
loggingいいえ「はい」にすると、reCAPTCHAは無効な入力をログファイル(recaptcha.log)に記録します。
項目(変数)デフォルト説明
site_key(未入力)reCAPTCHA APIのSite Keyを入力します。お持ちでない場合は、https://www.google.com/recaptcha/admin/createで登録して入手してください。 +
secret_key(未入力)reCAPTCHA APIのSecret Keyを入力します。お持ちでない場合は、https://www.google.com/recaptcha/admin/createで登録して入手してください。 +
invisible_site_key(未入力)Invisible reCAPTCHA APIのSite Keyを入力します。お持ちでない場合は、https://www.google.com/recaptcha/admin/createで登録して入手してください。 +
invisible_secret_key(未入力)Invisible reCAPTCHA APIのSecret Keyを入力します。お持ちでない場合は、https://www.google.com/recaptcha/admin/createで登録して入手してください。 +
loggingいいえ「はい」にすると、reCAPTCHAは無効な入力をログファイル(recaptcha.log)に記録します。

Geeklogへの統合

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
項目(変数)デフォルト説明
anonymous_onlyいいえ「はい」にすると、reCAPTCHAはゲストユーザーに対してのみ表示されます。
remoteusersいいえ「はい」にすると、reCAPTCHAが全てのリモートユーザーに対して強制されるようになります。
enable_commentはい「はい」にすると、reCAPTCHAがコメントに対して有効になります。
enable_contactはい「はい」にすると、reCAPTCHAがメール送信に対して有効になります。
enable_emailstoryはい「はい」にすると、reCAPTCHAが「記事をメールする」に対して有効になります。
enable_forumはい「はい」にすると、reCAPTCHAが掲示板プラグインに対して有効になります。
enable_registrationはい「はい」にすると、reCAPTCHAがユーザー登録の際に有効になります。
enable_mediagalleryはい「はい」にすると、reCAPTCHAがメディアギャラリー(Mediagallery)プラグインに対して有効になります。
enable_ratingはい「はい」にすると、reCAPTCHAがレーティング(Rating)プラグインに対して有効になります。
enable_storyはい「はい」にすると、reCAPTCHAが記事を投稿する際に有効になります。
enable_calendarはい「はい」にすると、reCAPTCHAがカレンダープラグインに対して有効になります。
enable_linksはい「はい」にすると、reCAPTCHAがリンクプラグインに対して有効になります。
enable_getpasswordはい「はい」にすると、reCAPTCHAがパスワード再設定フォームに対して有効になります。
enable_loginfotmYes「はい」にすると、reCAPTCHAがログインフォームに対して有効になります。
項目(変数)デフォルト説明
anonymous_onlyいいえ「はい」にすると、reCAPTCHAはゲストユーザーに対してのみ表示されます。
remoteusersいいえ「はい」にすると、reCAPTCHAが全てのリモートユーザーに対して強制されるようになります。
enable_commentはい「はい」にすると、reCAPTCHAがコメントに対して有効になります。
enable_contactはい「はい」にすると、reCAPTCHAがメール送信に対して有効になります。
enable_emailstoryはい「はい」にすると、reCAPTCHAが「記事をメールする」に対して有効になります。
enable_forumはい「はい」にすると、reCAPTCHAが掲示板プラグインに対して有効になります。
enable_registrationはい「はい」にすると、reCAPTCHAがユーザー登録の際に有効になります。
enable_mediagalleryはい「はい」にすると、reCAPTCHAがメディアギャラリー(Mediagallery)プラグインに対して有効になります。
enable_ratingはい「はい」にすると、reCAPTCHAがレーティング(Rating)プラグインに対して有効になります。
enable_storyはい「はい」にすると、reCAPTCHAが記事を投稿する際に有効になります。
enable_calendarはい「はい」にすると、reCAPTCHAがカレンダープラグインに対して有効になります。
enable_linksはい「はい」にすると、reCAPTCHAがリンクプラグインに対して有効になります。
enable_getpasswordはい「はい」にすると、reCAPTCHAがパスワード再設定フォームに対して有効になります。
enable_loginfotmYes「はい」にすると、reCAPTCHAがログインフォームに対して有効になります。
diff --git a/public_html/admin/plugins/recaptcha/docs/japanese/install.html b/public_html/admin/plugins/recaptcha/docs/japanese/install.html index 61202e04c..e5d1312ba 100644 --- a/public_html/admin/plugins/recaptcha/docs/japanese/install.html +++ b/public_html/admin/plugins/recaptcha/docs/japanese/install.html @@ -1,10 +1,10 @@ - - - - Geeklog reCAPTCHAプラグイン + + + + Geeklog reCAPTCHAプラグイン @@ -12,118 +12,155 @@

Geeklog reCAPTCHAプラグインのインストール/アンインストー

reCAPTCHAとは

-

ReCAPTCHA®は強力なCAPTCHAを提供する無料の対ボットシステムです。このプラグインを使うことで、GeeklogでreCAPTCHAを簡単に利用できるようになります。

+

ReCAPTCHA®は強力なCAPTCHAを提供する無料の対ボットシステムです。このプラグインを使うことで、GeeklogでreCAPTCHAを簡単に利用できるようになります。 +

システム要件

    -
  • バージョン1.1.0以降、PHP-5.3.2が必要になりました。PHP-5-3.0やPHP-5.3.1でも動作すると思いますが、確認はしていません。
  • -
  • バージョン1.1.6以降、Geeklog 1.8.0以降が必要になりました。
  • +
  • バージョン1.1.0以降、PHP-5.3.2が必要になりました。PHP-5-3.0やPHP-5.3.1でも動作すると思いますが、確認はしていません。 +
  • +
  • バージョン1.1.6以降、Geeklog 1.8.0以降が必要になりました。
  • +
  • バージョン1.2.0以降、Geeklog 2.2.0以降が必要になりました。

インストール

以下の説明で、

    -
  • <geeklog_dir>は、システムのdb-config.php が存在するディレクトリ
  • -
  • <admin>は、管理者用ファイルが存在するディレクトリ(ふつうは、<public_html>ディレクトリの下)
  • +
  • <geeklog_dir>は、システムのdb-config.php が存在するディレクトリ
  • +
  • <admin>は、管理者用ファイルが存在するディレクトリ(ふつうは、<public_html>ディレクトリの下) +

を表しています。

    -
  1. recaptchaプラグインのアーカイブを<geeklog_dir>/pluginsディレクトリに展開します。recaptchaという名前のディレクトリができます。
  2. -
  3. adminディレクトリを作ります。<admin>/plugins/ ディレクトリの下にrecaptchaという名前のディレクトリを作ります。
  4. -
  5. <geeklog_dir>/plugins/recaptcha/ ディレクトリに移動します。adminディレクトリの内容を、2.で作成した <admin>/plugins/recaptcha/ ディレクトリにコピーします。
  6. -
  7. 管理者としてログインし、プラグインエディタからインストールを実行します。失敗した場合には、エラーログ(error.log)を調べてください。
  8. -
  9. 重要: APIキーを設定します。https://www.google.com/recaptcha/admin/createでサインアップして、APIキーを入手してください。取得したSite KeyとSecret Keyをコンフィギュレーションで設定して初めて、reCAPTCHAを使用できるようになります
  10. +
  11. recaptchaプラグインのアーカイブを<geeklog_dir>/pluginsディレクトリに展開します。recaptchaという名前のディレクトリができます。 +
  12. +
  13. adminディレクトリを作ります。<admin>/plugins/ ディレクトリの下にrecaptchaという名前のディレクトリを作ります。
  14. +
  15. <geeklog_dir>/plugins/recaptcha/ ディレクトリに移動します。adminディレクトリの内容を、2.で作成した <admin>/plugins/recaptcha/ ディレクトリにコピーします。 +
  16. +
  17. 管理者としてログインし、プラグインエディタからインストールを実行します。失敗した場合には、エラーログ(error.log)を調べてください。
  18. +
  19. 重要: APIキーを設定します。https://www.google.com/recaptcha/admin/createでサインアップして、APIキーを入手してください。取得したSite + KeyとSecret Keyをコンフィギュレーションで設定して初めて、reCAPTCHAを使用できるようになります。 +

アンインストール

    -
  1. プラグインエディタから、recaptchaプラグインをアンインストールします。
  2. -
  3. インストールの過程で作成した2つのディレクトリ(<geeklog-dir>/plugins/recaptcha/と<admin>/plugins/recaptcha/ を削除します。
  4. +
  5. プラグインエディタから、recaptchaプラグインをアンインストールします。
  6. +
  7. インストールの過程で作成した2つのディレクトリ(<geeklog-dir>/plugins/recaptcha/と<admin>/plugins/recaptcha/ + を削除します。 +

アップグレード

    -
  1. 管理者としてサイトにログインしてから、プラグインエディタでreCAPTCHAプラグインを無効にします。
  2. -
  3. インストール時と同様に、recaptchaプラグインのアーカイブを展開してからサーバーにアップロードします。
  4. -
  5. プラグインエディタでreCAPTCHAを有効にしてから、アップグレードします。
  6. +
  7. 管理者としてサイトにログインしてから、プラグインエディタでreCAPTCHAプラグインを無効にします。
  8. +
  9. インストール時と同様に、recaptchaプラグインのアーカイブを展開してからサーバーにアップロードします。
  10. +
  11. プラグインエディタでreCAPTCHAを有効にしてから、アップグレードします。

更新履歴

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
バージョン日付(YYYY-MM-DD)説明
1.1.62017-11-27 -
    -
  • パスワード再設定フォームをサポートしました。
  • -
  • ログインフォームをサポートしました。
  • -
  • Geeklog 2.2.0で導入されるデモモードをサポートしました。
  • -
-
1.1.52017-04-12 -
    -
  • $_RECAPTCHA_CONF['logging']がfalseの場合に入力判定に失敗していたバグを修正しました。
  • -
-
1.1.42017-01-18 -
    -
  • 軽微なバグを修正しました。
  • -
-
1.1.32016-08-12 -
    -
  • COM_siteHeaderとCOM_siteFooterをCOM_createHTMLDocumentに置き換えました。
  • -
-
1.1.22016-02-20 -
    -
  • reCAPTCHAのライブラリをv1.1.2にアップグレードしました。
  • -
-
1.1.02015-07-03 -
    -
  • Google reCAPTCHA v2にアップグレードしました。
  • -
  • ログファイルの項目にエラーコードを追加しました。パッチ提供はTomさんです。
  • -
-
1.0.12014-01-26 -
    -
  • reCAPTCHAのコードをくるむ<div>タグを追加しました。パッチ提供はTomさんです。
  • -
  • エラーログを"logs/recaptch.log"に書き込むようにしました。パッチ提供はTomさんです。
  • -
-
1.0.02014-01-24最初のリリースです。
バージョン日付(YYYY-MM-DD)説明
1.2.02017-12-02 +
    +
  • Invisible reCAPTCHAをサポートしました。
  • +
  • Geeklog 2.2.0が必要になりました。
  • +
+
1.1.62017-11-27 +
    +
  • パスワード再設定フォームをサポートしました。
  • +
  • ログインフォームをサポートしました。
  • +
  • Geeklog 2.2.0で導入されるデモモードをサポートしました。
  • +
+
1.1.52017-04-12 +
    +
  • $_RECAPTCHA_CONF['logging']がfalseの場合に入力判定に失敗していたバグを修正しました。
  • +
+
1.1.42017-01-18 +
    +
  • 軽微なバグを修正しました。
  • +
+
1.1.32016-08-12 +
    +
  • COM_siteHeaderとCOM_siteFooterをCOM_createHTMLDocumentに置き換えました。
  • +
+
1.1.22016-02-20 +
    +
  • reCAPTCHAのライブラリをv1.1.2にアップグレードしました。
  • +
+
1.1.02015-07-03 +
    +
  • Google reCAPTCHA v2にアップグレードしました。
  • +
  • ログファイルの項目にエラーコードを追加しました。パッチ提供はTomさんです。
  • +
+
1.0.12014-01-26 +
    +
  • reCAPTCHAのコードをくるむ<div>タグを追加しました。パッチ提供はTomさんです。
  • +
  • エラーログを"logs/recaptch.log"に書き込むようにしました。パッチ提供はTomさんです。
  • +
+
1.0.02014-01-24最初のリリースです。
diff --git a/public_html/admin/plugins/recaptcha/index.php b/public_html/admin/plugins/recaptcha/index.php index 8e5b0ea45..2a399d16b 100644 --- a/public_html/admin/plugins/recaptcha/index.php +++ b/public_html/admin/plugins/recaptcha/index.php @@ -34,30 +34,15 @@ // Only let admin users access this page if (!SEC_hasRights('recaptcha.edit')) { - // Someone is trying to illegally access this page - COM_errorLog("Someone has tried to illegally access the recaptcha Admin page. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$_SERVER['REMOTE_ADDR']}", 1); - - if (is_callable('COM_createHTMLDocument')) { - $content = COM_startBlock(RECAPTCHA_esc($LANG_ACCESS['accessdenied'])) - . RECAPTCHA_esc($LANG_ACCESS['plugin_access_denied_msg']) - . COM_endBlock(); - $display = COM_createHTMLDocument($content); - } else { - $display = COM_siteHeader() - . COM_startBlock(RECAPTCHA_esc($LANG_ACCESS['accessdenied'])) - . RECAPTCHA_esc($LANG_ACCESS['plugin_access_denied_msg']) - . COM_endBlock() - . COM_siteFooter(); - } - - if (is_callable('COM_output')) { - COM_output($display); - } else { - header('Content-Type: text/html; charset=' . COM_getCharset()); - echo $display; - } - - exit; + // Someone is trying to illegally access this page + COM_errorLog("Someone has tried to illegally access the recaptcha Admin page. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$_SERVER['REMOTE_ADDR']}", 1); + + $content = COM_startBlock(RECAPTCHA_esc($LANG_ACCESS['accessdenied'])) + . RECAPTCHA_esc($LANG_ACCESS['plugin_access_denied_msg']) + . COM_endBlock(); + $display = COM_createHTMLDocument($content); + COM_output($display); + exit; } // Main diff --git a/public_html/layout/denim/comment/commentform.thtml b/public_html/layout/denim/comment/commentform.thtml index 221e4c507..0c493df3e 100644 --- a/public_html/layout/denim/comment/commentform.thtml +++ b/public_html/layout/denim/comment/commentform.thtml @@ -53,11 +53,13 @@
{!if allow_save} - + + {!endif} {!if allow_delete} - + + {!endif} diff --git a/public_html/layout/denim/comment/commentform_advanced.thtml b/public_html/layout/denim/comment/commentform_advanced.thtml index e496a3180..2a668fb73 100644 --- a/public_html/layout/denim/comment/commentform_advanced.thtml +++ b/public_html/layout/denim/comment/commentform_advanced.thtml @@ -59,11 +59,13 @@
{!if allow_save} - + + {!endif} {!if allow_delete} - + + {!endif} diff --git a/public_html/layout/denim/profiles/contactauthorform.thtml b/public_html/layout/denim/profiles/contactauthorform.thtml index f725ec4fb..fdf5e7588 100644 --- a/public_html/layout/denim/profiles/contactauthorform.thtml +++ b/public_html/layout/denim/profiles/contactauthorform.thtml @@ -34,7 +34,7 @@
- +
diff --git a/public_html/layout/denim/profiles/contactuserform.thtml b/public_html/layout/denim/profiles/contactuserform.thtml index f30f059a6..12e59a12a 100644 --- a/public_html/layout/denim/profiles/contactuserform.thtml +++ b/public_html/layout/denim/profiles/contactuserform.thtml @@ -29,7 +29,7 @@
- +
diff --git a/public_html/layout/denim/submit/submitarticle.thtml b/public_html/layout/denim/submit/submitarticle.thtml index df7527ab5..bb7d8f467 100644 --- a/public_html/layout/denim/submit/submitarticle.thtml +++ b/public_html/layout/denim/submit/submitarticle.thtml @@ -42,7 +42,10 @@ - {save_button} + {!if allow_save} + + + {!endif} diff --git a/public_html/layout/denim/submit/submitarticle_advanced.thtml b/public_html/layout/denim/submit/submitarticle_advanced.thtml index b45b43306..831456c99 100644 --- a/public_html/layout/denim/submit/submitarticle_advanced.thtml +++ b/public_html/layout/denim/submit/submitarticle_advanced.thtml @@ -48,7 +48,10 @@ - {save_button} + {!if allow_save} + + + {!endif} diff --git a/public_html/layout/denim/users/getpasswordform.thtml b/public_html/layout/denim/users/getpasswordform.thtml index 4485c0368..fe82249ce 100644 --- a/public_html/layout/denim/users/getpasswordform.thtml +++ b/public_html/layout/denim/users/getpasswordform.thtml @@ -19,7 +19,7 @@
- +
diff --git a/public_html/layout/denim/users/loginform.thtml b/public_html/layout/denim/users/loginform.thtml index 308eb7d91..b8320dd56 100644 --- a/public_html/layout/denim/users/loginform.thtml +++ b/public_html/layout/denim/users/loginform.thtml @@ -20,7 +20,7 @@ {captcha}
- +
{lang_newreglink}
diff --git a/public_html/layout/denim/users/registrationform.thtml b/public_html/layout/denim/users/registrationform.thtml index 0ea87598b..0bc35158c 100644 --- a/public_html/layout/denim/users/registrationform.thtml +++ b/public_html/layout/denim/users/registrationform.thtml @@ -23,7 +23,7 @@
- +
diff --git a/public_html/submit.php b/public_html/submit.php index 93763c330..c25f5d576 100644 --- a/public_html/submit.php +++ b/public_html/submit.php @@ -75,12 +75,12 @@ function submissionform($type = 'story', $mode = '') . COM_endBlock(); if ((strlen($type) > 0) && ($type !== 'story')) { - $formresult = PLG_showSubmitForm($type); - if ($formresult == false) { + $formResult = PLG_showSubmitForm($type); + if ($formResult == false) { COM_errorLog("Someone tried to submit an item to the {$type}-plugin, which cannot be found.", 1); COM_displayMessageAndAbort(79, '', 410, 'Gone'); } else { - $retval .= $formresult; + $retval .= $formResult; } } else { $retval .= submitstory(); @@ -97,7 +97,7 @@ function submissionform($type = 'story', $mode = '') */ function submitstory() { - global $_CONF, $_TABLES, $_USER, $LANG01, $LANG12, $LANG24, $LANG_ADMIN, $_SCRIPTS; + global $_CONF, $_TABLES, $_USER, $LANG01, $LANG12, $LANG24, $LANG_ADMIN, $_SCRIPTS, $_PLUGINS; // Add JavaScript $_SCRIPTS->setJavaScriptFile('postmode_control', '/javascript/postmode_control.js'); @@ -210,13 +210,13 @@ function submitstory() $storyForm->set_var('story_sid', $story->EditElements('sid')); $storyForm->set_var('story_date', $story->EditElements('unixdate')); $storyForm->set_var('lang_preview', $LANG12[32]); + $storyForm->set_var('lang_save', $LANG12[8]); PLG_templateSetVars('story', $storyForm); if (($_CONF['skip_preview'] == 1) || (Geeklog\Input::post('mode') === $LANG12[32])) { - $storyForm->set_var( - 'save_button', - '' - ); + $storyForm->set_var('allow_save', true); + } else { + $storyForm->set_var('allow_save', false); } $retval .= COM_startBlock($LANG12[6], 'submitstory.html'); @@ -331,6 +331,7 @@ function savestory(array $A) * @param string $type Type of submission we are dealing with * @param array $A Data for that submission * @return string + * @throws Exception */ function savesubmission($type, $A) { From 63215f91f24cabc8cfacc417a37fb66eb60d74d6 Mon Sep 17 00:00:00 2001 From: Kenji ITO Date: Sat, 2 Dec 2017 21:21:42 +0900 Subject: [PATCH 7/7] Added Invisible reCAPTCHA support for Modern Curve theme --- plugins/recaptcha/functions.inc | 32 +++++++++---------- .../modern_curve/comment/commentform.thtml | 10 ++++-- .../comment/commentform_advanced.thtml | 10 ++++-- .../profiles/contactauthorform.thtml | 2 +- .../profiles/contactuserform.thtml | 2 +- .../modern_curve/submit/submitarticle.thtml | 5 ++- .../submit/submitarticle_advanced.thtml | 5 ++- .../modern_curve/users/getpasswordform.thtml | 2 +- .../layout/modern_curve/users/loginform.thtml | 4 +-- .../modern_curve/users/registrationform.thtml | 2 +- 10 files changed, 46 insertions(+), 28 deletions(-) diff --git a/plugins/recaptcha/functions.inc b/plugins/recaptcha/functions.inc index e4bae170b..7f01d4650 100644 --- a/plugins/recaptcha/functions.inc +++ b/plugins/recaptcha/functions.inc @@ -619,52 +619,52 @@ function RECAPTCHA_getIP() */ function RECAPTCHA_getFormId($type) { switch ($type) { - case 'comment': // OK + case 'comment': $formId = 'commentform'; break; - case 'story': // OK + case 'story': $formId = 'submitstory'; break; - case 'registration': // OK + case 'registration': $formId = 'registrationform'; break; - case 'loginform': // OK + case 'loginform': $formId = 'userloginform'; break; - case 'getpassword': // OK + case 'getpassword': $formId = 'getpasswordform'; break; - case 'contact': // OK + case 'contact': $formId = 'contactuserform'; break; - case 'emailstory': // OK + case 'emailstory': $formId = 'contactauthorform'; break; - case 'forum': - $formId = ''; + case 'links': + $formId = 'submitlink'; break; - case 'mediagallery': - $formId = ''; + case 'calendar': + $formId = 'submit_event_form'; break; - case 'rating': + case 'forum': $formId = ''; break; - case 'links': // OK - $formId = 'submitlink'; + case 'rating': + $formId = ''; break; - case 'calendar': - $formId = 'submit_event_form'; + case 'mediagallery': + $formId = ''; break; default: diff --git a/public_html/layout/modern_curve/comment/commentform.thtml b/public_html/layout/modern_curve/comment/commentform.thtml index 67dcfb442..3663cbaef 100644 --- a/public_html/layout/modern_curve/comment/commentform.thtml +++ b/public_html/layout/modern_curve/comment/commentform.thtml @@ -54,9 +54,15 @@
  • - {save_option} +{!if allow_save} + + +{!endif} - {delete_option} +{!if allow_delete} + + +{!endif} {notification}
  • diff --git a/public_html/layout/modern_curve/comment/commentform_advanced.thtml b/public_html/layout/modern_curve/comment/commentform_advanced.thtml index e775788ff..34584405a 100644 --- a/public_html/layout/modern_curve/comment/commentform_advanced.thtml +++ b/public_html/layout/modern_curve/comment/commentform_advanced.thtml @@ -61,9 +61,15 @@
  • - {save_option} +{!if allow_save} + + +{!endif} - {delete_option} +{!if allow_delete} + + +{!endif} {notification}
  • diff --git a/public_html/layout/modern_curve/profiles/contactauthorform.thtml b/public_html/layout/modern_curve/profiles/contactauthorform.thtml index e55c56b6a..b994de232 100644 --- a/public_html/layout/modern_curve/profiles/contactauthorform.thtml +++ b/public_html/layout/modern_curve/profiles/contactauthorform.thtml @@ -35,7 +35,7 @@
  • - +
  • diff --git a/public_html/layout/modern_curve/profiles/contactuserform.thtml b/public_html/layout/modern_curve/profiles/contactuserform.thtml index c83985243..c28bc6e7b 100644 --- a/public_html/layout/modern_curve/profiles/contactuserform.thtml +++ b/public_html/layout/modern_curve/profiles/contactuserform.thtml @@ -30,7 +30,7 @@
  • - +
  • diff --git a/public_html/layout/modern_curve/submit/submitarticle.thtml b/public_html/layout/modern_curve/submit/submitarticle.thtml index 3026e1256..916a3dc2d 100644 --- a/public_html/layout/modern_curve/submit/submitarticle.thtml +++ b/public_html/layout/modern_curve/submit/submitarticle.thtml @@ -48,7 +48,10 @@ - {save_button} + {!if allow_save} + + + {!endif} diff --git a/public_html/layout/modern_curve/submit/submitarticle_advanced.thtml b/public_html/layout/modern_curve/submit/submitarticle_advanced.thtml index 21c8f6365..e303f2810 100644 --- a/public_html/layout/modern_curve/submit/submitarticle_advanced.thtml +++ b/public_html/layout/modern_curve/submit/submitarticle_advanced.thtml @@ -54,7 +54,10 @@ - {save_button} + {!if allow_save} + + + {!endif} diff --git a/public_html/layout/modern_curve/users/getpasswordform.thtml b/public_html/layout/modern_curve/users/getpasswordform.thtml index 89a4ef7bf..6a192a721 100644 --- a/public_html/layout/modern_curve/users/getpasswordform.thtml +++ b/public_html/layout/modern_curve/users/getpasswordform.thtml @@ -20,7 +20,7 @@
    • - +
    diff --git a/public_html/layout/modern_curve/users/loginform.thtml b/public_html/layout/modern_curve/users/loginform.thtml index 99fc9279a..1efaa78fe 100644 --- a/public_html/layout/modern_curve/users/loginform.thtml +++ b/public_html/layout/modern_curve/users/loginform.thtml @@ -20,8 +20,8 @@ {!if captcha} {captcha}
    - {!endif} - + {!endif} +