[ 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/ -> stats.ctrl.php (source)

   1  <?php
   2  /**

   3   * This file implements the UI controller for browsing the (hitlog) statistics.

   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-2007 by Francois PLANQUE - {@link http://fplanque.net/}.

   9   *

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

  11   *

  12   * {@internal Open Source relicensing agreement:

  13   * Vegar BERG GULDAL grants Francois PLANQUE the right to license

  14   * Vegar BERG GULDAL's contributions to this file and the b2evolution project

  15   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  16   * }}

  17   *

  18   * @package admin

  19   *

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

  21   * @author blueyed: Daniel HAHLER

  22   * @author fplanque: Francois PLANQUE

  23   * @author vegarg: Vegar BERG GULDAL

  24   *

  25   * @version $Id: stats.ctrl.php,v 1.2 2007/09/19 09:41:57 yabs Exp $

  26   */
  27  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  28  
  29  
  30  load_class('sessions/model/_hitlist.class.php');
  31  
  32  /**

  33   * @var User

  34   */
  35  global $current_User;
  36  
  37  // Do we have permission to view all stats (aggregated stats) ?

  38  $perm_view_all = $current_User->check_perm( 'stats', 'view' );
  39  
  40  // We set the default to -1 so that blog=0 will make its way into regenerate_url()s whenever watching global stats.

  41  memorize_param( 'blog', 'integer', -1 );
  42  
  43  $tab = param( 'tab', 'string', 'summary', true );
  44  if( $tab == 'sessions' && (!$perm_view_all || $blog != 0) )
  45  {    // Sessions tab is not narrowed down to blog level:
  46      $tab = 'summary';
  47  }
  48  $AdminUI->set_path( 'stats', $tab );
  49  $AdminUI->title = T_('View Stats for Blog:');
  50  
  51  param( 'action', 'string' );
  52  
  53  if( $blog == 0 && $perm_view_all )
  54  {    // We want to view aggregate stats
  55  }
  56  elseif( $blog == 0 )
  57  {    // Find a blog we can view stats for:
  58      if( ! $selected = autoselect_blog( 'stats', 'view' ) )
  59      { // No blog could be selected
  60          $Messages->add( T_('Sorry, there is no blog you have permission to view stats for.'), 'error' );
  61          $action = 'nil';
  62      }
  63      elseif( set_working_blog( $selected ) )    // set $blog & memorize in user prefs
  64      {    // Selected a new blog:
  65          $BlogCache = & get_Cache( 'BlogCache' );
  66          $Blog = & $BlogCache->get_by_ID( $blog );
  67      }
  68  }
  69  
  70  switch( $action )
  71  {
  72      case 'changetype': // Change the type of a hit
  73          // Check permission:

  74          $current_User->check_perm( 'stats', 'edit', true );
  75  
  76          param( 'hit_ID', 'integer', true );      // Required!

  77          param( 'new_hit_type', 'string', true ); // Required!

  78  
  79          Hitlist::change_type( $hit_ID, $new_hit_type );
  80          $Messages->add( sprintf( T_('Changed hit #%d type to: %s.'), $hit_ID, $new_hit_type), 'success' );
  81          break;
  82  
  83  
  84      case 'delete': // DELETE A HIT
  85          // Check permission:

  86          $current_User->check_perm( 'stats', 'edit', true );
  87  
  88          param( 'hit_ID', 'integer', true ); // Required!

  89  
  90          if( Hitlist::delete( $hit_ID ) )
  91          {
  92              $Messages->add( sprintf( T_('Deleted hit #%d.'), $hit_ID ), 'success' );
  93          }
  94          else
  95          {
  96              $Messages->add( sprintf( T_('Could not delete hit #%d.'), $hit_ID ), 'note' );
  97          }
  98          break;
  99  
 100  
 101      case 'prune': // PRUNE hits for a certain date
 102          // Check permission:

 103          $current_User->check_perm( 'stats', 'edit', true );
 104  
 105          param( 'date', 'integer', true ); // Required!

 106          if( $r = Hitlist::prune( $date ) )
 107          {
 108              $Messages->add( sprintf( /* TRANS: %s is a date */ T_('Deleted %d hits for %s.'), $r, date( locale_datefmt(), $date) ), 'success' );
 109          }
 110          else
 111          {
 112              $Messages->add( sprintf( /* TRANS: %s is a date */ T_('No hits deleted for %s.'), date( locale_datefmt(), $date) ), 'note' );
 113          }
 114          break;
 115  }
 116  
 117  if( $perm_view_all )
 118  {
 119      $blogListButtons = $AdminUI->get_html_collection_list( 'stats', 'view',
 120                      'admin.php?ctrl=stats&amp;tab='.$tab.'&amp;blog=%d', T_('All'),
 121                      'admin.php?ctrl=stats&amp;tab='.$tab.'&amp;blog=0' );
 122  }
 123  else
 124  {    // No permission to view aggregated stats:
 125      $blogListButtons = $AdminUI->get_html_collection_list( 'stats', 'view',
 126                      'admin.php?ctrl=stats&amp;tab='.$tab.'&amp;blog=%d' );
 127  }
 128  
 129  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)

 130  $AdminUI->disp_html_head();
 131  
 132  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)

 133  $AdminUI->disp_body_top();
 134  
 135  // Begin payload block:

 136  $AdminUI->disp_payload_begin();
 137  
 138  
 139  switch( $AdminUI->get_path(1) )
 140  {
 141      case 'summary':
 142          // Display VIEW:

 143          $AdminUI->disp_view( 'sessions/views/_stats_summary.view.php' );
 144          break;
 145  
 146      case 'browserhits':
 147          // Display VIEW:

 148          $AdminUI->disp_view( 'sessions/views/_stats_browserhits.view.php' );
 149          break;
 150  
 151      case 'other':
 152          // Display VIEW:

 153          $AdminUI->disp_view( 'sessions/views/_stats_direct.view.php' );
 154          break;
 155  
 156      case 'referers':
 157          // Display VIEW:

 158          $AdminUI->disp_view( 'sessions/views/_stats_referers.view.php' );
 159          break;
 160  
 161      case 'refsearches':
 162          // Display VIEW:

 163          $AdminUI->disp_view( 'sessions/views/_stats_refsearches.view.php' );
 164          break;
 165  
 166      case 'robots':
 167          // Display VIEW:

 168          $AdminUI->disp_view( 'sessions/views/_stats_robots.view.php' );
 169          break;
 170  
 171      case 'syndication':
 172          // Display VIEW:

 173          $AdminUI->disp_view( 'sessions/views/_stats_syndication.view.php' );
 174          break;
 175  
 176      case 'useragents':
 177          // Display VIEW:

 178          $AdminUI->disp_view( 'sessions/views/_stats_useragents.view.php' );
 179          break;
 180  
 181      case 'domains':
 182          // Display VIEW:

 183          $AdminUI->disp_view( 'sessions/views/_stats_refdomains.view.php' );
 184          break;
 185  
 186      case 'sessions':
 187          // Display VIEW:

 188          $AdminUI->disp_view( 'sessions/views/_stats_sessions.view.php' );
 189          break;
 190  }
 191  
 192  // End payload block:

 193  $AdminUI->disp_payload_end();
 194  
 195  // Display body bottom, debug info and close </html>:

 196  $AdminUI->disp_global_footer();
 197  
 198  /*

 199   * $Log: stats.ctrl.php,v $

 200   * Revision 1.2  2007/09/19 09:41:57  yabs

 201   * minor bug fix

 202   *

 203   * Revision 1.1  2007/06/25 11:00:56  fplanque

 204   * MODULES (refactored MVC)

 205   *

 206   * Revision 1.37  2007/05/13 18:49:55  fplanque

 207   * made autoselect_blog() more robust under PHP4

 208   *

 209   * Revision 1.36  2007/04/26 00:11:16  fplanque

 210   * (c) 2007

 211   *

 212   * Revision 1.35  2007/03/20 09:55:06  fplanque

 213   * Letting boggers view their own stats.

 214   * + Letthing admins view the aggregate by default.

 215   *

 216   * Revision 1.33  2007/03/02 01:36:51  fplanque

 217   * small fixes

 218   *

 219   * Revision 1.32  2006/12/07 23:21:00  fplanque

 220   * dashboard blog switching

 221   */
 222  ?>


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