Changeset 1370

Show
Ignore:
Timestamp:
11/28/08 00:03:31 (6 weeks ago)
Author:
ayunyan
Message:

plugin:dnsbl added ipbl function

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • plugins/dnsbl/trunk/dnsbl.plugin.php

    r1248 r1370  
    5555    { 
    5656        if (Plugins::id_from_file($file) != Plugins::id_from_file(__FILE__)) return; 
     57        Options::set('dnsbl__ipbl', "dnsbl.spam-champuru.livedoor.com"); 
     58        Options::set('dnsbl__urlbl', "bsb.spamlookup.net"); 
    5759 
    5860    } 
     
    8183        if ($plugin_id != $this->plugin_id()) return; 
    8284        if ($action == _t('Configure')) { 
    83             $ui= new FormUI(strtolower(get_class($this))); 
    84             $ui->append('submit', 'save', _t( 'Save' )); 
    85             $ui->out(); 
     85            $form = new FormUI(strtolower(get_class($this))); 
     86            $form->append('textarea', 'ipbl', 'dnsbl__ipbl', _t('IP Blacklists: ', 'dnsbl')); 
     87            $form->append('submit', 'save', _t('Save')); 
     88            $form->out(); 
    8689        } 
    8790    } 
     
    112115    public function action_comment_insert_before($comment) 
    113116    { 
     117        $ipaddrs = explode('.', $comment->ip, 4); 
     118        $reverse_ipaddr = join('.', array_reverse($ipaddrs)); 
     119 
     120        $ipbls = Options::get('dnsbl__ipbl'); 
     121        $ipbls = str_replace("\r", '', $ipbls); 
     122        $ipbls = explode("\n", trim($ipbls)); 
     123 
     124        $checks = array(); 
     125        @reset($ipbls); 
     126        while (list(, $ipbl) = @each($ipbls)) { 
     127            $addr = gethostbyname($reverse_ipaddr . '.' . $ipbl); 
     128            if ($addr == '127.0.0.2') { 
     129                $checks[] = sprintf(_t('Flagged by DNSBL (%s)', 'dnsbl'), $ipbl); 
     130            } 
     131        } 
     132 
     133        if (count($checks) > 0) { 
     134            $comment->status = 'spam'; 
     135            if (isset($comment->info->spamcheck)) { 
     136                $comment->info->spamcheck = array_unique(array_merge($comment->info->spamcheck, $checks)); 
     137            } else { 
     138                $comment->info->spamcheck = $checks; 
     139            } 
     140        } 
    114141    } 
    115142}