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

   1  <?php
   2  /**

   3   * This file implements the UI view for the general hit summary.

   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_summary.view.php,v 1.2 2007/09/03 19:36:06 fplanque Exp $

  25   */
  26  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  27  
  28  global $blog, $admin_url;
  29  
  30  
  31  echo '<h2>'.T_('Global hits summary').'</h2>';
  32  
  33  echo '<p>'.sprintf( T_('This page includes all recorded hits, split down by <a %s>user agent</a> type.'), ' href="?ctrl=stats&tab=useragents&blog='.$blog.'"' ).'</p>';
  34  
  35  
  36  // fplanque>> I don't get it, it seems that GROUP BY on the referer type ENUM fails pathetically!!

  37  // Bug report: http://lists.mysql.com/bugs/36

  38  // Solution : CAST to string

  39  // TODO: I've also limited this to agnt_type "browser" here, according to the change for "referers" (Rev 1.6)

  40  //       -> an RSS service that sends a referer is not a real referer (though it should be listed in the robots list)! (blueyed)

  41  $sql = '
  42      SELECT COUNT(*) AS hits, agnt_type, EXTRACT(YEAR FROM hit_datetime) AS year,
  43                 EXTRACT(MONTH FROM hit_datetime) AS month, EXTRACT(DAY FROM hit_datetime) AS day
  44          FROM T_hitlog INNER JOIN T_useragents ON hit_agnt_ID = agnt_ID';
  45  if( $blog > 0 )
  46  {
  47      $sql .= ' WHERE hit_blog_ID = '.$blog;
  48  }
  49  $sql .= ' GROUP BY year, month, day, agnt_type
  50                      ORDER BY year DESC, month DESC, day DESC, agnt_type';
  51  $res_hits = $DB->get_results( $sql, ARRAY_A, 'Get hit summary' );
  52  
  53  
  54  /*

  55   * Chart

  56   */
  57  if( count($res_hits) )
  58  {
  59      $last_date = 0;
  60  
  61      $col_mapping = array(
  62              'rss' => 1,
  63              'robot' => 2,
  64              'browser' => 3,
  65              'unknown' => 4,
  66          );
  67  
  68      $chart[ 'chart_data' ][ 0 ] = array();
  69      $chart[ 'chart_data' ][ 1 ] = array();
  70      $chart[ 'chart_data' ][ 2 ] = array();
  71      $chart[ 'chart_data' ][ 3 ] = array();
  72      $chart[ 'chart_data' ][ 4 ] = array();
  73  
  74      $count = 0;
  75      foreach( $res_hits as $row_stats )
  76      {
  77          $this_date = mktime( 0, 0, 0, $row_stats['month'], $row_stats['day'], $row_stats['year'] );
  78          if( $last_date != $this_date )
  79          { // We just hit a new day, let's display the previous one:
  80                  $last_date = $this_date;    // that'll be the next one

  81                  $count ++;
  82                  array_unshift( $chart[ 'chart_data' ][ 0 ], date( locale_datefmt(), $last_date ) );
  83                  array_unshift( $chart[ 'chart_data' ][ 1 ], 0 );
  84                  array_unshift( $chart[ 'chart_data' ][ 2 ], 0 );
  85                  array_unshift( $chart[ 'chart_data' ][ 3 ], 0 );
  86                  array_unshift( $chart[ 'chart_data' ][ 4 ], 0 );
  87          }
  88          $col = $col_mapping[$row_stats['agnt_type']];
  89          $chart['chart_data'][$col][0] = $row_stats['hits'];
  90      }
  91  
  92      array_unshift( $chart[ 'chart_data' ][ 0 ], '' );
  93      array_unshift( $chart[ 'chart_data' ][ 1 ], 'XML (RSS/Atom)' );
  94      array_unshift( $chart[ 'chart_data' ][ 2 ], 'Robots' );
  95      array_unshift( $chart[ 'chart_data' ][ 3 ], 'Browsers' );    // Translations need to be UTF-8

  96      array_unshift( $chart[ 'chart_data' ][ 4 ], 'Unknown' );
  97  
  98      $chart[ 'canvas_bg' ] = array (
  99              'width'  => 780,
 100              'height' => 400,
 101              'color'  => 'efede0'
 102          );
 103  
 104      $chart[ 'chart_rect' ] = array (
 105              'x'      => 50,
 106              'y'      => 50,
 107              'width'  => 700,
 108              'height' => 250
 109          );
 110  
 111      $chart[ 'legend_rect' ] = array (
 112              'x'      => 50,
 113              'y'      => 365,
 114              'width'  => 700,
 115              'height' => 8,
 116              'margin' => 6
 117          );
 118  
 119      $chart[ 'draw_text' ] = array (
 120              array (
 121                      'color'    => '9e9286',
 122                      'alpha'    => 75,
 123                      'font'     => "arial",
 124                      'rotation' => 0,
 125                      'bold'     => true,
 126                      'size'     => 42,
 127                      'x'        => 50,
 128                      'y'        => 6,
 129                      'width'    => 700,
 130                      'height'   => 50,
 131                      'text'     => 'Global hits', // Needs UTF-8
 132                      'h_align'  => "right",
 133                      'v_align'  => "bottom" ),
 134              );
 135  
 136      $chart[ 'chart_bg' ] = array (
 137              'positive_color' => "ffffff",
 138              // 'negative_color'  =>  string,

 139              'positive_alpha' => 20,
 140              // 'negative_alpha'  =>  int

 141          );
 142  
 143      $chart [ 'legend_bg' ] = array (
 144              'bg_color'          =>  "ffffff",
 145              'bg_alpha'          =>  20,
 146              // 'border_color'      =>  "000000",

 147              // 'border_alpha'      =>  100,

 148              // 'border_thickness'  =>  1

 149          );
 150  
 151      $chart [ 'legend_label' ] = array(
 152              // 'layout'  =>  "horizontal",

 153              // 'font'    =>  string,

 154              // 'bold'    =>  boolean,

 155              'size'    =>  10,
 156              // 'color'   =>  string,

 157              // 'alpha'   =>  int

 158          );
 159  
 160      $chart[ 'chart_border' ] = array (
 161              'color'=>"000000",
 162              'top_thickness'=>1,
 163              'bottom_thickness'=>1,
 164              'left_thickness'=>1,
 165              'right_thickness'=>1
 166          );
 167  
 168      $chart[ 'chart_type' ] = 'stacked column';
 169  
 170      // $chart[ 'series_color' ] = array ( "4e627c", "c89341" );

 171  
 172      $chart[ 'series_gap' ] = array ( 'set_gap'=>0, 'bar_gap'=>0 );
 173  
 174  
 175      $chart[ 'axis_category' ] = array (
 176              'font'  =>"arial",
 177              'bold'  =>true,
 178              'size'  =>11,
 179              'color' =>'000000',
 180              'alpha' =>75,
 181              'orientation' => 'diagonal_up',
 182              // 'skip'=>2

 183          );
 184  
 185      $chart[ 'axis_value' ] = array (
 186              // 'font'   =>"arial",

 187              // 'bold'   =>true,

 188              'size'   => 11,
 189              'color'  => '000000',
 190              'alpha'  => 75,
 191              'steps'  => 4,
 192              'prefix' => "",
 193              'suffix' => "",
 194              'decimals'=> 0,
 195              'separator'=> "",
 196              'show_min'=> false );
 197  
 198      $chart[ 'chart_value' ] = array (
 199              // 'prefix'         =>  string,

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

 201              // 'decimals'       =>  int,

 202              // 'separator'      =>  string,

 203              'position'       =>  "cursor",
 204              'hide_zero'      =>  true,
 205              // 'as_percentage'  =>  boolean,

 206              'font'           =>  "arial",
 207              'bold'           =>  true,
 208              'size'           =>  20,
 209              'color'          =>  "ffffff",
 210              'alpha'          =>  75
 211          );
 212  
 213      echo '<div class="center">';
 214      DrawChart( $chart );
 215      echo '</div>';
 216  
 217  
 218      /*

 219       * Table:

 220       */
 221      $hits = array(
 222          'browser' => 0,
 223          'robot' => 0,
 224          'rss' => 0,
 225          'unknown' => 0,
 226      );
 227      $hits_total = $hits;
 228  
 229      $last_date = 0;
 230  
 231      ?>
 232  
 233      <table class="grouped" cellspacing="0">
 234          <tr>
 235              <th class="firstcol"><?php echo T_('Date') ?></th>
 236              <th><?php echo T_('XML') ?></th>
 237              <th><?php echo T_('Robots') ?></th>
 238              <th><?php echo T_('Browser') ?></th>
 239              <th><?php echo T_('Unknown') ?></th>
 240              <th class="lastcol"><?php echo T_('Total') ?></th>
 241          </tr>
 242          <?php
 243          $count = 0;
 244          foreach( $res_hits as $row_stats )
 245          {
 246              $this_date = mktime( 0, 0, 0, $row_stats['month'], $row_stats['day'], $row_stats['year'] );
 247              if( $last_date == 0 ) $last_date = $this_date;    // that'll be the first one

 248              if( $last_date != $this_date )
 249              { // We just hit a new day, let's display the previous one:
 250                  ?>
 251                  <tr class="<?php echo ( $count%2 == 1 ) ? 'odd' : 'even'; ?>">
 252                      <td class="firstcol"><?php if( $current_User->check_perm( 'stats', 'edit' ) )
 253                          {
 254                              echo action_icon( T_('Prune hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=stats&amp;action=prune&amp;date='.$last_date.'&amp;show=summary&amp;blog='.$blog ) );
 255                          }
 256                          echo date( locale_datefmt(), $last_date ) ?>
 257                      </td>
 258                      <td class="right"><?php echo $hits['rss'] ?></td>
 259                      <td class="right"><?php echo $hits['robot'] ?></td>
 260                      <td class="right"><?php echo $hits['browser'] ?></td>
 261                      <td class="right"><?php echo $hits['unknown'] ?></td>
 262                      <td class="lastcol right"><?php echo array_sum($hits) ?></td>
 263                  </tr>
 264                  <?php
 265                      $hits = array(
 266                          'browser' => 0,
 267                          'robot' => 0,
 268                          'rss' => 0,
 269                          'unknown' => 0,
 270                      );
 271                      $last_date = $this_date;    // that'll be the next one

 272                      $count ++;
 273              }
 274  
 275              // Increment hitcounter:

 276              $hits[$row_stats['agnt_type']] = $row_stats['hits'];
 277              $hits_total[$row_stats['agnt_type']] += $row_stats['hits'];
 278          }
 279  
 280          if( $last_date != 0 )
 281          { // We had a day pending:
 282              ?>
 283                  <tr class="<?php echo ( $count%2 == 1 ) ? 'odd' : 'even'; ?>">
 284                  <td class="firstcol"><?php if( $current_User->check_perm( 'stats', 'edit' ) )
 285                      {
 286                          echo action_icon( T_('Prune hits for this date!'), 'delete', url_add_param( $admin_url, 'ctrl=stats&amp;action=prune&amp;date='.$last_date.'&amp;show=summary&amp;blog='.$blog ) );
 287                      }
 288                      echo date( locale_datefmt(), $this_date ) ?>
 289                  </td>
 290                  <td class="right"><?php echo $hits['rss'] ?></td>
 291                  <td class="right"><?php echo $hits['robot'] ?></td>
 292                  <td class="right"><?php echo $hits['browser'] ?></td>
 293                  <td class="right"><?php echo $hits['unknown'] ?></td>
 294                  <td class="lastcol right"><?php echo array_sum($hits) ?></td>
 295              </tr>
 296              <?php
 297          }
 298  
 299          // Total numbers:

 300          ?>
 301  
 302          <tr class="total">
 303          <td class="firstcol"><?php echo T_('Total') ?></td>
 304          <td class="right"><?php echo $hits_total['rss'] ?></td>
 305          <td class="right"><?php echo $hits_total['robot'] ?></td>
 306          <td class="right"><?php echo $hits_total['browser'] ?></td>
 307          <td class="right"><?php echo $hits_total['unknown'] ?></td>
 308          <td class="lastcol right"><?php echo array_sum($hits_total) ?></td>
 309          </tr>
 310  
 311      </table>
 312  
 313      <img src="'.$rsc_url.'/img/blank.gif" width="1" height="1" /><!-- for IE -->
 314      <?php
 315  }
 316  
 317  
 318  /*

 319   * $Log: _stats_summary.view.php,v $

 320   * Revision 1.2  2007/09/03 19:36:06  fplanque

 321   * chicago admin skin

 322   *

 323   * Revision 1.1  2007/06/25 11:01:07  fplanque

 324   * MODULES (refactored MVC)

 325   *

 326   * Revision 1.8  2007/04/26 00:11:13  fplanque

 327   * (c) 2007

 328   *

 329   * Revision 1.7  2007/02/10 17:57:16  waltercruz

 330   * Changing the MySQL date functions to the standart ones

 331   *

 332   * Revision 1.6  2006/11/26 01:42:10  fplanque

 333   * doc

 334   */
 335  ?>


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