WordPress.org

Plugin Directory

Changeset 496814


Ignore:
Timestamp:
01/29/12 09:38:21 (2 years ago)
Author:
ramon fincken
Message:

New version

Location:
antispam-for-all-fields
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • antispam-for-all-fields/trunk/antispam-for-all-fields-core.php

    r476885 r496814  
    1919     */ 
    2020    public function string_is_spam($stringtotest, $spamword) { 
    21         if (preg_match("#\b(" . str_replace("\*", ".*?", preg_quote($stringtotest, '#')) . ")\b#i", $spamword)) { 
     21        //if (preg_match("#\b(" . str_replace("\*", ".*?", preg_quote($stringtotest, '#')) . ")\b#i", $spamword)) { 
     22         
     23        $spamword = trim($spamword,'*'); 
     24        if (preg_match("/\b$spamword\b/i",$stringtotest)) { 
    2225            return true; 
    2326        } 
     
    8891        } 
    8992    } 
    90      
    91     // Antispam Extra V 0.2 By Budhiman 
    92     // add_action('check_comment_flood', array('AntispamExtra', 'check_referrer')); 
    93     // No comments without proper HTTP referer 
    94     function check_referrer() { 
    95  
    96         if (get_option('antispamextra_disallow_nonreferers')) { 
    97             if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == '' || strpos($_SERVER['HTTP_REFERER'], get_option('siteurl')) < 0) { 
    98                 if (get_option('antispamextra_spam_response_mode')) { 
    99                     header('HTTP/1.1 403 Forbidden'); 
    100                     die(get_option('antispamextra_message'));                
    101                 } 
    102                 else die(); 
    103             } 
    104         } 
    105     }    
    106      
     93 
    10794    /** 
    10895     * Notifies admin or custom inserted replacement 
     
    129116            $body .= sprintf( __('Blacklist IP and remove same email and URL: %s'), admin_url($this->plugin_config_url."&action=blacklist_ip&blacklist_extra=true&ip=".$this->user_ip."&comment_key=$commment_key") ) . "\r\n\r\n"; 
    130117            $body .= sprintf( __('Blacklist IP: %s'), admin_url($this->plugin_config_url."&action=blacklist_ip&ip=".$this->user_ip."&comment_key=$commment_key") ) . "\r\n\r\n"; 
     118            $body .= "Ip info: http://www.whois.sc/".$this->user_ip. "\r\n\r\n"; 
    131119        } 
    132120         
     
    498486        return $results[0]['numberofrows']; 
    499487    } 
     488     
     489    protected function check_user_agent_is_spam($useragent) 
     490    { 
     491        global $wpdb; 
     492 
     493        $sql = 'SELECT COUNT(`comment_agent`) AS numberofrows FROM ' . $wpdb->comments . ' WHERE comment_approved =%s'; 
     494        $preparedsql = $wpdb->prepare($sql, $this->wpdb_spam_status); 
     495        $results = $wpdb->get_results($preparedsql, ARRAY_A); 
     496        $spammed = $results[0]['numberofrows']; 
     497 
     498        $sql = 'SELECT COUNT(`comment_agent`) AS numberofrows FROM ' . $wpdb->comments . ' WHERE comment_approved =%s'; 
     499        $preparedsql = $wpdb->prepare($sql, 1); 
     500        $results = $wpdb->get_results($preparedsql, ARRAY_A); 
     501        $not_spammed = $results[0]['numberofrows']; 
     502         
     503        if($spammed == 0) 
     504        { 
     505            return false; 
     506        } 
     507         
     508        // Fallthrough if spammed > 0 
     509         
     510        // Only spammed? 
     511        if($not_spammed == 0) 
     512        { 
     513            return $this->wpdb_spam_status; 
     514        } 
     515         
     516        // Hits for spam and nonspam, but more spam? 
     517        if($spammed > $not_spammed) 
     518        { 
     519            // hmmz what to do? 
     520            return 'challenge'; 
     521        } 
     522         
     523        return false; 
     524    } 
    500525} 
    501526?> 
  • antispam-for-all-fields/trunk/antispam-for-all-fields.php

    r491786 r496814  
    55 Description: Class and functions 
    66 Author: Ramon Fincken 
    7  Version: 0.7.8 
     7 Version: 0.7.9 
    88 Author URI: http://www.mijnpress.nl 
    99 */ 
     
    1616} 
    1717 
    18 define('PLUGIN_ANTISPAM_FOR_ALL_FIELDS_VERSION', '0.7.6'); 
     18define('PLUGIN_ANTISPAM_FOR_ALL_FIELDS_VERSION', '0.7.9'); 
    1919 
    2020if(!class_exists('antispam_for_all_fields_core')) 
     
    442442        $url = $commentdata['comment_author_url']; 
    443443        $comment_content = $commentdata['comment_content']; 
     444        $comment_agent = $commentdata['comment_agent']; 
    444445                 
    445446        // Trackback or pingback? 
     
    473474        } 
    474475         
    475         // Comments only 
    476  
    477  
    478  
     476        // Comments only below this point 
     477     
     478        // Antispam Extra V 0.2 By Budhiman 
     479        // No comments without proper HTTP referer 
     480        if (get_option('antispamextra_disallow_nonreferers')) { 
     481            if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == '' || strpos($_SERVER['HTTP_REFERER'], get_option('siteurl')) < 0) { 
     482                $this->update_stats('killed'); 
     483                if ( defined('DOING_AJAX') ) 
     484                { 
     485                    die( __($this->language['explain']) ); 
     486                } 
     487                wp_die( __($this->language['explain']), '', array('response' => 403) );              
     488            } 
     489        } 
     490 
     491 
     492        if(!empty($comment_agent)) 
     493        { 
     494            $check = $this->check_user_agent_is_spam($comment_agent); 
     495            if($check == $this->wpdb_spam_status) 
     496            { 
     497                    // Get lost 
     498                    foreach ($commentdata as $key => $val) { 
     499                        $body .= "$key : $val \n"; 
     500                    } 
     501 
     502                    $commment_key = $this->store_comment($commentdata,'spammed'); 
     503                    $this->mail_details('rejected spammed based comment agent', $body,$commment_key); 
     504                    $this->update_stats('spammed'); 
     505                    return 'spam'; 
     506            } 
     507            else 
     508            { 
     509                if($check == 'challenge') 
     510                { 
     511                     
     512                } 
     513            } 
     514        } 
    479515         
    480516        if (!empty ($email)) { 
     
    577613                // random <a href="http://website.com">random</a>, [url=http://website.com]random[/url], [link=http://website.com]random[/link], http://website.com 
    578614                if (preg_match('/^([[:alnum:]])( ?)(.*?)(href)(.*?)((nofollow)?(.*?))(url)(.*?)(link)(.*?)$/', $comment_content)) { 
    579                     $this->update_stats('spammed'); 
     615                    $this->update_stats('killed'); 
    580616                    if ( defined('DOING_AJAX') ) 
    581617                    { 
     
    587623                // random [url=http://website.com]random[/url], [link=http://website.com]random[/link], http://website.com 
    588624                if (preg_match('/^([[:alnum:]])( ?)(.*?)(url)(.*?)(link)(.*?)$/', $comment_content)) { 
    589                     $this->update_stats('spammed'); 
     625                    $this->update_stats('killed'); 
    590626                    if ( defined('DOING_AJAX') ) 
    591627                    { 
     
    598634            // HTML? 
    599635            if (preg_match('/^(<strong>)(.*?)(<\/strong>)(.*?)([(\.)])(.*?)([(\.)])(.*?)$/s', $comment_content) || preg_match('/^(<b>)(.*?)(<\/b>)(.*?)([(\.)])(.*?)([(\.)])(.*?)$/s', $comment_content)) { 
    600                     $this->update_stats('spammed'); 
     636                    $this->update_stats('killed'); 
    601637                    if ( defined('DOING_AJAX') ) 
    602638                    { 
  • antispam-for-all-fields/trunk/readme.txt

    r491786 r496814  
    55Requires at least: 2.0.2 
    66Tested up to: 3.3.1 
    7 Stable tag: 0.7.8 
     7Stable tag: 0.7.9 
    88 
    99Plugin to reject spam. Port from same author from http://www.phpbbantispam.com 
     
    2020* Detailed information by email about the spammed comment. You can approve the comment later on, or blacklist the IP adres.<br> 
    2121* Future feature: Add hidden fields with random names<br> 
    22 Need PHP5 on your webserver. Does not work on PHP4 webservers. 
     22<small><strong>Need PHP5 on your webserver. Does not work on PHP4 webservers.</strong></small> 
    2323 
    2424<br> 
     
    4040 
    4141== Changelog == 
     42= 0.7.9 = 
     43Added: IP whois link in email to admin 
     44Added: Incorporated "No comments without proper HTTP referer" by "Antispam Extra V 0.2 By Budhiman" 
     45Changed: string_is_spam function 
     46Added: Useragent spam check 
     47 
    4248= 0.7.8 = 
    4349Added:  Lots of (more then 25%) dots in mail and free-email 
Note: See TracChangeset for help on using the changeset viewer.