Make WordPress Core


Ignore:
Timestamp:
06/07/2006 11:17:59 PM (19 years ago)
Author:
ryan
Message:

Reworg post/page/attachment functions. #2525

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r3740 r3851  
    196196}
    197197
     198function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
     199    global $wpdb;
     200
     201    do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);
     202
     203    if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) {
     204        foreach ($chars[1] as $char) {
     205            // If it's an encoded char in the normal ASCII set, reject
     206            if ( 38 == $char )
     207                continue; // Unless it's &
     208            if ($char < 128)
     209                return true;
     210        }
     211    }
     212
     213    $mod_keys = trim( get_settings('blacklist_keys') );
     214    if ('' == $mod_keys )
     215        return false; // If moderation keys are empty
     216    $words = explode("\n", $mod_keys );
     217
     218    foreach ($words as $word) {
     219        $word = trim($word);
     220
     221        // Skip empty lines
     222        if ( empty($word) ) { continue; }
     223
     224        // Do some escaping magic so that '#' chars in the
     225        // spam words don't break things:
     226        $word = preg_quote($word, '#');
     227
     228        $pattern = "#$word#i";
     229        if ( preg_match($pattern, $author    ) ) return true;
     230        if ( preg_match($pattern, $email     ) ) return true;
     231        if ( preg_match($pattern, $url       ) ) return true;
     232        if ( preg_match($pattern, $comment   ) ) return true;
     233        if ( preg_match($pattern, $user_ip   ) ) return true;
     234        if ( preg_match($pattern, $user_agent) ) return true;
     235    }
     236
     237    if ( isset($_SERVER['REMOTE_ADDR']) ) {
     238        if ( wp_proxy_check($_SERVER['REMOTE_ADDR']) ) return true;
     239    }
     240
     241    return false;
     242}
     243
    198244function wp_delete_comment($comment_id) {
    199245    global $wpdb;
Note: See TracChangeset for help on using the changeset viewer.