コード例 #1
0
/**
 * 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();
        }
    }
}
コード例 #2
0
/**
 * Inner function - Sends the results of moderation
 * @param string $feedback_request
 * @return bool
 */
function ct_send_feedback($feedback_request = null)
{
    global $ct_options, $ct_data;
    $ct_options = ct_get_options();
    $ct_data = ct_get_data();
    ct_init_session();
    if (empty($feedback_request) && isset($_SESSION['feedback_request']) && preg_match("/^[a-z0-9\\;\\:]+\$/", $_SESSION['feedback_request'])) {
        $feedback_request = $_SESSION['feedback_request'];
        unset($_SESSION['feedback_request']);
    }
    if ($feedback_request !== null) {
        require_once 'cleantalk.class.php';
        $config = get_option('cleantalk_server');
        $ct = new Cleantalk();
        $ct->work_url = $config['ct_work_url'];
        $ct->server_url = $ct_options['server'];
        $ct->server_ttl = $config['ct_server_ttl'];
        $ct->server_changed = $config['ct_server_changed'];
        $ct_request = new CleantalkRequest();
        $ct_request->auth_key = $ct_options['apikey'];
        $ct_request->feedback = $feedback_request;
        $ct->sendFeedback($ct_request);
        if ($ct->server_change) {
            update_option('cleantalk_server', array('ct_work_url' => $ct->work_url, 'ct_server_ttl' => $ct->server_ttl, 'ct_server_changed' => time()));
        }
        return true;
    }
    return false;
}
コード例 #3
0
/**
 * Admin action 'admin_init' - Add the admin settings and such
 */
