';
$cust_html_code .= $cap_form;
return $cust_html_code;
}
function insert_captcha_question_form_multi($error)
{
global $aio_wp_security;
$aio_wp_security->captcha_obj->display_captcha_form();
}
function process_signup_form_multi($result)
{
global $aio_wp_security;
//Check if captcha enabled
if (array_key_exists('aiowps-captcha-answer', $_POST)) //If the register form with captcha was submitted then do some processing
{
isset($_POST['aiowps-captcha-answer'])?$captcha_answer = strip_tags(trim($_POST['aiowps-captcha-answer'])): $captcha_answer = '';
$captcha_secret_string = $aio_wp_security->configs->get_value('aiowps_captcha_secret_key');
$submitted_encoded_string = base64_encode($_POST['aiowps-captcha-temp-string'].$captcha_secret_string.$captcha_answer);
$trans_handle = sanitize_text_field($_POST['aiowps-captcha-string-info']);
$captcha_string_info_trans = (AIOWPSecurity_Utility::is_multisite_install() ? get_site_transient('aiowps_captcha_string_info_'.$trans_handle) : get_transient('aiowps_captcha_string_info_'.$trans_handle));
if($submitted_encoded_string !== $captcha_string_info_trans)
{
//This means a wrong answer was entered
$result['errors']->add('generic', __('ERROR: Your answer was incorrect - please try again.', 'all-in-one-wp-security-and-firewall'));
}
}
return $result;
}
function insert_captcha_question_form(){
global $aio_wp_security;
$aio_wp_security->captcha_obj->display_captcha_form();
}
function insert_honeypot_hidden_field(){
$honey_input = '
';
$honey_input .= '
';
echo $honey_input;
}
function process_comment_post( $comment )
{
global $aio_wp_security;
if (is_user_logged_in()) {
return $comment;
}
//Don't process captcha for comment replies inside admin menu
if (isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'replyto-comment' &&
(check_ajax_referer('replyto-comment', '_ajax_nonce', false) || check_ajax_referer('replyto-comment', '_ajax_nonce-replyto-comment', false))) {
return $comment;
}
//Don't do captcha for pingback/trackback
if ($comment['comment_type'] != '' && $comment['comment_type'] != 'comment') {
return $comment;
}
if (isset($_REQUEST['aiowps-captcha-answer']))
{
// If answer is empty
if ($_REQUEST['aiowps-captcha-answer'] == ''){
wp_die( __('Please enter an answer in the CAPTCHA field.', 'all-in-one-wp-security-and-firewall' ) );
}
$captcha_answer = trim($_REQUEST['aiowps-captcha-answer']);
$captcha_secret_string = $aio_wp_security->configs->get_value('aiowps_captcha_secret_key');
$submitted_encoded_string = base64_encode($_POST['aiowps-captcha-temp-string'].$captcha_secret_string.$captcha_answer);
$trans_handle = sanitize_text_field($_POST['aiowps-captcha-string-info']);
$captcha_string_info_trans = (AIOWPSecurity_Utility::is_multisite_install() ? get_site_transient('aiowps_captcha_string_info_'.$trans_handle) : get_transient('aiowps_captcha_string_info_'.$trans_handle));
if ($captcha_string_info_trans === $submitted_encoded_string){
//Correct answer given
return($comment);
}else{
//Wrong answer
wp_die( __('Error: You entered an incorrect CAPTCHA answer. Please go back and try again.', 'all-in-one-wp-security-and-firewall'));
}
}
}
function process_lost_password_form_post()
{
global $aio_wp_security;
//Check if captcha enabled
if ($aio_wp_security->configs->get_value('aiowps_enable_lost_password_captcha') == '1')
{
if (array_key_exists('aiowps-captcha-answer', $_POST)) //If the lost pass form with captcha was submitted then do some processing
{
isset($_POST['aiowps-captcha-answer'])?($captcha_answer = strip_tags(trim($_POST['aiowps-captcha-answer']))):($captcha_answer = '');
$captcha_secret_string = $aio_wp_security->configs->get_value('aiowps_captcha_secret_key');
$submitted_encoded_string = base64_encode($_POST['aiowps-captcha-temp-string'].$captcha_secret_string.$captcha_answer);
$trans_handle = sanitize_text_field($_POST['aiowps-captcha-string-info']);
$captcha_string_info_trans = (AIOWPSecurity_Utility::is_multisite_install() ? get_site_transient('aiowps_captcha_string_info_'.$trans_handle) : get_transient('aiowps_captcha_string_info_'.$trans_handle));
if($submitted_encoded_string !== $captcha_string_info_trans)
{
add_filter('allow_password_reset', array(&$this, 'add_lostpassword_captcha_error_msg'));
}
}
}
}
function add_lostpassword_captcha_error_msg()
{
//Insert an error just before the password reset process kicks in
return new WP_Error('aiowps_captcha_error',__('ERROR: Your answer was incorrect - please try again.', 'all-in-one-wp-security-and-firewall'));
}
function check_404_event()
{
if(is_404()){
//This means a 404 event has occurred - let's log it!
AIOWPSecurity_Utility::event_logger('404');
}
}
function buddy_press_signup_validate_captcha($errors)
{
global $bp, $aio_wp_security;
//Check if captcha enabled
if (array_key_exists('aiowps-captcha-answer', $_POST)) //If the register form with captcha was submitted then do some processing
{
isset($_POST['aiowps-captcha-answer'])?$captcha_answer = strip_tags(trim($_POST['aiowps-captcha-answer'])): $captcha_answer = '';
$captcha_secret_string = $aio_wp_security->configs->get_value('aiowps_captcha_secret_key');
$submitted_encoded_string = base64_encode($_POST['aiowps-captcha-temp-string'].$captcha_secret_string.$captcha_answer);
$trans_handle = sanitize_text_field($_POST['aiowps-captcha-string-info']);
$captcha_string_info_trans = (AIOWPSecurity_Utility::is_multisite_install() ? get_site_transient('aiowps_captcha_string_info_'.$trans_handle) : get_transient('aiowps_captcha_string_info_'.$trans_handle));
if($submitted_encoded_string !== $captcha_string_info_trans)
{
//This means a wrong answer was entered
$bp->signup->errors['aiowps-captcha-answer'] = __('Your CAPTCHA answer was incorrect - please try again.', 'all-in-one-wp-security-and-firewall');
}
}
return;
}
//Displays a notice message if the plugin was reactivated after being initially deactivated.
//Notice message gives users option of re-applying the aiowps rules which were deleted from the .htaccess when deactivation occurred
function reapply_htaccess_rules_notice()
{
if (get_option('aiowps_temp_configs') !== FALSE){
echo '
Would you like All In One WP Security & Firewall to re-insert the security rules in your .htaccess file which were cleared when you deactivated the plugin? YesNo
';
}
}
//This is a fix for cases when the password reset URL in the email was not decoding all html entities properly
function decode_reset_pw_msg($message, $key, $user_login, $user_data)
{
global $aio_wp_security;
$message = html_entity_decode($message);
return $message;
}
function modify_registration_page_messages($errors, $redirect_to)
{
if( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ){
if(is_wp_error($errors)){
$errors->remove('registered');
$pending_approval_msg = __('Your registration is pending approval.', 'all-in-one-wp-security-and-firewall');
$pending_approval_msg = apply_filters('aiowps_pending_registration_message', $pending_approval_msg);
$errors->add('registered', $pending_approval_msg, array('registered'=>'message'));
}
}
return $errors;
}
}