[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/modules/ -> mod_whosonline.php (source)

   1  <?php
   2  /**
   3  * @version $Id: mod_whosonline.php 2728 2006-03-09 14:01:19Z stingrey $
   4  * @package Joomla
   5  * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
   6  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
   7  * Joomla! is free software. This version may have been modified pursuant
   8  * to the GNU General Public License, and as distributed it includes or
   9  * is derivative of works licensed under the GNU General Public License or
  10  * other free or open source software licenses.
  11  * See COPYRIGHT.php for copyright notices and details.
  12  */
  13  
  14  // no direct access
  15  defined( '_VALID_MOS' ) or die( 'Restricted access' );
  16  
  17  $showmode     = $params->get( 'showmode', 0 );
  18  
  19  $output     = '';
  20  
  21  // show online count
  22  if ($showmode==0 || $showmode==2) {
  23      $query = "SELECT guest, usertype"
  24      . "\n FROM #__session"
  25      ;
  26      $database->setQuery( $query );
  27      $sessions = $database->loadObjectList();
  28  
  29      // calculate number of guests and members
  30      $user_array     = 0;
  31      $guest_array     = 0;
  32      foreach( $sessions as $session ) {        
  33          // if guest increase guest count by 1
  34          if ( $session->guest == 1 && !$session->usertype ) {
  35              $guest_array++;
  36          }
  37          // if member increase member count by 1
  38          if ( $session->guest == 0 ) {
  39              $user_array++;
  40          }
  41      }
  42      
  43      // check if any guest or member is on the site
  44      if ($guest_array != 0 || $user_array != 0) {
  45          $output .= _WE_HAVE;
  46              
  47          // guest count handling
  48          if ($guest_array == 1) {
  49          // 1 guest only
  50              $output .= sprintf( _GUEST_COUNT, $guest_array );
  51          } else if ($guest_array > 1) {
  52          // more than 1 guest
  53              $output .= sprintf( _GUESTS_COUNT, $guest_array );
  54          }
  55      
  56          // if there are guests and members online
  57          if ($guest_array != 0 && $user_array != 0) {
  58              $output .= _AND;
  59          }
  60              
  61          // member count handling
  62          if ($user_array == 1) {
  63          // 1 member only
  64              $output .= sprintf( _MEMBER_COUNT, $user_array );
  65          } else if ($user_array > 1) {
  66          // more than 1 member
  67              $output .= sprintf( _MEMBERS_COUNT, $user_array );
  68          }
  69          
  70          $output .= _ONLINE;
  71      }
  72  }
  73  
  74  // show online member names
  75  if ($showmode > 0) {
  76      $query = "SELECT DISTINCT a.username"
  77      ."\n FROM #__session AS a"
  78      ."\n WHERE a.guest = 0"
  79      ;
  80      $database->setQuery($query);
  81      $rows = $database->loadObjectList();
  82      
  83      if ( count( $rows ) ) {
  84          // output
  85          $output .= '<ul>';
  86          foreach($rows as $row) {
  87              $output .= '<li>';
  88              $output .= '<strong>';
  89              $output .= $row->username;
  90              $output .= '</strong>';
  91              $output .= '</li>';
  92          }
  93          $output .= '</ul>';
  94      }
  95  }
  96  
  97  echo $output;
  98  ?>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics