Location: PHPKode > projects > Esvon Personals > esvon-personals/inc/pages/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/
//
// --------------------------------------------------------------------------

if(!defined('SITE_PATH')) die('Access Denied');

// define('ZIP_UF','v_255_8');

ShowOnline();

function ShowOnline(){
global $db;

  $whitelist = array(
    's_by' => array(
      'type' => 'alpha',
    ),
    'a_d' => array(
      'type' => 'option',
      'options' => array('asc', 'desc'),
    ),
    'off' => array(
      'type' => 'int',
    ),
  );
  
  $clean = esFilter($_GET, $whitelist);

  // nav stuff
  $hw_num = 20;
  if(!$clean['off'] || $_SERVER['REQUEST_METHOD']=='POST') $clean['off'] = 0;
  $num = $clean['off'] * $hw_num;

  $tpl_v = array();
  $tpl_v['num_rows'] = $db->one_data('SELECT COUNT(*) FROM '.TBL_USER_ON.' WHERE '.UNIX_TIMESTAMP(accessdate).'>'.(HW_TIME-ONLINE_TIME));
  $tpl_v['nav'] = GetNavigation($_SERVER['PHP_SELF'],$hw_num,10,$tpl_v['num_rows'],$clean['off'],'&page=online&s_by='.$clean['s_by']);

  $ql = 'SELECT u.* FROM '.TBL_USER_ON.' o,'.TBL_USER.' u WHERE o.id=u.id AND UNIX_TIMESTAMP(o.accessdate)>'.(HW_TIME-ONLINE_TIME);
  
/*  
  $ses_uid = (int)hwSessionGetVar('userid');
  include SITE_PATH.'modules/Zip_Search/hw_user_api.php';
  if($ses_uid) {
  	$user_zip = $db->one_data("SELECT ".ZIP_UF." FROM ".TBL_USER." WHERE id='$ses_uid'");
  	if(!empty($user_zip))$ql .= ZipSearchGetSQL($user_zip,100);
  }
*/

  $O_UFS = &Factory::singleton('FieldsSet', '{user_fields}');

  $s_by_field = '';

  if($clean['s_by']){
    $O_UFS->rewind();
    while($o_f = &$O_UFS->next()){
      if(!$o_f->ACTIVE) continue;
      if($o_f->ID==$clean['s_by']){
        $s_by_field = 'u.'.$o_f->DB_F;
        break;
      }
    }
  }

  
  if(!$s_by_field) { $clean['s_by'] = ''; $s_by_field = 'o.accessdate'; $clean['a_d'] = 'desc'; }
  elseif(!$clean['a_d']) $clean['a_d'] = 'asc';

  $ql .= " ORDER BY $s_by_field ".$clean['a_d']." LIMIT $num, $hw_num";

  $res = $db->query($ql);

  $tpl = new HawkTpl;
  $tpl->InitArray('row');

  while($a_User = mysql_fetch_assoc($res)){
    $v = $O_UFS->FillCustomFieldsArray($a_User, true);
    $O_UFS->AdjustCustomFields($v);
    $v['id'] = $a_User['id'];
    $tpl->AddCell('row', $v);
  }

  $tpl_v['href'] = strip_tags($_SERVER['QUERY_STRING']);
  if(isset($_GET['s_by'])){
    $tpl_v['href'] = preg_replace('/&s_by=[^&]*/','',$tpl_v['href']).'&s_by=';
    if(isset($_GET['a_d'])) $tpl_v['href'] = preg_replace('/&a_d=[^&]*/','',$tpl_v['href']);
  }
  else $tpl_v['href'].='&s_by=';
  $tpl_v['href'] = $_SERVER['PHP_SELF'].'?'.$tpl_v['href'];
  

  $buf = hwReadTpl(TPL_PATH.'online.htm');
  if($clean['s_by']) $buf = str_replace('##href##'.$clean['s_by'],'##href##'.$clean['s_by'].'&a_d='.($clean['a_d']=='desc' ? 'asc' : 'desc'),$buf);
  $tpl->setBuf($buf);
  $tpl->Parse('', $tpl_v, 1);

}

?>
Return current item: Esvon Personals