当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_blacklist_check函数代码示例

本文整理汇总了PHP中wp_blacklist_check函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_blacklist_check函数的具体用法?PHP wp_blacklist_check怎么用?PHP wp_blacklist_check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_blacklist_check函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_should_return_false_when_no_match

 public function test_should_return_false_when_no_match()
 {
     $author = 'Krusty the Clown';
     $author_email = 'krusty@example.com';
     $author_url = 'http://example.com';
     $comment = "And we're sending our love down the well.";
     $author_ip = '192.168.0.1';
     $user_agent = '';
     update_option('blacklist_keys', "sideshow\nfoobar");
     $result = wp_blacklist_check($author, $author_email, $author_url, $comment, $author_ip, $user_agent);
     $this->assertFalse($result);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:12,代码来源:wpBlacklistCheck.php

示例2: jw_fuckspam

function jw_fuckspam($comment)
{
    if (is_user_logged_in()) {
        return $comment;
    }
    if (wp_blacklist_check($comment['comment_author'], $comment['comment_author_email'], $comment['comment_author_url'], $comment['comment_content'], $comment['comment_author_IP'], $comment['comment_agent'])) {
        header("Content-type: text/html; charset=utf-8");
        wp_die('您评论包含辱骂,过激或者违反法律等言论,或者您的IP已被加入黑名单,如有疑问请联系管理员处理!<a href="javascript:history.go(-1);">返回文章页</a><br> Your Comment is blocked. For any question please contact the administrator.  <a href="javascript:history.go(-1);">Back</a>');
    } else {
        return $comment;
    }
}
开发者ID:qtxh,项目名称:wordpress-optimize,代码行数:12,代码来源:wordpress-optimize.php

示例3: is_blacklisted

 function is_blacklisted($contact)
 {
     return wp_blacklist_check($contact['name'], $contact['email'], isset($contact['website']) ? $contact['email'] : false, $contact['message'], preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']), substr($_SERVER['HTTP_USER_AGENT'], 0, 254));
 }
开发者ID:ramonvloon,项目名称:Ingrid,代码行数:4,代码来源:index.php

示例4: wp_allow_comment

function wp_allow_comment($commentdata) {
	global $wpdb;
	extract($commentdata);

	$comment_user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($comment_author_IP) );

	// Simple duplicate check
	$dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$comment_author' ";
	if ( $comment_author_email )
		$dupe .= "OR comment_author_email = '$comment_author_email' ";
	$dupe .= ") AND comment_content = '$comment_content' LIMIT 1";
	if ( $wpdb->get_var($dupe) )
		die( __('Duplicate comment detected; it looks as though you\'ve already said that!') );

	// Simple flood-protection
	if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$comment_author_IP' OR comment_author_email = '$comment_author_email' ORDER BY comment_date DESC LIMIT 1") ) {
		$time_lastcomment = mysql2date('U', $lasttime);
		$time_newcomment  = mysql2date('U', $comment_date_gmt);
		if ( ($time_newcomment - $time_lastcomment) < 15 ) {
			do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
			die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') );
		}
	}

	if ( $user_id ) {
		$userdata = get_userdata($user_id);
		$user = new WP_User($user_id);
		$post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1");
	}

	// The author and the admins get respect.
	if ( $userdata && ( $user_id == $post_author || $user->has_cap('level_9') ) ) {
		$approved = 1;
	}

	// Everyone else's comments will be checked.
	else {
		if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) )
			$approved = 1;
		else
			$approved = 0;
		if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )
			$approved = 'spam';
	}

	$approved = apply_filters('pre_comment_approved', $approved);
	return $approved;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:48,代码来源:comment-functions.php

示例5: wp_allow_comment

/**
 * wp_allow_comment() - Validates whether this comment is allowed to be made or not
 *
 * {@internal Missing Long Description}}
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses apply_filters() Calls 'pre_comment_approved' hook on the type of comment
 * @uses do_action() Calls 'check_comment_flood' hook on $comment_author_IP, $comment_author_email, and $comment_date_gmt
 *
 * @param array $commentdata Contains information on the comment
 * @return mixed Signifies the approval status (0|1|'spam')
 */
