b2evolution PHP Cross Reference Blogging Systems

Source: /inc/antispam/views/_antispam_ipranges.view.php - 184 lines - 6486 bytes - Summary - Text - Print

Description: This file display the Antispam IP ranges 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 display the Antispam IP ranges

   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   * Parts of this file are copyright (c)2005 by Daniel HAHLER - {@link http://thequod.de/contact}.

  10   *

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

  12   *

  13   * @package admin

  14   *

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

  16   * @author fplanque: Francois PLANQUE.

  17   *

  18   * @version $Id: _antispam_ipranges.view.php 849 2012-02-16 09:09:09Z attila $

  19   */
  20  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  21  
  22  global $admin_url, $UserSettings, $Plugins;
  23  
  24  $ip_address = param( 'ip_address', 'string', '', true );
  25  
  26  $SQL = new SQL();
  27  $SQL->SELECT( '*' );
  28  $SQL->FROM( 'T_antispam__iprange' );
  29  
  30  $CountSQL = new SQL();
  31  $CountSQL->SELECT( 'SQL_NO_CACHE COUNT( aipr_ID )' );
  32  $CountSQL->FROM( 'T_antispam__iprange' );
  33  
  34  if( !empty( $ip_address ) )
  35  { // Filter by IP address
  36      $ip_address = ip2int( $ip_address );
  37  
  38      $SQL->WHERE( 'aipr_IPv4start <= '.$DB->quote( $ip_address ) );
  39      $SQL->WHERE_and( 'aipr_IPv4end >= '.$DB->quote( $ip_address ) );
  40  
  41      $CountSQL->WHERE( 'aipr_IPv4start <= '.$DB->quote( $ip_address ) );
  42      $CountSQL->WHERE_and( 'aipr_IPv4end >= '.$DB->quote( $ip_address ) );
  43  }
  44  
  45  // Create result set:

  46  $Results = new Results( $SQL->get(), 'aipr_', 'A', $UserSettings->get( 'results_per_page' ), $CountSQL->get() );
  47  
  48  $Results->title = T_('IP Ranges').' ('.$Results->total_rows.')'.get_manual_link('ip-ranges-tab');
  49  $Results->Cache = get_IPRangeCache();
  50  
  51  /**

  52   * Callback to add filters on top of the result set

  53   *

  54   * @param Form

  55   */
  56  function filter_email_blocked( & $Form )
  57  {
  58      $Form->text_input( 'ip_address', get_param( 'ip_address' ), 40, T_('IP address') );
  59  }
  60  $Results->filter_area = array(
  61      'callback' => 'filter_email_blocked',
  62      'presets' => array(
  63          'all' => array( T_('All'), $admin_url.'?ctrl=antispam&amp;tab3=ipranges' ),
  64          )
  65      );
  66  
  67  $Results->cols[] = array(
  68          'th' => T_('ID'),
  69          'td' => '$aipr_ID$',
  70          'order' => 'aipr_ID',
  71          'th_class' => 'shrinkwrap',
  72          'td_class' => 'shrinkwrap',
  73      );
  74  
  75  $Results->cols[] = array(
  76          'th' => T_('Status'),
  77          'td' => /* Check permission: */$current_User->check_perm( 'spamblacklist', 'edit' ) ?
  78              /* Current user can edit IP ranges */'<a href="#" rel="$aipr_status$">%aipr_status_title( #aipr_status# )%</a>' :
  79              /* No edit, only view the status */'%aipr_status_title( #aipr_status# )%',
  80          'td_class' => 'iprange_status_edit',
  81          'order' => 'aipr_status',
  82          'extra' => array ( 'style' => 'background-color: %aipr_status_color( "#aipr_status#" )%;', 'format_to_output' => false )
  83      );
  84  
  85  $Results->cols[] = array(
  86          'th' => T_('IP Range Start'),
  87          'td' => /* Check permission: */$current_User->check_perm( 'spamblacklist', 'edit' ) ?
  88              /* Current user can edit IP ranges */'<a href="'.$admin_url.'?ctrl=antispam&amp;tab3=ipranges&amp;iprange_ID=$aipr_ID$&amp;action=iprange_edit">%int2ip( #aipr_IPv4start# )%</a>' :
  89              /* No edit, only view the IP address */'%int2ip( #aipr_IPv4start# )%',
  90          'order' => 'aipr_IPv4start',
  91      );
  92  
  93  $Results->cols[] = array(
  94          'th' => T_('IP Range End'),
  95          'td' => /* Check permission: */$current_User->check_perm( 'spamblacklist', 'edit' ) ?
  96              /* Current user can edit IP ranges */'<a href="'.$admin_url.'?ctrl=antispam&amp;tab3=ipranges&amp;iprange_ID=$aipr_ID$&amp;action=iprange_edit">%int2ip( #aipr_IPv4end# )%</a>' :
  97              /* No edit, only view the IP address */'%int2ip( #aipr_IPv4end# )%',
  98          'order' => 'aipr_IPv4end',
  99      );
 100  
 101  $Results->cols[] = array(
 102          'th' => T_('User count'),
 103          'td' => '$aipr_user_count$',
 104          'order' => 'aipr_user_count',
 105      );
 106  
 107  $Results->cols[] = array(
 108          'th' => T_('Block count'),
 109          'td' => '$aipr_block_count$',
 110          'order' => 'aipr_block_count',
 111      );
 112  
 113  // Get additional columns from the Plugins

 114  $Plugins->trigger_event( 'GetAdditionalColumnsTable', array(
 115      'table'   => 'ipranges',
 116      'column'  => 'aipr_IPv4start',
 117      'Results' => $Results ) );
 118  
 119  if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
 120  {    // Check permission to edit IP ranges:
 121      $Results->cols[] = array(
 122              'th' => T_('Actions'),
 123              'th_class' => 'shrinkwrap',
 124              'td_class' => 'shrinkwrap',
 125              'td' => action_icon( TS_('Edit this IP range...'), 'properties',
 126                      $admin_url.'?ctrl=antispam&amp;tab3=ipranges&amp;iprange_ID=$aipr_ID$&amp;action=iprange_edit' )
 127                      .action_icon( T_('Delete this IP range!'), 'delete',
 128                          regenerate_url( 'iprange_ID,action', 'iprange_ID=$aipr_ID$&amp;action=iprange_delete&amp;'.url_crumb('iprange') ) ),
 129          );
 130  }
 131  
 132  $Results->global_icon( T_('Add a new IP range...'), 'new', regenerate_url( 'action', 'action=iprange_new'), T_('New IP range').' &raquo;', 3, 4  );
 133  
 134  $Results->display();
 135  
 136  if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
 137  {    // Check permission to edit IP ranges:
 138  ?>
 139  <script type="text/javascript">
 140  jQuery( document ).ready( function()
 141  {
 142      jQuery( '.iprange_status_edit' ).editable( htsrv_url + 'async.php?action=iprange_status_edit&<?php echo url_crumb( 'iprange' ) ?>',
 143      {
 144      data : function( value, settings )
 145          {
 146              value = ajax_debug_clear( value );
 147              var re =  /rel="(.*)"/;
 148              var result = value.match(re);
 149              return {
 150                  ''         : '<?php echo aipr_status_title( '' ) ?>',
 151                  'trusted'  : '<?php echo aipr_status_title( 'trusted' ) ?>',
 152                  'suspect'  : '<?php echo aipr_status_title( 'suspect' ) ?>',
 153                  'blocked'  : '<?php echo aipr_status_title( 'blocked' ) ?>',
 154                  'selected' : result[1]
 155              }
 156          },
 157      type     : 'select',
 158      name     : 'new_status',
 159      tooltip  : 'Click to edit',
 160      event    : 'click',
 161      callback : function( settings, original )
 162          {
 163              //evoFadeSuccess( this );

 164              jQuery( this ).html( ajax_debug_clear( settings ) );
 165              var link = jQuery( this ).find( 'a' );
 166              jQuery( this ).css( 'background-color', link.attr( 'color' ) );
 167              link.removeAttr( 'color' );
 168          },
 169      onsubmit: function( settings, original ) {
 170      },
 171      submitdata: function( value, settings ) {
 172              var id = jQuery( ':first', jQuery( this ).parent() ).text();
 173              return { iprange_ID: id }
 174          },
 175      onerror : function( settings, original, xhr ) {
 176              evoFadeFailure( original );
 177          }
 178      } );
 179  } );
 180  </script>
 181  <?php
 182  }
 183  
 184  ?>

title

Description

title

Description

title

Description

title

title

Body