b2evolution PHP Cross Reference Blogging Systems

Source: /inc/sessions/_sessions.init.php - 359 lines - 12089 bytes - Summary - Text - Print

Description: This is the init file for the session module. 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 is the init file for the session module.
   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   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  25   * @author fplanque: Francois PLANQUE.
  26   *
  27   * @version $Id: _sessions.init.php 6136 2014-03-08 07:59:48Z manuel $
  28   */
  29  if( !defined('EVO_CONFIG_LOADED') ) die( 'Please, do not access this page directly.' );
  30  
  31  
  32  /**
  33   * Minimum PHP version required for sessions module to function properly
  34   */
  35  $required_php_version[ 'sessions' ] = '5.0';
  36  
  37  /**
  38   * Minimum MYSQL version required for sessions module to function properly
  39   */
  40  $required_mysql_version[ 'sessions' ] = '5.0.3';
  41  
  42  /**
  43   * Aliases for table names:
  44   *
  45   * (You should not need to change them.
  46   *  If you want to have multiple b2evo installations in a single database you should
  47   *  change {@link $tableprefix} in _basic_config.php)
  48   */
  49  $db_config['aliases']['T_basedomains'] = $tableprefix.'basedomains';
  50  $db_config['aliases']['T_hitlog'] = $tableprefix.'hitlog';
  51  $db_config['aliases']['T_track__keyphrase'] = $tableprefix.'track__keyphrase';
  52  $db_config['aliases']['T_sessions'] = $tableprefix.'sessions';
  53  $db_config['aliases']['T_track__goal'] = $tableprefix.'track__goal';
  54  $db_config['aliases']['T_track__goalhit'] = $tableprefix.'track__goalhit';
  55  $db_config['aliases']['T_logs__internal_searches'] = $tableprefix.'logs__internal_searches';
  56  
  57  
  58  /**
  59   * Controller mappings.
  60   *
  61   * For each controller name, we associate a controller file to be found in /inc/ .
  62   * The advantage of this indirection is that it is easy to reorganize the controllers into
  63   * subdirectories by modules. It is also easy to deactivate some controllers if you don't
  64   * want to provide this functionality on a given installation.
  65   *
  66   * Note: while the controller mappings might more or less follow the menu structure, we do not merge
  67   * the two tables since we could, at any time, decide to make a skin with a different menu structure.
  68   * The controllers however would most likely remain the same.
  69   *
  70   * @global array
  71   */
  72  $ctrl_mappings['stats'] = 'sessions/stats.ctrl.php';
  73  $ctrl_mappings['goals'] = 'sessions/goals.ctrl.php';
  74  $ctrl_mappings['internalsearches'] = 'sessions/internal_searches.ctrl.php';
  75  
  76  
  77  /**
  78   * Get the GoalCache
  79   *
  80   * @return GoalCache
  81   */
  82  function & get_GoalCache()
  83  {
  84      global $GoalCache;
  85  
  86      if( ! isset( $GoalCache ) )
  87      {    // Cache doesn't exist yet:
  88          $GoalCache = new DataObjectCache( 'Goal', false, 'T_track__goal', 'goal_', 'goal_ID', 'goal_name', 'goal_name' ); // COPY (FUNC)
  89      }
  90  
  91      return $GoalCache;
  92  }
  93  
  94  /**
  95   * Get the Internal Searches Cache
  96   *
  97   * @return InternalSearchesCache
  98   */
  99  function & get_InternalSearchesCache()
 100  {
 101      global $InternalSearchesCache;
 102  
 103      if( ! isset( $InternalSearchesCache ) )
 104      {    // Cache doesn't exist yet:
 105          $InternalSearchesCache = new DataObjectCache( 'InternalSearches', false, 'T_logs__internal_searches', 'isrch_', 'isrch_ID', 'isrch_sessionID', 'isrch_keywords' ); // COPY (FUNC)
 106      }
 107  
 108      return $InternalSearchesCache;
 109  }
 110  
 111  
 112  /**
 113   * sessions_Module definition
 114   */
 115  class sessions_Module extends Module
 116  {
 117      /**
 118       * Do the initializations. Called from in _main.inc.php.
 119       * This is typically where classes matching DB tables for this module are registered/loaded.
 120       *
 121       * Note: this should only load/register things that are going to be needed application wide,
 122       * for example: for constructing menus.
 123       * Anything that is needed only in a specific controller should be loaded only there.
 124       * Anything that is needed only in a specific view should be loaded only there.
 125       */
 126  	function init()
 127      {
 128          $this->check_required_php_version( 'sessions' );
 129      }
 130  
 131      /**
 132       * Build the evobar menu
 133       */
 134  	function build_evobar_menu()
 135      {
 136          /**
 137           * @var Menu
 138           */
 139          global $topleft_Menu;
 140          global $current_User;
 141          global $admin_url;
 142          global $Blog;
 143  
 144          if( !$current_User->check_perm( 'admin', 'normal' ) )
 145          {
 146              return;
 147          }
 148  
 149          if( !empty($Blog) && $current_User->check_perm( 'stats', 'list' ) )
 150          {    // Permission to view stats for user's blogs:
 151              $entries = array();
 152              $entries['stats_sep'] = array(
 153                  'separator' => true,
 154              );
 155              $entries['stats'] = array(
 156                  'text' => T_('Blog analytics'),
 157                  'href' => $admin_url.'?ctrl=stats&amp;tab=summary&amp;tab3=global&amp;blog='.$Blog->ID,
 158                  'entries' => array(
 159                      'summary' => array(
 160                          'text' => T_('Hit summary').'&hellip;',
 161                          'href' => $admin_url.'?ctrl=stats&amp;tab=summary&amp;tab3=global&amp;blog='.$Blog->ID ),
 162                      'refsearches' => array(
 163                          'text' => T_('Search B-hits').'&hellip;',
 164                          'href' => $admin_url.'?ctrl=stats&amp;tab=refsearches&amp;tab3=hits&amp;blog='.$Blog->ID ),
 165                      'referers' => array(
 166                          'text' => T_('Referered B-hits').'&hellip;',
 167                          'href' => $admin_url.'?ctrl=stats&amp;tab=referers&amp;blog='.$Blog->ID ),
 168                      'other' => array(
 169                          'text' => T_('Direct B-hits').'&hellip;',
 170                          'href' => $admin_url.'?ctrl=stats&amp;tab=other&amp;blog='.$Blog->ID ),
 171                      'hits' => array(
 172                          'text' => T_('All Hits').'&hellip;',
 173                          'href' => $admin_url.'?ctrl=stats&amp;tab=hits&amp;blog='.$Blog->ID ),
 174                      'domains' => array(
 175                          'text' => T_('Referring domains').'&hellip;',
 176                          'href' => $admin_url.'?ctrl=stats&amp;tab=domains&amp;blog='.$Blog->ID ),
 177                      )
 178              );
 179  
 180              $topleft_Menu->add_menu_entries( 'blog', $entries );
 181          }
 182  
 183          if( $current_User->check_perm( 'stats', 'view' ) )
 184          {    // We have permission to view all stats
 185  
 186              // TODO: this is hackish and would require a proper function call
 187              $topleft_Menu->_menus['entries']['tools']['disabled'] = false;
 188  
 189              // TODO: this is hackish and would require a proper function call
 190              if( ! empty($topleft_Menu->_menus['entries']['tools']['entries']) )
 191              {    // There are already entries aboce, insert a separator:
 192                  $topleft_Menu->add_menu_entries( 'tools', array(
 193                          'stats_sep' => array(
 194                                  'separator' => true,
 195                              ),
 196                      )
 197                  );
 198              }
 199  
 200              $entries = array();
 201              $entries['stats'] = array(
 202                      'text' => T_('Global analytics'),
 203                      'href' => $admin_url.'?ctrl=stats&amp;tab=summary&amp;tab3=global&amp;blog=0',
 204                      'entries' => array(
 205                          'summary' => array(
 206                              'text' => T_('Hit summary').'&hellip;',
 207                              'href' => $admin_url.'?ctrl=stats&amp;tab=summary&amp;tab3=global&amp;blog=0' ),
 208                          'refsearches' => array(
 209                              'text' => T_('Search B-hits').'&hellip;',
 210                              'href' => $admin_url.'?ctrl=stats&amp;tab=refsearches&amp;tab3=hits&amp;blog=0' ),
 211                          'referers' => array(
 212                              'text' => T_('Referered B-hits').'&hellip;',
 213                              'href' => $admin_url.'?ctrl=stats&amp;tab=referers&amp;blog=0' ),
 214                          'other' => array(
 215                              'text' => T_('Direct B-hits').'&hellip;',
 216                              'href' => $admin_url.'?ctrl=stats&amp;tab=other&amp;blog=0' ),
 217                          'hits' => array(
 218                              'text' => T_('All Hits').'&hellip;',
 219                              'href' => $admin_url.'?ctrl=stats&amp;tab=hits&amp;blog=0' ),
 220                          'domains' => array(
 221                              'text' => T_('Referring domains').'&hellip;',
 222                              'href' => $admin_url.'?ctrl=stats&amp;tab=domains&amp;blog=0' ),
 223                          'goals' => array(
 224                              'text' => T_('Goals').'&hellip;',
 225                              'href' => $admin_url.'?ctrl=goals' ),
 226                          )
 227                  );
 228  
 229              if( !is_admin_page() )
 230              {
 231                  $blog_ID = empty( $Blog ) ? 0 : $Blog->ID;
 232                  $entries['stats_page'] = array(
 233                          'text' => T_('Page stats').'&hellip;',
 234                          'href' => $admin_url.'?ctrl=stats&tab=hits&blog='.$blog_ID.'&reqURI='.rawurlencode( $_SERVER['REQUEST_URI'] ),
 235                      );
 236              }
 237  
 238              $topleft_Menu->add_menu_entries( 'tools', $entries );
 239          }
 240      }
 241  
 242  
 243      /**
 244       * Builds the 1st half of the menu. This is the one with the most important features
 245       */
 246  	function build_menu_1()
 247      {
 248          global $blog, $dispatcher;
 249          /**
 250           * @var User
 251           */
 252          global $current_User;
 253          global $Blog;
 254          /**
 255           * @var AdminUI_general
 256           */
 257          global $AdminUI;
 258  
 259          if( !$current_User->check_perm( 'admin', 'normal' ) )
 260          {
 261              return;
 262          }
 263  
 264          if( $current_User->check_perm( 'stats', 'list' ) )
 265          {    // Permission to view stats for user's blogs:
 266              $AdminUI->add_menu_entries(
 267                      NULL, // root
 268                      array(
 269                          'stats' => array(
 270                              'text' => T_('Analytics'),
 271                              'href' => $dispatcher.'?ctrl=stats&amp;tab=summary&amp;tab3=global',
 272                              'entries' => array(
 273                                  'summary' => array(
 274                                      'text' => T_('Hit summary'),
 275                                      'href' => $dispatcher.'?ctrl=stats&amp;tab=summary&amp;tab3=global&amp;blog='.$blog,
 276                                      'entries' => array(
 277                                          'global' => array(
 278                                              'text' => T_('Global hits'),
 279                                              'href' => $dispatcher.'?ctrl=stats&amp;tab=summary&amp;tab3=global&amp;blog='.$blog ),
 280                                          'browser' => array(
 281                                              'text' => T_('Browser hits'),
 282                                              'href' => $dispatcher.'?ctrl=stats&amp;tab=summary&amp;tab3=browser&amp;blog='.$blog ),
 283                                          'robot' => array(
 284                                              'text' => T_('Robot hits'),
 285                                              'href' => $dispatcher.'?ctrl=stats&amp;tab=summary&amp;tab3=robot&amp;blog='.$blog ),
 286                                          'feed' => array(
 287                                              'text' => T_('RSS/Atom hits'),
 288                                              'href' => $dispatcher.'?ctrl=stats&amp;tab=summary&amp;tab3=feed&amp;blog='.$blog ),
 289                                          ),
 290                                      ),
 291                                  ),
 292                              ),
 293                          )
 294                      );
 295  
 296              $AdminUI->add_menu_entries( 'stats', array(
 297                                  'refsearches' => array(
 298                                      'text' => T_('Search B-hits'),
 299                                      'href' => $dispatcher.'?ctrl=stats&amp;tab=refsearches&amp;tab3=hits&amp;blog='.$blog,
 300                                      'entries' => array(
 301                                          'hits' => array(
 302                                              'text' => T_('Search hits'),
 303                                              'href' => $dispatcher.'?ctrl=stats&amp;tab=refsearches&amp;tab3=hits&amp;blog='.$blog ),
 304                                          'keywords' => array(
 305                                              'text' => T_('Keywords'),
 306                                              'href' => $dispatcher.'?ctrl=stats&amp;tab=refsearches&amp;tab3=keywords&amp;blog='.$blog ),
 307                                          'topengines' => array(
 308                                              'text' => T_('Top engines'),
 309                                              'href' => $dispatcher.'?ctrl=stats&amp;tab=refsearches&amp;tab3=topengines&amp;blog='.$blog ),
 310                                          ),
 311                                       ),
 312                                  'referers' => array(
 313                                      'text' => T_('Referered B-hits'),
 314                                      'href' => $dispatcher.'?ctrl=stats&amp;tab=referers&amp;blog='.$blog ),
 315                                  'other' => array(
 316                                      'text' => T_('Direct B-hits'),
 317                                      'href' => $dispatcher.'?ctrl=stats&amp;tab=other&amp;blog='.$blog ),
 318                                  'hits' => array(
 319                                      'text' => T_('All Hits'),
 320                                      'href' => $dispatcher.'?ctrl=stats&amp;tab=hits&amp;blog='.$blog ),
 321                                  'domains' => array(
 322                                      'text' => T_('Referring domains'),
 323                                      'href' => $dispatcher.'?ctrl=stats&amp;tab=domains&amp;blog='.$blog ),
 324                              )
 325                          );
 326          }
 327  
 328          if( $blog == 0 && $current_User->check_perm( 'stats', 'view' ) )
 329          {    // Viewing aggregate + Permission to view stats for ALL blogs:
 330              $AdminUI->add_menu_entries(
 331                      'stats',
 332                      array(
 333                          'goals' => array(
 334                              'text' => T_('Goals'),
 335                              'href' => $dispatcher.'?ctrl=goals',
 336                              'entries' => array(
 337                                  'goals' => array(
 338                                      'text' => T_('Goals'),
 339                                      'href' => $dispatcher.'?ctrl=goals'
 340                                      ),
 341                                  'hits' => array(
 342                                      'text' => T_('Goal hits'),
 343                                      'href' => $dispatcher.'?ctrl=stats&amp;tab=goals&amp;tab3=hits&amp;blog=0'
 344                                      ),
 345                                  'stats' => array(
 346                                      'text' => T_('Stats'),
 347                                      'href' => $dispatcher.'?ctrl=goals&amp;tab3=stats'
 348                                      ),
 349                                  ),
 350                              ),
 351                          )
 352                  );
 353          }
 354      }
 355  }
 356  
 357  $sessions_Module = new sessions_Module();
 358  
 359  ?>

title

Description

title

Description

title

Description

title

title

Body