/** * Init functions * @return mixed[] Array of options */ function ct_init() { global $ct_wplp_result_label, $ct_jp_comments, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_direct_post, $ct_options, $ct_data, $ct_check_post_result, $test_external_forms; $ct_options = ct_get_options(); $ct_data = ct_get_data(); //fix for EPM registration form if (isset($_POST) && isset($_POST['reg_email']) && shortcode_exists('epm_registration_form')) { unset($_POST['ct_checkjs_register_form']); } ct_init_session(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (is_array($_SESSION) && !array_key_exists($ct_formtime_label, $_SESSION) && session_id() != '') { $ct_direct_post = 1; } } else { /*if(isset($_SERVER['HTTP_REFERER']) && stripos($_SERVER['HTTP_REFERER'],'preview')!==false) { //do nothing } else {*/ $_SESSION[$ct_formtime_label] = time(); //} } if ($test_external_forms && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['cleantalk_hidden_method']) && isset($_POST['cleantalk_hidden_action'])) { $action = htmlspecialchars($_POST['cleantalk_hidden_action']); $method = htmlspecialchars($_POST['cleantalk_hidden_method']); unset($_POST['cleantalk_hidden_action']); unset($_POST['cleantalk_hidden_method']); ct_contact_form_validate(); print "<html><body><form method='{$method}' action='{$action}'>"; ct_print_form($_POST, ''); print "</form><center>Redirecting to " . $action . "... Anti-spam by CleanTalk.</center></body></html>"; print "<script>document.forms[0].submit();</script>"; die; } if (isset($ct_options['general_postdata_test'])) { $ct_general_postdata_test = @intval($ct_options['general_postdata_test']); //hook for Anonymous Post add_action('template_redirect', 'ct_contact_form_validate_postdata', 1); } else { $ct_general_postdata_test = 0; } if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1) { add_action('CMA_custom_post_type_nav', 'ct_contact_form_validate_postdata', 1); add_action('template_redirect', 'ct_contact_form_validate', 1); /*if(isset($_GET['ait-action'])&&$_GET['ait-action']=='register') { $tmp=$_POST['redirect_to']; unset($_POST['redirect_to']); ct_contact_form_validate(); $_POST['redirect_to']=$tmp; }*/ } if ($ct_general_postdata_test == 1) { add_action('CMA_custom_post_type_nav', 'ct_contact_form_validate_postdata', 1); } //add_action('wp_footer','ct_ajaxurl'); // Fast Secure contact form if (defined('FSCF_VERSION')) { add_filter('si_contact_display_after_fields', 'ct_si_contact_display_after_fields'); add_filter('si_contact_form_validate', 'ct_si_contact_form_validate'); } // WooCoomerse signups if (class_exists('WooCommerce')) { add_filter('woocommerce_register_post', 'ct_register_post', 1, 3); } // JetPack Contact form $jetpack_active_modules = false; if (defined('JETPACK__VERSION')) { add_filter('grunion_contact_form_field_html', 'ct_grunion_contact_form_field_html', 10, 2); if (JETPACK__VERSION == '3.4-beta') { add_filter('contact_form_is_spam', 'ct_contact_form_is_spam'); } else { if (JETPACK__VERSION == '3.4-beta2' || JETPACK__VERSION >= '3.4') { add_filter('jetpack_contact_form_is_spam', 'ct_contact_form_is_spam_jetpack', 1, 2); } else { add_filter('contact_form_is_spam', 'ct_contact_form_is_spam'); } } $jetpack_active_modules = get_option('jetpack_active_modules'); if (class_exists('Jetpack', false) && $jetpack_active_modules && in_array('comments', $jetpack_active_modules)) { $ct_jp_comments = true; } } // Contact Form7 if (defined('WPCF7_VERSION')) { add_filter('wpcf7_form_elements', 'ct_wpcf7_form_elements'); if (WPCF7_VERSION >= '3.0.0') { add_filter('wpcf7_spam', 'ct_wpcf7_spam'); } else { add_filter('wpcf7_acceptance', 'ct_wpcf7_spam'); } } // Formidable if (class_exists('FrmSettings')) { add_action('frm_validate_entry', 'ct_frm_validate_entry', 20, 2); add_action('frm_entries_footer_scripts', 'ct_frm_entries_footer_scripts', 20, 2); } // BuddyPress if (class_exists('BuddyPress')) { add_action('bp_before_registration_submit_buttons', 'ct_register_form', 1); add_filter('bp_signup_validate', 'ct_registration_errors', 1); } // bbPress if (class_exists('bbPress')) { add_filter('bbp_new_topic_pre_content', 'ct_bbp_new_pre_content', 1); add_filter('bbp_new_reply_pre_content', 'ct_bbp_new_pre_content', 1); add_action('bbp_theme_before_topic_form_content', 'ct_comment_form'); add_action('bbp_theme_before_reply_form_content', 'ct_comment_form'); } add_action('comment_form', 'ct_comment_form'); //intercept WordPress Landing Pages POST if (defined('LANDINGPAGES_CURRENT_VERSION') && !empty($_POST)) { if (array_key_exists('action', $_POST) && $_POST['action'] === 'inbound_store_lead') { // AJAX action(s) ct_check_wplp(); } else { if (array_key_exists('inbound_submitted', $_POST) && $_POST['inbound_submitted'] == '1') { // Final submit ct_check_wplp(); } } } // intercept S2member POST if (defined('WS_PLUGIN__S2MEMBER_PRO_VERSION') && (isset($_POST[$ct_post_data_label]['email']) || isset($_POST[$ct_post_data_authnet_label]['email']))) { ct_s2member_registration_test(); } // // New user approve hack // https://wordpress.org/plugins/new-user-approve/ // if (ct_plugin_active('new-user-approve/new-user-approve.php')) { add_action('register_post', 'ct_register_post', 1, 3); } // // Load JS code to website footer // if (!(defined('DOING_AJAX') && DOING_AJAX)) { add_action('wp_footer', 'ct_footer_add_cookie', 1); } if (ct_is_user_enable()) { ct_cookies_test(); if (isset($ct_options['general_contact_forms_test']) && $ct_options['general_contact_forms_test'] == 1 && !isset($_POST['comment_post_ID']) && !isset($_GET['for'])) { $ct_check_post_result = false; ct_contact_form_validate(); } if ($_SERVER['REQUEST_METHOD'] == 'POST' && $ct_general_postdata_test == 1 && !is_admin()) { $ct_check_post_result = false; ct_contact_form_validate_postdata(); } } }
/** * Inner function - Default data array for senders * @return array */ function get_sender_info() { global $ct_direct_post, $ct_options, $ct_data; $php_session = session_id() != '' ? 1 : 0; // Raw data to validated JavaScript test in the cloud $checkjs_data_cookies = null; if (isset($_COOKIE['ct_checkjs'])) { $checkjs_data_cookies = $_COOKIE['ct_checkjs']; } $checkjs_data_post = null; if (count($_POST) > 0) { foreach ($_POST as $k => $v) { if (preg_match("/^ct_check.+/", $k)) { $checkjs_data_post = $v; } } } /*$options2server = array( // Options for sending to server for support information 'apikey' => $ct_options['apikey'], 'registrations_test' => $ct_options['registrations_test'], 'comments_test' => $ct_options['comments_test'], 'contact_forms_test' => $ct_options['contact_forms_test'], 'general_contact_forms_test' => $ct_options['general_contact_forms_test'], 'remove_old_spam' => $ct_options['remove_old_spam'], 'autoPubRevelantMess' => $ct_options['autoPubRevelantMess'], 'spam_store_days' => $ct_options['spam_store_days'], 'ssl_on' => $ct_options['ssl_on'], );*/ $options2server = $ct_options; return $sender_info = array('page_url' => htmlspecialchars(@$_SERVER['SERVER_NAME'] . @$_SERVER['REQUEST_URI']), 'cms_lang' => substr(get_locale(), 0, 2), 'REFFERRER' => htmlspecialchars(@$_SERVER['HTTP_REFERER']), 'USER_AGENT' => htmlspecialchars(@$_SERVER['HTTP_USER_AGENT']), 'php_session' => $php_session, 'cookies_enabled' => ct_cookies_test(true), 'direct_post' => $ct_direct_post, 'checkjs_data_post' => $checkjs_data_post, 'checkjs_data_cookies' => $checkjs_data_cookies, 'ct_options' => json_encode($options2server), 'fields_number' => sizeof($_POST)); }