[ 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_robots.view.php (source)

   1  <?php
   2  /**

   3   * This file implements the UI view for the robot 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_robots.view.php,v 1.1 2007/06/25 11:01:06 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  echo '<h2>'.T_('Robot hits').'</h2>';
  37  echo '<p>'.sprintf( T_('This page only includes hits identified as made by <a %s>indexing robots</a> a.k.a. web crawlers.'), ' href="?ctrl=stats&amp;tab=useragents&amp;agnt_robot=1&amp;blog='.$blog.'"' ).'</p>';
  38  echo '<p>'. /* TRANS: %s is a filesystem path */ T_('In order to be detected, robots must be listed in %s.').'</p>';
  39  
  40  $sql = "
  41      SELECT COUNT(*) AS hits, EXTRACT(YEAR FROM hit_datetime) AS year,
  42                 EXTRACT(MONTH FROM hit_datetime) AS month, EXTRACT(DAY FROM hit_datetime) AS day
  43          FROM T_hitlog INNER JOIN T_useragents ON hit_agnt_ID = agnt_ID
  44       WHERE agnt_type = 'robot'";
  45  if( $blog > 0 )
  46  {
  47      $sql .= ' AND hit_blog_ID = '.$blog;
  48  }
  49  $sql .= ' GROUP BY year, month, day
  50                      ORDER BY year DESC, month DESC, day DESC';
  51  $res_hits = $DB->get_results( $sql, ARRAY_A, 'Get robot summary' );
  52  
  53  
  54  /*

  55   * Chart

  56   */
  57  if( count($res_hits) )
  58  {
  59      $last_date = 0;
  60  
  61      $chart[ 'chart_data' ][ 0 ] = array();
  62      $chart[ 'chart_data' ][ 1 ] = array();
  63  
  64      $count = 0;
  65      foreach( $res_hits as $row_stats )
  66      {
  67          $this_date = mktime( 0, 0, 0, $row_stats['month'], $row_stats['day'], $row_stats['year'] );
  68          if( $last_date != $this_date )
  69          { // We just hit a new day, let's display the previous one:
  70                  $last_date = $this_date;    // that'll be the next one

  71                  $count ++;
  72                  array_unshift( $chart[ 'chart_data' ][ 0 ], date( locale_datefmt(), $last_date ) );
  73                  array_unshift( $chart[ 'chart_data' ][ 1 ], 0 );
  74          }
  75          $chart [ 'chart_data' ][1][0] = $row_stats['hits'];
  76      }
  77  
  78      array_unshift( $chart[ 'chart_data' ][ 0 ], '' );
  79      array_unshift( $chart[ 'chart_data' ][ 1 ], 'Robot hits' );    // Translations need to be UTF-8

  80  
  81      $chart[ 'canvas_bg' ] = array (
  82              'width'  => 780,
  83              'height' => 400,
  84              'color'  => 'efede0'
  85          );
  86  
  87      $chart[ 'chart_rect' ] = array (
  88              'x'      => 50,
  89              'y'      => 50,
  90              'width'  => 700,
  91              'height' => 250
  92          );
  93  
  94      $chart[ 'legend_rect' ] = array (
  95              'x'      => 50,
  96              'y'      => 365,
  97              'width'  => 700,
  98              'height' => 8,
  99              'margin' => 6
 100          );
 101  
 102      $chart[ 'draw_text' ] = array (
 103              array (
 104                      'color'    => '9e9286',
 105                      'alpha'    => 75,
 106                      'font'     => "arial",
 107                      'rotation' => 0,
 108                      'bold'     => true,
 109                      'size'     => 42,
 110                      'x'        => 50,
 111                      'y'        => 6,
 112                      'width'    => 700,
 113                      'height'   => 50,
 114                      'text'     => 'Robot hits', // Needs UTF-8
 115                      'h_align'  => "right",
 116                      'v_align'  => "bottom" ),
 117              );
 118  
 119      $chart[ 'chart_bg' ] = array (
 120              'positive_color' => "ffffff",
 121              // 'negative_color'  =>  string,

 122              'positive_alpha' => 20,
 123              // 'negative_alpha'  =>  int

 124          );
 125  
 126      $chart [ 'legend_bg' ] = array (
 127              'bg_color'          =>  "ffffff",
 128              'bg_alpha'          =>  20,
 129              // 'border_color'      =>  "000000",

 130              // 'border_alpha'      =>  100,

 131              // 'border_thickness'  =>  1

 132          );
 133  
 134      $chart [ 'legend_label' ] = array(
 135              // 'layout'  =>  "horizontal",

 136              // 'font'    =>  string,

 137              // 'bold'    =>  boolean,

 138              'size'    =>  10,
 139              // 'color'   =>  string,

 140              // 'alpha'   =>  int

 141          );
 142  
 143      $chart[ 'chart_border' ] = array (
 144              'color'=>"000000",
 145              'top_thickness'=>1,
 146              'bottom_thickness'=>1,
 147              'left_thickness'=>1,
 148              'right_thickness'=>1
 149          );
 150  
 151      $chart[ 'chart_type' ] = 'stacked column';
 152  
 153      // $chart[ 'series_color' ] = array ( "4e627c", "c89341" );

 154  
 155      $chart[ 'series_gap' ] = array ( 'set_gap'=>0, 'bar_gap'=>0 );
 156  
 157  
 158      $chart[ 'axis_category' ] = array (
 159              'font'  =>"arial",
 160              'bold'  =>true,
 161              'size'  =>11,
 162              'color' =>'000000',
 163              'alpha' =>75,
 164              'orientation' => 'diagonal_up',
 165              // 'skip'=>2

 166          );
 167  
 168      $chart[ 'axis_value' ] = array (
 169              // 'font'   =>"arial",

 170              // 'bold'   =>true,

 171              'size'   => 11,
 172              'color'  => '000000',
 173              'alpha'  => 75,
 174              'steps'  => 4,
 175              'prefix' => "",
 176              'suffix' => "",
 177              'decimals'=> 0,
 178              'separator'=> "",
 179              'show_min'=> false );
 180  
 181      $chart [ 'chart_value' ] = array (
 182              // 'prefix'         =>  string,

 183              // 'suffix'         =>  " views",

 184              // 'decimals'       =>  int,

 185              // 'separator'      =>  string,

 186              'position'       =>  "cursor",
 187              'hide_zero'      =>  true,
 188              // 'as_percentage'  =>  boolean,

 189              'font'           =>  "arial",
 190              'bold'           =>  true,
 191              'size'           =>  20,
 192              'color'          =>  "ffffff",
 193              'alpha'          =>  75
 194          );
 195  
 196      echo '<div class="center">';
 197      DrawChart( $chart );
 198      echo '</div>';
 199  
 200  }
 201  
 202  
 203  
 204  // TOP INDEXING ROBOTS

 205  
 206  echo '<h2>'.T_('Top Indexing Robots').':</h2>';
 207  
 208  // Create result set:

 209  $sql = "SELECT COUNT(*) AS hit_count, agnt_signature
 210                      FROM T_hitlog INNER JOIN T_useragents ON hit_agnt_ID = agnt_ID
 211                   WHERE agnt_type = 'robot' "
 212                               .( empty($blog) ? '' : 'AND hit_blog_ID = '.$blog ).'
 213                   GROUP BY agnt_signature';
 214  
 215  $count_sql = "SELECT COUNT( DISTINCT agnt_signature )
 216                                  FROM T_hitlog INNER JOIN T_useragents ON hit_agnt_ID = agnt_ID
 217                               WHERE agnt_type = 'robot' "
 218                               .( empty($blog) ? '' : 'AND hit_blog_ID = '.$blog );
 219  
 220  $Results = & new Results( $sql, 'topidx', '-D', 20, $count_sql );
 221  
 222  $total_hit_count = $DB->get_var( "
 223          SELECT COUNT(*)
 224              FROM T_hitlog INNER JOIN T_useragents ON hit_agnt_ID = agnt_ID
 225           WHERE agnt_type = 'robot' "
 226          .( empty($blog) ? '' : 'AND hit_blog_ID = '.$blog ) );
 227  
 228  $Results->title = T_('Top Indexing Robots');
 229  
 230  /**

 231   * Helper function to translate agnt_signature to a "human-friendly" version from {@link $user_agents}.

 232   * @return string

 233   */
 234  function translate_user_agent( $agnt_signature )
 235  {
 236      global $user_agents;
 237  
 238      foreach ($user_agents as $curr_user_agent)
 239      {
 240          if (stristr($agnt_signature, $curr_user_agent[1]))
 241          {
 242              return '<span title="'.htmlspecialchars($agnt_signature).'">'.htmlspecialchars($curr_user_agent[2]).'</span>';
 243          }
 244      }
 245  
 246      return htmlspecialchars($agnt_signature);
 247  }
 248  
 249  // User agent:

 250  $Results->cols[] = array(
 251          'th' => T_('Robot'),
 252          'order' => 'agnt_signature',
 253          'td' => '%translate_user_agent(\'$agnt_signature$\')%',
 254      );
 255  
 256  // Hit count:

 257  $Results->cols[] = array(
 258          'th' => T_('Hit count'),
 259          'order' => 'hit_count',
 260          'td_class' => 'right',
 261          'td' => '$hit_count$',
 262      );
 263  
 264  // Hit %

 265  $Results->cols[] = array(
 266          'th' => T_('Hit %'),
 267          'order' => 'hit_count',
 268          'td_class' => 'right',
 269          'td' => '%percentage( #hit_count#, '.$total_hit_count.' )%',
 270      );
 271  
 272  // Display results:

 273  $Results->display();
 274  
 275  
 276  /*

 277   * $Log: _stats_robots.view.php,v $

 278   * Revision 1.1  2007/06/25 11:01:06  fplanque

 279   * MODULES (refactored MVC)

 280   *

 281   * Revision 1.7  2007/04/26 00:11:13  fplanque

 282   * (c) 2007

 283   *

 284   * Revision 1.6  2007/03/20 09:53:26  fplanque

 285   * Letting boggers view their own stats.

 286   * + Letthing admins view the aggregate by default.

 287   *

 288   * Revision 1.5  2007/02/10 17:55:25  waltercruz

 289   * Changing double quotes to single quotes and the MySQL date functions to the standart ones

 290   *

 291   * Revision 1.4  2006/11/26 23:40:34  blueyed

 292   * trans

 293   *

 294   * Revision 1.3  2006/11/26 01:42:10  fplanque

 295   * doc

 296   */
 297  ?>


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