Commit acd981bf authored by shammash's avatar shammash Committed by lechuck

updated wp-recaptcha to 3.1.3

parent 9069ba41
<?php
require_once('wp-plugin.php');
if (!class_exists('MailHide')) {
class MailHide extends WPPlugin {
// member variables
private $mcrypt_loaded;
function MailHide($options_name) {
$args = func_get_args();
call_user_func_array(array(&$this, "__construct"), $args);
}
function __construct($options_name) {
// instantiate super class (sets: options, environment, options_name)
parent::__construct($options_name);
$this->register_default_options();
// require the recaptcha library
$this->require_library();
// verify mcrypt is loaded
$this->verify_mcrypt();
// register the hooks
$this->register_actions();
$this->register_filters();
// keep this in the arsenal just in case
// disable the make_clickable filter cause it screws things up
/*
if ($this->mailhide_enabled()) {
remove_filter('comment_text', 'make_clickable', 9);
}*/
}
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')); // this way it only happens once, when the plugin is activated
add_action('admin_init', array(&$this, 'register_settings_group'));
add_action('admin_init', array(&$this, 'settings_section'));
// admin notice
add_action('admin_notices', array(&$this, 'missing_mcrypt_notice'));
add_action('admin_notices', array(&$this, 'missing_keys_notice'));
}
function register_filters() {
// add the filters only if mcrypt is loaded
if ($this->mcrypt_loaded) {
if ($this->options['use_in_posts'])
add_filter('the_content', array(&$this, 'mailhide_emails'), 9000);
if ($this->options['use_in_comments'])
add_filter('comment_text', array(&$this, 'mailhide_emails'), 9000);
// todo: this seems like it doesn't work: http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content_rss
// instead check for is_feed() on 'the_content' filter
// the_excerpt_rss filter works fine
// concern: it seems like the feeds still show the email encoded in CDATA
if ($this->options['use_in_rss']) {
add_filter('the_content_rss', array(&$this, 'mailhide_emails'), 9000);
add_filter('the_excerpt_rss', array(&$this, 'mailhide_emails'), 9000); // this one is sometimes used instead
}
// todo: atom requires the html to be escaped, rss does not. do so accordingly in the preg_replace_callbacks
// todo: also be sure to escape replace_link_with
// - use htmlentities($var, ENT_QUOTES); for escaping?
if ($this->options['use_in_rss_comments'])
add_filter('comment_text_rss', array(&$this, 'mailhide_emails'), 9000);
}
}
function mailhide_enabled() {
return ($this->options['use_in_posts'] || $this->options['use_in_comments'] || $this->options['use_in_rss'] || $this->options['use_in_rss_comments']);
}
function keys_missing() {
return (empty($this->options['public_key']) || empty($this->options['private_key']));
}
function create_error_notice($message, $anchor = '') {
$options_url = admin_url('options-general.php?page=wp-recaptcha/recaptcha.php') . $anchor;
$error_message = sprintf(__($message . ' <a href="%s" title="WP-reCAPTCHA Options">Fix this</a>', 'recaptcha'), $options_url);
echo '<div class="error"><p><strong>' . $error_message . '</strong></p></div>';
}
function missing_mcrypt_notice() {
if ($this->mailhide_enabled() && !$this->mcrypt_loaded) {
$this->create_error_notice('You enabled MailHide but the mcrypt PHP extension does not seem to be loaded.', '#mailhide');
}
}
// todo: make a check in mailhide_settings partial so that if the keys are missing, the appropriate box is highlighted with #FFFFE0 bg-color 1px solid #E6DB55 border
function missing_keys_notice() {
if ($this->mailhide_enabled() && $this->keys_missing()) {
$this->create_error_notice('You enabled MailHide, but some of the MailHide API Keys seem to be missing.', '#mailhide');
}
}
function settings_section() {
add_settings_section('mailhide_options', '', array(&$this, 'show_settings_section'), 'recaptcha_options_page');
}
function show_settings_section() {
include('mailhide_settings.php');
}
function verify_mcrypt() {
$this->mcrypt_loaded = extension_loaded('mcrypt');
}
// require the recaptcha library
function require_library() {
require_once(WPPlugin::path_to_plugin_directory() . '/recaptchalib.php');
}
function load_textdomain() {
load_plugin_textdomain('recaptcha', false, 'languages');
}
function register_default_options() {
if ($this->options)
return;
$option_defaults = array();
$old_options = WPPlugin::retrieve_options("recaptcha");
if ($old_options) {
// keys
$option_defaults['public_key'] = $old_options['mailhide_pub']; // mailhide public key
$option_defaults['private_key'] = $old_options['mailhide_priv']; // mailhide private key
// placement
$option_defaults['use_in_posts'] = $old_options['use_mailhide_posts']; // mailhide for posts/pages
$option_defaults['use_in_comments'] = $old_options['use_mailhide_comments']; // use mailhide for comments
$option_defaults['use_in_rss'] = $old_options['use_mailhide_rss']; // use mailhide for the rss feed of the posts/pages
$option_defaults['use_in_rss_comments'] = $old_options['use_mailhide_rss_comments']; // use mailhide for the rss comments
// bypass levels
$option_defaults['bypass_for_registered_users'] = ($old_options['mh_bypass'] == "on") ? 1 : 0; // whether to sometimes skip the MailHide filter for registered users
$option_defaults['minimum_bypass_level'] = $old_options['mh_bypasslevel']; // who can see full emails normally (should be a valid WordPress capability slug)
if ($option_defaults['minimum_bypass_level'] == "level_10") {
$option_defaults['minimum_bypass_level'] = "activate_plugins";
}
// styling
$option_defaults['replace_link_with'] = $old_options['mh_replace_link']; // name the link something else
$option_defaults['replace_title_with'] = $old_options['mh_replace_title']; // title of the link
}
else {
// keys
$option_defaults['public_key'] = ''; // mailhide public key
$option_defaults['private_key'] = ''; // mailhide private key
// placement
$option_defaults['use_in_posts'] = 0; // mailhide for posts/pages
$option_defaults['use_in_comments'] = 0; // use mailhide for comments
$option_defaults['use_in_rss'] = 0; // use mailhide for the rss feed of the posts/pages
$option_defaults['use_in_rss_comments'] = 0; // use mailhide for the rss comments
// bypass levels
$option_defaults['bypass_for_registered_users'] = 0; // whether to sometimes skip the MailHide filter for registered users
$option_defaults['minimum_bypass_level'] = 'read'; // who can see full emails normally (should be a valid WordPress capability slug)
// styling
$option_defaults['replace_link_with'] = ''; // name the link something else
$option_defaults['replace_title_with'] = ''; // title of the link
}
// add the option based on what environment we're in
WPPlugin::add_options($this->options_name, $option_defaults);
}
function register_settings_group() {
register_setting('mailhide_options_group', 'mailhide_options', array(&$this, 'validate_options'));
}
function validate_dropdown($array, $key, $value) {
// make sure that the capability that was supplied is a valid capability from the drop-down list
if (in_array($value, $array))
return $value;
else // if not, load the old value
return $this->options[$key];
}
function validate_options($input) {
// keys
$validated['public_key'] = trim($input['public_key']); // mailhide public key
$validated['private_key'] = trim($input['private_key']); // mailhide private key
// placement
$validated['use_in_posts'] = ($input['use_in_posts'] == 1 ? 1 : 0); // mailhide for posts/pages
$validated['use_in_comments'] = ($input['use_in_comments'] == 1 ? 1 : 0); // use mailhide for comments
$validated['use_in_rss'] = ($input['use_in_rss'] == 1 ? 1 : 0); // use mailhide for the rss feed of the posts/pages
$validated['use_in_rss_comments'] = ($input['use_in_rss_comments'] == 1 ? 1 : 0); // use mailhide for the rss comments
$capabilities = array('read', 'edit_posts', 'publish_posts', 'moderate_comments', 'activate_plugins');
// bypass levels
$validated['bypass_for_registered_users'] = ($input['bypass_for_registered_users'] == 1 ? 1: 0); // whether to sometimes skip the MailHide filter for registered users
$validated['minimum_bypass_level'] = $this->validate_dropdown($capabilities, 'minimum_bypass_level', $input['minimum_bypass_level']); // who can see full emails normally (should be a valid WordPress capability slug)
// styling
$validated['replace_link_with'] = $input['replace_link_with']; // name the link something else
$validated['replace_title_with'] = $input['replace_title_with']; // title of the link
return $validated;
}
function build_dropdown($name, $keyvalue, $checked_value) {
echo '<select name="' . $name . '" id="' . $name . '">' . "\n";
foreach ($keyvalue as $key => $value) {
if ($value == $checked_value)
$checked = ' selected="selected" ';
echo '\t <option value="' . $value . '"' . $checked . ">$key</option> \n";
$checked = NULL;
}
echo "</select> \n";
}
function capabilities_dropdown() {
// define choices: Display text => permission slug
$capabilities = array(
__('all registered users', 'recaptcha') => 'read',
__('edit posts', 'recaptcha') => 'edit_posts',
__('publish posts', 'recaptcha') => 'publish_posts',
__('moderate comments', 'recaptcha') => 'moderate_comments',
__('activate plugins', 'recaptcha') => 'activate_plugins'
);
$this->build_dropdown('mailhide_options[minimum_bypass_level]', $capabilities, $this->options['minimum_bypass_level']);
}
function mailhide_emails($content) {
global $user_ID;
// set the minimum capability needed to skip the MailHide if there is one
if ($this->options['bypass_for_registered_users'] && $this->options['minimum_bypass_level'])
$needed_capability = $this->options['minimum_bypass_level'];
// skip the MailHide display if the minimum capability is met
// todo: only 'use in comments' is checked, have to check each of them?
// todo: wait, is that necessary? the filter isn't even added if that field is false, removed
if ($needed_capability && current_user_can($needed_capability)) {
// remove the nohides
$content = preg_replace('/\[\/?nohide\]/i','',$content);
return $content;
}
// Regular Expressions thanks to diabolic from EFNet #regex
// match hyperlinks with emails
$regex = '/(?!\[nohide\])<a[^>]*href="((?:mailto:)?([^@"]+@[^@"]+))"[^>]*>(.+?)<\/a>(?!\[\/nohide\])/i';
$content = preg_replace_callback($regex, array(&$this, "replace_hyperlinked"), $content);
// match emails
// this seems to no longer be necessary because wordpress automatically linkifies all plaintext emails
$regex = '/\b([\w.+-]+@[a-z\d.-]+\.[a-z]{2,6})\b(?!\s*\[\/nohide\]|(?:(?!<a[^>]*>).)*<\/a>)/i';
$content = preg_replace_callback($regex, array(&$this, "replace_plaintext"), $content);
// remove the nohides
$content = preg_replace('/\[\/?nohide\]/i','',$content);
return $content;
}
// replace the hyperlinked emails i.e. <a href="haha@lol.com">this</a> or <a href="mailto:haha@lol.com">that</a>
function replace_hyperlinked($matches) {
$html = "";
$email = $matches[2];
$text = $matches[3];
if ($email == $text) {
// employ the use of email parts instead
$html = recaptcha_mailhide_html($this->options['public_key'], $this->options['private_key'], $email);
// style it
$html = '<span class="mh-email">' . $html . "</span>";
}
else {
// get the url, the part inside the href. this is the email of course
$url = recaptcha_mailhide_url($this->options['public_key'], $this->options['private_key'], $email);
// construct a new hyperlink with the url hidden but the link text the same
$html = "<a href='" . $url . "' onclick=\"window.open('" . htmlentities ($url, ENT_QUOTES) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\">" . $text . "</a>";
// style it
$html = '<span class="mh-hyperlinked">' . $html . "</span>";
}
return $html;
}
// replace the plain text emails i.e. haha@lol.com
function replace_plaintext($matches) {
if ($this->options['replace_link_with'] == "" && $this->options['replace_title_with'] == "") {
// find plain text emails and hide them
$html = recaptcha_mailhide_html($this->options['public_key'], $this->options['private_key'], $matches[0]);
}
else {
// replace both things
if ($this->options['replace_link_with'] != "" && $this->options['replace_title_with'] != "") {
$url = recaptcha_mailhide_url($this->options['public_key'], $this->options['private_key'], $matches[0]);
$html = "<a href='" . htmlentities($url, ENT_QUOTES) .
"' onclick=\"window.open('" . htmlentities($url, ENT_QUOTES) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"" . $this->options['replace_title_with'] . "\">" . $this->options['replace_link_with'] . "</a>";
}
// only replace the link
else if ($this->options['replace_link_with'] != "" && $this->options['replace_title_with'] == "") {
$url = recaptcha_mailhide_url($this->options['public_key'], $this->options['private_key'], $matches[0]);
$html = "<a href='" . htmlentities($url, ENT_QUOTES) .
"' onclick=\"window.open('" . htmlentities($url, ENT_QUOTES) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">" . $this->options['replace_link_with'] . "</a>";
}
// only replace the title
else if ($this->options['replace_link_with'] == "" && $this->options['replace_title_with'] != "") {
$url = recaptcha_mailhide_url($this->options['public_key'], $this->options['private_key'], $matches[0]);
$emailparts = _recaptcha_mailhide_email_parts ($matches[0]);
$html = htmlentities($emailparts[0], ENT_QUOTES) . "<a href='" . htmlentities($url, ENT_QUOTES) .
"' onclick=\"window.open('" . htmlentities($url, ENT_QUOTES) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"" . $recaptcha_opt['replace_title_with'] . "\">...</a>@" . htmlentities($emailparts[0], ENT_QUOTES);
}
}
// style it
$html = '<span class="mh-email">' . $html . "</span>";
return $html;
}
} // end class declaration
} // end class exists clause
?>
\ No newline at end of file
<?php
if (defined('ALLOW_INCLUDE') === false)
die('no direct access');
?>
<a name="mailhide"></a>
<h2><?php _e('MailHide Options', 'recaptcha'); ?></h2>
<p><?php _e('One common misconception about MailHide is that it edits your email addresses on the database. This is false, your actual content is never actually modified. Instead, it is "filtered" such that it appears modified to the reader.', 'recaptcha'); ?></p>
<form method="post" action="options.php">
<?php settings_fields('mailhide_options_group'); ?>
<h3><?php _e('Authentication', 'recaptcha'); ?></h3>
<p><?php _e('These keys are required before you are able to do anything else.', 'recaptcha'); ?> <?php _e('You can get the keys', 'recaptcha'); ?> <a href="http://mailhide.recaptcha.net/apikey" title="<?php _e('Get your reCAPTCHA API Keys', 'recaptcha'); ?>"><?php _e('here', 'recaptcha'); ?></a>.</p>
<p><?php _e('Be sure not to mix them up! The public and private keys are not interchangeable!'); ?></p>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Public Key', 'recaptcha'); ?></th>
<td>
<input type="text" name="mailhide_options[public_key]" size="40" value="<?php echo $this->options['public_key']; ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Private Key', 'recaptcha'); ?></th>
<td>
<input type="text" name="mailhide_options[private_key]" size="40" value="<?php echo $this->options['private_key']; ?>" />
</td>
</tr>
</table>
<h3><?php _e('General Options', 'recaptcha'); ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Use MailHide in', 'recaptcha'); ?></th>
<td>
<input type="checkbox" id="mailhide_options[use_in_posts]" name="mailhide_options[use_in_posts]" value="1" <?php checked('1', $this->options['use_in_posts']); ?> />
<label for="mailhide_options[use_in_posts]"><?php _e('Posts and Pages', 'recaptcha'); ?></label><br />
<input type="checkbox" id="mailhide_options[use_in_comments]" name="mailhide_options[use_in_comments]" value="1" <?php checked('1', $this->options['use_in_comments']); ?> />
<label for="mailhide_options[use_in_comments]"><?php _e('Comments', 'recaptcha'); ?></label><br />
<input type="checkbox" id="mailhide_options[use_in_rss]" name="mailhide_options[use_in_rss]" value="1" <?php checked('1', $this->options['use_in_rss']); ?> />
<label for="mailhide_options[use_in_rss]"><?php _e('RSS Feed of Posts and Pages', 'recaptcha'); ?></label><br />
<input type="checkbox" id="mailhide_options[use_in_rss_comments]" name="mailhide_options[use_in_rss_comments]" value="1" <?php checked('1', $this->options['use_in_rss_comments']); ?> />
<label for="mailhide_options[use_in_rss_comments]"><?php _e('RSS Feed of Comments', 'recaptcha'); ?></label><br />
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Target', 'recaptcha'); ?></th>
<td>
<input type="checkbox" id="mailhide_options[bypass_for_registered_users]" name="mailhide_options[bypass_for_registered_users]" value="1" <?php checked('1', $this->options['bypass_for_registered_users']); ?> />
<label for="mailhide_options[bypass_for_registered_users]"><?php _e('Show actual email addresses to Registered Users who can', 'recaptcha'); ?></label>
<?php $this->capabilities_dropdown(); ?>
</td>
</tr>
</table>
<h3><?php _e('Presentation', 'recaptcha'); ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Replace Link With', 'recaptcha'); ?></th>
<td>
<input type="text" name="mailhide_options[replace_link_with]" size="70" value="<?php echo $this->options['replace_link_with']; ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Replace Title With', 'recaptcha'); ?></th>
<td>
<input type="text" name="mailhide_options[replace_title_with]" size="70" value="<?php echo $this->options['replace_title_with']; ?>" />
</td>
</tr>
</table>
<h3><?php _e('Styling', 'recaptcha'); ?></h3>
<p>You can style hidden emails using a variety of classes. Style the classes in your theme's stylesheet and be sure to clear any caches you might have to see the results.</p>
<ul>
<li><strong>.mh-email</strong> is assigned to the complete email</li>
<li><strong>.mh-first</strong> is assigned to the first part of the email</li>
<li><strong>.mh-middle</strong> is assigned to the middle of the email (the link)</li>
<li><strong>.mh-last</strong> is assigned to the last part of the email</li>
</ul>
<p>The following is an example of the structure:</p>
<code>
&lt;span class=&quot;mh-email&quot;&gt; <br \>
&nbsp;&nbsp;&nbsp; &lt;span class=&quot;mh-first&quot;&gt;jorg&lt;/span&gt; <br \>
&nbsp;&nbsp;&nbsp; &lt;a href=&quot;url&quot; class=&quot;mh-middle&quot;&gt;...&lt;/a&gt; <br \>
&nbsp;&nbsp;&nbsp; &lt;span class=&quot;mh-last&quot;&gt;@gmail.com&lt;/span&gt; <br \>
&lt;/span&gt;
</code>
<p class="submit"><input type="submit" class="button-primary" title="<?php _e('Save MailHide Options') ?>" value="<?php _e('Save MailHide Changes') ?> &raquo;" /></p>
</form>
\ No newline at end of file
......@@ -2,9 +2,9 @@
Contributors: BlaenkDenum
Donate link: http://www.blaenkdenum.com
Tags: comments, registration, recaptcha, antispam, mailhide, captcha, wpmu
Requires at least: 2.5
Tested up to: 3.0.1
Stable tag: 2.9.8.2
Requires at least: 2.7
Tested up to: 2.9.1
Stable tag: 3.1.3
Integrates reCAPTCHA anti-spam methods with WordPress including comment, registration, and email spam protection. WPMU Compatible.
......@@ -12,28 +12,26 @@ Integrates reCAPTCHA anti-spam methods with WordPress including comment, registr
= What is reCAPTCHA? =
[reCAPTCHA](http://recaptcha.net/ "reCAPTCHA") is an anti-spam method originating from [Carnegie Mellon University](http://www.cmu.edu/index.shtml "Carnegie Mellon University") which uses [CAPTCHAs](http://recaptcha.net/captcha.html "CAPTCHA") in a [genius way](http://recaptcha.net/learnmore.html "How Does it Work? - reCAPTCHA"). Instead of randomly generating useless characters which users grow tired of continuosly typing in, risking the possibility that spammers will eventually write sophisticated spam bots which use [OCR](http://en.wikipedia.org/wiki/Optical_character_recognition "Optical Character Recognition - Wikipedia") libraries to read the characters, reCAPTCHA uses a different approach.
[reCAPTCHA](http://recaptcha.net/ "reCAPTCHA") is an anti-spam method originating from [Carnegie Mellon University](http://www.cmu.edu/index.shtml "Carnegie Mellon University"), then acquired by [Google](http://www.google.com/recaptcha) which uses [CAPTCHAs](http://recaptcha.net/captcha.html "CAPTCHA") in a [genius way](http://recaptcha.net/learnmore.html "How Does it Work? - reCAPTCHA"). Instead of randomly generating useless characters which users grow tired of continuosly typing in, risking the possibility that spammers will eventually write sophisticated spam bots which use [OCR](http://en.wikipedia.org/wiki/Optical_character_recognition "Optical Character Recognition - Wikipedia") libraries to read the characters, reCAPTCHA uses a different approach.
While the world is in the process of digitizing books, sometimes certain words cannot be read. reCAPTCHA uses a combination of these words, further distorts them, and then constructs a CAPTCHA image. After a ceratin percentage of users solve the 'uknown' word the same way it is assumed that it is the correct spelling of the word. This helps digitize books, giving users a ***reason*** to solve reCAPTCHA forms. Because the industry level scanners and OCR software which are used to digitize the books can't read the words with which the CAPTCHAs are constructed, it is safe to assume that in-house spam-bot OCR techniques will not be able to bypass the CAPTCHA either.
The world is in the process of digitizing books by use of automated machines which employ the use of Optical Character Recognition software. Sometimes the certain words cannot be read by the software. reCAPTCHA uses a combination of these words, further distorts them, and then constructs a CAPTCHA image. After a certain percentage of users solve the 'unknown' word the same way, it is assumed that it is the correct spelling of the word. This helps digitize books, giving users a ***reason*** to solve reCAPTCHA forms. Because the industry level scanners and OCR software which are used to digitize the books can't read the words with which the CAPTCHAs are constructed, it is safe to assume that in-house spam-bot OCR techniques will not be able to bypass the resulting CAPTCHA, which is a further distortion of the unreadable word.
reCAPTCHA has earned a very prestigious reputation among the various CAPTCHA systems available and is used by such sites as [Facebook](http://www.facebook.com), [Twitter](http://www.twitter.com), [StumbleUpon](http://www.stumbleupon.com), and a few U.S. Government Websites such as the [TV Converter Box Coupon Program Website](https://www.dtv2009.gov/ "TV Converter Box Coupon Program Website").
reCAPTCHA is probably the most popular and widely accepted CAPTCHA systems by both end-users and site-owners. It is used by such sites prominent sites as [Facebook](http://www.facebook.com), [Twitter](http://www.twitter.com), to the Average Joe's little blog out there on the corner of the Internet.
It is accessible by everyone. If the user has trouble reading the CAPTCHA challenge, he or she has the option of requesting a new one. If this does not help, there is also an audio challenge which users may use.
This plugin is [WordPress MU](http://mu.wordpress.org/) compatible.
For more information please view the [plugin page](http://www.blaenkdenum.com/wp-recaptcha/ "WP-reCAPTCHA - Blaenk Denum")..
For more information please view the [plugin page](http://www.blaenkdenum.com/wp-recaptcha/ "WP-reCAPTCHA - Blaenk Denum").
== Installation ==
To install in regular WordPress:
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
1. Activate the plugin through the `Plugins` menu in WordPress
1. Get the reCAPTCHA keys [here](http://recaptcha.net/api/getkey?domain=www.blaenkdenum.com&app=wordpress "reCAPTCHA API keys") and/or the MailHide keys [here](http://mailhide.recaptcha.net/apikey "MailHide keys")
To install in WordPress MU (Optional Activation by Users):
1. Follow the instructions for regular WordPress above
To install in WordPress MU (Forced Activation/Site-Wide):
1. Upload the `wp-recaptcha` folder to the `/wp-content/mu-plugins` directory
......@@ -51,6 +49,22 @@ To install in WordPress MU (Forced Activation/Site-Wide):
== ChangeLog ==
= 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 =
......@@ -85,7 +99,7 @@ To install in WordPress MU (Forced Activation/Site-Wide):
* 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.
* Accomodated for the fact that in +2.6 the wp-content folder can be anywhere.
* Accommodated for the fact that in +2.6 the wp-content folder can be anywhere.
== Frequently Asked Questions ==
......@@ -95,10 +109,10 @@ 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 [home page](http://www.blaenkdenum.com/wp-recaptcha/ Blaenk Denum - WP-reCAPTCHA), 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.
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.
= 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.
......
This diff is collapsed.
......@@ -4,7 +4,7 @@
* - Documentation and latest version
* http://recaptcha.net/plugins/php/
* - Get a reCAPTCHA API Key
* http://recaptcha.net/api/getkey
* https://www.google.com/recaptcha/admin/create
* - Discussion group
* http://groups.google.com/group/recaptcha
*
......@@ -35,25 +35,27 @@
/**
* The reCAPTCHA server URL's
*/
define("RECAPTCHA_API_SERVER", "http://api.recaptcha.net");
define("RECAPTCHA_API_SECURE_SERVER", "https://api-secure.recaptcha.net");
define("RECAPTCHA_VERIFY_SERVER", "api-verify.recaptcha.net");
define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
/**
* Encodes the given data into a query string format
* @param $data - array of string elements to be encoded
* @return string - encoded request
*/
function _recaptcha_qsencode($data) {
$req = "";
foreach ($data as $key => $value)
$req .= $key . '=' . urlencode(stripslashes($value)) . '&';
// Cut the last '&'
$req=substr($req,0,strlen($req)-1);
return $req;
function _recaptcha_qsencode ($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 POST to a reCAPTCHA server
* @param string $host
......@@ -63,30 +65,30 @@ function _recaptcha_qsencode($data) {
* @return array response
*/
function _recaptcha_http_post($host, $path, $data, $port = 80) {
$req = _recaptcha_qsencode ($data);
$http_request = "POST $path HTTP/1.0\r\n";
$http_request .= "Host: $host\r\n";
$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
$http_request .= "Content-Length: " . strlen($req) . "\r\n";
$http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
$http_request .= "\r\n";
$http_request .= $req;
$response = '';