[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/antispam/ -> antispam_list.ctrl.php (source)

   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-2007 by Francois PLANQUE - {@link http://fplanque.net/}.

   9   * Parts of this file are copyright (c)2004 by Vegar BERG GULDAL - {@link http://funky-m.com/}.

  10   *

  11   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)

  12   *

  13   * {@internal Open Source relicensing agreement:

  14   * Daniel HAHLER grants Francois PLANQUE the right to license

  15   * Daniel HAHLER's contributions to this file and the b2evolution project

  16   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  17   * Vegar BERG GULDAL grants Francois PLANQUE the right to license

  18   * Vegar BERG GULDAL's contributions to this file and the b2evolution project

  19   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  20   * Halton STEWART grants Francois PLANQUE the right to license

  21   * Halton STEWART's contributions to this file and the b2evolution project

  22   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  23   * }}

  24   *

  25   * @package admin

  26   *

  27   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  28   * @author blueyed: Daniel HAHLER.

  29   * @author fplanque: Francois PLANQUE.

  30   * @author vegarg: Vegar BERG GULDAL.

  31   * @author halton: Halton STEWART.

  32   *

  33   * @todo Allow applying / re-checking of the known data, not just after an update!

  34   *

  35   * @version $Id: antispam_list.ctrl.php,v 1.2 2007/09/04 14:56:19 fplanque Exp $

  36   */
  37  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  38  
  39  $AdminUI->set_path( 'tools', 'antispam' );
  40  
  41  param_action( '' );
  42  param( 'confirm', 'string' );
  43  param( 'keyword', 'string', '', true );
  44  param( 'domain', 'string' );
  45  param( 'filteron', 'string', '', true );
  46  param( 'filter', 'array', array() );
  47  
  48  if( isset($filter['off']) )
  49  {
  50      unset( $filteron );
  51      forget_param( 'filteron' );
  52  }
  53  
  54  // Check permission:

  55  $current_User->check_perm( 'spamblacklist', 'view', true );
  56  
  57  switch( $action )
  58  {
  59      case 'ban': // only an action if further "actions" given
  60          // Check permission:

  61          $current_User->check_perm( 'spamblacklist', 'edit', true ); // TODO: This should become different for 'edit'/'add' perm level - check for 'add' here.

  62  
  63          $keyword = substr( $keyword, 0, 80 );
  64          param( 'delhits', 'integer', 0 );
  65          param( 'delcomments', 'integer', 0 );
  66          param( 'blacklist_locally', 'integer', 0 );
  67          param( 'report', 'integer', 0 );
  68  
  69          // Check if the string is too short,

  70          // it has to be a minimum of 5 characters to avoid being too generic

  71          if( strlen($keyword) < 5 )
  72          {
  73              $Messages->add( sprintf( T_('The keyword &laquo;%s&raquo; is too short, it has to be a minimum of 5 characters!'), htmlspecialchars($keyword) ), 'error' );
  74              break;
  75          }
  76  
  77          if( $delhits )
  78          { // Delete all banned hit-log entries
  79              $r = $DB->query('DELETE FROM T_hitlog
  80                                                  WHERE hit_referer LIKE '.$DB->quote('%'.$keyword.'%'),
  81                                                  'Delete all banned hit-log entries' );
  82  
  83              $Messages->add( sprintf( T_('Deleted %d logged hits matching &laquo;%s&raquo;.'), $r, htmlspecialchars($keyword) ), 'success' );
  84          }
  85  
  86          if( $delcomments )
  87          { // Then all banned comments
  88              $r = $DB->query('DELETE FROM T_comments
  89                                WHERE comment_author LIKE '.$DB->quote('%'.$keyword.'%').'
  90                                   OR comment_author_email LIKE '.$DB->quote('%'.$keyword.'%').'
  91                                   OR comment_author_url LIKE '.$DB->quote('%'.$keyword.'%').'
  92                                   OR comment_content LIKE '.$DB->quote('%'.$keyword.'%') );
  93              $Messages->add( sprintf( T_('Deleted %d comments matching &laquo;%s&raquo;.'), $r, htmlspecialchars($keyword) ), 'success' );
  94          }
  95  
  96          if( $blacklist_locally )
  97          { // Local blacklist:
  98              if( antispam_create( $keyword ) )
  99              {
 100                  $Messages->add( sprintf( T_('The keyword &laquo;%s&raquo; has been blacklisted locally.'), htmlspecialchars($keyword) ), 'success' );
 101              }
 102              else
 103              { // TODO: message?
 104              }
 105          }
 106  
 107          if( $report && $report_abuse )
 108          { // Report this keyword as abuse:
 109              antispam_report_abuse( $keyword );
 110          }
 111  
 112          // We'll ask the user later what to do, if no "sub-action" given.

 113          break;
 114  
 115  
 116      case 'remove':
 117          // Remove a domain from ban list:

 118  
 119          // Check permission:

 120          $current_User->check_perm( 'spamblacklist', 'edit', true );
 121  
 122          param( 'hit_ID', 'integer', true );    // Required!

 123          $Messages->add( sprintf( T_('Removing entry #%d from the ban list...'), $hit_ID), 'note' );
 124          antispam_delete( $hit_ID );
 125          break;
 126  
 127  
 128      case 'report':
 129          // Report an entry as abuse to centralized blacklist:

 130  
 131          // Check permission:

 132          $current_User->check_perm( 'spamblacklist', 'edit', true );
 133  
 134          // Report this keyword as abuse:

 135          antispam_report_abuse( $keyword );
 136          break;
 137  
 138  
 139      case 'poll':
 140          // request abuse list from central blacklist:

 141  
 142          // Check permission:

 143          $current_User->check_perm( 'spamblacklist', 'edit', true );
 144  
 145          ob_start();
 146          antispam_poll_abuse();
 147          $Debuglog->add( ob_get_contents(), 'antispam_poll' );
 148          ob_end_clean();
 149          break;
 150  }
 151  
 152  
 153  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)

 154  $AdminUI->disp_html_head();
 155  
 156  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)

 157  $AdminUI->disp_body_top();
 158  
 159  // Begin payload block:

 160  $AdminUI->disp_payload_begin();
 161  
 162  
 163  if( $action == 'ban' && !$Messages->count('error') && !( $delhits || $delcomments || $blacklist_locally || $report ) )
 164  { // Nothing to do, ask user:
 165      $AdminUI->disp_view( 'antispam/views/_antispam_ban.form.php' );
 166  }
 167  else
 168  {    // Display blacklist:
 169      $AdminUI->disp_view( 'antispam/views/_antispam_list.view.php' );
 170  }
 171  
 172  // End payload block:

 173  $AdminUI->disp_payload_end();
 174  
 175  // Display body bottom, debug info and close </html>:

 176  $AdminUI->disp_global_footer();
 177  
 178  
 179  /*

 180   * $Log: antispam_list.ctrl.php,v $

 181   * Revision 1.2  2007/09/04 14:56:19  fplanque

 182   * antispam cleanup

 183   *

 184   * Revision 1.1  2007/06/25 10:59:23  fplanque

 185   * MODULES (refactored MVC)

 186   *

 187   * Revision 1.10  2007/04/26 00:11:14  fplanque

 188   * (c) 2007

 189   *

 190   * Revision 1.9  2007/03/01 02:42:03  fplanque

 191   * prevent miserable failure when trying to delete heavy spam.

 192   *

 193   * Revision 1.8  2006/12/07 21:16:55  fplanque

 194   * killed templates

 195   */
 196  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics