b2evolution PHP Cross Reference Blogging Systems

Source: /inc/antispam/views/_antispam_list.view.php - 181 lines - 5216 bytes - Summary - Text - Print

Description: This file implements the UI controller for the antispam management. This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}. See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the UI controller for the antispam management.
   4   *
   5   * This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}.
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}.
   9   *
  10   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)
  11   *
  12   * {@internal Open Source relicensing agreement:
  13   * }}
  14   *
  15   * @package admin
  16   *
  17   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  18   *
  19   * @todo Allow applying / re-checking of the known data, not just after an update!
  20   *
  21   * @version $Id: _antispam_list.view.php 6136 2014-03-08 07:59:48Z manuel $
  22   */
  23  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  24  
  25  
  26  if( get_param('display_mode') == 'js' )
  27  {    // This is an Ajax response
  28      echo '<h2>'.T_('Antispam blacklist').'</h2>';
  29  }
  30  
  31  // ADD KEYWORD FORM:
  32  if( $current_User->check_perm( 'spamblacklist', 'edit' ) ) // TODO: check for 'add' here once it's mature.
  33  { // add keyword or domain
  34      global $keyword;
  35  
  36      $Form = new Form( NULL, 'antispam_add', 'post', 'compact' );
  37      $Form->begin_form( 'fform', T_('Add a banned keyword') );
  38          $Form->add_crumb('antispam');
  39          $Form->hidden_ctrl();
  40          $Form->hidden( 'action', 'ban' );
  41          $Form->text( 'keyword', $keyword, 50, T_('Keyword/phrase to ban'), '', 80 ); // TODO: add note
  42          /*
  43           * TODO: explicitly add a domain?
  44           * $add_Form->text( 'domain', $domain, 30, T_('Add a banned domain'), 'note..', 80 ); // TODO: add note
  45           */
  46      $Form->end_form( array( array( 'submit', 'submit', T_('Check & ban...'), 'SaveButton' ) ) );
  47  }
  48  
  49  
  50  echo '<p class="center">'.T_('Any URL containing one of the following keywords will be banned from posts, comments and logs.');
  51  if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
  52  {
  53      echo '<br />'.T_( 'If a keyword restricts legitimate domains, click on the green tick to stop banning with this keyword.');
  54  }
  55  echo '</p>';
  56  
  57  
  58  if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
  59  { // User can edit:
  60      ?>
  61      <p class="center">
  62          [<a href="?ctrl=antispam&amp;action=poll&amp;<?php echo url_crumb('antispam') ?>"><?php echo T_('Request abuse update from centralized blacklist!') ?></a>]
  63          [<a href="http://b2evolution.net/about/terms.html"><?php echo T_('Terms of service') ?></a>]
  64      </p>
  65      <?php
  66  }
  67  
  68  
  69  /*
  70   * Query antispam blacklist:
  71   */
  72  $keywords = param( 'keywords', 'string', '', true );
  73  
  74  $SQL = new SQL();
  75  
  76  $SQL->SELECT( 'aspm_ID, aspm_string, aspm_source' );
  77  $SQL->FROM( 'T_antispam' );
  78  
  79  if( !empty( $keywords ) )
  80  {
  81      $SQL->add_search_field( 'aspm_string' );
  82      $SQL->WHERE_keywords( $keywords, 'AND' );
  83  }
  84  
  85  // Create result set:
  86  $Results = new Results( $SQL->get(), 'antispam_' );
  87  
  88  $Results->title = T_('Banned keywords blacklist');
  89  
  90  
  91  /**
  92   * Callback to add filters on top of the result set
  93   *
  94   * @param Form
  95   */
  96  function filter_antispam( & $Form )
  97  {
  98      $Form->text( 'keywords', get_param('keywords'), 20, T_('Keywords'), T_('Separate with space'), 50 );
  99  }
 100  $Results->filter_area = array(
 101      'callback' => 'filter_antispam',
 102      'url_ignore' => 'results_antispam_page,keywords',
 103      'presets' => array(
 104          'all' => array( T_('All keywords'), '?ctrl=antispam' ),
 105          )
 106      );
 107  
 108  
 109  
 110  /*
 111   * Column definitions:
 112   */
 113  $Results->cols[] = array(
 114                          'th' => T_('Keyword'),
 115                          'order' => 'aspm_string',
 116                          'td' => '%htmlspecialchars(#aspm_string#)%',
 117                      );
 118  
 119  // Set columns:
 120  function antispam_source2( & $row )
 121  {
 122      static $aspm_sources = NULL;
 123  
 124      if( $aspm_sources === NULL )
 125      {
 126          /**
 127           * the antispam sources
 128           * @var array
 129           * @static
 130           */
 131          $aspm_sources = array (
 132              'local' => T_('Local'),
 133              'reported' => T_('Reported'),
 134              'central' => T_('Central'),
 135          );
 136      }
 137  
 138      return $aspm_sources[$row->aspm_source];
 139  }
 140  $Results->cols[] = array(
 141                          'th' => T_('Source'),
 142                          'order' => 'aspm_source',
 143                          'td' => '%antispam_source2({row})%',
 144                      );
 145  
 146  // Check if we need to display more:
 147  if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
 148  { // User can edit, spamlist: add controls to output columns:
 149      // Add CHECK to 1st column:
 150      $Results->cols[0]['td'] = action_icon( TS_('Allow keyword back (Remove it from the blacklist)'), 'allowback',
 151                                                               '?ctrl=antispam&amp;action=remove&amp;hit_ID=$aspm_ID$&amp;'.url_crumb('antispam') )
 152                                                               .$Results->cols[0]['td'];
 153  
 154      // Add a column for actions:
 155  	function antispam_actions( & $row )
 156      {
 157          $output = '';
 158  
 159          if( $row->aspm_source == 'local' )
 160          {
 161              $output .= '[<a href="'.regenerate_url( 'action,keyword', 'action=report&amp;keyword='
 162                                      .rawurlencode( $row->aspm_string )).'&amp;'.url_crumb('antispam').'" title="'.
 163                                      T_('Report abuse to centralized ban blacklist!').'">'.
 164                                      T_('Report').'</a>]';
 165          }
 166  
 167          return $output.'[<a href="'.regenerate_url( 'action,keyword', 'action=ban&amp;keyword='
 168                                      .rawurlencode( $row->aspm_string )).'&amp;'.url_crumb('antispam').'" title="'.
 169                                      T_('Check hit-logs and comments for this keyword!').'">'.
 170                                      T_('Re-check').'</a>]';
 171      }
 172      $Results->cols[] = array(
 173                              'th' => T_('Actions'),
 174                              'td' => '%antispam_actions({row})%',
 175                          );
 176  }
 177  
 178  // Display results:
 179  $Results->display();
 180  
 181  ?>

title

Description

title

Description

title

Description

title

title

Body