Dotclear

Changeset 3047:b6338d32a3eb


Ignore:
Timestamp:
07/10/15 17:39:03 (10 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Message:

Add page actions to directly blacklist IP from comments page.
Fix #1343

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/actions/class.dcactioncomments.php

    r2821 r3047  
    140140               ); 
    141141          } 
     142 
     143          $ip_filter_active = true; 
     144          if ($core->blog->settings->antispam->antispam_filters !== null) { 
     145               $filters_opt = @unserialize($core->blog->settings->antispam->antispam_filters); 
     146               if (is_array($filters_opt)) { 
     147                    $ip_filter_active = isset($filters_opt['dcFilterIP']) && is_array($filters_opt['dcFilterIP']) && $filters_opt['dcFilterIP'][0]==1; 
     148               } 
     149          } 
     150 
     151          if ($ip_filter_active) { 
     152               $blacklist_actions = array(__('Blacklist IP') => 'blacklist'); 
     153               if ($core->auth->isSuperAdmin()) { 
     154                    $blacklist_actions[__('Blacklist IP (global)')] = 'blacklist_global'; 
     155               } 
     156 
     157               $ap->addAction( 
     158                    array(__('IP address') => $blacklist_actions), 
     159                    array('dcDefaultCommentActions','doBlacklistIP') 
     160               ); 
     161          } 
    142162     } 
    143163 
     
    180200          $ap->redirect(false); 
    181201     } 
     202 
     203     public static function doBlacklistIP($core, dcCommentsActionsPage $ap, $post) { 
     204          $action = $ap->getAction(); 
     205          $co_ids = $ap->getIDs(); 
     206          if (empty($co_ids)) { 
     207               throw new Exception(__('No comment selected')); 
     208          } 
     209 
     210          $global = !empty($action) && $action == 'blacklist_global' && $core->auth->isSuperAdmin(); 
     211 
     212          $ip_filter = new dcFilterIP($core); 
     213          $rs = $ap->getRS(); 
     214          while ($rs->fetch()) { 
     215               $ip_filter->addIP('black',$rs->comment_ip,$global); 
     216          } 
     217 
     218          dcPage::addSuccessNotice(__('IP addresses for selected comments have been blacklisted.')); 
     219          $ap->redirect(true); 
     220     } 
    182221} 
  • locales/fr/main.po

    r3044 r3047  
    885885msgstr "Les commentaires indésirables ont été supprimés." 
    886886 
     887msgid "IP addresses for selected comments have been blacklisted." 
     888msgstr "Les adresses IP des commentaires sélectionnés ont été ajoutées en liste noire." 
     889 
     890msgid "Blacklist IP" 
     891msgstr "Ajouter en liste noire" 
     892 
     893msgid "Blacklist IP (global)" 
     894msgstr "Ajouter en liste noire (pour tous les blogs)" 
     895 
    887896msgid "You have one spam comment." 
    888897msgstr "Vous avez un commentaire indésirable." 
  • plugins/antispam/filters/class.dc.filter.ip.php

    r2566 r3047  
    222222     } 
    223223 
    224      private function addIP($type,$pattern,$global) 
     224     public function addIP($type,$pattern,$global) 
    225225     { 
    226226          $this->ipmask($pattern,$ip,$mask); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map