Dotclear


Ignore:
Timestamp:
11/17/13 20:25:53 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Children:
2567:6c11245cbf04, 2568:61c67a7d17fa
Message:

Add some people in CREDITS, remove trailing spaces and tabs.

Location:
plugins/antispam
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • plugins/antispam/_admin.php

    r2330 r2566  
    9696          '</div>'; 
    9797     } 
    98       
     98 
    9999     public static function adminBeforeBlogSettingsUpdate($settings) 
    100100     { 
     
    103103     } 
    104104} 
    105 ?> 
  • plugins/antispam/_define.php

    r1179 r2566  
    2222     ) 
    2323); 
    24 ?> 
  • plugins/antispam/_install.php

    r1179 r2566  
    2626     ->rule_type    ('varchar',    16,  false,    "'word'") 
    2727     ->rule_content ('varchar',    128, false) 
    28       
     28 
    2929     ->primary('pk_spamrule','rule_id') 
    3030     ; 
     
    5454$core->setVersion('antispam',$version); 
    5555return true; 
    56 ?> 
  • plugins/antispam/_public.php

    r1179 r2566  
    1515$core->addBehavior('publicBeforeTrackbackCreate',array('dcAntispam','isSpam')); 
    1616$core->addBehavior('publicBeforeDocument',array('dcAntispam','purgeOldSpam')); 
    17 ?> 
  • plugins/antispam/filters/class.dc.filter.ip.php

    r2322 r2566  
    321321     } 
    322322} 
    323 ?> 
  • plugins/antispam/filters/class.dc.filter.iplookup.php

    r2322 r2566  
    114114     } 
    115115} 
    116 ?> 
  • plugins/antispam/filters/class.dc.filter.linkslookup.php

    r1366 r2566  
    1515{ 
    1616     public $name = 'Links Lookup'; 
    17       
     17 
    1818     private $server = 'multi.surbl.org'; 
    19       
     19 
    2020     protected function setInfo() 
    2121     { 
    2222          $this->description = __('Checks links in comments against surbl.org'); 
    2323     } 
    24       
     24 
    2525     public function getStatusMessage($status,$comment_id) 
    2626     { 
    2727          return sprintf(__('Filtered by %1$s with server %2$s.'),$this->guiLink(),$status); 
    2828     } 
    29       
     29 
    3030     public function isSpam($type,$author,$email,$site,$ip,$content,$post_id,&$status) 
    3131     { 
     
    3333               return; 
    3434          } 
    35            
     35 
    3636          $urls = $this->getLinks($content); 
    3737          array_unshift($urls,$site); 
    38            
     38 
    3939          foreach ($urls as $u) 
    4040          { 
     
    5353                    $host = $domain_elem[$i - 1].'.'.$host; 
    5454                    $i--; 
    55                     if (substr(gethostbyname($host.'.'.$this->server),0,3) == "127" )  
     55                    if (substr(gethostbyname($host.'.'.$this->server),0,3) == "127" ) 
    5656                    { 
    5757                         $status = substr($domain,0,128); 
    5858                         return true; 
    59                     }                    
     59                    } 
    6060               } while ($i > 0); 
    6161          } 
    6262     } 
    63       
     63 
    6464     private function getLinks($text) 
    6565     { 
     
    7070     } 
    7171} 
    72 ?> 
  • plugins/antispam/filters/class.dc.filter.words.php

    r2322 r2566  
    362362     } 
    363363} 
    364 ?> 
  • plugins/antispam/inc/class.dc.spamfilter.php

    r2322 r2566  
    2020     public $auto_delete = false; 
    2121     public $help = null; 
    22       
     22 
    2323     protected $has_gui = false; 
    2424     protected $gui_url = null; 
    25       
     25 
    2626     protected $core; 
    27       
     27 
    2828     /** 
    2929     Object constructor 
    30       
     30 
    3131     @param    core      <b>dcCore</b>       Dotclear core object 
    3232     */ 
     
    3535          $this->core =& $core; 
    3636          $this->setInfo(); 
    37            
     37 
    3838          if (!$this->name) { 
    3939               $this->name = get_class($this); 
    4040          } 
    41            
     41 
    4242          $this->gui_url = 'plugin.php?p=antispam&f='.get_class($this); 
    4343     } 
    44       
     44 
    4545     /** 
    4646     This method is called by the constructor and allows you to change some 
     
    5151          $this->description = __('No description'); 
    5252     } 
    53       
     53 
    5454     /** 
    5555     This method should return if a comment is a spam or not. If it returns true 
    5656     or false, execution of next filters will be stoped. If should return nothing 
    5757     to let next filters apply. 
    58       
     58 
    5959     Your filter should also fill $status variable with its own information if 
    6060     comment is a spam. 
    61       
     61 
    6262     @param         type      <b>string</b>       Comment type (comment or trackback) 
    6363     @param         author    <b>string</b>       Comment author 
     
    7373     { 
    7474     } 
    75       
     75 
    7676     /** 
    7777     This method is called when a non-spam (ham) comment becomes spam or when a 
    7878     spam becomes a ham. 
    79       
     79 
    8080     @param    type      <b>string</b>       Comment type (comment or trackback) 
    8181     @param    filter    <b>string</b>       Filter name 
     
    9292     { 
    9393     } 
    94       
     94 
    9595     /** 
    9696     This method returns filter status message. You can overload this method to 
    9797     return a custom message. Message is shown in comment details and in 
    9898     comments list. 
    99       
     99 
    100100     @param    status         <b>string</b>       Filter status. 
    101101     @param    comment_id     <b>record</b>       Comment record 
     
    106106          return sprintf(__('Filtered by %1$s (%2$s)'),$this->guiLink(),$status); 
    107107     } 
    108       
     108 
    109109     /** 
    110110     This method is called when you enter filter configuration. Your class should 
    111111     have $has_gui property set to "true" to enable GUI. 
    112       
     112 
    113113     In this method you should put everything related to filter configuration. 
    114114     $url variable is the URL of GUI <i>unescaped</i>. 
    115       
     115 
    116116     @param    url       <b>string</b>       GUI URL. 
    117117     */ 
     
    119119     { 
    120120     } 
    121       
     121 
    122122     public function hasGUI() 
    123123     { 
     
    125125               return false; 
    126126          } 
    127            
     127 
    128128          if (!$this->has_gui) { 
    129129               return false; 
    130130          } 
    131            
     131 
    132132          return true; 
    133133     } 
    134       
     134 
    135135     public function guiURL() 
    136136     { 
     
    138138               return false; 
    139139          } 
    140            
     140 
    141141          return $this->gui_url; 
    142142     } 
    143       
     143 
    144144     /** 
    145145     Returns a link to filter GUI if exists or only filter name if has_gui 
    146146     property is false. 
    147       
     147 
    148148     @return   <b>string</b> 
    149149     */ 
     
    156156               $link = '%1$s'; 
    157157          } 
    158            
     158 
    159159          return sprintf($link,$this->name,$url); 
    160160     } 
     
    164164     } 
    165165} 
    166 ?> 
  • plugins/antispam/inc/class.dc.spamfilters.php

    r1179 r2566  
    1717     private $filters_opt = array(); 
    1818     private $core; 
    19       
     19 
    2020     public function __construct($core) 
    2121     { 
    2222          $this->core =& $core; 
    2323     } 
    24       
     24 
    2525     public function init($filters) 
    2626     { 
     
    3030                    continue; 
    3131               } 
    32                 
     32 
    3333               $r = new ReflectionClass($f); 
    3434               $p = $r->getParentClass(); 
    35                 
     35 
    3636               if (!$p || $p->name != 'dcSpamFilter') { 
    3737                    continue; 
    3838               } 
    39                 
     39 
    4040               $this->filters[$f] = new $f($this->core); 
    4141          } 
    42            
     42 
    4343          $this->setFilterOpts(); 
    4444          if (!empty($this->filters_opt)) { 
     
    4646          } 
    4747     } 
    48       
     48 
    4949     public function getFilters() 
    5050     { 
    5151          return $this->filters; 
    5252     } 
    53       
     53 
    5454     public function isSpam($cur) 
    5555     { 
     
    5959                    continue; 
    6060               } 
    61                 
     61 
    6262               $type = $cur->comment_trackback ? 'trackback' : 'comment'; 
    6363               $author = $cur->comment_author; 
     
    6767               $content = $cur->comment_content; 
    6868               $post_id = $cur->post_id; 
    69                 
     69 
    7070               $is_spam = $f->isSpam($type,$author,$email,$site,$ip,$content,$post_id,$status); 
    71                 
     71 
    7272               if ($is_spam === true) { 
    7373                    if ($f->auto_delete) { 
     
    8383               } 
    8484          } 
    85            
     85 
    8686          return false; 
    8787     } 
    88       
     88 
    8989     public function trainFilters($rs,$status,$filter_name) 
    9090     { 
     
    9494                    continue; 
    9595               } 
    96                 
     96 
    9797               $type = $rs->comment_trackback ? 'trackback' : 'comment'; 
    9898               $author = $rs->comment_author; 
     
    101101               $ip = $rs->comment_ip; 
    102102               $content = $rs->comment_content; 
    103                 
     103 
    104104               $f->trainFilter($status,$filter_name,$type,$author,$email,$site,$ip,$content,$rs); 
    105105          } 
    106106     } 
    107       
     107 
    108108     public function statusMessage($rs,$filter_name) 
    109109     { 
    110110          $f = isset($this->filters[$filter_name]) ? $this->filters[$filter_name] : null; 
    111            
     111 
    112112          if ($f === null) 
    113113          { 
     
    117117          { 
    118118               $status = $rs->exists('comment_spam_status') ? $rs->comment_spam_status : null; 
    119                 
     119 
    120120               return $f->getStatusMessage($status,$rs->comment_id); 
    121121          } 
    122122     } 
    123       
     123 
    124124     public function saveFilterOpts($opts,$global=false) 
    125125     { 
     
    130130          $this->core->blog->settings->antispam->put('antispam_filters',serialize($opts),'string','Antispam Filters',true,$global); 
    131131     } 
    132       
     132 
    133133     private function setFilterOpts() 
    134134     { 
     
    136136               $this->filters_opt = @unserialize($this->core->blog->settings->antispam->antispam_filters); 
    137137          } 
    138            
     138 
    139139          # Create default options if needed 
    140140          if (!is_array($this->filters_opt)) { 
     
    142142               $this->filters_opt = array(); 
    143143          } 
    144            
     144 
    145145          foreach ($this->filters_opt as $k => $o) 
    146146          { 
    147                if (isset($this->filters[$k]) && is_array($o)) {        
     147               if (isset($this->filters[$k]) && is_array($o)) { 
    148148                    $this->filters[$k]->active = isset($o[0])?$o[0]:false; 
    149149                    $this->filters[$k]->order = isset($o[1])?$o[1]:0; 
     
    152152          } 
    153153     } 
    154       
     154 
    155155     private function orderCallBack($a,$b) 
    156156     { 
     
    158158               return 0; 
    159159          } 
    160            
     160 
    161161          return $a->order > $b->order ? 1 : -1; 
    162162     } 
    163163} 
    164 ?> 
  • plugins/antispam/inc/lib.dc.antispam.php

    r1478 r2566  
    1515{ 
    1616     public static $filters; 
    17       
     17 
    1818     public static function initFilters() 
    1919     { 
    2020          global $core; 
    21            
     21 
    2222          if (!isset($core->spamfilters)) { 
    2323               return; 
    2424          } 
    25            
     25 
    2626          self::$filters = new dcSpamFilters($core); 
    2727          self::$filters->init($core->spamfilters); 
    2828     } 
    29       
     29 
    3030     public static function isSpam($cur) 
    3131     { 
     
    3333          self::$filters->isSpam($cur); 
    3434     } 
    35       
     35 
    3636     public static function trainFilters($blog,$cur,$rs) 
    3737     { 
     
    4141               $status = 'spam'; 
    4242          } 
    43            
     43 
    4444          # From spam to ham 
    4545          if ($rs->comment_status == -2 && $cur->comment_status == 1) { 
    4646               $status = 'ham'; 
    4747          } 
    48            
     48 
    4949          # the status of this comment has changed 
    5050          if ($status) 
    5151          { 
    5252               $filter_name = $rs->exists('comment_spam_filter') ? $rs->comment_spam_filter : null; 
    53                 
     53 
    5454               self::initFilters(); 
    5555               self::$filters->trainFilters($rs,$status,$filter_name); 
    5656          } 
    5757     } 
    58       
     58 
    5959     public static function statusMessage($rs) 
    6060     { 
     
    6262          { 
    6363               $filter_name = $rs->exists('comment_spam_filter') ? $rs->comment_spam_filter : null; 
    64                 
     64 
    6565               self::initFilters(); 
    66                 
     66 
    6767               return 
    6868               '<p><strong>'.__('This comment is a spam:').'</strong> '. 
     
    7070          } 
    7171     } 
    72       
     72 
    7373     public static function dashboardIcon($core, $icons) 
    7474     { 
     
    7878          } 
    7979     } 
    80       
     80 
    8181     public static function dashboardIconTitle($core) 
    8282     { 
     
    8888          } 
    8989     } 
    90       
     90 
    9191     public static function countSpam($core) 
    9292     { 
    9393          return $core->blog->getComments(array('comment_status'=>-2),true)->f(0); 
    9494     } 
    95       
     95 
    9696     public static function countPublishedComments($core) 
    9797     { 
    9898          return $core->blog->getComments(array('comment_status'=>1),true)->f(0); 
    9999     } 
    100       
     100 
    101101     public static function delAllSpam($core, $beforeDate = null) 
    102102     { 
     
    110110               $strReq .= 'AND comment_dt < \''.$beforeDate.'\' '; 
    111111          } 
    112            
     112 
    113113          $rs = $core->con->select($strReq); 
    114114          $r = array(); 
     
    116116               $r[] = (integer) $rs->comment_id; 
    117117          } 
    118            
     118 
    119119          if (empty($r)) { 
    120120               return; 
    121121          } 
    122            
     122 
    123123          $strReq = 
    124124          'DELETE FROM '.$core->prefix.'comment '. 
    125125          'WHERE comment_id '.$core->con->in($r).' '; 
    126            
     126 
    127127          $core->con->execute($strReq); 
    128128     } 
    129       
     129 
    130130     public static function getUserCode($core) 
    131131     { 
     
    135135          return bin2hex($code); 
    136136     } 
    137       
     137 
    138138     public static function checkUserCode($core,$code) 
    139139     { 
    140140          $code = pack('H*',$code); 
    141            
     141 
    142142          $user_id = trim(@pack('a32',substr($code,0,32))); 
    143143          $pwd = @unpack('H40hex',substr($code,32,40)); 
    144            
     144 
    145145          if ($user_id === false || $pwd === false) { 
    146146               return false; 
    147147          } 
    148            
     148 
    149149          $pwd = $pwd['hex']; 
    150            
     150 
    151151          $strReq = 'SELECT user_id, user_pwd '. 
    152152                    'FROM '.$core->prefix.'user '. 
    153153                    "WHERE user_id = '".$core->con->escape($user_id)."' "; 
    154            
     154 
    155155          $rs = $core->con->select($strReq); 
    156            
     156 
    157157          if ($rs->isEmpty()) { 
    158158               return false; 
    159159          } 
    160            
     160 
    161161          if (crypt::hmac(DC_MASTER_KEY,$rs->user_pwd) != $pwd) { 
    162162               return false; 
    163163          } 
    164            
     164 
    165165          $permissions = $core->getBlogPermissions($core->blog->id); 
    166            
     166 
    167167          if ( empty($permissions[$rs->user_id]) ) { 
    168168               return false; 
    169169          } 
    170            
     170 
    171171          return $rs->user_id; 
    172172     } 
    173       
     173 
    174174     public static function purgeOldSpam($core) 
    175175     { 
     
    177177          $defaultModerationTTL = '7'; 
    178178          $init = false; 
    179            
     179 
    180180          // settings 
    181181          $core->blog->settings->addNamespace('antispam'); 
    182            
     182 
    183183          $dateLastPurge = $core->blog->settings->antispam->antispam_date_last_purge; 
    184184          if ($dateLastPurge === null) { 
     
    192192               $moderationTTL = $defaultModerationTTL; 
    193193          } 
    194            
     194 
    195195          if ($moderationTTL < 0) { 
    196196               // disabled 
    197197               return; 
    198198          } 
    199            
     199 
    200200          // we call the purge every day 
    201201          if ((time()-$dateLastPurge) > (86400)) { 
     
    203203               if (!$init) { 
    204204                    $core->blog->settings->antispam->put('antispam_date_last_purge',time(),null,null,true,false); 
    205                }     
     205               } 
    206206               $date = date('Y-m-d H:i:s', time() - $moderationTTL*86400); 
    207207               dcAntispam::delAllSpam($core, $date); 
     
    209209     } 
    210210} 
    211 ?> 
  • plugins/antispam/inc/lib.dc.antispam.url.php

    r1179 r2566  
    1818          self::genFeed('ham',$args); 
    1919     } 
    20       
     20 
    2121     public static function spamFeed($args) 
    2222     { 
    2323          self::genFeed('spam',$args); 
    2424     } 
    25       
     25 
    2626     private static function genFeed($type,$args) 
    2727     { 
    2828          global $core; 
    2929          $user_id = dcAntispam::checkUserCode($core,$args); 
    30            
     30 
    3131          if ($user_id === false) { 
    3232               self::p404(); 
    3333               return; 
    3434          } 
    35            
     35 
    3636          $core->auth->checkUser($user_id,null,null); 
    37            
     37 
    3838          header('Content-Type: application/xml; charset=UTF-8'); 
    39            
     39 
    4040          $title = $core->blog->name.' - '.__('Spam moderation'). ' - '; 
    4141          $params = array(); 
     
    4949               $params['sql'] = ' AND comment_status IN (1,-1) '; 
    5050          } 
    51            
     51 
    5252          echo 
    5353          '<?xml version="1.0" encoding="utf-8"?>'."\n". 
     
    5959          '<link>'.(DC_ADMIN_URL ? DC_ADMIN_URL.'comments.php'.$end_url : 'about:blank').'</link>'."\n". 
    6060          '<description></description>'."\n"; 
    61            
     61 
    6262          $rs = $core->blog->getComments($params); 
    6363          $maxitems = 20; 
    64           $nbitems = 0;        
    65            
     64          $nbitems = 0; 
     65 
    6666          while ($rs->fetch() && ($nbitems < $maxitems)) 
    6767          { 
     
    7474               } 
    7575               $id = $rs->getFeedID(); 
    76                 
     76 
    7777               $content = '<p>IP: '.$rs->comment_ip; 
    78                 
     78 
    7979               if (trim($rs->comment_site)) { 
    8080                    $content .= '<br />URL: <a href="'.$rs->comment_site.'">'.$rs->comment_site.'</a>'; 
     
    8282               $content .= "</p><hr />\n"; 
    8383               $content .= $rs->comment_content; 
    84                 
     84 
    8585               echo 
    8686               '<item>'."\n". 
    87                '  <title>'.html::escapeHTML($title).'</title>'."\n".                  
     87               '  <title>'.html::escapeHTML($title).'</title>'."\n". 
    8888               '  <link>'.$uri.'</link>'."\n". 
    8989               '  <guid>'.$id.'</guid>'."\n". 
    9090               '  <pubDate>'.$rs->getRFC822Date().'</pubDate>'."\n". 
    9191               '  <dc:creator>'.html::escapeHTML($author).'</dc:creator>'."\n". 
    92                '  <description>'.html::escapeHTML($content).'</description>'."\n".         
     92               '  <description>'.html::escapeHTML($content).'</description>'."\n". 
    9393               '</item>'; 
    9494          } 
    95            
    96           echo "</channel>\n</rss>";     
     95 
     96          echo "</channel>\n</rss>"; 
    9797     } 
    9898} 
    99 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map