Dotclear


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

File:
1 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} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map