[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/modules/ -> mod_whosonline.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @author Mambo Foundation Inc see README.php
   5  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   6  * See COPYRIGHT.php for copyright notices and details.
   7  * @license GNU/GPL Version 2, see LICENSE.php
   8  *
   9  * Redistributions of files must retain the above copyright notice.
  10  *
  11  * Mambo is free software; you can redistribute it and/or
  12  * modify it under the terms of the GNU General Public License
  13  * as published by the Free Software Foundation; version 2 of the License.
  14  */
  15  
  16  /** ensure this file is being included by a parent file */
  17  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  18  
  19  $showmode = $params->get( 'showmode' );
  20  $moduleclass_sfx = $params->get( 'moduleclass_sfx' );
  21  
  22  $content="";
  23  
  24  if ($showmode==0 || $showmode==2) {
  25      $query1 = "SELECT count(session_id) as guest_online FROM #__session WHERE guest=1 AND (usertype is NULL OR usertype='')";
  26      $database->setQuery($query1);
  27      $guest_array = $database->loadResult();
  28  
  29      $query2 = "SELECT DISTINCT count(username) as user_online FROM #__session WHERE guest=0 AND usertype <> 'administrator' AND usertype <> 'superadministrator'";
  30      $database->setQuery($query2);
  31      $user_array = $database->loadResult();
  32  
  33      if ($guest_array<>0 && $user_array==0) {
  34          $content .= sprintf(Tn_( 'We have %d guest online', 'We have %d guests online', $guest_array), $guest_array);
  35      }
  36  
  37      if ($guest_array==0 && $user_array<>0) {
  38          $content .= sprintf(Tn_('We have %d member online', 'We have %d members online', $user_array), $user_array);
  39      }
  40  
  41      if ($guest_array<>0 && $user_array<>0) {
  42          $content .= sprintf(Tn_('We have %d guest online and ', 'We have %d guests online and ', $guest_array), $guest_array);
  43          $content .= sprintf(Tn_(' %d member online', ' %d members online', $user_array), $user_array);
  44      }
  45  }
  46  
  47  if ($showmode==1 || $showmode==2) {
  48      $query = "SELECT DISTINCT a.username"
  49      ."\n FROM #__session AS a"
  50      ."\n WHERE (a.guest=0)";
  51      $database->setQuery($query);
  52      $rows = $database->loadObjectList();
  53      if (is_array($rows)) {
  54          foreach($rows as $row) {
  55              $content .= "<ul>\n";
  56              $content .= "<li><strong>" . $row->username . "</strong></li>\n";
  57              $content .= "</ul>\n";
  58          }
  59      }
  60      if ($content == "") {
  61          echo T_( 'No Users Online') ."\n";
  62      }
  63  }
  64  ?>