[ 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_settings.ctrl.php (source)

   1  <?php
   2  /**

   3   * This file implements the UI controller for Antispam Features.

   4   *

   5   * This file is part of the evoCore framework - {@link http://evocore.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-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.

  10   *

  11   * {@internal License choice

  12   * - If you have received this file as part of a package, please find the license.txt file in

  13   *   the same folder or the closest folder above for complete license terms.

  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)

  15   *   then you must choose one of the following licenses before using the file:

  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php

  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php

  18   * }}

  19   *

  20   * {@internal Open Source relicensing agreement:

  21   * Daniel HAHLER grants Francois PLANQUE the right to license

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

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

  24   * }}

  25   *

  26   * @package admin

  27   *

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

  29   * @author blueyed: Daniel HAHLER.

  30   *

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

  32   */
  33  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  34  
  35  
  36  // Check minimum permission:

  37  $current_User->check_perm( 'options', 'view', true );
  38  
  39  
  40  $AdminUI->set_path( 'options', 'antispam' );
  41  
  42  param( 'action', 'string' );
  43  
  44  switch( $action )
  45  {
  46      case 'update':
  47          // Check permission:

  48          $current_User->check_perm( 'options', 'edit', true );
  49  
  50          param( 'submit', 'array', array() );
  51          if( isset($submit['restore_defaults']) )
  52          { // RESTORE DEFAULTS:
  53              $Settings->delete_array( array(
  54                  'antispam_threshold_publish', 'antispam_threshold_delete', 'antispam_block_spam_referers' ) );
  55  
  56              // Set "spam detection relevance weight" back to 1 for all plugins:

  57              $changed = $DB->query( 'UPDATE T_plugins SET plug_spam_weight = 1' );
  58  
  59              if( $Settings->dbupdate() || $changed )
  60              {
  61                  $Messages->add( T_('Restored default values.'), 'success' );
  62              }
  63              else
  64              {
  65                  $Messages->add( T_('Settings have not changed.'), 'note' );
  66              }
  67          }
  68          else
  69          { // UPDATE:
  70              param_integer_range( 'antispam_threshold_publish', -100, 100, T_('The threshold must be between -100 and 100.') );
  71              $Settings->set( 'antispam_threshold_publish', $antispam_threshold_publish );
  72  
  73              param_integer_range( 'antispam_threshold_delete', -100, 100, T_('The threshold must be between -100 and 100.') );
  74              $Settings->set( 'antispam_threshold_delete', $antispam_threshold_delete );
  75  
  76              param( 'antispam_block_spam_referers', 'integer', 0 );
  77              $Settings->set( 'antispam_block_spam_referers', $antispam_block_spam_referers );
  78  
  79              $changed_weight = false;
  80              param( 'antispam_plugin_spam_weight', 'array', array() );
  81              foreach( $antispam_plugin_spam_weight as $l_plugin_ID => $l_weight )
  82              {
  83                  if( ! is_numeric($l_weight) )
  84                  {
  85                      continue;
  86                  }
  87                  if( $l_weight < 0 || $l_weight > 100 )
  88                  {
  89                      param_error( 'antispam_plugin_spam_weight['.$l_plugin_ID.']', T_('Spam weight has to be in the range of 0-100.') );
  90                      continue;
  91                  }
  92                  if( $DB->query( '
  93                          UPDATE T_plugins
  94                             SET plug_spam_weight = '.$DB->quote($l_weight).'
  95                           WHERE plug_ID = '.(int)$l_plugin_ID ) )
  96                  {
  97                      $changed_weight = true;
  98                  }
  99              }
 100              if( $changed_weight )
 101              { // Reload plugins table (for display):
 102                  $Plugins->loaded_plugins_table = false;
 103                  $Plugins->load_plugins_table();
 104              }
 105  
 106  
 107              if( ! $Messages->count('error') )
 108              {
 109                  if( $Settings->dbupdate() || $changed_weight )
 110                  {
 111                      $Messages->add( T_('Settings updated.'), 'success' );
 112                  }
 113                  else
 114                  {
 115                      $Messages->add( T_('Settings have not changed.'), 'note' );
 116                  }
 117              }
 118          }
 119          break;
 120  }
 121  
 122  
 123  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)

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

 127  $AdminUI->disp_body_top();
 128  
 129  // Begin payload block:

 130  $AdminUI->disp_payload_begin();
 131  
 132  // Display VIEW:

 133  $AdminUI->disp_view( 'antispam/views/_antispam_settings.form.php' );
 134  
 135  // End payload block:

 136  $AdminUI->disp_payload_end();
 137  
 138  // Display body bottom, debug info and close </html>:

 139  $AdminUI->disp_global_footer();
 140  
 141  /*

 142   * $Log: antispam_settings.ctrl.php,v $

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

 144   * antispam cleanup

 145   *

 146   * Revision 1.1  2007/06/25 10:59:24  fplanque

 147   * MODULES (refactored MVC)

 148   *

 149   * Revision 1.11  2007/04/26 00:11:14  fplanque

 150   * (c) 2007

 151   *

 152   * Revision 1.10  2006/11/26 01:42:09  fplanque

 153   * doc

 154   *

 155   */
 156  ?>


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