Dotclear


Ignore:
Timestamp:
05/08/11 21:44:10 (14 years ago)
Author:
annso <as.tranchet@…>
Branch:
default
Children:
224:23ec5a339bcf, 225:411ee50a8664, 249:d0a17b7ca6e0
Message:

Ajout de label et title dans les formulaires du plugin antispam

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/antispam/filters/class.dc.filter.words.php

    r3 r223  
    1616     public $has_gui = true; 
    1717     public $name = 'Bad Words'; 
    18       
     18 
    1919     private $style_list = 'height: 200px; overflow: auto; margin-bottom: 1em; '; 
    2020     private $style_p = 'margin: 1px 0 0 0; padding: 0.2em 0.5em; '; 
    2121     private $style_global = 'background: #ccff99; '; 
    22       
     22 
    2323     private $con; 
    2424     private $table; 
    25       
     25 
    2626     public function __construct($core) 
    2727     { 
     
    3030          $this->table = $core->prefix.'spamrule'; 
    3131     } 
    32       
     32 
    3333     protected function setInfo() 
    3434     { 
    3535          $this->description = __('Words Blacklist'); 
    3636     } 
    37       
     37 
    3838     public function getStatusMessage($status,$comment_id) 
    3939     { 
    4040          return sprintf(__('Filtered by %1$s with word %2$s.'),$this->guiLink(),'<em>'.$status.'</em>'); 
    4141     } 
    42       
     42 
    4343     public function isSpam($type,$author,$email,$site,$ip,$content,$post_id,&$status) 
    4444     { 
    4545          $str = $author.' '.$email.' '.$site.' '.$content; 
    46            
     46 
    4747          $rs = $this->getRules(); 
    48            
     48 
    4949          while ($rs->fetch()) 
    5050          { 
    5151               $word = $rs->rule_content; 
    52                 
     52 
    5353               if (substr($word,0,1) == '/' && substr($word,-1,1) == '/') { 
    5454                    $reg = substr(substr($word,1),0,-1); 
     
    5757                    $reg = '(^|\s+|>|<)'.$reg.'(>|<|\s+|\.|$)'; 
    5858               } 
    59                 
     59 
    6060               if (preg_match('/'.$reg.'/msiu',$str)) { 
    6161                    $status = $word; 
     
    6464          } 
    6565     } 
    66       
     66 
    6767     public function gui($url) 
    6868     { 
    6969          $core =& $this->core; 
    70            
     70 
    7171          # Create list 
    7272          if (!empty($_POST['createlist'])) 
     
    7979               } 
    8080          } 
    81            
     81 
    8282          # Adding a word 
    8383          if (!empty($_POST['swa'])) 
    8484          { 
    8585               $globalsw = !empty($_POST['globalsw']) && $core->auth->isSuperAdmin(); 
    86                 
     86 
    8787               try { 
    8888                    $this->addRule($_POST['swa'],$globalsw); 
     
    9292               } 
    9393          } 
    94            
     94 
    9595          # Removing spamwords 
    9696          if (!empty($_POST['swd']) && is_array($_POST['swd'])) 
     
    103103               } 
    104104          } 
    105            
     105 
    106106          /* DISPLAY 
    107107          ---------------------------------------------- */ 
    108108          $res = ''; 
    109            
     109 
    110110          if (!empty($_GET['list'])) { 
    111111               $res .= '<p class="message">'.__('Words have been successfully added.').'</p>'; 
     
    117117               $res .= '<p class="message">'.__('Words have been successfully removed.').'</p>'; 
    118118          } 
    119            
     119 
    120120          $res .= 
    121121          '<form action="'.html::escapeURL($url).'" method="post">'. 
    122122          '<fieldset><legend>'.__('Add a word').'</legend>'. 
    123           '<p>'.form::field('swa',20,128).' '; 
    124            
     123          '<p><label class="classic" for="swa">'.__('Add a word').' '.form::field('swa',20,128).'</label>'; 
     124 
    125125          if ($core->auth->isSuperAdmin()) { 
    126                $res .= '<label class="classic">'.form::checkbox('globalsw',1).' '. 
     126               $res .= '<label class="classic" for="globalsw">'.form::checkbox('globalsw',1).' '. 
    127127               __('Global word').'</label> '; 
    128128          } 
    129            
     129 
    130130          $res .= 
    131131          $core->formNonce(). 
     
    133133          '</fieldset>'. 
    134134          '</form>'; 
    135            
     135 
    136136          $rs = $this->getRules(); 
    137137          if ($rs->isEmpty()) 
     
    145145               '<fieldset><legend>' . __('List') . '</legend>'. 
    146146               '<div style="'.$this->style_list.'">'; 
    147                 
     147 
    148148               while ($rs->fetch()) 
    149149               { 
     
    154154                         $p_style .= $this->style_global; 
    155155                    } 
    156                      
     156 
    157157                    $res .= 
    158158                    '<p style="'.$p_style.'"><label class="classic">'. 
    159                     form::checkbox(array('swd[]'),$rs->rule_id,false,'','',$disabled_word).' '. 
     159                    form::checkbox(array('swd[]'),$rs->rule_id,false,'','',$disabled_word, 'title="'.html::escapeHTML($rs->rule_content).'"').' '. 
    160160                    html::escapeHTML($rs->rule_content). 
    161161                    '</label></p>'; 
    162162               } 
    163                 
     163 
    164164               $res .= 
    165165               '</div>'. 
     
    169169               '</fieldset></form>'; 
    170170          } 
    171            
     171 
    172172          if ($core->auth->isSuperAdmin()) 
    173173          { 
     
    180180               '</form>'; 
    181181          } 
    182            
     182 
    183183          return $res; 
    184184     } 
    185       
     185 
    186186     private function getRules() 
    187187     { 
     
    192192                    "OR blog_id IS NULL ) ". 
    193193                    'ORDER BY blog_id ASC, rule_content ASC '; 
    194            
     194 
    195195          return $this->con->select($strReq); 
    196196     } 
    197       
     197 
    198198     private function addRule($content,$general=false) 
    199199     { 
     
    202202                    "AND rule_content = '".$this->con->escape($content)."' "; 
    203203          $rs = $this->con->select($strReq); 
    204            
     204 
    205205          if (!$rs->isEmpty()) { 
    206206               throw new Exception(__('This word exists')); 
    207207          } 
    208            
     208 
    209209          $rs = $this->con->select('SELECT MAX(rule_id) FROM '.$this->table); 
    210210          $id = (integer) $rs->f(0) + 1; 
    211            
     211 
    212212          $cur = $this->con->openCursor($this->table); 
    213213          $cur->rule_id = $id; 
    214214          $cur->rule_type = 'word'; 
    215215          $cur->rule_content = (string) $content; 
    216            
     216 
    217217          if ($general && $this->core->auth->isSuperAdmin()) { 
    218218               $cur->blog_id = null; 
     
    220220               $cur->blog_id = $this->core->blog->id; 
    221221          } 
    222            
     222 
    223223          $cur->insert(); 
    224224     } 
    225       
     225 
    226226     private function removeRule($ids) 
    227227     { 
    228228          $strReq = 'DELETE FROM '.$this->table.' '; 
    229            
     229 
    230230          if (is_array($ids)) { 
    231231               foreach ($ids as &$v) { 
     
    237237               $strReq .= 'WHERE rule_id = '.$ids.' '; 
    238238          } 
    239            
     239 
    240240          if (!$this->core->auth->isSuperAdmin()) { 
    241241               $strReq .= "AND blog_id = '".$this->con->escape($this->core->blog->id)."' "; 
    242242          } 
    243            
     243 
    244244          $this->con->execute($strReq); 
    245245     } 
    246       
     246 
    247247     public function defaultWordsList() 
    248248     { 
     
    347347               'zolus' 
    348348          ); 
    349            
     349 
    350350          foreach ($words as $w) { 
    351351               try { 
     
    356356} 
    357357?> 
     358 
Note: See TracChangeset for help on using the changeset viewer.

Sites map