b2evolution PHP Cross Reference Blogging Systems

Source: /inc/files/views/_file_suspicious.view.php - 165 lines - 5956 bytes - Summary - Text - Print

Description: This file implements the Suspicious file list. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**

   3   * This file implements the Suspicious file list.

   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-2014 by Francois Planque - {@link http://fplanque.com/}

   9   *

  10   * @package admin

  11   *

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

  13   * @author fplanque: Francois PLANQUE.

  14   *

  15   * @version $Id: _file_suspicious.view.php 849 2012-02-16 09:09:09Z yura $

  16   */
  17  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  18  
  19  
  20  global $DB, $UserSettings;
  21  
  22  // set filter params

  23  $min_inappropriate_votes = param( 'miv', 'integer', 1, true );
  24  $min_spam_votes = param( 'msv', 'integer', 0, true );
  25  
  26  // set default order

  27  $default_order = ( $min_inappropriate_votes >= $min_spam_votes ) ? '----D' : '-----D';
  28  
  29  // Create result set:

  30  $SQL = new SQL();
  31  $SQL->SELECT( 'f1.*,
  32      SUM( IFNULL( fvot_like, 0 ) ) as total_like,
  33      SUM( IFNULL( fvot_inappropriate, 0 ) ) as total_inappropriate,
  34      SUM( IFNULL( fvot_spam, 0 ) ) as total_spam,
  35      ( SELECT COUNT( file_ID ) FROM T_files AS f2 WHERE f1.file_hash = f2.file_hash ) - 1 AS total_duplicates' );
  36  $SQL->FROM( 'T_files__vote' );
  37  $SQL->FROM_add( 'INNER JOIN T_files AS f1 ON fvot_file_ID = file_ID' );
  38  $SQL->GROUP_BY( 'fvot_file_ID' );
  39  $SQL->ORDER_BY( '*, total_spam DESC, total_inappropriate DESC' );
  40  
  41  // Set filters condition to SQL queries

  42  if( $min_inappropriate_votes <= 1 && $min_spam_votes <= 1 && ( !( $min_inappropriate_votes && $min_spam_votes ) ) )
  43  { // We must show all votes or where is at least one spam vote or where is at least one inappropriate ( one filter must be 0 and none of them > 1 )
  44      if( $min_inappropriate_votes )
  45      { // Min inappropriate filter is set to 1 but min spam is 0
  46          $sql_where = 'fvot_inappropriate = 1';
  47      }
  48      elseif( $min_spam_votes )
  49      { // Min spam filter is set to 1 but min inappropriate is 0
  50          $sql_where = 'fvot_spam = 1';
  51      }
  52      else
  53      { // We have to show all files which has any kind of spam vote
  54          $sql_where = '( fvot_inappropriate = 1 OR fvot_spam = 1 )';
  55      }
  56      // Set the main query where condition

  57      $SQL->WHERE_and( $sql_where );
  58      // Create count result query

  59      $count_SQL = new SQL();
  60      $count_SQL->SELECT( 'COUNT( DISTINCT( fvot_file_ID ) )' );
  61      $count_SQL->FROM( 'T_files__vote' );
  62      $count_SQL->WHERE_and( $sql_where );
  63      // count the number of filtered result

  64      $filtered_num_results = $DB->get_var( $count_SQL->get() );
  65  }
  66  else
  67  { // check to fit at least one of the minimum requirements
  68      // Set the main query having condition

  69      $SQL->HAVING( '( total_inappropriate >= '.$DB->quote( $min_inappropriate_votes ).' ) AND ( total_spam >= '.$DB->quote( $min_spam_votes ).' )' );
  70      // Create count result query

  71      $count_SQL = new SQL();
  72      $count_SQL->SELECT( 'fvot_file_ID' );
  73      $count_SQL->FROM( 'T_files__vote' );
  74      $count_SQL->GROUP_BY( 'fvot_file_ID' );
  75      $count_SQL->HAVING( '( SUM( fvot_inappropriate ) >= '.$DB->quote( $min_inappropriate_votes ).' ) AND ( SUM( fvot_spam ) >= '.$DB->quote( $min_spam_votes ).' )' );
  76      // count the number of filtered result ( we need subquery because we can't count all when we have group by )

  77      $filtered_num_results = $DB->get_var( "SELECT COUNT(*) FROM (". $count_SQL->get() ." )  AS TotalSelected " );
  78  }
  79  
  80  $Results = new Results( $SQL->get(), 'fsusp_', $default_order, $UserSettings->get( 'results_per_page' ), (int)$filtered_num_results );
  81  $Results->Cache = & get_FileCache();
  82  $Results->title = T_('Suspicious files');
  83  
  84  
  85  /**

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

  87   *

  88   * @param Form

  89   */
  90  function callback_filter_file_suspicious( & $Form )
  91  {
  92      $Form->text( 'miv', get_param( 'miv' ), 5, T_('Minimun inappropriate votes'), '', 6 );
  93  
  94      $Form->text( 'msv', get_param( 'msv' ), 5, T_('Minimun spam votes'), '', 6 );
  95  }
  96  
  97  $filter_presets = array(
  98          'all' => array( T_('All'), '?ctrl=filemod&amp;miv=0&amp;msv=0' ),
  99          'inappropriate' => array( T_('Inappropriate'), '?ctrl=filemod&amp;miv=1&amp;msv=0' ),
 100          'spam' => array( T_('Spam'), '?ctrl=filemod&amp;miv=0&amp;msv=1' ),
 101      );
 102  
 103  $Results->filter_area = array(
 104      'callback' => 'callback_filter_file_suspicious',
 105      'url_ignore' => 'results_fsusp_page',
 106      'presets' => $filter_presets,
 107      );
 108  
 109  $Results->cols[] = array(
 110          'th' => T_('Icon/Type'),
 111          'th_class' => 'shrinkwrap',
 112          'td_class' => 'shrinkwrap',
 113          'td' => '% {Obj}->get_preview_thumb( "fulltype", true ) %',
 114      );
 115  
 116  $Results->cols[] = array(
 117          'th' => T_('Path'),
 118          'td' => '% {Obj}->get_view_link() % % {Obj}->get_target_icon() %',
 119          'order' => 'file_path'
 120      );
 121  
 122  $Results->cols[] = array(
 123          'th' => T_('Attached To'),
 124          'td' => '%get_file_links( #file_ID# )%',
 125      );
 126  
 127  $Results->cols[] = array(
 128          'th' => /* TRANS: Header for # of times photo has been liked */ T_('Likes'),
 129          'td' => '$total_like$',
 130          'th_class' => 'shrinkwrap',
 131          'td_class' => 'center',
 132          'order' => 'total_like',
 133          'default_dir' => 'D',
 134      );
 135  
 136  $Results->cols[] = array(
 137          'th' => /* TRANS: Header for # of times photo has been votes inappropriate */ T_('Inappropriate'),
 138          'td' => '$total_inappropriate$',
 139          'th_class' => 'shrinkwrap',
 140          'td_class' => 'center',
 141          'order' => 'total_inappropriate',
 142          'default_dir' => 'D',
 143      );
 144  
 145  $Results->cols[] = array(
 146          'th' => T_('Spam'),
 147          'td' => '$total_spam$',
 148          'th_class' => 'shrinkwrap',
 149          'td_class' => 'center',
 150          'order' => 'total_spam',
 151          'default_dir' => 'D',
 152      );
 153  
 154  $Results->cols[] = array(
 155          'th' => T_('Duplicates'),
 156          'td' => '~conditional( #total_duplicates# >= 1, "<a href=\"?ctrl=filemod&amp;tab=duplicates&amp;file_ID=#file_ID#\">'./* TRANS: "This file" in suspicious file view */ T_('this one').' + #total_duplicates#</a>", "'.T_('none').'")~',
 157          'th_class' => 'shrinkwrap',
 158          'td_class' => 'center',
 159          'order' => 'total_duplicates',
 160          'default_dir' => 'D',
 161      );
 162  
 163  $Results->display();
 164  
 165  ?>

title

Description

title

Description

title

Description

title

title

Body