function wp_allow_comment($commentdata)
{
    global $wpdb;
    extract($commentdata, EXTR_SKIP);
    // Simple duplicate check
    // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' ";
    if ($comment_author_email) {
        $dupe .= "OR comment_author_email = '{$comment_author_email}' ";
    }
    $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        wp_die(__('Duplicate comment detected; it looks as though you\'ve already said that!'));
    }
    do_action('check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt);
    if ($user_id) {
        $userdata = get_userdata($user_id);
        $user = new WP_User($user_id);
        $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $comment_post_ID));
    }
    if ($userdata && ($user_id == $post_author || $user->has_cap('level_9'))) {
        // The author and the admins get respect.
        $approved = 1;
    } else {
        // Everyone else's comments will be checked.
        if (check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type)) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent)) {
            $approved = 'spam';
        }
    }
    $approved = apply_filters('pre_comment_approved', $approved);
    return $approved;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:50,代码来源:comment.php

示例6: xt_allow_comment

function xt_allow_comment($commentdata)
{
    global $wpdb;
    extract($commentdata, EXTR_SKIP);
    // Simple duplicate check
    $dupe = "SELECT id FROM " . XT_TABLE_SHARE_COMMENT . " WHERE share_id = '{$share_id}' AND user_id = '{$user_id}' AND content = '{$content}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        do_action('xt_comment_duplicate_trigger', $commentdata);
        if (defined('DOING_AJAX')) {
            die('重复评论啦!');
        }
        wp_die('重复评论啦!');
    }
    do_action('xt_check_comment_flood', $ip, $create_date);
    if (isset($user_id) && $user_id) {
        $userdata = get_userdata($user_id);
        $user = new WP_User($user_id);
        $share_author = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM " . XT_TABLE_SHARE . " WHERE ID = %d LIMIT 1", $share_id));
    }
    if (isset($userdata) && ($user_id == $share_author || $user->has_cap('moderate_comments'))) {
        // The author and the admins get respect.
        $approved = 1;
    } else {
        // Everyone else's comments will be checked.
        if (xt_check_comment($user_name, $content, $ip)) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($user_name, '', '', $content, $ip, '')) {
            $approved = 'spam';
        }
    }
    $approved = apply_filters('xt_pre_status', $approved, $commentdata);
    return $approved;
}
开发者ID:aspirin,项目名称:wp-xintaoke,代码行数:36,代码来源:query-comment.php

示例7: wp_allow_comment

/**
 * Validates whether this comment is allowed to be made.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentdata Contains information on the comment
 * @return int|string Signifies the approval status (0|1|'spam')
 */
function wp_allow_comment($commentdata)
{
    global $wpdb;
    // Simple duplicate check
    // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
    $dupe = $wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", wp_unslash($commentdata['comment_post_ID']), wp_unslash($commentdata['comment_parent']), wp_unslash($commentdata['comment_author']));
    if ($commentdata['comment_author_email']) {
        $dupe .= $wpdb->prepare("OR comment_author_email = %s ", wp_unslash($commentdata['comment_author_email']));
    }
    $dupe .= $wpdb->prepare(") AND comment_content = %s LIMIT 1", wp_unslash($commentdata['comment_content']));
    $dupe_id = $wpdb->get_var($dupe);
    /**
     * Filters the ID, if any, of the duplicate comment found when creating a new comment.
     *
     * Return an empty value from this filter to allow what WP considers a duplicate comment.
     *
     * @since 4.4.0
     *
     * @param int   $dupe_id     ID of the comment identified as a duplicate.
     * @param array $commentdata Data for the comment being created.
     */
    $dupe_id = apply_filters('duplicate_comment_id', $dupe_id, $commentdata);
    if ($dupe_id) {
        /**
         * Fires immediately after a duplicate comment is detected.
         *
         * @since 3.0.0
         *
         * @param array $commentdata Comment data.
         */
        do_action('comment_duplicate_trigger', $commentdata);
        if (defined('DOING_AJAX')) {
            die(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!'));
        }
        wp_die(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!'), 409);
    }
    /**
     * Fires immediately before a comment is marked approved.
     *
     * Allows checking for comment flooding.
     *
     * @since 2.3.0
     *
     * @param string $comment_author_IP    Comment author's IP address.
     * @param string $comment_author_email Comment author's email.
     * @param string $comment_date_gmt     GMT date the comment was posted.
     */
    do_action('check_comment_flood', $commentdata['comment_author_IP'], $commentdata['comment_author_email'], $commentdata['comment_date_gmt']);
    if (!empty($commentdata['user_id'])) {
        $user = get_userdata($commentdata['user_id']);
        $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $commentdata['comment_post_ID']));
    }
    if (isset($user) && ($commentdata['user_id'] == $post_author || $user->has_cap('moderate_comments'))) {
        // The author and the admins get respect.
        $approved = 1;
    } else {
        // Everyone else's comments will be checked.
        if (check_comment($commentdata['comment_author'], $commentdata['comment_author_email'], $commentdata['comment_author_url'], $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_agent'], $commentdata['comment_type'])) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($commentdata['comment_author'], $commentdata['comment_author_email'], $commentdata['comment_author_url'], $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_agent'])) {
            $approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam';
        }
    }
    /**
     * Filter a comment's approval status before it is set.
     *
     * @since 2.1.0
     *
     * @param bool|string $approved    The approval status. Accepts 1, 0, or 'spam'.
     * @param array       $commentdata Comment data.
     */
    $approved = apply_filters('pre_comment_approved', $approved, $commentdata);
    return $approved;
}
开发者ID:hadywisam,项目名称:WordPress,代码行数:87,代码来源:comment-functions.php

示例8: akismet_auto_check_update_meta

function akismet_auto_check_update_meta($id, $comment)
{
    global $akismet_last_comment;
    // failsafe for old WP versions
    if (!function_exists('add_comment_meta')) {
        return false;
    }
    if (!isset($akismet_last_comment['comment_author_email'])) {
        $akismet_last_comment['comment_author_email'] = '';
    }
    // wp_insert_comment() might be called in other contexts, so make sure this is the same comment
    // as was checked by akismet_auto_check_comment
    if (is_object($comment) && !empty($akismet_last_comment) && is_array($akismet_last_comment)) {
        if (isset($akismet_last_comment['comment_post_ID']) && intval($akismet_last_comment['comment_post_ID']) == intval($comment->comment_post_ID) && $akismet_last_comment['comment_author'] == $comment->comment_author && $akismet_last_comment['comment_author_email'] == $comment->comment_author_email) {
            // normal result: true or false
            if ($akismet_last_comment['akismet_result'] == 'true') {
                update_comment_meta($comment->comment_ID, 'akismet_result', 'true');
                akismet_update_comment_history($comment->comment_ID, __('Akismet caught this comment as spam'), 'check-spam');
                if ($comment->comment_approved != 'spam') {
                    akismet_update_comment_history($comment->comment_ID, sprintf(__('Comment status was changed to %s'), $comment->comment_approved), 'status-changed' . $comment->comment_approved);
                }
            } elseif ($akismet_last_comment['akismet_result'] == 'false') {
                update_comment_meta($comment->comment_ID, 'akismet_result', 'false');
                akismet_update_comment_history($comment->comment_ID, __('Akismet cleared this comment'), 'check-ham');
                if ($comment->comment_approved == 'spam') {
                    if (wp_blacklist_check($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent)) {
                        akismet_update_comment_history($comment->comment_ID, __('Comment was caught by wp_blacklist_check'), 'wp-blacklisted');
                    } else {
                        akismet_update_comment_history($comment->comment_ID, sprintf(__('Comment status was changed to %s'), $comment->comment_approved), 'status-changed-' . $comment->comment_approved);
                    }
                }
                // abnormal result: error
            } else {
                update_comment_meta($comment->comment_ID, 'akismet_error', time());
                akismet_update_comment_history($comment->comment_ID, sprintf(__('Akismet was unable to check this comment (response: %s), will automatically retry again later.'), substr($akismet_last_comment['akismet_result'], 0, 50)), 'check-error');
            }
            // record the complete original data as submitted for checking
            if (isset($akismet_last_comment['comment_as_submitted'])) {
                update_comment_meta($comment->comment_ID, 'akismet_as_submitted', $akismet_last_comment['comment_as_submitted']);
            }
        }
    }
}
开发者ID:GarryVeles,项目名称:Artibaltika,代码行数:43,代码来源:akismet.php

示例9: spamfree_content_filter


