$email, 'sender_nickname' => '', 'sender_info' => $sender_info, 'js_on' => $checkjs, ), true ); $ct_result = $base_call_result['ct_result']; if ( $ct_result->allow === 0 ) { $is_good = false; } } if ( $is_good ) { $ajaxresult = array( 'description' => null, 'cssClass' => 'noon', 'code' => 'success' ); } else { $ajaxresult = array( 'description' => 'Invalid Email', 'cssClass' => 'error-container', 'code' => 'error' ); } $ajaxresult = json_encode($ajaxresult); print $ajaxresult; wp_die(); } /** * AjaxLogin plugin handler * * @param $user_id * * @return mixed */ function ct_user_register_ajaxlogin($user_id) { if ( class_exists('AjaxLogin') && Post::get('action') === 'register_submit' ) { $checkjs = apbct_js_test('ct_checkjs', $_POST); $sender_info['post_checkjs_passed'] = $checkjs; if ( $checkjs === null ) { $checkjs = apbct_js_test('ct_checkjs', $_COOKIE, true); $sender_info['cookie_checkjs_passed'] = $checkjs; } //Making a call $base_call_result = apbct_base_call( array( 'sender_email' => Post::get('email', null, 'cleanEmail'), 'sender_nickname' => Post::get('login', null, 'cleanEmail'), 'sender_info' => $sender_info, 'js_on' => $checkjs, ), true ); $ct_result = $base_call_result['ct_result']; if ( $ct_result->allow === 0 ) { wp_delete_user($user_id); } } return $user_id; } /** * Hook into MailChimp for WordPress `mc4wp_form_errors` filter. * * @param array $errors * * @return array * @throws Exception */ function ct_mc4wp_ajax_hook(array $errors) { $result = ct_ajax_hook(); // only return modified errors array when function returned a string value (the message key) if ( is_string($result) ) { $errors[] = $result; } return $errors; } /** * Main handler of ajax forms checking * * @param array|object $message_obj * * @return array|bool|string|null * * @throws Exception * * @psalm-suppress ComplexFunction */ function ct_ajax_hook($message_obj = null) { global $current_user; $message_obj = (array)$message_obj; // Get current_user and set it globally apbct_wp_set_current_user($current_user instanceof WP_User ? $current_user : apbct_wp_get_current_user()); // $_REQUEST['action'] to skip. Go out because of not spam data $skip_post = array( 'apbct_js_keys__get', // Our service code 'gmaps_display_info_window', // Geo My WP pop-up windows. 'gmw_ps_display_info_window', // Geo My WP pop-up windows. 'the_champ_user_auth', // Super Socializer 'simbatfa-init-otp', //Two-Factor Auth 'wppb_msf_check_required_fields', //ProfileBuilder skip step checking 'boss_we_login', //Login form 'sidebar_login_process', // Login CF7 'cp_update_style_settings', // Convert Pro. Saving settings 'updraft_savesettings', // UpdraftPlus 'wpdUpdateAutomatically', //Comments update 'upload-attachment', // Skip ulpload attachments 'iwj_update_profile', //Skip profile page checker 'st_partner_create_service', //Skip add hotel via admin 'vp_ajax_vpt_option_save', // https://themeforest.net/item/motor-vehicles-parts-equipments-accessories-wordpress-woocommerce-theme/16829946 'mailster_send_test', //Mailster send test admin 'acf/validate_save_post', //ACF validate post admin 'admin:saveThemeOptions', //Ait-theme admin checking 'save_tourmaster_option', //Tourmaster admin save 'validate_register_email', //Elementor Pro 'phone-orders-for-woocommerce', //Phone orders for woocommerce backend 'ihc_check_reg_field_ajax', //Ajax check required fields 'OSTC_lostPassword', //Lost password ajax form 'check_retina_image_availability', //There are too many ajax requests from mobile 'uap_check_reg_field_ajax', // Ultimate Affiliate Pro. Form validation. 'edit-comment', // Edit comments by admin ??? that shouldn't happen 'formcraft3_save_form_progress', // FormCraft – Contact Form Builder for WordPress. Save progress. 'wpdmpp_save_settings', // PayPal save settings. 'iwj_login', // Fix for unknown plugin for user #133315 'custom_user_login', // Fix for unknown plugin for user #466875 'wordfence_ls_authenticate', //Fix for wordfence auth 'frm_strp_amount', //Admin stripe form 'wouCheckOnlineUsers', //Skip updraft admin checking users 'et_fb_get_shortcode_from_fb_object', //Skip generate shortcode 'pp_lf_process_login', //Skip login form 'check_email', //Ajax email checking 'dflg_do_sign_in_user', // Unknown plugin 'cartflows_save_cart_abandonment_data', // WooCommerce cartflow 'rcp_process_register_form', // WordPress Membership Plugin – Restrict Content 'apus_ajax_login', // ???? plugin authorization 'bookly_save_customer', //bookly 'postmark_test', //Avocet 'postmark_save', //Avocet 'ck_get_subscriber', //ConvertKit checking the subscriber 'metorik_send_cart', //Metorik skip 'ppom_ajax_validation', // PPOM add to cart validation 'wpforms_form_abandonment', // WPForms. Quiting without submitting 'post_woo_ml_email_cookie', //Woocommerce system 'ig_es_draft_broadcast', //Icegram broadcast ajax 'simplefilelistpro_edit_job', //Simple File List editing current job 'wfu_ajax_action_ask_server', //WFU skip ask server 'wcap_save_guest_data', //WooCommerce skip 'ajaxlogin', //Skip ajax login redirect 'heartbeat', //Gravity multipage 'erforms_field_change_command', //ERForms internal request 'wl_out_of_stock_notify', // Sumo Waitlist 'rac_preadd_guest', //Rac internal request 'apbct_email_check_before_post', //Interal request 'edd_process_checkout', // Easy Digital Downloads ajax skip /* !! Do not add actions here. Use apbct_is_skip_request() function below !! */ //Unknown plugin Ticket #25047 'alhbrmeu', // Ninja Forms 'nf_preview_update', 'nf_save_form' ); global $apbct; // Skip test if if ( ! $apbct->settings['forms__general_contact_forms_test'] || // Test disabled ! apbct_is_user_enable($apbct->user) || // User is admin, editor, author // (function_exists('get_current_user_id') && get_current_user_id() != 0) || // Check with default wp_* function if it's admin ( ! $apbct->settings['data__protect_logged_in'] && ($apbct->user instanceof WP_User) && $apbct->user->ID !== 0) || // Logged in user apbct_exclusions_check__url() || // url exclusions (Post::get('action') && in_array(Post::get('action'), $skip_post)) || // Special params (Get::get('action') && in_array(Get::get('action'), $skip_post)) || // Special params Post::get('quform_submit') || //QForms multi-paged form skip // QAEngine Theme fix ((string)current_filter() !== 'et_pre_insert_answer' && ( (isset($message_obj['author']) && (int)$message_obj['author'] === 0) || (isset($message_obj['post_author']) && (int)$message_obj['post_author'] === 0) ) ) || (Post::get('action') === 'arm_shortcode_form_ajax_action' && Post::get('arm_action') === 'please-login') || //arm forms skip login (Post::get('action') === 'erf_login_user' && in_array('easy-registration-forms/erforms.php', apply_filters('active_plugins', get_option('active_plugins')))) || //Easy Registration Forms login form skip (Post::get('action') === 'mailpoet' && Post::get('endpoint') === 'ImportExport' && Post::get('method') === 'processImport') //Mailpoet import ) { do_action('apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST); return false; } if ( apbct_is_skip_request(true) ) { do_action( 'apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__ . '(' . apbct_is_skip_request(true) . ')', $_POST ); return false; } //General post_info for all ajax calls $post_info = array( 'comment_type' => 'feedback_ajax', 'post_url' => apbct_get_server_variable('HTTP_REFERER'), // Page URL must be an previous page ); if ( Post::get('action') === 'cleantalk_force_ajax_check' ) { $post_info['comment_type'] = 'feedback_ajax_external_form'; } $checkjs = apbct_js_test('ct_checkjs', $_COOKIE, true); //QAEngine Theme answers if ( ! empty($message_obj) && isset($message_obj['post_type'], $message_obj['post_content']) ) { $curr_user = get_user_by('id', $message_obj['author']); if ( ! $curr_user ) { $curr_user = get_user_by('id', $message_obj['post_author']); } $ct_post_temp['comment'] = $message_obj['post_content']; $ct_post_temp['email'] = $curr_user->data->user_email; $ct_post_temp['name'] = $curr_user->data->user_login; } //CSCF fix if ( Post::get('action') === 'cscf-submitform' ) { $ct_post_temp[] = $message_obj['comment_author']; $ct_post_temp[] = $message_obj['comment_author_email']; $ct_post_temp[] = $message_obj['comment_content']; } //??? fix if ( Post::get('target') && (Post::get('action') === 'request_appointment' || Post::get('action') === 'send_message') ) { $ct_post_temp = $_POST; $ct_post_temp['target'] = 1; } //UserPro fix if ( Post::get('action') === 'userpro_process_form' && Post::get('template') === 'register' ) { $ct_post_temp = $_POST; $ct_post_temp['shortcode'] = ''; } //Pre-filled form 426869223 if ( Post::get('action') !== '' && Post::get('response-email-address') !== '' && Post::get('response-email-sender-address') !== '' && Post::get('action') === 'contact-owner:send' ) { unset($_POST['response-email-address']); unset($_POST['response-email-sender-address']); } //Reviewer fix if ( Post::get('action') === 'rwp_ajax_action_rating' ) { $ct_post_temp['name'] = Post::get('user_name'); $ct_post_temp['email'] = Post::get('user_email', null, 'cleanEmail'); $ct_post_temp['comment'] = Post::get('comment'); } //Woocommerce checkout if ( Post::get('action') === 'woocommerce_checkout' || Post::get('action') === 'save_data' ) { $post_info['comment_type'] = 'order'; if ( empty($apbct->settings['forms__wc_checkout_test']) ) { do_action('apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST); return false; } } //Easy Forms for Mailchimp if ( Post::get('action') === 'process_form_submission' ) { $post_info['comment_type'] = 'contact_enquire_wordpress_easy_forms_for_mailchimp'; if ( Post::get('form_data') ) { $form_data = explode('&', urldecode(Post::get('form_data'))); $form_data_arr = array(); foreach ( $form_data as $val ) { $form_data_element = explode('=', $val); $form_data_arr[$form_data_element[0]] = @$form_data_element[1]; } if ( isset($form_data_arr['EMAIL']) ) { $ct_post_temp['email'] = $form_data_arr['EMAIL']; } if ( isset($form_data_arr['FNAME']) ) { $ct_post_temp['nickname'] = $form_data_arr['FNAME']; } } } if ( Post::get('action') === 'ufbl_front_form_action' ) { $ct_post_temp = $_POST; foreach ( $ct_post_temp as $key => $_value ) { if ( preg_match('/form_data_\d_name/', $key) ) { unset($ct_post_temp[$key]); } } } // Kali form integration if (Post::hasString('action', 'kaliforms_form_process')) { $ct_post_temp = Post::get('data'); } // FixTeam Integration - preparation data for post filter if ( apbct_is_theme_active('fixteam') && Post::equal('action', 'send_sc_form') && Post::get('data') !== '' ) { $form_data = Post::get('data'); $form_data = explode('&', $form_data); for ($index = 0; $index < count($form_data); $index++) { if (stripos($form_data[$index], 'apbct_visible_fields') === 0) { unset($form_data[$index]); } } $form_data = implode('&', $form_data); parse_str($form_data, $ct_post_temp); $_POST['data'] = $form_data; } // Fusion Builder Avada Form integration if ( Post::hasString('action', 'fusion_form_submit_form_to_database_email') || Post::hasString('action', 'fusion_form_submit_form_to_email') || Post::hasString('action', 'fusion_form_submit_ajax') ) { if (Post::get('formData')) { $form_data = Post::get('formData'); $form_data = explode('&', $form_data); for ($index = 0; $index < count($form_data); $index++) { if (stripos($form_data[$index], 'apbct_visible_fields') === 0) { unset($form_data[$index]); } } $form_data = implode('&', $form_data); $_POST['formData'] = $form_data; } } /** * Filter for POST */ if (!empty($ct_post_temp)) { $input_array = apply_filters('apbct__filter_post', $ct_post_temp); } else { $input_array = apply_filters('apbct__filter_post', $_POST); } $ct_temp_msg_data = ct_get_fields_any($input_array); $sender_email = $ct_temp_msg_data['email'] ?: ''; $sender_nickname = $ct_temp_msg_data['nickname'] ?: ''; $subject = $ct_temp_msg_data['subject'] ?: ''; $contact_form = $ct_temp_msg_data['contact'] ?: true; $message = $ct_temp_msg_data['message'] ?: array(); if ( $subject !== '' ) { $message['subject'] = $subject; } // Skip submission if no data found if ( $contact_form === false ) { do_action('apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST); return false; } // Mailpoet fix if ( isset($message['wysijaData'], $message['wysijaplugin'], $message['task'], $message['controller']) && $message['wysijaplugin'] === 'wysija-newsletters' && $message['controller'] === 'campaigns' ) { do_action('apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST); return false; } // Mailpoet3 admin skip fix if ( Post::get('action') === 'mailpoet' && Post::get('method') === 'save' ) { do_action('apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST); return false; } // WP Foto Vote Fix if ( ! empty($_FILES) ) { foreach ( $message as $key => $_value ) { if ( strpos($key, 'oje') !== false ) { do_action('apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '():' . __LINE__, $_POST); return false; } } } /** * @todo Contact form detect */ // Detect contact form an set it's name to $contact_form to use later $contact_form = null; foreach ( $_POST as $param => $_value ) { if ( strpos($param, 'et_pb_contactform_submit') === 0 ) { $contact_form = 'contact_form_divi_theme'; } if ( strpos($param, 'avia_generated_form') === 0 ) { $contact_form = 'contact_form_enfold_theme'; } if ( ! empty($contact_form) ) { break; } } $base_call_params = array( 'message' => $message, 'sender_email' => $sender_email, 'sender_nickname' => $sender_nickname, 'sender_info' => array('post_checkjs_passed' => $checkjs), 'post_info' => $post_info, 'js_on' => $checkjs, ); if ( apbct_is_exception_arg_request() ) { $base_call_params['exception_action'] = 1; $base_call_params['sender_info']['exception_description'] = apbct_is_exception_arg_request(); } // EZ Form Calculator - clearing the message if ( apbct_is_plugin_active('ez-form-calculator-premium/ezfc.php') && Post::equal('action', 'ezfc_frontend') ) { if (!is_array($message)) { $message = preg_split('/\r\n|\r|\n/', $message); } foreach ($message as $key => $string) { if ( $string === '__HIDDEN__' || $string === '0' || (int)$string !== 0 ) { unset($message[$key]); } } $base_call_params['message'] = implode('\n', $message); } $base_call_result = apbct_base_call($base_call_params); $ct_result = $base_call_result['ct_result']; if ( $ct_result->allow == 0 ) { if ( Post::get('action') === 'wpuf_submit_register' ) { $result = array('success' => false, 'error' => $ct_result->comment); @header('Content-Type: application/json; charset=' . get_option('blog_charset')); print json_encode($result); die(); } if ( Post::get('action') === 'mymail_form_submit' ) { $result = array('success' => false, 'html' => $ct_result->comment); @header('Content-Type: application/json; charset=' . get_option('blog_charset')); print json_encode($result); die(); } if ( Post::get('action') === 'wysija_ajax' && Post::get('task') !== 'send_preview' && Post::get('task') !== 'send_test_mail' ) { $result = array('result' => false, 'msgs' => array('updated' => array($ct_result->comment))); print Get::get('callback') . '(' . json_encode($result) . ');'; die(); } if ( Post::get('action') === 'cs_registration_validation' ) { $result = array("type" => "error", "message" => $ct_result->comment); print json_encode($result); die(); } if ( Post::get('action') === 'request_appointment' || Post::get('action') === 'send_message' ) { print $ct_result->comment; die(); } if ( Post::get('action') === 'zn_do_login' ) { print '