function ct_admin_init()
{
    global $ct_server_timeout, $show_ct_notice_autokey, $ct_notice_autokey_label, $ct_notice_autokey_value, $show_ct_notice_renew, $ct_notice_renew_label, $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $renew_notice_showtime, $trial_notice_showtime, $ct_plugin_name, $ct_options, $ct_data, $trial_notice_check_timeout, $account_notice_check_timeout, $ct_user_token_label, $cleantalk_plugin_version, $notice_check_timeout;
    //$ct_options = ct_get_options();
    //$ct_data = ct_get_data();
    $current_version = @trim($ct_data['current_version']);
    if ($current_version != $cleantalk_plugin_version) {
        $ct_data['current_version'] = $cleantalk_plugin_version;
        update_option('cleantalk_data', $ct_data);
        $ct_base_call_result = ct_base_call(array('message' => 'CleanTalk connection test', 'example' => null, 'sender_email' => '*****@*****.**', 'sender_nickname' => 'CleanTalk', 'post_info' => '', 'checkjs' => 1));
    }
    if (isset($_POST['option_page']) && $_POST['option_page'] == 'cleantalk_settings') {
        $ct_base_call_result = ct_base_call(array('message' => 'CleanTalk connection test', 'example' => null, 'sender_email' => '*****@*****.**', 'sender_nickname' => 'CleanTalk', 'post_info' => '', 'checkjs' => 1));
    }
    $show_ct_notice_trial = false;
    if (isset($_COOKIE[$ct_notice_trial_label])) {
        if ($_COOKIE[$ct_notice_trial_label] == 1) {
            $show_ct_notice_trial = true;
        }
    }
    $show_ct_notice_renew = false;
    if (isset($_COOKIE[$ct_notice_renew_label])) {
        if ($_COOKIE[$ct_notice_renew_label] == 1) {
            $show_ct_notice_renew = true;
        }
    }
    $show_ct_notice_autokey = false;
    if (isset($_COOKIE[$ct_notice_autokey_label]) && !empty($_COOKIE[$ct_notice_autokey_label])) {
        if (!empty($_COOKIE[$ct_notice_autokey_label])) {
            $show_ct_notice_autokey = true;
            $ct_notice_autokey_value = base64_decode($_COOKIE[$ct_notice_autokey_label]);
            setcookie($ct_notice_autokey_label, '', 1, '/');
        }
    }
    if (isset($_POST['get_apikey_auto'])) {
        $email = get_option('admin_email');
        $website = parse_url(get_option('siteurl'), PHP_URL_HOST);
        $platform = 'wordpress';
        $result = getAutoKey($email, $website, $platform);
        if ($result) {
            $result = json_decode($result, true);
            if (isset($result['data']) && is_array($result['data'])) {
                $result = $result['data'];
            }
            if (isset($result['user_token'])) {
                $ct_data['user_token'] = $result['user_token'];
                update_option('cleantalk_data', $ct_data);
            }
            if (isset($result['auth_key']) && !empty($result['auth_key'])) {
                $_POST['cleantalk_settings']['apikey'] = $result['auth_key'];
                $ct_options['apikey'] = $result['auth_key'];
                update_option('cleantalk_settings', $ct_options);
                $ct_base_call_result = ct_base_call(array('message' => 'CleanTalk connection test', 'example' => null, 'sender_email' => '*****@*****.**', 'sender_nickname' => 'CleanTalk', 'post_info' => '', 'checkjs' => 1));
            } else {
                setcookie($ct_notice_autokey_label, (string) base64_encode($result['error_message']), 0, '/');
            }
        } else {
            setcookie($ct_notice_autokey_label, (string) base64_encode(sprintf(__('Unable to connect to %s.', 'cleantalk'), 'api.cleantalk.org')), 0, '/');
        }
    }
    if (time() > $ct_data['next_account_status_check'] || isset($_POST['option_page']) && $_POST['option_page'] == 'cleantalk_settings' && $ct_options['apikey'] != $_POST['cleantalk_settings']['apikey']) {
        $result = false;
        if (function_exists('curl_init') && function_exists('json_decode') && ct_valid_key($ct_options['apikey'])) {
            if (@isset($_POST['cleantalk_settings']['apikey'])) {
                $result = noticePaidTill($_POST['cleantalk_settings']['apikey']);
            } else {
                $result = noticePaidTill($ct_options['apikey']);
            }
            if ($result) {
                $result = json_decode($result, true);
                if (isset($result['data']) && is_array($result['data'])) {
                    $result = $result['data'];
                }
                if (isset($result['show_notice'])) {
                    if ($result['show_notice'] == 1 && isset($result['trial']) && $result['trial'] == 1) {
                        $notice_check_timeout = $trial_notice_check_timeout;
                        $show_ct_notice_trial = true;
                    }
                    if ($result['show_notice'] == 1 && isset($result['renew']) && $result['renew'] == 1) {
                        $notice_check_timeout = $account_notice_check_timeout;
                        $show_ct_notice_renew = true;
                    }
                    if ($result['show_notice'] == 0) {
                        $notice_check_timeout = $account_notice_check_timeout;
                    }
                }
                if (isset($result['user_token'])) {
                    $ct_data['user_token'] = $result['user_token'];
                }
            }
            // Save next status request time
            $ct_data['next_account_status_check'] = strtotime("+{$notice_check_timeout} hours", time());
            update_option('cleantalk_data', $ct_data);
        }
        if ($result) {
            if ($show_ct_notice_trial == true) {
                setcookie($ct_notice_trial_label, (string) $show_ct_notice_trial, strtotime("+{$trial_notice_showtime} minutes"), '/');
            }
            if ($show_ct_notice_renew == true) {
                setcookie($ct_notice_renew_label, (string) $show_ct_notice_renew, strtotime("+{$renew_notice_showtime} minutes"), '/');
            }
        }
    }
    $show_ct_notice_online = '';
    if (isset($_COOKIE[$ct_notice_online_label])) {
        if ($_COOKIE[$ct_notice_online_label] === 'BAD_KEY') {
            $show_ct_notice_online = 'N';
        } else {
            if (time() - $_COOKIE[$ct_notice_online_label] <= 5) {
                $show_ct_notice_online = 'Y';
            }
        }
    }
    ct_init_session();
    if (isset($ct_data['testing_failed']) && $ct_data['testing_failed'] == 1) {
        $buttons_html = '	
<style type="text/css">
#ct_button_check_comments, #ct_button_check_users {background: #999999;}
    	
    	';
    } else {
        $buttons_html = '
<style type="text/css">
#ct_button_check_comments, #ct_button_check_users {background: #69dd69;}
    	
    	';
    }
    $buttons_html .= '
#ct_button_check_comments, #ct_button_check_users  {padding: 10px; color: #fff; border:0 none;
    cursor:pointer;
    -webkit-border-radius: 5px;
    border-radius: 5px; 
    font-size: 12pt;
    text-decoration:none;
    margin-bottom:5px;
    display:inline-block;
}
</style>';
    if (isset($ct_data['testing_failed']) && $ct_data['testing_failed'] == 1) {
        $buttons_html .= '<a href="#" id="ct_button_check_comments" onclick="alert(' . "'" . __('Feature is disabled, because testing of access key is failed!', 'cleantalk') . "'" . ')">' . __('Check comments', 'cleantalk') . '</a>
<a href="#" id="ct_button_check_users" onclick="alert(' . "'" . __('Feature is disabled, because testing of access key is failed!', 'cleantalk') . "'" . ')">' . __('Check users', 'cleantalk') . '</a><div class="clear"></div>';
    } else {
        $buttons_html .= '<a href="edit-comments.php?page=ct_check_spam&do_check=1" id="ct_button_check_comments">' . __('Check comments', 'cleantalk') . '</a>
<a href="users.php?page=ct_check_users&do_check=1" id="ct_button_check_users">' . __('Check users', 'cleantalk') . '</a><div class="clear"></div>';
    }
    register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
    add_settings_section('cleantalk_settings_main', __($ct_plugin_name, 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
    add_settings_section('cleantalk_settings_state', "<hr>" . __('Protection is active for:', 'cleantalk'), 'ct_section_settings_state', 'cleantalk');
    //add_settings_section('cleantalk_settings_autodel', "<hr>", 'ct_section_settings_autodel', 'cleantalk');
    add_settings_section('cleantalk_settings_anti_spam', "<hr>Check existing comments and users <br /><br />{$buttons_html}<hr>" . __('Advanced settings', 'cleantalk'), 'ct_section_settings_anti_spam', 'cleantalk');
    add_settings_field('cleantalk_apikey', __('Access key', 'cleantalk'), 'ct_input_apikey', 'cleantalk', 'cleantalk_settings_main');
    add_settings_field('cleantalk_remove_old_spam', __('Automatically delete spam comments', 'cleantalk'), 'ct_input_remove_old_spam', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_registrations_test', __('Registration forms', 'cleantalk'), 'ct_input_registrations_test', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_comments_test', __('Comments form', 'cleantalk'), 'ct_input_comments_test', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_contact_forms_test', __('Contact forms', 'cleantalk'), 'ct_input_contact_forms_test', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_general_contact_forms_test', __('Custom contact forms', 'cleantalk'), 'ct_input_general_contact_forms_test', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_general_postdata_test', __('Check all post data', 'cleantalk'), 'ct_input_general_postdata_test', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_show_adminbar', __('Show statistics in admin bar', 'cleantalk'), 'ct_input_show_adminbar', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_use_ajax', __('Use AJAX for JavaScript check', 'cleantalk'), 'ct_input_use_ajax', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_check_external', __('Protect external forms', 'cleantalk'), 'ct_input_check_external', 'cleantalk', 'cleantalk_settings_anti_spam');
}
コード例 #4
0
/**
 * Admin action 'admin_init' - Add the admin settings and such
 */
function ct_admin_init()
{
    global $show_ct_notice_trial, $ct_notice_trial_label, $show_ct_notice_online, $ct_notice_online_label, $trial_notice_showtime, $ct_plugin_name, $ct_options, $trial_notice_check_timeout, $account_notice_check_timeout, $ct_user_token_label, $ct_account_status_check;
    $ct_options = ct_get_options();
    $show_ct_notice_trial = false;
    if (isset($_COOKIE[$ct_notice_trial_label])) {
        if ($_COOKIE[$ct_notice_trial_label] == 1) {
            $show_ct_notice_trial = true;
        }
    }
    if (time() > $ct_options['next_account_status_check']) {
        $result = false;
        if (function_exists('curl_init') && function_exists('json_decode') && ct_valid_key($ct_options['apikey'])) {
            $url = 'https://cleantalk.org/app_notice';
            $server_timeout = 2;
            $data['auth_key'] = $ct_options['apikey'];
            $data['param'] = 'notice_paid_till';
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_TIMEOUT, $server_timeout);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
            // receive server response ...
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            // resolve 'Expect: 100-continue' issue
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
            $result = curl_exec($ch);
            curl_close($ch);
            $notice_check_timeout = $trial_notice_check_timeout;
            if ($result) {
                $result = json_decode($result, true);
                if (isset($result['show_notice'])) {
                    if ($result['show_notice'] == 1 && isset($result['trial']) && $result['trial'] == 1) {
                        $show_ct_notice_trial = true;
                    }
                    if ($result['show_notice'] == 0) {
                        $notice_check_timeout = $account_notice_check_timeout;
                    }
                }
                if (isset($result['user_token'])) {
                    $ct_options['user_token'] = $result['user_token'];
                }
            }
            // Save next status request time
            $ct_options['next_account_status_check'] = strtotime("+{$notice_check_timeout} hours", time());
            $ct_account_status_check = time();
            update_option('cleantalk_settings', $ct_options);
        }
        if ($result) {
            setcookie($ct_notice_trial_label, (string) $show_ct_notice_trial, strtotime("+{$trial_notice_showtime} minutes"), '/');
        }
    }
    $show_ct_notice_online = '';
    if (isset($_COOKIE[$ct_notice_online_label])) {
        if ($_COOKIE[$ct_notice_online_label] === 'BAD_KEY') {
            $show_ct_notice_online = 'N';
        } else {
            if (time() - $_COOKIE[$ct_notice_online_label] <= 5) {
                $show_ct_notice_online = 'Y';
            }
        }
    }
    ct_init_session();
    register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
    add_settings_section('cleantalk_settings_main', __($ct_plugin_name, 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
    add_settings_section('cleantalk_settings_anti_spam', __('Anti-spam settings', 'cleantalk'), 'ct_section_settings_anti_spam', 'cleantalk');
    add_settings_field('cleantalk_apikey', __('Access key', 'cleantalk'), 'ct_input_apikey', 'cleantalk', 'cleantalk_settings_main');
    add_settings_field('cleantalk_remove_old_spam', __('Automatically delete spam comments', 'cleantalk'), 'ct_input_remove_old_spam', 'cleantalk', 'cleantalk_settings_main');
    add_settings_field('cleantalk_registrations_test', __('Registration forms', 'cleantalk'), 'ct_input_registrations_test', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_comments_test', __('Comments form', 'cleantalk'), 'ct_input_comments_test', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_contact_forms_test', __('Contact forms', 'cleantalk'), 'ct_input_contact_forms_test', 'cleantalk', 'cleantalk_settings_anti_spam');
    add_settings_field('cleantalk_general_contact_forms_test', __('Custom contact forms', 'cleantalk'), 'ct_input_general_contact_forms_test', 'cleantalk', 'cleantalk_settings_anti_spam');
}
コード例 #5
0
/**
 * Test S2member registration
 * @return array with errors 
 */
function ct_s2member_registration_test()
{
    global $ct_agent_version, $ct_post_data_label, $ct_post_data_authnet_label, $ct_formtime_label, $ct_options, $ct_data;
    $ct_options = ct_get_options();
    $ct_data = ct_get_data();
    if ($ct_options['registrations_test'] == 0) {
        return null;
    }
    $submit_time = submit_time_test();
    $checkjs = js_test('ct_checkjs', $_COOKIE, true);
    require_once 'cleantalk.class.php';
    $sender_info = get_sender_info();
    $sender_info = json_encode($sender_info);
    if ($sender_info === false) {
        $sender_info = '';
    }
    $sender_email = null;
    if (isset($_POST[$ct_post_data_label]['email'])) {
        $sender_email = $_POST[$ct_post_data_label]['email'];
    }
    if (isset($_POST[$ct_post_data_authnet_label]['email'])) {
        $sender_email = $_POST[$ct_post_data_authnet_label]['email'];
    }
    $sender_nickname = null;
    if (isset($_POST[$ct_post_data_label]['username'])) {
        $sender_nickname = $_POST[$ct_post_data_label]['username'];
    }
    if (isset($_POST[$ct_post_data_authnet_label]['username'])) {
        $sender_nickname = $_POST[$ct_post_data_authnet_label]['username'];
    }
    $config = get_option('cleantalk_server');
    $ct = new Cleantalk();
    $ct->work_url = $config['ct_work_url'];
    $ct->server_url = $ct_options['server'];
    $ct->server_ttl = $config['ct_server_ttl'];
    $ct->server_changed = $config['ct_server_changed'];
    $ct->ssl_on = $ct_options['ssl_on'];
    $ct_request = new CleantalkRequest();
    $ct_request->auth_key = $ct_options['apikey'];
    $ct_request->sender_email = $sender_email;
    $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
    $ct_request->sender_nickname = $sender_nickname;
    $ct_request->agent = $ct_agent_version;
    $ct_request->sender_info = $sender_info;
    $ct_request->js_on = $checkjs;
    $ct_request->submit_time = $submit_time;
    $ct_result = $ct->isAllowUser($ct_request);
    if ($ct->server_change) {
        update_option('cleantalk_server', array('ct_work_url' => $ct->work_url, 'ct_server_ttl' => $ct->server_ttl, 'ct_server_changed' => time()));
    }
    if ($ct_result->errno != 0) {
        return false;
    }
    // Restart submit form counter for failed requests
    if ($ct_result->allow == 0) {
        ct_init_session();
        $_SESSION[$ct_formtime_label] = time();
    }
    if ($ct_result->allow == 0) {
        ct_die_extended($ct_result->comment);
    }
    return true;
}
コード例 #6
0
    $cleantalk_use_buffer = true;
}
if (defined('CLEANTALK_AJAX_USE_FOOTER_HEADER')) {
    $cleantalk_use_footer_header = CLEANTALK_AJAX_USE_FOOTER_HEADER;
} else {
    $cleantalk_use_footer_header = true;
}
if (!defined('CLEANTALK_PLUGIN_DIR')) {
    define('CLEANTALK_PLUGIN_DIR', plugin_dir_path(__FILE__));
    global $ct_options, $ct_data;
    require_once CLEANTALK_PLUGIN_DIR . 'cleantalk-common.php';
    $ct_options = ct_get_options();
    $ct_data = ct_get_data();
    $jigo_version = @get_option('jigoshop_db_version', '');
    if ($jigo_version == '') {
        ct_init_session();
    }
    if (!isset($_SESSION['ct_redirects'])) {
        $_SESSION['ct_redirects'] = 0;
    }
    if (isset($ct_options['check_external'])) {
        if (@intval($ct_options['check_external']) == 1) {
            $test_external_forms = true;
        } else {
            $test_external_forms = false;
        }
    } else {
        $test_external_forms = false;
    }
    // Activation/deactivation functions must be in main plugin file.
    // http://codex.wordpress.org/Function_Reference/register_activation_hook