Options saved...
');
}
$opt = get_option('nocaptcha_login_recaptcha_options');
?>
Are you robot? Google reCAPTCHA settings
Get the public key and private key Google recaptcha
|
Like us on Facebook
|
';
if (1 == $login_recaptcha_err) {
$captcha_code .= 'Human verification failed!
';
}
}
echo $captcha_code;
}
if($nocaptcha_opts["login"]=="1") {
add_action('login_form', 'nocaptcha_login_recaptcha_form');
}
if (!function_exists('nocaptcha_login_recaptcha_get_ip')) {
function nocaptcha_login_recaptcha_get_ip() {
return $_SERVER['REMOTE_ADDR'];
}
}
if (!function_exists('nocaptcha_login_recaptcha_get_post')) {
function nocaptcha_login_recaptcha_get_post($var_name) {
if (isset($_POST[$var_name])) {
return $_POST[$var_name];
} else {
return '';
}
}
}
if (!function_exists('nocaptcha_login_recaptcha_process')) {
function nocaptcha_login_recaptcha_process() {
if (array() == $_POST) {
return true;
}
$opt = get_option('nocaptcha_login_recaptcha_options');
$parameters = array(
'secret' => $opt['secret_key'],
'response' => nocaptcha_login_recaptcha_get_post('g-recaptcha-response'),
'remoteip' => nocaptcha_login_recaptcha_get_ip()
);
$url = 'https://www.google.com/recaptcha/api/siteverify?' . http_build_query($parameters);
$response = nocaptcha_login_recaptcha_open_url($url);
$json_response = json_decode($response, true);
if (!empty($opt['secret_key']) && isset($json_response['success']) && true !== $json_response['success']) {
header('Location: wp-login.php?login_recaptcha_err=1');
exit();
}
}
}
if($nocaptcha_opts["login"]=="1") {
add_action('wp_authenticate', 'nocaptcha_login_recaptcha_process', 1);
}
if (!function_exists('nocaptcha_login_recaptcha_open_url')) {
function nocaptcha_login_recaptcha_open_url($url) {
if (function_exists('curl_init') && function_exists('curl_setopt') && function_exists('curl_exec')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
} else {
$response = file_get_contents($url);
}
return trim($response);
}
}
function login_style_fix() {
$wowinitialize = ' ';
echo $wowinitialize;
}
if($nocaptcha_opts["login"]=="1") {
add_action('login_head', 'login_style_fix');
}
/* Registration Page */
if (!function_exists('nocaptcha_login_recaptcha_reg_process')) {
function nocaptcha_login_recaptcha_reg_process()
{
if (array() == $_POST) {
return true;
}
$opt = get_option('nocaptcha_login_recaptcha_options');
$parameters = array(
'secret' => $opt['secret_key'],
'response' => nocaptcha_login_recaptcha_get_post('g-recaptcha-response'),
'remoteip' => nocaptcha_login_recaptcha_get_ip()
);
$url = 'https://www.google.com/recaptcha/api/siteverify?' . http_build_query($parameters);
$response = nocaptcha_login_recaptcha_open_url($url);
$json_response = json_decode($response, true);
if (!empty($opt['secret_key']) && isset($json_response['success']) && true !== $json_response['success']) {
header('Location: wp-login.php?action=register&login_recaptcha_err=1');
exit();
}
}
}
if($nocaptcha_opts["register"]=="1") {
add_action('register_form', 'nocaptcha_login_recaptcha_form');
add_action('register_post', 'nocaptcha_login_recaptcha_reg_process', 10, 3);
}
if($nocaptcha_opts["comments"]=="1") {
add_action( 'comment_form_after_fields', 'nocaptcha_comment_form');
add_action( 'comment_form_logged_in_after', 'nocaptcha_comment_form');
}
if (!function_exists('nocaptcha_comment_form')) {
function nocaptcha_comment_form() {
if ( is_user_logged_in()) {
return true;
}
$opt = get_option('nocaptcha_login_recaptcha_options');
$captcha_code = '';
if ('' != $opt['site_key'] && '' != $opt['secret_key']) {
$captcha_code .= '
';
if (1 == $login_recaptcha_err) {
$captcha_code .= 'Human verification failed!
';
}
}
echo $captcha_code;
return true;
}
}
if($nocaptcha_opts["comments"]=="1") {
add_filter('preprocess_comment', 'cptch_comment_post');
}
if ( ! function_exists( 'cptch_comment_post' ) ) {
function cptch_comment_post( $comment ) {
if ( is_user_logged_in() ) {
return $comment;
}
if ( isset( $_REQUEST['action'] ) && 'replyto-comment' == $_REQUEST['action'] &&
( check_ajax_referer( 'replyto-comment', '_ajax_nonce', false ) || check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment', false ) ) ) {
return $comment;
}
if ( '' != $comment['comment_type'] && 'comment' != $comment['comment_type'] ) {
return $comment;
}
$opt = get_option('nocaptcha_login_recaptcha_options');
$parameters = array(
'secret' => $opt['secret_key'],
'response' => nocaptcha_login_recaptcha_get_post('g-recaptcha-response'),
'remoteip' => nocaptcha_login_recaptcha_get_ip()
);
$url = 'https://www.google.com/recaptcha/api/siteverify?' . http_build_query($parameters);
$response = nocaptcha_login_recaptcha_open_url($url);
$json_response = json_decode($response, true);
if (!empty($opt['secret_key']) && isset($json_response['success']) && true !== $json_response['success']) {
wp_die( __('Human verification failed', 'captcha' ) );
}else{
return( $comment );
}
}
}
/* buddypress */
if ( ! function_exists( 'bp_add_recaptcha' ) ) {
function bp_add_recaptcha()
{
global $bp;
$opt = get_option('nocaptcha_login_recaptcha_options');
$captcha_code = '';
if ('' != $opt['site_key'] && '' != $opt['secret_key']) {
$captcha_code .= '
';
}
$html = '';
$html .= '
';
$html .= '
';
if (!empty($bp->signup->errors['recaptcha_response_field'])) {
$html .= '
';
$html .= $bp->signup->errors['recaptcha_response_field'];
$html .= '
';
}
$html .= $captcha_code;
$html .= '
';
$html .= '
';
echo $html;
}
}
if ( ! function_exists( 'bp_validate_recaptcha' ) ) {
function bp_validate_recaptcha($errors)
{
global $bp, $strError;
$opt = get_option('nocaptcha_login_recaptcha_options');
$parameters = array(
'secret' => $opt['secret_key'],
'response' => nocaptcha_login_recaptcha_get_post('g-recaptcha-response'),
'remoteip' => nocaptcha_login_recaptcha_get_ip()
);
$url = 'https://www.google.com/recaptcha/api/siteverify?' . http_build_query($parameters);
$response = nocaptcha_login_recaptcha_open_url($url);
$json_response = json_decode($response, true);
if (!empty($opt['secret_key']) && isset($json_response['success']) && true !== $json_response['success']) {
$bp->signup->errors['recaptcha_response_field'] = 'Human verification failed!
';
}
return;
}
}
if($nocaptcha_opts["buddypress"]=="1") {
add_action('bp_before_registration_submit_buttons', 'bp_add_recaptcha');
add_action('bp_signup_validate', 'bp_validate_recaptcha');
}
/* cf7 */
function is_cf7_active() {
return in_array(
'contact-form-7/wp-contact-form-7.php',
apply_filters(
'active_plugins',
get_option(
'active_plugins' ) ) );
}
if(is_cf7_active()) {
add_action('wpcf7_init', 'add_shortcode_no_gcaptcha');
add_filter('wpcf7_validate_no_captcha', 'nocap_validation_filter_func', 10, 2);
}
function add_shortcode_no_gcaptcha() {
wpcf7_add_shortcode( 'no_captcha', 'shortcode_no_gcaptcha_handler' ); // "clock" is the type of the form-tag
}
function shortcode_no_gcaptcha_handler( $tag ) {
$opt = get_option('nocaptcha_login_recaptcha_options');
$captcha_code = '';
if ('' != $opt['site_key'] && '' != $opt['secret_key']) {
$captcha_code .= '
';
}else{
$captcha_code .= 'Please configure private key & public key in settings
';
}
return $captcha_code;
}
function nocap_validation_filter_func( $result, $tag ) {
$opt = get_option('nocaptcha_login_recaptcha_options');
$parameters = array(
'secret' => $opt['secret_key'],
'response' => nocaptcha_login_recaptcha_get_post('g-recaptcha-response'),
'remoteip' => nocaptcha_login_recaptcha_get_ip()
);
$url = 'https://www.google.com/recaptcha/api/siteverify?' . http_build_query($parameters);
$response = nocaptcha_login_recaptcha_open_url($url);
$json_response = json_decode($response, true);
if (!empty($opt['secret_key']) && isset($json_response['success']) && true !== $json_response['success']) {
$result['valid'] = false;
$result['reason']['no_recaptcha'] = "Recaptcha verification failed..";
}
return $result;
}
?>