Error submitting form!
Please make sure both javascript and cookies are enabled in your browser.
Use the back button to try again...
(Note: if this still doesn't help, then refreshing your cache might)", 'anti_captcha'));
add_action('login_head', 'anti_captcha_head');
//add_action('wp_authenticate', 'anti_captcha_process_login');
add_action('wp_head', 'anti_captcha_head');
add_action('register_post','anti_captcha_process_registration',10,3);
add_action('lostpassword_post','anti_captcha_process_lostpassword',10,3);
add_filter('preprocess_comment', 'anti_captcha_process_comment');
function anti_captcha_head()
{
if (is_user_logged_in()) return;
wp_enqueue_script('anti-captcha', '/wp-content/plugins/anti-captcha/anti-captcha-0.3.js.php', array(), md5(rand(1111,9999)));
wp_print_scripts('anti-captcha');
}
function anti_captcha_verify_token($token)
{
if (sha1($token) == $_COOKIE['anti-captcha-crc']) {
setcookie ('anti-captcha-crc', sha1(rand(1111,9999)), time() + 3600, '/');
return true;
}
return false;
}
function anti_captcha_process_comment($incoming_comment)
{
// Default to spam
$commentStatus = 'spam';
// Approve comment if user is logged in or provides a valid anti-capcha-token
if (is_user_logged_in() || anti_captcha_verify_token($_POST['anti-captcha-token'])) {
$commentStatus = '1';
// If a mailaddress is provided, check it for format and MX-records
if (strlen($incoming_comment['comment_author_email'])) {
// If this test fails, hold comment for moderation
if (!anti_captcha_validate_email($incoming_comment['comment_author_email'])) {
$commentStatus = '0';
}
}
}
add_filter('pre_comment_approved', create_function('$a', "return '" . $commentStatus . "';"));
return $incoming_comment;
}
/*
// Uncomment this if you want Anti-Captcha to also work on login form
function anti_captcha_process_login()
{
if (count($_POST)) {
if (!anti_captcha_verify_token($_POST['anti-captcha-token'])) {
wp_die(ANTI_CAPTCHA_ERROR);
}
}
}
*/
function anti_captcha_process_registration($login,$email,$errors)
{
if (!anti_captcha_verify_token($_POST['anti-captcha-token'])) {
$errors->add('anti_captcha_error', ANTI_CAPTCHA_ERROR);
}
}
function anti_captcha_process_lostpassword()
{
if (!anti_captcha_verify_token($_POST['anti-captcha-token'])) {
wp_die(ANTI_CAPTCHA_ERROR);
}
}
function anti_captcha_validate_email($email)
{
if (!strstr($email,'@')) { return false; }
$email = strtolower($email);
list($local, $domain) = explode('@', $email);
if (count(dns_get_record($domain, DNS_MX)) < 1) {
return false;
}
$match_local = preg_match('#^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$#', $local);
$match_domain = preg_match('#^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$#', $domain);
return ($match_local && $match_domain ? true : false);
}