diff --git a/wp-content/plugins/wp-recaptcha-bp/LICENSE b/wp-content/plugins/wp-recaptcha-bp/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..5cb775f9a48b57e47f7a424e9e9bc213fb45d412 --- /dev/null +++ b/wp-content/plugins/wp-recaptcha-bp/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2008 reCAPTCHA -- http://recaptcha.net +AUTHORS: + Mike Crawford + Ben Maurer + Jorge Pe�a + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + * +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + * +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/wp-content/plugins/wp-recaptcha-bp/README.rst b/wp-content/plugins/wp-recaptcha-bp/README.rst new file mode 100644 index 0000000000000000000000000000000000000000..17996be9b124127fd63403b9e8be3006b09584a4 --- /dev/null +++ b/wp-content/plugins/wp-recaptcha-bp/README.rst @@ -0,0 +1,38 @@ +Introduction +------------ +This just takes wp-recaptcha and adds a few callbacks to make it work with +Buddypress. + +You only need this plugin if you use Buddypress with wordpress and want a +recaptcha at the registration page. + +Future +------ +The patch to do this on top of wp-recaptcha is **VERY simple**. + +As google is the owner of wp-recaptcha, it is expected to be always up to date. +And as the patch to add Buddypress is very simple, updating the wp-recaptcha +plugin version this is based on is expected to be very simple. + +With some luck, this plugin won't be needed in the future. A bug has been opened +to Buddypress here [#]_ to fix it. And they plan to do something in the future, as +that bug says. Also, a bug to meanwhile make wp-recaptcha work with BuddyPress +has been openeded here [#]_ too. + +.. [#] https://buddypress.trac.wordpress.org/ticket/6068 +.. [#] https://wordpress.org/support/topic/easy-way-to-add-recaptcha-to-custom-actions-like-buddypress-actions?replies=1#post-6296863 + +Version of wp-recaptcha it is based +----------------------------------- +Currently is based on wp-recaptcha 4.1. + +See it live! +------------ +You can see this plugin in a site using buddypress here [#]_. If you go to "join", +you will see the recaptcha there. + +.. [#] http://community.phplist.com + +Bugs and patches +---------------- +Please submit bugs and patches via github, on github.com/rata/wp-recaptcha-bp diff --git a/wp-content/plugins/wp-recaptcha-bp/readme.txt b/wp-content/plugins/wp-recaptcha-bp/readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..c42da0456b4385e1bfa0ce6721645ec2518f972e --- /dev/null +++ b/wp-content/plugins/wp-recaptcha-bp/readme.txt @@ -0,0 +1,135 @@ +=== Plugin Name === +Contributors: elrata_ +Tags: comments, registration, recaptcha, antispam, captcha, buddypress +Requires at least: 2.7 +Tested up to: 4.3.0 +Stable tag: 4.1 + +Integrates reCAPTCHA anti-spam methods with WordPress sites using BuddyPress plugin, including comment and registration spam protection. + +== Description == + +This is a small modification of the wp-recaptcha plugin to make it work with +BuddyPress. Currently uses recaptcha v2 (the last one). + +You only need this plugin if you use Buddypress with wordpress and want a +recaptcha at the registration page. + +It is always rebased on top of wp-recaptcha. See +https://github.com/rata/wp-recaptcha-bp for more info + +What is reCAPTCHA? + +reCAPTCHA is a free CAPTCHA service that protects your site against spam, malicious registrations and other forms of attacks where computers try to disguise themselves as a human; a CAPTCHA is a Completely Automated Public Turing test to tell Computers and Human Apart. reCAPTCHA comes in the form of a widget that you can easily add to your blog, forum, registration form, etc. + +In addition to protecting your site, reCAPTCHA also helps us digitize old books and newspapers, transcribe street numbers and solve hard AI problems. [Learn how reCAPTCHA works](http://www.google.com/recaptcha) and join our [forum](https://groups.google.com/forum/#!forum/recaptcha). + +== Installation == + +To install in regular WordPress and [WordPress MultiSite](http://codex.wordpress.org/Create_A_Network): + +1. Upload the `wp-recaptcha` folder to the `/wp-content/plugins/` directory +2. Activate the plugin through the `Plugins` menu in WordPress +3. Get the reCAPTCHA keys [here](https://www.google.com/recaptcha/admin#whyrecaptcha). + +== Requirements == + +* You need the reCAPTCHA keys [here](https://www.google.com/recaptcha/admin#whyrecaptcha). +* Your theme must have a `do_action('comment_form', $post->ID);` call right before the end of your form (*Right before the closing form tag*). Most themes do. + +== ChangeLog == + += Version 4.0 +* Upgrade to reCAPTCHA V2. +* Increase supported languages to 40+. += Version 3.2 +* Transferred ownership back to Google += Version 3.1.6 = +* WordPress MS fixes. Should now work out of the box at the individual blog level. Thanks to [huyz](http://huyz.us/) +* NOTICE: If anyone is interested in taking up development of this plugin, please contact me at blaenk@gmail.com. += Version 3.1.5 = +* Thanks to [Ken Newman](https://github.com/WraithKenny) for these changes +* Update author website +* Stop generating javascript errors on unnecessary pages +* Better SSL support += Version 3.1.4 = +* Fixed an XSS vulnerability += Version 3.1.3 = +* Added a collision aversion prefix to the Plugin class. bbouton from github alerted me to a collision between WP-reCAPTCHA's plugin class and the JW Player Plugin's Plugin class. += Version 3.1.2 = +* Fixed option migration. The plugin was actually written to be made to import the old options, but the hook that functionality was registered to does not fire when the wordpress interface updates a plugin, only when a plugin is updated manually. Now the plugin will import or register default options as long as the options don't already exist. +* Fixed a case where recaptcha theme would not change. This happened because of the above problem, creating a situation in which the tab index field could be empty, and being empty this then caused a problem with the recaptcha options when they were output to the page. If you're running version 3.0 of the plugin, go ahead and add a number to the tab index (e.g. 5 for comments, 30 for registration), if not, this plugin should automatically fix it next time you change save the settings. +* Modified the options page submit buttons to more explicitly show that they are specific to their own respective sections, that is, one button ONLY saves the changes for one reCAPTCHA, and the other ONLY saves the changes for MailHide. += Version 3.0 = +* Rewrote the entire plugin in an object-oriented manner with separation of concerns in mind to increase maintainability and extensibility +* Implemented the ability to import the options from the option set of older versions of the plugin, such as 2.9.8.2 and less +* Redesigned the options page for the plugin, now using newer wordpress options/form functionality with support for input-validation +* Options for recaptcha and mailhide are independent of each other +* Added support for localization, using gettext +* Fixed the issue where comments would not be saved if the reCAPTCHA was entered incorrectly (or not entered at all). requires javascript +* Fixed an issue where saved comments (from bad reCAPTCHA response) would replace double quotes with backslashes +* Fixed an issue in wordpress 3 and above in which mailhide would not work due to interference with a new filter, make_clickable, which auto-links emails and URLs +* Fixed a role-check issue in wordpress 3 and above. level_10 (and all levels for that matter) have been deprecated. now using activate_plugins instead. += Version 2.9.8.2 = +* Fixed a bug with WordPress 3.0 Multi-Site += Version 2.9.8 = +* Added support for WordPress 3.0 Multi-Site thanks to Tom Lynch += Version 2.9.7 = +* Fixed a relatively new [critical bug](http://www.blaenkdenum.com/2010/03/recaptcha-marking-all-comments-as-spam/) which marked new comments as spam regardless of reCAPTCHA response += Version 2.9.6 = +* Fixed a careless bug affecting custom hidden emails +* Fixed broken links in readme.txt += Version 2.9.5 = +* Added flexibility to the enabling of MailHide. Can now separately choose to enable/disable MailHide for posts/pages, comments, RSS feed of posts/pages, and RSS feed of comments +* Fixed an ['endless redirection' bug](http://wordpress.org/support/topic/245154?replies=1 "endless redirection in wp-reCAPTCHA options form") thanks to Edilton Siqueira +* Fixed a bug in WPMU where wp-admin/user-new.php kept trying to validate the user registration with reCAPTCHA information despite not having shown the reCAPTCHA form, thanks to [Daniel Collis-Puro](http://blogs.law.harvard.edu/ "Weblogs at Harvard Law School") for letting me know +* Added a line break after the reCAPTCHA form to add some padding space between it and the submit button. Due to [popular demand](http://www.chriscredendino.com/2009/03/08/adding-space-between-recaptcha-and-the-comment-submit-button-on-wordpress/ "Adding space between reCAPTCHA and the comment Submit Button on WordPress") +* Fixed a validation problem where a style attribute was missing. Thanks to [nv1962](http://wordpress.org/support/profile/304093 "nv1962's profile") +* Public and Private keys are now trimmed since they are usually pasted from the recaptcha site, to avoid any careless errors +* Fixed the regular expressions for matching the emails, email@provider.co.uk type emails now work += Version 2.9.4 = +* Fixed a bug where the comment would not be saved if the CAPTCHA wasn't entered correctly. Thanks to Justin Heideman. += Version 2.9.3 = +* Fixed the `recaptcha_wp_saved_comment` function. Thanks to Tomi M. += Version 2.9.2 = +* 'Beautified' the options page. +* Added two options to allow users to enter their own custom error messages. Also good for foreign language support. +* Fixed a conflict bug with the OpenID plugin where the reCAPTCHA form would show under the OpenID section in the registration form. +* Added two new options which allow one to choose the text to be shown for all hidden Emails and/or the title of the link. +* Fixed a 'Could not open socket' error in recaptchalib.php. [Bug ID 26](http://code.google.com/p/recaptcha/issues/detail?id=26 "recaptchalib.php: Could not open socket (Fix included)") +* Fixed a WPMU issue where blog registrations weren't possible due to a redirection to the first step in the registration process. Thanks to [Edward](http://yisheng.wordpress.com/2008/08/14/wp-recaptcha-for-wpmu-26/ "Edward"). += Version 2.9.1 = +* Forgot that if you can see emails in their true form, then you shouldn't have to see the [nohide][/nohide] tags either. Fixed. += Version 2.8.6 = +* Administration interface is now integrated with 2.5's look and feel. Thanks to [Jeremy Clarke](http://simianuprising.com/ "Jeremy Clarke"). +* Users can now have more control over who sees the reCAPTCHA form and who can see emails in their true form (If MailHide is enabled). Thanks to [Jeremy Clarke](http://simianuprising.com/ "Jeremy Clarke"). +* Fixed a very stupid (**One character deal**) fatal error on most Windows Servers which don't support short tags (short_open_tag). I'm speaking of the so called 'Unexpected $end' error. +* Accommodated for the fact that in +2.6 the wp-content folder can be anywhere. + +== Frequently Asked Questions == + += HELP, I'm still getting spam! = +There are four common issues that make reCAPTCHA appear to be broken: + +1. **Moderation Emails**: reCAPTCHA marks comments as spam, so even though the comments don't actually get posted, you will be notified of what is supposedly new spam. It is recommended to turn off moderation emails with reCAPTCHA. +1. **Akismet Spam Queue**: Again, because reCAPTCHA marks comments with a wrongly entered CAPTCHA as spam, they are added to the spam queue. These comments however weren't posted to the blog so reCAPTCHA is still doing it's job. It is recommended to either ignore the Spam Queue and clear it regularly or disable Akismet completely. reCAPTCHA takes care of all of the spam created by bots, which is the usual type of spam. The only other type of spam that would get through is human spam, where humans are hired to manually solve CAPTCHAs. If you still get spam while only having reCAPTCHA enabled, you could be a victim of the latter practice. If this is the case, then turning on Akismet will most likely solve your problem. Again, just because it shows up in the Spam Queue does NOT mean that spam is being posted to your blog, it's more of a 'comments that have been caught as spam by reCAPTCHA' queue. +1. **Trackbacks and Pingbacks**: reCAPTCHA can't do anything about pingbacks and trackbacks. You can disable pingbacks and trackbacks in Options > Discussion > Allow notifications from other Weblogs (Pingbacks and trackbacks). +1. **Human Spammers**: Believe it or not, there are people who are paid (or maybe slave labor?) to solve CAPTCHAs all over the internet and spam. This is the last and rarest reason for which it might appear that reCAPTCHA is not working, but it does happen. On this plugin's [page](http://www.blaenkdenum.com/wp-recaptcha/ "WP-reCAPTCHA - Blaenk Denum"), these people sometimes attempt to post spam to try and make it seem as if reCAPTCHA is not working. A combination of reCAPTCHA and Akismet might help to solve this problem, and if spam still gets through for this reason, it would be very minimal and easy to manually take care of. + += Why am I getting Warning: pack() [function.pack]: Type H: illegal hex digit? +You have the keys in the wrong place. Remember, the reCAPTCHA keys are different from the MailHide keys. And the Public keys are different from the Private keys as well. You can't mix them around. Go through your keys and make sure you have them each in the correct box. + += Aren't you increasing the time users spend solving CAPTCHAs by requiring them to type two words instead of one? = +Actually, no. Most CAPTCHAs on the Web ask users to enter strings of random characters, which are slower to type than English words. reCAPTCHA requires no more time to solve than most other CAPTCHAs. + += Are reCAPTCHAs less secure than other CAPTCHAs that use random characters instead of words? = +Because we ask users to enter two words instead of one, we can increase the security of reCAPTCHA against programs that attempt to guess the words using a dictionary. Whenever an IP address fails one reCAPTCHA, we can show them more distorted words, and give them challenges for which we know both words. The probability of randomly guessing both words correctly would be less than one in ten million. + += Are CAPTCHAs secure? I heard spammers are using porn sites to solve them: the CAPTCHAs are sent to a porn site, and the porn site users are asked to solve the CAPTCHA before being able to see a pornographic image. = + +CAPTCHAs offer great protection against abuse from automated programs. While it might be the case that some spammers have started using porn sites to attack CAPTCHAs (although there is no recorded evidence of this), the amount of damage this can inflict is tiny (so tiny that we haven't even seen this happen!). Whereas it is trivial to write a bot that abuses an unprotected site millions of times a day, redirecting CAPTCHAs to be solved by humans viewing pornography would only allow spammers to abuse systems a few thousand times per day. The economics of this attack just don't add up: every time a porn site shows a CAPTCHA before a porn image, they risk losing a customer to another site that doesn't do this. + +== Screenshots == + +1. The reCAPTCHA Settings +2. Comments page with reCAPTCHA diff --git a/wp-content/plugins/wp-recaptcha-bp/recaptcha.php b/wp-content/plugins/wp-recaptcha-bp/recaptcha.php new file mode 100644 index 0000000000000000000000000000000000000000..73461902f3ac1f16647c63cc794a776113ef0d66 --- /dev/null +++ b/wp-content/plugins/wp-recaptcha-bp/recaptcha.php @@ -0,0 +1,498 @@ +<?php +/** + * This is a PHP library that handles calling reCAPTCHA. + * - Documentation and latest version + * https://developers.google.com/recaptcha/docs/php + * - Get a reCAPTCHA API Key + * https://www.google.com/recaptcha/admin/create + * - Discussion group + * http://groups.google.com/group/recaptcha + * + * @link http://www.google.com/recaptcha + */ + +require_once('wp-plugin.php'); + +if (class_exists('ReCAPTCHAPlugin')) +{ + return; +} + +class ReCAPTCHAPlugin extends WPPlugin +{ + private $_saved_error; + private $_reCaptchaLib; + + /** + * Php 4 Constructor. + * + * @param string $options_name + */ + function ReCAPTCHAPlugin($options_name) { + $args = func_get_args(); + call_user_func_array(array(&$this, "__construct"), $args); + } + + /** + * Php 5 Constructor. + * + * @param string $options_name + */ + function __construct($options_name) { + parent::__construct($options_name); + $this->register_default_options(); + + // require the recaptcha library + $this->_require_library(); + + // register the hooks + $this->register_actions(); + $this->register_filters(); + } + + function register_actions() { + // load the plugin's textdomain for localization + add_action('init', array(&$this, 'load_textdomain')); + + // options + register_activation_hook(WPPlugin::path_to_plugin_directory() . + '/wp-recaptcha.php', + array(&$this, 'register_default_options')); + add_action('admin_init', array(&$this, 'register_settings_group')); + + if ($this->is_multi_blog()) { + add_action('signup_extra_fields', array(&$this, + 'show_recaptcha_in_registration')); + } else { + add_action('register_form', array(&$this, + 'show_recaptcha_in_registration')); + add_action('bp_before_registration_submit_buttons', array(&$this, + 'show_recaptcha_in_registration')); + add_action('bp_signup_validate', array(&$this, + 'check_recaptcha_generic'), 0); + } + + add_action('lostpassword_form', array(&$this, + 'show_recaptcha_in_registration')); + add_action('lostpassword_post', array(&$this, + 'check_recaptcha_generic'), 0); + + add_action('comment_form', array(&$this, 'show_recaptcha_in_comments')); + + // recaptcha comment processing + add_action('wp_head', array(&$this, 'saved_comment'), 0); + add_action('preprocess_comment', array(&$this, 'check_comment'), 0); + add_action('comment_post_redirect', array(&$this, 'relative_redirect'), + 0, 2); + + // administration (menus, pages, notifications, etc.) + add_filter("plugin_action_links", array(&$this, 'show_settings_link'), + 10, 2); + + add_action('admin_menu', array(&$this, 'add_settings_page')); + // admin notices + add_action('admin_notices', array(&$this, 'missing_keys_notice')); + } + + function register_filters() { + if ($this->is_multi_blog()) { + add_filter('wpmu_validate_user_signup', + array(&$this, 'validate_recaptcha_response_wpmu')); + } else { + add_filter('registration_errors', array(&$this, + 'validate_recaptcha_response')); + } + } + + function load_textdomain() { + load_plugin_textdomain('recaptcha', false, 'languages'); + } + + // set the default options + function register_default_options() { + if ($this->options) + return; + $option_defaults = array(); + $old_options = WPPlugin::retrieve_options("recaptcha"); + if ($old_options) { + $option_defaults['site_key'] = $old_options['pubkey']; + $option_defaults['secret'] = $old_options['privkey']; + + // styling + $option_defaults['recaptcha_language'] = $old_options['re_lang']; + + // error handling + $option_defaults['no_response_error'] = $old_options['error_blank']; + } else { + $old_options = WPPlugin::retrieve_options($this->options_name); + if ($old_options) { + $option_defaults['site_key'] = $old_options['public_key']; + $option_defaults['secret'] = $old_options['private_key']; + $option_defaults['comments_theme'] = 'standard'; + $option_defaults['recaptcha_language'] = $old_options['recaptcha_language']; + $option_defaults['no_response_error'] = $old_options['no_response_error']; + } else { + $option_defaults['site_key'] = ''; + $option_defaults['secret'] = ''; + $option_defaults['comments_theme'] = 'standard'; + $option_defaults['recaptcha_language'] = 'en'; + $option_defaults['no_response_error'] = + '<strong>ERROR</strong>: Please fill in the reCAPTCHA form.'; + } + } + // add the option based on what environment we're in + WPPlugin::add_options($this->options_name, $option_defaults); + } + + // require the recaptcha library + private function _require_library() { + require_once($this->path_to_plugin_directory() . '/recaptchalib.php'); + } + + // register the settings + function register_settings_group() { + register_setting("recaptcha_options_group", 'recaptcha_options', + array(&$this, 'validate_options')); + } + + function keys_missing() { + return (empty($this->options['site_key']) || + empty($this->options['secret'])); + } + + function create_error_notice($message, $anchor = '') { + $options_url = admin_url( + 'options-general.php?page=wp-recaptcha-bp/recaptcha.php') . $anchor; + $error_message = sprintf(__($message . + ' <a href="%s" title="WP-reCAPTCHA-bp Options">Fix this</a>', + 'recaptcha'), $options_url); + echo '<div class="error"><p><strong>' . $error_message . + '</strong></p></div>'; + } + + function missing_keys_notice() { + if ($this->keys_missing()) { + $this->create_error_notice('reCAPTCHA API Keys are missing.'); + } + } + + function validate_dropdown($array, $key, $value) { + if (in_array($value, $array)) { + return $value; + } else { // if not, load the old value + return $this->options[$key]; + } + } + + function validate_options($input) { + // trim the spaces out of the key + $validated['site_key'] = trim($input['site_key']); + $validated['secret'] = trim($input['secret']); + + $themes = array ('standard', 'light', 'dark'); + $validated['comments_theme'] = $this->validate_dropdown($themes, + 'comments_theme', $input['comments_theme']); + $validated['recaptcha_language'] = $input['recaptcha_language']; + $validated['no_response_error'] = $input['no_response_error']; + return $validated; + } + // display recaptcha + function show_recaptcha_in_registration($errors) { + $escaped_error = htmlentities($_GET['rerror'], ENT_QUOTES); + + // if it's for wordpress mu, show the errors + if ($this->is_multi_blog()) { + $error = $errors->get_error_message('captcha'); + echo '<label for="verification">Verification:</label>'; + echo ($error ? '<p class="error">' . $error . '</p>' : ''); + echo $this->get_recaptcha_html(); + } else { // for regular wordpress + echo $this->get_recaptcha_html(); + } + } + + function validate_recaptcha_response($errors) { + if (empty($_POST['g-recaptcha-response']) || + $_POST['g-recaptcha-response'] == '') { + $errors->add('blank_captcha', $this->options['no_response_error']); + return $errors; + } + + if ($this->_reCaptchaLib == null) { + $this->_reCaptchaLib = new ReCaptcha($this->options['secret']); + } + $response = $this->_reCaptchaLib->verifyResponse( + $_SERVER['REMOTE_ADDR'], + $_POST['g-recaptcha-response']); + + // response is bad, add incorrect response error + if (!$response->success) + $errors->add('captcha_wrong', $response->error); + + return $errors; + } + + function validate_recaptcha_response_wpmu($result) { + if (!$this->is_authority()) { + // blogname in 2.6, blog_id prior to that + // todo: why is this done? + if (isset($_POST['blog_id']) || isset($_POST['blogname'])) + return $result; + // no text entered + if (empty($_POST['g-recaptcha-response']) || + $_POST['g-recaptcha-response'] == '') { + $result['errors']->add('blank_captcha', + $this->options['no_response_error']); + return $result['errors']; + } + + if ($this->_reCaptchaLib == null) { + $this->_reCaptchaLib = new ReCaptcha($this->options['secret']); + } + $response = $this->_reCaptchaLib->verifyResponse( + $_SERVER['REMOTE_ADDR'], + $_POST['g-recaptcha-response']); + + // response is bad, add incorrect response error + if (!$response->success) { + $result['errors']->add('captcha_wrong', $response->error); + echo '<div class="error">' . $response->error . '</div>'; + } + return $result; + } + } + // utility methods + function hash_comment($id) { + define ("RECAPTCHA_WP_HASH_SALT", "b7e0638d85f5d7f3694f68e944136d62"); + if (function_exists('wp_hash')) + return wp_hash(RECAPTCHA_WP_HASH_SALT . $id); + else + return md5(RECAPTCHA_WP_HASH_SALT . $this->options['secret'] . $id); + } + + function get_recaptcha_html() { + return '<div class="g-recaptcha" data-sitekey="' . + $this->options['site_key'] . + '" data-theme="' . $this->options['comments_theme'] . + '"></div><script type="text/javascript"' . + 'src="https://www.google.com/recaptcha/api.js?hl=' . + $this->options['recaptcha_language'] . + '"></script>'; + } + + function show_recaptcha_in_comments() { + global $user_ID; + + //modify the comment form for the reCAPTCHA widget + add_action('wp_footer', array(&$this, 'save_comment_script')); + + $comment_string = <<<COMMENT_FORM + <div id="recaptcha-submit-btn-area"> </div> + <noscript> + <style type='text/css'>#submit {display:none;}</style> + <input name="submit" type="submit" id="submit-alt" tabindex="6" + value="Submit Comment"/> + </noscript> +COMMENT_FORM; + + $use_ssl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on"); + + $escaped_error = htmlentities($_GET['rerror'], ENT_QUOTES); + + echo $this->get_recaptcha_html() . $comment_string; + } + + // this is what does the submit-button re-ordering + function save_comment_script() { + $javascript = <<<JS + <script type="text/javascript"> + var sub = document.getElementById('submit'); + document.getElementById('recaptcha-submit-btn-area').appendChild (sub); + document.getElementById('submit').tabIndex = 6; + if ( typeof _recaptcha_wordpress_savedcomment != 'undefined') { + document.getElementById('comment').value = + _recaptcha_wordpress_savedcomment; + } + </script> +JS; + echo $javascript; + } + + function check_comment($comment_data) { + global $user_ID; + // do not check trackbacks/pingbacks + if ($comment_data['comment_type'] == '') { + if ($this->_reCaptchaLib == null) { + $this->_reCaptchaLib = new ReCaptcha($this->options['secret']); + } + $response = $this->_reCaptchaLib->verifyResponse( + $_SERVER['REMOTE_ADDR'], + $_POST['g-recaptcha-response']); + + if (!$response->success) { + $this->_saved_error = $response->error; + add_filter('pre_comment_approved', + create_function('$a', 'return \'spam\';')); + } + } + return $comment_data; + } + + function check_recaptcha_generic() { + global $user_ID; + if ($this->_reCaptchaLib == null) { + $this->_reCaptchaLib = new ReCaptcha($this->options['secret']); + } + $response = $this->_reCaptchaLib->verifyResponse( + $_SERVER['REMOTE_ADDR'], + $_POST['g-recaptcha-response']); + + if (!$response->success) { + $this->_saved_error = $response->error; + $error = __('Please check the CAPTCHA code. It\'s not correct.', 'g-recaptcha'); + wp_die("<strong>$error</strong>"); + return false; + } + return true; + } + + function relative_redirect($location, $comment) { + if ($this->_saved_error != '') { + // replace #comment- at the end of $location with #commentform + $location = substr($location, 0, strpos($location, '#')) . + ((strpos($location, "?") === false) ? "?" : "&") . + 'rcommentid=' . $comment->comment_ID . + '&rerror=' . $this->_saved_error . + '&rchash=' . $this->hash_comment($comment->comment_ID) . + '#commentform'; + } + return $location; + } + + function saved_comment() { + if (!is_single() && !is_page()) + return; + $comment_id = $_REQUEST['rcommentid']; + $comment_hash = $_REQUEST['rchash']; + if (empty($comment_id) || empty($comment_hash)) + return; + if ($comment_hash == $this->hash_comment($comment_id)) { + $comment = get_comment($comment_id); + + // todo: removed double quote from list of 'dangerous characters' + $com = preg_replace('/([\\/\(\)\+\;\'])/e', + '\'%\' . dechex(ord(\'$1\'))', + $comment->comment_content); + $com = preg_replace('/\\r\\n/m', '\\\n', $com); + echo " + <script type='text/javascript'> + var _recaptcha_wordpress_savedcomment = '" . $com ."'; + _recaptcha_wordpress_savedcomment = + unescape(_recaptcha_wordpress_savedcomment); + </script> + "; + + wp_delete_comment($comment->comment_ID); + } + } + + // add a settings link to the plugin in the plugin list + function show_settings_link($links, $file) { + if ($file == plugin_basename($this->path_to_plugin_directory() . + '/wp-recaptcha.php')) { + $settings_title = __('Settings for this Plugin', 'recaptcha'); + $settings = __('Settings', 'recaptcha'); + $settings_link = + '<a href="options-general.php?page=wp-recaptcha-bp/recaptcha.php"' . + ' title="' . $settings_title . '">' . $settings . '</a>'; + array_unshift($links, $settings_link); + } + return $links; + } + + // add the settings page + function add_settings_page() { + // add the options page + if ($this->environment == Environment::WordPressMU && + $this->is_authority()) + add_submenu_page('wpmu-admin.php', 'WP-reCAPTCHA-bp', 'WP-reCAPTCHA-bp', + 'manage_options', __FILE__, array(&$this, 'show_settings_page')); + add_options_page('WP-reCAPTCHA-bp', 'WP-reCAPTCHA-bp', 'manage_options', + __FILE__, array(&$this, 'show_settings_page')); + } + // store the xhtml in a separate file and use include on it + function show_settings_page() { + include("settings.php"); + } + + function build_dropdown($name, $keyvalue, $checked_value) { + echo '<select name="' . $name . '" id="' . $name . '">' . "\n"; + foreach ($keyvalue as $key => $value) { + $checked = ($value == $checked_value) ? + ' selected="selected" ' : ''; + echo '\t <option value="' . $value . '"' . $checked . + ">$key</option> \n"; + $checked = NULL; + } + echo "</select> \n"; + } + + function theme_dropdown() { + $themes = array ( + __('Standard', 'recaptcha') => 'standard', + __('Light', 'recaptcha') => 'light', + __('Dark', 'recaptcha') => 'dark' + ); + $this->build_dropdown('recaptcha_options[comments_theme]', $themes, + $this->options['comments_theme']); + } + + function recaptcha_language_dropdown() { + $languages = array ( + __('English', 'recaptcha') => 'en', + __('Arabic', 'recaptcha') => 'ar', + __('Bulgarian', 'recaptcha') => 'bg', + __('Catalan Valencian', 'recaptcha') => 'ca', + __('Czech', 'recaptcha') => 'cs', + __('Danish', 'recaptcha') => 'da', + __('German', 'recaptcha') => 'de', + __('Greek', 'recaptcha') => 'el', + __('British English', 'recaptcha') => 'en_gb', + __('Spanish', 'recaptcha') => 'es', + __('Persian', 'recaptcha') => 'fa', + __('French', 'recaptcha') => 'fr', + __('Canadian French', 'recaptcha') => 'fr_ca', + __('Hindi', 'recaptcha') => 'hi', + __('Croatian', 'recaptcha') => 'hr', + __('Hungarian', 'recaptcha') => 'hu', + __('Indonesian', 'recaptcha') => 'id', + __('Italian', 'recaptcha') => 'it', + __('Hebrew', 'recaptcha') => 'iw', + __('Jananese', 'recaptcha') => 'ja', + __('Korean', 'recaptcha') => 'ko', + __('Lithuanian', 'recaptcha') => 'lt', + __('Latvian', 'recaptcha') => 'lv', + __('Dutch', 'recaptcha') => 'nl', + __('Norwegian', 'recaptcha') => 'no', + __('Polish', 'recaptcha') => 'pl', + __('Portuguese', 'recaptcha') => 'pt', + __('Romanian', 'recaptcha') => 'ro', + __('Russian', 'recaptcha') => 'ru', + __('Slovak', 'recaptcha') => 'sk', + __('Slovene', 'recaptcha') => 'sl', + __('Serbian', 'recaptcha') => 'sr', + __('Swedish', 'recaptcha') => 'sv', + __('Thai', 'recaptcha') => 'th', + __('Turkish', 'recaptcha') => 'tr', + __('Ukrainian', 'recaptcha') => 'uk', + __('Vietnamese', 'recaptcha') => 'vi', + __('Simplified Chinese', 'recaptcha') => 'zh_cn', + __('Traditional Chinese', 'recaptcha') => 'zh_tw' + ); + + $this->build_dropdown('recaptcha_options[recaptcha_language]', + $languages, $this->options['recaptcha_language']); + } +} // end class declaration + +?> diff --git a/wp-content/plugins/wp-recaptcha-bp/recaptchalib.php b/wp-content/plugins/wp-recaptcha-bp/recaptchalib.php new file mode 100644 index 0000000000000000000000000000000000000000..a9053e2904ac7e04faafc0d83890161116b4b884 --- /dev/null +++ b/wp-content/plugins/wp-recaptcha-bp/recaptchalib.php @@ -0,0 +1,140 @@ +<?php +/** + * This is a PHP library that handles calling reCAPTCHA. + * - Documentation and latest version + * https://developers.google.com/recaptcha/docs/php + * - Get a reCAPTCHA API Key + * https://www.google.com/recaptcha/admin/create + * - Discussion group + * http://groups.google.com/group/recaptcha + * + * @copyright Copyright (c) 2014, Google Inc. + * @link http://www.google.com/recaptcha + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * A ReCaptchaResponse is returned from checkAnswer(). + */ +class ReCaptchaResponse +{ + public $success; + public $errorCodes; +} + +class ReCaptcha +{ + private static $_signupUrl = "https://www.google.com/recaptcha/admin"; + private static $_siteVerifyUrl = + "https://www.google.com/recaptcha/api/siteverify?"; + private $_secret; + private static $_version = "wp_php_1.0"; + + /** + * Constructor. + * + * @param string $secret shared secret between site and ReCAPTCHA server. + */ + function ReCaptcha($secret) + { + if ($secret == null || $secret == "") { + die("To use reCAPTCHA you must get an API key from <a href='" + . self::$_signupUrl . "'>" . self::$_signupUrl . "</a>"); + } + $this->_secret=$secret; + } + + /** + * Encodes the given data into a query string format. + * + * @param array $data array of string elements to be encoded. + * + * @return string - encoded request. + */ + private function _encodeQS($data) + { + $req = ""; + foreach ($data as $key => $value) { + $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; + } + + // Cut the last '&' + $req=substr($req, 0, strlen($req)-1); + return $req; + } + + /** + * Submits an HTTP GET to a reCAPTCHA server. + * + * @param string $path url path to recaptcha server. + * @param array $data array of parameters to be sent. + * + * @return array response + */ + private function _submitHTTPGet($path, $data) + { + $req = $this->_encodeQS($data); + $response = file_get_contents($path . $req); + return $response; + } + + /** + * Calls the reCAPTCHA siteverify API to verify whether the user passes + * CAPTCHA test. + * + * @param string $remoteIp IP address of end user. + * @param string $response response string from recaptcha verification. + * + * @return ReCaptchaResponse + */ + public function verifyResponse($remoteIp, $response) + { + // Discard empty solution submissions + if ($response == null || strlen($response) == 0) { + $recaptchaResponse = new ReCaptchaResponse(); + $recaptchaResponse->success = false; + $recaptchaResponse->errorCodes = 'missing-input'; + return $recaptchaResponse; + } + + $getResponse = $this->_submitHttpGet( + self::$_siteVerifyUrl, + array ( + 'secret' => $this->_secret, + 'remoteip' => $remoteIp, + 'v' => self::$_version, + 'response' => $response + ) + ); + $answers = json_decode($getResponse, true); + $recaptchaResponse = new ReCaptchaResponse(); + + if (trim($answers [success]) == true) { + $recaptchaResponse->success = true; + } else { + $recaptchaResponse->success = false; + $recaptchaResponse->errorCodes = $answers [error-codes]; + } + + return $recaptchaResponse; + } +} + +?> diff --git a/wp-content/plugins/wp-recaptcha-bp/screenshot-1.png b/wp-content/plugins/wp-recaptcha-bp/screenshot-1.png new file mode 100644 index 0000000000000000000000000000000000000000..4db34f71c2b9399d41fb586a2f2e236938351ac4 Binary files /dev/null and b/wp-content/plugins/wp-recaptcha-bp/screenshot-1.png differ diff --git a/wp-content/plugins/wp-recaptcha-bp/screenshot-2.png b/wp-content/plugins/wp-recaptcha-bp/screenshot-2.png new file mode 100644 index 0000000000000000000000000000000000000000..acaf1b3dffe5c1284e6c28b363b9130f923f1a92 Binary files /dev/null and b/wp-content/plugins/wp-recaptcha-bp/screenshot-2.png differ diff --git a/wp-content/plugins/wp-recaptcha-bp/settings.php b/wp-content/plugins/wp-recaptcha-bp/settings.php new file mode 100644 index 0000000000000000000000000000000000000000..fb3606ee63ebf6a1d128d79cbb07458c756f8aa7 --- /dev/null +++ b/wp-content/plugins/wp-recaptcha-bp/settings.php @@ -0,0 +1,77 @@ +<?php +/** + * This is a WordPress plugin settings that handles calling reCAPTCHA. + * - Documentation and latest version + * https://developers.google.com/recaptcha/docs/php + * - Get a reCAPTCHA API Key + * https://www.google.com/recaptcha/admin/create + * - Discussion group + * http://groups.google.com/group/recaptcha + * + * @link http://www.google.com/recaptcha + */ + +if (defined('ALLOW_INCLUDE') === false) + die('no direct access'); +?> + +<div class="wrap"> + <a name="recaptcha"></a> + <h2><?php _e('reCAPTCHA Options', 'recaptcha'); ?></h2> + <p><?php _e('reCAPTCHA is a free, accessible CAPTCHA service that helps to block spam on your blog.', 'recaptcha'); ?></p> + + <form method="post" action="options.php"> + <?php settings_fields('recaptcha_options_group'); ?> + + <h3><?php _e('Authentication', 'recaptcha'); ?></h3> + <p><?php _e('These keys are required. You can register them at', 'recaptcha'); ?> + <a href="http://www.google.com/recaptcha/admin/create" title="<?php _e('Get your reCAPTCHA API Keys', 'recaptcha'); ?>"><?php _e('here', 'recaptcha'); ?></a>.</p> + <p><?php _e('These keys should be non-global key!', 'recaptcha'); ?></p> + + <table class="form-table"> + <tr valign="top"> + <th scope="row"><?php _e('Site Key (Public Key)', 'recaptcha'); ?></th> + <td> + <input type="text" name="recaptcha_options[site_key]" size="40" value="<?php echo $this->options['site_key']; ?>" /> + </td> + </tr> + <tr valign="top"> + <th scope="row"><?php _e('Secret (Private Key)', 'recaptcha'); ?></th> + <td> + <input type="text" name="recaptcha_options[secret]" size="40" value="<?php echo $this->options['secret']; ?>" /> + </td> + </tr> + </table> + + <h3><?php _e('General Options', 'recaptcha'); ?></h3> + <table class="form-table"> + <tr valign="top"> + <th scope="row"><?php _e('Theme', 'recaptcha'); ?></th> + <td> + <?php $this->theme_dropdown(); ?> + </td> + </tr> + + <tr valign="top"> + <th scope="row"><?php _e('Language', 'recaptcha'); ?></th> + <td> + <?php $this->recaptcha_language_dropdown(); ?> + </td> + </tr> + </table> + + <h3><?php _e('Error Messages', 'recaptcha'); ?></h3> + <table class="form-table"> + <tr valign="top"> + <th scope="row"><?php _e('reCAPTCHA Ignored', 'recaptcha'); ?></th> + <td> + <input type="text" name="recaptcha_options[no_response_error]" size="70" value="<?php echo $this->options['no_response_error']; ?>" /> + </td> + </tr> + </table> + + <p class="submit"><input type="submit" class="button-primary" title="<?php _e('Save reCAPTCHA Options') ?>" value="<?php _e('Save reCAPTCHA Changes') ?> »" /></p> + </form> + + <?php do_settings_sections('recaptcha_options_page'); ?> +</div> \ No newline at end of file diff --git a/wp-content/plugins/wp-recaptcha-bp/uninstall.php b/wp-content/plugins/wp-recaptcha-bp/uninstall.php new file mode 100644 index 0000000000000000000000000000000000000000..3e23a59d4325cb4020626fab68ac534610130123 --- /dev/null +++ b/wp-content/plugins/wp-recaptcha-bp/uninstall.php @@ -0,0 +1,15 @@ +<?php +// this is the uninstall handler +// include unregister_setting, delete_option, and other uninstall behavior here + +require_once('wp-plugin.php'); + +function uninstall_options($name) { + unregister_setting("${name}_group", $name); + WPPlugin::remove_options($name); +} + +// recaptcha +uninstall_options('recaptcha_options'); + +?> \ No newline at end of file diff --git a/wp-content/plugins/wp-recaptcha-bp/wp-plugin.php b/wp-content/plugins/wp-recaptcha-bp/wp-plugin.php new file mode 100644 index 0000000000000000000000000000000000000000..ef05111ee044ab2808dec671cceaa10b15970ffb --- /dev/null +++ b/wp-content/plugins/wp-recaptcha-bp/wp-plugin.php @@ -0,0 +1,131 @@ +<?php + +// just making sure the constant is defined +if (!defined('WP_CONTENT_DIR')) + define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); + +if (!class_exists('Environment')) { + class Environment { + const WordPress = 1; // regular wordpress + const WordPressMU = 2; // wordpress mu + const WordPressMS = 3; // wordpress multi-site + } +} + +if (!class_exists('WPPlugin')) { + abstract class WPPlugin { + protected $environment; // what environment are we in + protected $options_name; // the name of the options + + protected $options; + + function WPPlugin($options_name) { + $args = func_get_args(); + call_user_func_array(array(&$this, "__construct"), $args); + } + + function __construct($options_name) { + $this->environment = WPPlugin::determine_environment(); + $this->options_name = $options_name; + + $this->options = WPPlugin::retrieve_options($this->options_name); + } + + // sub-classes determine what actions and filters to hook + abstract protected function register_actions(); + abstract protected function register_filters(); + + // environment checking + static function determine_environment() { + global $wpmu_version; + + if (function_exists('is_multisite')) + if (is_multisite()) + return Environment::WordPressMS; + + if (!empty($wpmu_version)) + return Environment::WordPressMU; + + return Environment::WordPress; + } + + // path finding + static function plugins_directory() { + if (WPPlugin::determine_environment() == Environment::WordPressMU) + return WP_CONTENT_DIR . '/mu-plugins'; + else + return WP_CONTENT_DIR . '/plugins'; + } + + static function plugins_url() { + if (WPPlugin::determine_environment() == Environment::WordPressMU) + return site_url() . '/wp-content/mu-plugins'; + else + return site_url() . '/wp-content/plugins'; + } + + static function path_to_plugin_directory() { + $current_directory = basename(dirname(__FILE__)); + + return WPPlugin::plugins_directory() . "/${current_directory}"; + } + + static function url_to_plugin_directory() { + $current_directory = basename(dirname(__FILE__)); + + return WPPlugin::plugins_url() . "/${current_directory}"; + } + + static function path_to_plugin($file_path) { + $file_name = basename($file_path); // /etc/blah/file.txt => file.txt + + if (WPPlugin::determine_environment() == Environment::WordPressMU) + return WPPlugin::plugins_directory() . "/${file_name}"; + else + return WPPlugin::path_to_plugin_directory() . "/${file_name}"; + } + + // options + abstract protected function register_default_options(); + + // option retrieval + static function retrieve_options($options_name) { + if (WPPlugin::determine_environment() == Environment::WordPressMU) + return get_site_option($options_name); + else + return get_option($options_name); + } + + static function remove_options($options_name) { + if (WPPlugin::determine_environment() == Environment::WordPressMU) + return delete_site_option($options_name); + else + return delete_option($options_name); + } + + static function add_options($options_name, $options) { + if (WPPlugin::determine_environment() == Environment::WordPressMU) + return add_site_option($options_name, $options); + else + return add_option($options_name, $options); + } + + protected function is_multi_blog() { + return $this->environment != Environment::WordPress; + } + + // calls the appropriate 'authority' checking function + protected function is_authority() { + if ($this->environment == Environment::WordPress) + return is_admin(); + + if ($this->environment == Environment::WordPressMU) + return is_site_admin(); + + if ($this->environment == Environment::WordPressMS) + return is_super_admin(); + } + } +} + +?> diff --git a/wp-content/plugins/wp-recaptcha-bp/wp-recaptcha.php b/wp-content/plugins/wp-recaptcha-bp/wp-recaptcha.php new file mode 100644 index 0000000000000000000000000000000000000000..3851bf9197cb6230af2bfa0406ae17449eac1279 --- /dev/null +++ b/wp-content/plugins/wp-recaptcha-bp/wp-recaptcha.php @@ -0,0 +1,17 @@ +<?php +/* +Plugin Name: WP-reCAPTCHA-bp +Description: Integrates reCAPTCHA anti-spam solutions with wordpress sites using BuddyPress +Version: 4.1 +Email: rodrigo@phplist.com +*/ + +// this is the 'driver' file that instantiates the objects and registers every hook + +define('ALLOW_INCLUDE', true); + +require_once('recaptcha.php'); + +$recaptcha = new ReCAPTCHAPlugin('recaptcha_options'); + +?>