Location: PHPKode > projects > Esvon Personals > esvon-personals/inc/blocks/block-Who_is_Online.php
<?php

// --------------------------------------------------------------------------
//
// Esvon Classifieds v.4.0
// Copyright(C), Esvon LTD, 2001-2010, All Rights Reserved.
// E-mail: hide@address.com
//
// All forms of reproduction, including, but not limited to, internet posting, 
// printing, e-mailing, faxing and recording are strictly prohibited.
// One license required per site running Esvon Classifieds. 
// To obtain a license for using Esvon Classifieds, please register at
// http://www.esvon.com/pg/products/p_classifieds/
//
// --------------------------------------------------------------------------

/*  Store user sessions data in database must be enabled in "General Setup"
 for "Guests online now" amount tracking */

// Amount of members and guests online now

function block_Who_is_Online(&$tpl){
  
  global $db;
  
  $v = array();

  $v['on_members'] = $db->one_data('SELECT COUNT(*) FROM '.TBL_USER_ON.' WHERE
    UNIX_TIMESTAMP(accessdate)>'.(HW_TIME-ONLINE_TIME));

  if(EN_DB_SESSION){
    $expires = HW_TIME + ini_get('session.gc_maxlifetime') - ONLINE_TIME;
    $v['on_total'] = $db->one_data('SELECT COUNT(*) FROM '.TBL_SESSION.' WHERE expires>'.$expires);
  }
  else $v['on_total'] = $v['on_members'];

  $v['on_guests'] = $v['on_total'] - $v['on_members'];
  if($v['on_guests'] < 0) $v['on_guests'] = 0;

  $v['on_username'] = (int)hwSessionGetVar('userid') ? hwSessionGetVar('username') : '{guest}';
  $v['EN_DB_SESSION'] = EN_DB_SESSION;

  $tpl->AddCell('b_Who_is_Online',$v);

}

?>
Return current item: Esvon Personals