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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map