b2evolution PHP Cross Reference Blogging Systems

Source: /inc/sessions/views/_stats_sessions_list.view.php - 172 lines - 5157 bytes - Summary - Text - Print

Description: This file implements the UI view for the Session 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 UI view for the Session 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   * {@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_sessions_list.view.php 6136 2014-03-08 07:59:48Z manuel $
  25   */
  26  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  27  
  28  global $blog, $admin_url, $rsc_url, $UserSettings, $edited_User, $user_tab, $Plugins;
  29  
  30  /**
  31   * View funcs
  32   */
  33  require_once dirname(__FILE__).'/_stats_view.funcs.php';
  34  
  35  $user_ID = param( 'user_ID', 'integer', 0, true );
  36  
  37  // Create result set:
  38  $SQL = new SQL();
  39  $SQL->SELECT( 'SQL_NO_CACHE sess_ID, user_login, TIMESTAMPDIFF( SECOND, sess_start_ts, sess_lastseen_ts ) as sess_length, sess_lastseen_ts, sess_ipaddress' );
  40  $SQL->FROM( 'T_sessions LEFT JOIN T_users ON sess_user_ID = user_ID' );
  41  
  42  $Count_SQL = new SQL();
  43  $Count_SQL->SELECT( 'SQL_NO_CACHE COUNT(sess_ID)' );
  44  $Count_SQL->FROM( 'T_sessions LEFT JOIN T_users ON sess_user_ID = user_ID' );
  45  
  46  if( empty( $user_ID ) )
  47  { // display only this user sessions in user tab
  48      $user_ID = $edited_User->ID;
  49  }
  50  
  51  $SQL->WHERE( 'user_ID = '.$user_ID );
  52  $Count_SQL->WHERE( 'user_ID = '.$user_ID );
  53  
  54  memorize_param( 'user_tab', 'string', '', $user_tab );
  55  
  56  // Begin payload block:
  57  $this->disp_payload_begin();
  58  
  59  // ------------------- PREV/NEXT USER LINKS -------------------
  60  user_prevnext_links( array(
  61          'block_start'  => '<table class="prevnext_user"><tr>',
  62          'prev_start'   => '<td width="33%">',
  63          'prev_end'     => '</td>',
  64          'prev_no_user' => '<td width="33%">&nbsp;</td>',
  65          'back_start'   => '<td width="33%" class="back_users_list">',
  66          'back_end'     => '</td>',
  67          'next_start'   => '<td width="33%" class="right">',
  68          'next_end'     => '</td>',
  69          'next_no_user' => '<td width="33%">&nbsp;</td>',
  70          'block_end'    => '</tr></table>',
  71          'user_tab'     => 'sessions'
  72      ) );
  73  // ------------- END OF PREV/NEXT USER LINKS -------------------
  74  
  75  $Results = new Results( $SQL->get(), 'sess_', 'D', $UserSettings->get( 'results_per_page' ), $Count_SQL->get() );
  76  
  77  // echo user edit action icons
  78  echo_user_actions( $Results, $edited_User, 'edit' );
  79  echo '<span class="floatright">'.$Results->gen_global_icons().'</span>';
  80  $Results->global_icons = array();
  81  
  82  // echo user tabs
  83  echo '<div>'.get_usertab_header( $edited_User, $user_tab, T_( 'Sessions' ) ).'</div>';
  84  
  85  $Results->title = T_('Recent sessions');
  86  
  87  /**
  88   * Callback to add filters on top of the result set
  89   *
  90   * @param Form
  91   */
  92  
  93  $Results->cols[] = array(
  94                          'th' => T_('ID'),
  95                          'order' => 'sess_ID',
  96                          'default_dir' => 'D',
  97                          'td_class' => 'right',
  98                          'td' => '<a href="?ctrl=stats&amp;tab=hits&amp;blog=0&amp;sess_ID=$sess_ID$">$sess_ID$</a>',
  99                      );
 100  
 101  $Results->cols[] = array(
 102                          'th' => T_('Last seen'),
 103                          'order' => 'sess_lastseen_ts',
 104                          'default_dir' => 'D',
 105                          'td_class' => 'timestamp',
 106                          'td' => '%mysql2localedatetime_spans( #sess_lastseen_ts# )%',
 107                       );
 108  
 109  $Results->cols[] = array(
 110                          'th' => T_('User login'),
 111                          'order' => 'user_login',
 112                          'td' => '%stat_session_login( #user_login# )%',
 113                      );
 114  
 115  $Results->cols[] = array(
 116                          'th' => T_('Remote IP'),
 117                          'order' => 'sess_ipaddress',
 118                          'td' => '$sess_ipaddress$',
 119                      );
 120  
 121  // Get additional columns from the Plugins
 122  $Plugins->trigger_event( 'GetAdditionalColumnsTable', array(
 123      'table'   => 'sessions',
 124      'column'  => 'sess_ipaddress',
 125      'Results' => $Results ) );
 126  
 127  function display_sess_length( $sess_ID, $sess_length )
 128  {
 129      $result = '';
 130      $second = $sess_length % 60;
 131      $sess_length = ( $sess_length - $second ) / 60;
 132      $minute = $sess_length % 60;
 133      $sess_length = ( $sess_length - $minute ) / 60;
 134      $hour = $sess_length % 24;
 135      $day = ( $sess_length - $hour ) / 24;
 136  
 137      if( $day > 0 )
 138      {
 139          $result = sprintf( ( ( $day > 1 ) ? T_( '%d days' ) : T_( '%d day' ) ), $day ).' ';
 140      }
 141      if( $hour < 10 )
 142      {
 143          $hour = '0'.$hour;
 144      }
 145      if( $minute < 10 )
 146      {
 147          $minute = '0'.$minute;
 148      }
 149      if( $second < 10 )
 150      {
 151          $second = '0'.$second;
 152      }
 153  
 154      $result .= $hour.':'.$minute.':'.$second;
 155      return stat_session_hits( $sess_ID, $result );
 156  }
 157  
 158  $Results->cols[] = array(
 159                          'th' => T_('Session length'),
 160                          'order' => 'sess_length',
 161                          'td_class' => 'center',
 162                          'total_class' => 'right',
 163                          'td' => '%display_sess_length( #sess_ID#, #sess_length# )%',
 164                      );
 165  
 166  // Display results:
 167  $Results->display();
 168  
 169  // End payload block:
 170  $this->disp_payload_end();
 171  
 172  ?>

title

Description

title

Description

title

Description

title

title

Body