[ 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/sessions/views/ -> _stats_useragents.view.php (source)

   1  <?php
   2  /**

   3   * This file implements the UI view for the User Agents stats.

   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   *

  10   * {@internal License choice

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

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

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

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

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

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

  17   * }}

  18   *

  19   * {@internal Open Source relicensing agreement:

  20   * }}

  21   *

  22   * @package admin

  23   *

  24   * @version $Id: _stats_useragents.view.php,v 1.1 2007/06/25 11:01:10 fplanque Exp $

  25   */
  26  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  27  
  28  /**

  29   * View funcs

  30   */
  31  require_once dirname(__FILE__).'/_stats_view.funcs.php';
  32  
  33  
  34  global $blog, $admin_url, $rsc_url;
  35  
  36  global $agnt_browser, $agnt_robot, $agnt_rss, $agnt_unknown;
  37  
  38  // For the user agents list:

  39  param( 'agnt_browser', 'integer', 0, true );
  40  param( 'agnt_robot', 'integer', 0, true );
  41  param( 'agnt_rss', 'integer', 0, true );
  42  param( 'agnt_unknown', 'integer', 0, true );
  43  
  44  if( !$agnt_browser && !$agnt_robot && !$agnt_rss && !$agnt_unknown )
  45  {    // Set default status filters:
  46      $agnt_browser = 1;
  47      $agnt_robot = 1;
  48      $agnt_rss = 1;
  49      $agnt_unknown = 1;
  50  }
  51  
  52  
  53  echo '<h2>'.T_('User agents').'</h2>';
  54  
  55  $selected_agnt_types = array();
  56  if( $agnt_browser ) $selected_agnt_types[] = "'browser'";
  57  if( $agnt_robot ) $selected_agnt_types[] = "'robot'";
  58  if( $agnt_rss ) $selected_agnt_types[] = "'rss'";
  59  if( $agnt_unknown ) $selected_agnt_types[] = "'unknown'";
  60  $from = 'T_useragents LEFT JOIN T_hitlog ON agnt_ID = hit_agnt_ID';
  61  $where_clause =  ' WHERE agnt_type IN ('.implode(',',$selected_agnt_types).')';
  62  
  63  if( !empty($blog) )
  64  {
  65      $from .= ' INNER JOIN T_blogs ON hit_blog_ID = blog_ID';
  66      $where_clause .= ' AND hit_blog_ID = '.$blog;
  67  }
  68  
  69  $total_hit_count = $DB->get_var( "
  70          SELECT COUNT(*) AS hit_count
  71              FROM $from "
  72              .$where_clause, 0, 0, 'Get total hit count - hits with an UA' );
  73  
  74  
  75  // Create result set:

  76  $sql = "SELECT agnt_signature, agnt_type, COUNT( * ) AS hit_count
  77                      FROM $from"
  78              .$where_clause.'
  79                   GROUP BY agnt_ID ';
  80  
  81  $count_sql = "SELECT COUNT( agnt_ID )
  82                      FROM $from"
  83              .$where_clause;
  84  
  85  $Results = & new Results( $sql, 'uagnt_', '--D', 20, $count_sql );
  86  
  87  
  88  /**

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

  90   *

  91   * @param Form

  92   */
  93  function filter_useragents( & $Form )
  94  {
  95      global $blog, $agnt_browser, $agnt_robot, $agnt_rss, $agnt_unknown;
  96  
  97      $Form->checkbox( 'agnt_browser', $agnt_browser, T_('Browsers') );
  98      $Form->checkbox( 'agnt_robot', $agnt_robot, T_('Robots') );
  99      $Form->checkbox( 'agnt_rss', $agnt_rss, T_('XML readers') );
 100      $Form->checkbox( 'agnt_unknown', $agnt_unknown, T_('Unknown') );
 101  }
 102  $Results->filter_area = array(
 103      'callback' => 'filter_useragents',
 104      'url_ignore' => 'results_uagnt_page,agnt_browser,agnt_robot,agnt_rss,agnt_unknown',    // ignore page param and checkboxes
 105      'presets' => array(
 106              'browser' => array( T_('Browser'), '?ctrl=stats&amp;tab=useragents&amp;agnt_browser=1&amp;blog='.$blog ),
 107              'robot' => array( T_('Robots'), '?ctrl=stats&amp;tab=useragents&amp;agnt_robot=1&amp;blog='.$blog ),
 108              'rss' => array( T_('XML'), '?ctrl=stats&amp;tab=useragents&amp;agnt_rss=1&amp;blog='.$blog ),
 109              'unknown' => array( T_('Unknown'), '?ctrl=stats&amp;tab=useragents&amp;agnt_unknown=1&amp;blog='.$blog ),
 110              'all' => array( T_('All'), '?ctrl=stats&amp;tab=useragents&amp;agnt_browser=1&amp;agnt_robot=1&amp;agnt_rss=1&amp;agnt_unknown=1&amp;blog='.$blog ),
 111          )
 112      );
 113  
 114  
 115      $Results->title = T_('User agents');
 116  
 117  $Results->cols[] = array(
 118                          'th' => T_('Agent signature'),
 119                          'order' => 'agnt_signature',
 120                          'td' => '²agnt_signature²',
 121                          'total' => '<strong>'.T_('Global total').'</strong>',
 122                      );
 123  
 124  $Results->cols[] = array(
 125                          'th' => T_('Agent type'),
 126                          'order' => 'agnt_type',
 127                          'td' => '²agnt_type²',
 128                          'total' => '',
 129                      );
 130  
 131  $Results->cols[] = array(
 132                          'th' => T_('Hit count'),
 133                          'order' => 'hit_count',
 134                          'td_class' => 'right',
 135                          'total_class' => 'right',
 136                          'td' => '$hit_count$',
 137                          'total' => $total_hit_count,
 138                      );
 139  
 140  $Results->cols[] = array(
 141                          'th' => T_('Hit %'),
 142                          'order' => 'hit_count',
 143                          'td_class' => 'right',
 144                          'total_class' => 'right',
 145                          'td' => '%percentage( #hit_count#, '.$total_hit_count.' )%',
 146                          'total' => '%percentage( 100, 100 )%',
 147                      );
 148  
 149  // Display results:

 150  $Results->display();
 151  
 152  /*

 153   * $Log: _stats_useragents.view.php,v $

 154   * Revision 1.1  2007/06/25 11:01:10  fplanque

 155   * MODULES (refactored MVC)

 156   *

 157   * Revision 1.6  2007/04/26 00:11:13  fplanque

 158   * (c) 2007

 159   *

 160   * Revision 1.5  2007/03/20 09:53:26  fplanque

 161   * Letting boggers view their own stats.

 162   * + Letthing admins view the aggregate by default.

 163   *

 164   * Revision 1.4  2006/11/24 18:27:26  blueyed

 165   * Fixed link to b2evo CVS browsing interface in file docblocks

 166   */
 167  ?>


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