//.........这里部分代码省略.........
		if ( $filter_392_author_count >= 1 ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 392AUTH';
			}

	
		// Simple Author='' Tests - Non-Trackback/Non-Pingback
		if ( $commentdata_comment_author_lc == $filter_300400_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300400AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300401_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300401AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300402_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300402AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300403_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300403AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300404_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300404AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300405_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300405AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300406_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300406AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300407_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300407AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300408_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300408AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300409_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300409AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300410_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300410AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300411_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300411AUTH';
			}
		if ( $commentdata_comment_author_lc == $filter_300412_term ) {
			if ( !$content_filter_status ) { $content_filter_status = '1'; }
			$spamfree_error_code .= ' 300412AUTH';
			}
		}
	
	// Blacklist Word Combinations
	if ( $blacklist_word_combo >= $blacklist_word_combo_limit ) {
		if ( !$content_filter_status ) { $content_filter_status = '1'; }
		$spamfree_error_code .= ' BLC1000';
		}
	if ( $blacklist_word_combo_total >= $blacklist_word_combo_total_limit ) {
		if ( !$content_filter_status ) { $content_filter_status = '1'; }
		$spamfree_error_code .= ' BLC1010';
		}


	// WP Blacklist Check :: BEGIN
	
	// Test WP Blacklist if option set
	
	// Before long make own blacklist function - WP's is flawed with IP's
	if ( $spamfree_options['enhanced_comment_blacklist'] && !$content_filter_status ) {
		if ( wp_blacklist_check($commentdata_comment_author, $commentdata_comment_author_email, $commentdata_comment_author_url, $commentdata_comment_content, $commentdata_remote_addr, $commentdata_user_agent) ) {
			if ( !$content_filter_status ) { $content_filter_status = '100'; }
			$spamfree_error_code .= ' WP-BLACKLIST';
			}
		}
	// WP Blacklist Check :: END
	
	if ( !$spamfree_error_code ) {
		$spamfree_error_code = 'No Error';
		}
	else {
		$spamfree_error_code = ltrim($spamfree_error_code);
		if ( $spamfree_options['comment_logging'] ) {
			spamfree_log_data( $commentdata, $spamfree_error_code );
			}
		}

	$spamfree_error_data = array( $spamfree_error_code, $blacklist_word_combo, $blacklist_word_combo_total );
	
	return $content_filter_status;
	// CONTENT FILTERING :: END
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:101,代码来源:wp-spamfree.php

示例10: wp_allow_comment

/**
 * Validates whether this comment is allowed to be made.
 *
 * @since 2.0.0
 * @uses $wpdb
 *
 * @param array $commentdata Contains information on the comment
 * @return mixed Signifies the approval status (0|1|'spam')
 */
function wp_allow_comment($commentdata)
{
    global $wpdb;
    extract($commentdata, EXTR_SKIP);
    // Simple duplicate check
    // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
    $dupe = $wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", wp_unslash($comment_post_ID), wp_unslash($comment_parent), wp_unslash($comment_author));
    if ($comment_author_email) {
        $dupe .= $wpdb->prepare("OR comment_author_email = %s ", wp_unslash($comment_author_email));
    }
    $dupe .= $wpdb->prepare(") AND comment_content = %s LIMIT 1", wp_unslash($comment_content));
    if ($wpdb->get_var($dupe)) {
        /**
         * Fires immediately after a duplicate comment is detected.
         *
         * @since 3.0.0
         *
         * @param array $commentdata Comment data.
         */
        do_action('comment_duplicate_trigger', $commentdata);
        if (defined('DOING_AJAX')) {
            die(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!'));
        }
        wp_die(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!'));
    }
    /**
     * Fires immediately before a comment is marked approved.
     *
     * Allows checking for comment flooding.
     *
     * @since 2.3.0
     *
     * @param string $comment_author_IP    Comment author's IP address.
     * @param string $comment_author_email Comment author's email.
     * @param string $comment_date_gmt     GMT date the comment was posted.
     */
    do_action('check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt);
    if (!empty($user_id)) {
        $user = get_userdata($user_id);
        $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $comment_post_ID));
    }
    if (isset($user) && ($user_id == $post_author || $user->has_cap('moderate_comments'))) {
        // The author and the admins get respect.
        $approved = 1;
    } else {
        // Everyone else's comments will be checked.
        if (check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type)) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent)) {
            $approved = 'spam';
        }
    }
    /**
     * Filter a comment's approval status before it is set.
     *
     * @since 2.1.0
     *
     * @param bool|string $approved    The approval status. Accepts 1, 0, or 'spam'.
     * @param array       $commentdata Comment data.
     */
    $approved = apply_filters('pre_comment_approved', $approved, $commentdata);
    return $approved;
}
开发者ID:easinewe,项目名称:Avec2016,代码行数:75,代码来源:comment.php

示例11: wp_allow_comment

function wp_allow_comment($commentdata)
{
    global $wpdb;
    extract($commentdata);
    // Simple duplicate check
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' ";
    if ($comment_author_email) {
        $dupe .= "OR comment_author_email = '{$comment_author_email}' ";
    }
    $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        wp_die(__('Duplicate comment detected; it looks as though you\'ve already said that!'));
    }
    // Simple flood-protection
    if ($lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author_IP = '{$comment_author_IP}' OR comment_author_email = '{$comment_author_email}' ORDER BY comment_date DESC LIMIT 1")) {
        $time_lastcomment = mysql2date('U', $lasttime);
        $time_newcomment = mysql2date('U', $comment_date_gmt);
        $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
        if ($flood_die) {
            do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
            wp_die(__('You are posting comments too quickly.  Slow down.'));
        }
    }
    if ($user_id) {
        $userdata = get_userdata($user_id);
        $user = new WP_User($user_id);
        $post_author = $wpdb->get_var("SELECT post_author FROM {$wpdb->posts} WHERE ID = '{$comment_post_ID}' LIMIT 1");
    }
    if ($userdata && ($user_id == $post_author || $user->has_cap('level_9'))) {
        // The author and the admins get respect.
        $approved = 1;
    } else {
        // Everyone else's comments will be checked.
        if (check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type)) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent)) {
            $approved = 'spam';
        }
    }
    $approved = apply_filters('pre_comment_approved', $approved);
    return $approved;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:45,代码来源:comment.php

示例12: wp_new_comment

function wp_new_comment($commentdata, $spam = false)
{
    global $wpdb;
    $commentdata = apply_filters('preprocess_comment', $commentdata);
    extract($commentdata);
    $comment_post_ID = (int) $comment_post_ID;
    $user_id = apply_filters('pre_user_id', $user_ID);
    $author = apply_filters('pre_comment_author_name', $comment_author);
    $email = apply_filters('pre_comment_author_email', $comment_author_email);
    $url = apply_filters('pre_comment_author_url', $comment_author_url);
    $comment = apply_filters('pre_comment_content', $comment_content);
    $comment = apply_filters('post_comment_text', $comment);
    // Deprecated
    $comment = apply_filters('comment_content_presave', $comment);
    // Deprecated
    $user_ip = apply_filters('pre_comment_user_ip', $_SERVER['REMOTE_ADDR']);
    $user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($user_ip));
    $user_agent = apply_filters('pre_comment_user_agent', $_SERVER['HTTP_USER_AGENT']);
    $now = current_time('mysql');
    $now_gmt = current_time('mysql', 1);
    if ($user_id) {
        $userdata = get_userdata($user_id);
        $post_author = $wpdb->get_var("SELECT post_author FROM {$wpdb->posts} WHERE ID = '{$comment_post_ID}' LIMIT 1");
    }
    // Simple duplicate check
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$author}' ";
    if ($email) {
        $dupe .= "OR comment_author_email = '{$email}' ";
    }
    $dupe .= ") AND comment_content = '{$comment}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        die(__('Duplicate comment detected; it looks as though you\'ve already said that!'));
    }
    // Simple flood-protection
    if ($lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author_IP = '{$user_ip}' OR comment_author_email = '{$email}' ORDER BY comment_date DESC LIMIT 1")) {
        $time_lastcomment = mysql2date('U', $lasttime);
        $time_newcomment = mysql2date('U', $now_gmt);
        if ($time_newcomment - $time_lastcomment < 15) {
            do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
            die(__('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.'));
        }
    }
    if ($userdata && ($user_id == $post_author || $userdata->user_level >= 9)) {
        $approved = 1;
    } else {
        if (check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type)) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent)) {
            $approved = 'spam';
        }
    }
    $approved = apply_filters('pre_comment_approved', $approved);
    $result = $wpdb->query("INSERT INTO {$wpdb->comments}\n\t(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, user_id)\n\tVALUES\n\t('{$comment_post_ID}', '{$author}', '{$email}', '{$url}', '{$user_ip}', '{$now}', '{$now_gmt}', '{$comment}', '{$approved}', '{$user_agent}', '{$comment_type}', '{$user_id}')\n\t");
    $comment_id = $wpdb->insert_id;
    do_action('comment_post', $comment_id, $approved);
    if ('spam' !== $approved) {
        // If it's spam save it silently for later crunching
        if ('0' == $approved) {
            wp_notify_moderator($comment_id);
        }
        if (get_settings('comments_notify') && $approved) {
            wp_notify_postauthor($comment_id, $comment_type);
        }
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:steampress-svn,代码行数:69,代码来源:functions-post.php

示例13: approve_comment

 /**
  * Similar to wp_approve_comment(), but does not check for duplicates or die on failure.
  *
  * @since 1.4.7
  *
  * @param $commentdata
  * @return int 1 for approved, 0 for not approved, 'spam' for spam
  */
 protected function approve_comment($commentdata)
 {
     $user = get_user_by('id', $this->user_id);
     $post = get_post($this->post_id);
     if (isset($user) && ($commentdata['user_id'] == $post->post_author || $user->has_cap('moderate_comments'))) {
         // The author and the admins get respect.
         $approved = 1;
     } else {
         // Everyone else's comments will be checked.
         if (check_comment($commentdata['comment_author'], $commentdata['comment_author_email'], $commentdata['comment_author_url'], $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_agent'], $commentdata['comment_type'])) {
             $approved = 1;
         } else {
             $approved = 0;
         }
         if (wp_blacklist_check($commentdata['comment_author'], $commentdata['comment_author_email'], $commentdata['comment_author_url'], $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_agent'])) {
             $approved = 'spam';
         }
     }
     /**
      * Filter a comment's approval status before it is set.
      *
      * @since 2.1.0
      *
      * @param bool|string $approved The approval status. Accepts 1, 0, or 'spam'.
      * @param array $commentdata Comment data.
      */
     $approved = apply_filters('pre_comment_approved', $approved, $commentdata);
     return $approved;
 }
开发者ID:postmatic,项目名称:beta-dist,代码行数:37,代码来源:comment-command.php

示例14: bymt_fuckspam

function bymt_fuckspam($comment)
{
    if (is_user_logged_in()) {
        return $comment;
    }
    if (!isset($comment['comment_author_IP'])) {
        $comment['comment_author_IP'] = bymt_getIP('Ip');
    }
    if (!isset($comment['comment_agent'])) {
        $comment['comment_agent'] = $_SERVER['HTTP_USER_AGENT'];
    }
    if (wp_blacklist_check($comment['comment_author'], $comment['comment_author_email'], $comment['comment_author_url'], $comment['comment_content'], $comment['comment_author_IP'], $comment['comment_agent'])) {
        err(__('草你麻痹垃圾评论滚粗!'));
    } else {
        return $comment;
    }
}
开发者ID:wdq233,项目名称:BYMT2,代码行数:17,代码来源:bymt-comment.php

示例15: wp_allow_comment

/**
 * Validates whether this comment is allowed to be made.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses apply_filters() Calls 'pre_comment_approved' hook on the type of comment
 * @uses apply_filters() Calls 'comment_duplicate_trigger' hook on commentdata.
 * @uses do_action() Calls 'check_comment_flood' hook on $comment_author_IP, $comment_author_email, and $comment_date_gmt
 *
 * @param array $commentdata Contains information on the comment
 * @return mixed Signifies the approval status (0|1|'spam')
 */
function wp_allow_comment($commentdata)
{
    global $wpdb;
    extract($commentdata, EXTR_SKIP);
    // Simple duplicate check
    // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
    $dupe = $wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", wp_unslash($comment_post_ID), wp_unslash($comment_parent), wp_unslash($comment_author));
    if ($comment_author_email) {
        $dupe .= $wpdb->prepare("OR comment_author_email = %s ", wp_unslash($comment_author_email));
    }
    $dupe .= $wpdb->prepare(") AND comment_content = %s LIMIT 1", wp_unslash($comment_content));
    if ($wpdb->get_var($dupe)) {
        do_action('comment_duplicate_trigger', $commentdata);
        if (defined('DOING_AJAX')) {
            die(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!'));
        }
        wp_die(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!'));
    }
    do_action('check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt);
    if (!empty($user_id)) {
        $user = get_userdata($user_id);
        $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $comment_post_ID));
    }
    if (isset($user) && ($user_id == $post_author || $user->has_cap('moderate_comments'))) {
        // The author and the admins get respect.
        $approved = 1;
    } else {
        // Everyone else's comments will be checked.
        if (check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type)) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent)) {
            $approved = 'spam';
        }
    }
    $approved = apply_filters('pre_comment_approved', $approved, $commentdata);
    return $approved;
}
开发者ID:palimadra,项目名称:bubblegraphics-wpsite,代码行数:52,代码来源:comment.php


注:本文中的wp_blacklist_check函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。