<?php
/**
 * @version $Id: user_list.php v2.0 $
 * @package PBDigg
 * @copyright Copyright (C) 2007 - 2008 PBDigg.com. All Rights Reserved.
 * @license PBDigg is free software and use is subject to license terms
 */

define('PB_CSCRIPT', 'user_list');
require_once('include/common.inc.php');

$seo = array('pagetitle' => $pb_seotitle,'keywords' => $pb_seokeywords,'description' => $u_message['user_list']);

$rs = $memberlist = $mult = '';
$rssurl = 'rss.php?action=index';

$pagesize = 20;
$rs = $DB->db_fetch_one_array("SELECT COUNT(*) num FROM {$db_prefix}members");
$totalRecords = (int)$rs['num'];
$page = !is_Page($page) ? 1 : $page;
$start_limit = ($page -1) * $pagesize;
$mult = multLink($page, $totalRecords, $_PBENV['PB_URL'].'user_list.php?', $pagesize);

$SQL = 'SELECT m.uid, m.username, m.regdate, mx.location, mx.signature, mx.avatar 
		FROM '.$db_prefix.'members m  
		LEFT JOIN '.$db_prefix.'memberexp mx 
		USING (uid) 
		ORDER BY m.regdate DESC 
		LIMIT '.$start_limit.', '.$pagesize;
$DB->db_query($SQL);
while ($rs = $DB->db_fetch_array())
{
	if (!$rs['avatar'])
	{
		$rs['avatar'] = $_PBENV['PB_URL'].'images/avatars/portrait/default.png';
	}
	elseif (substr($rs['avatar'], 0, 7) != 'http://')
	{
		$rs['avatar'] = $_PBENV['PB_URL'].'images/avatars/'.$rs['avatar'];
	}
	$rs['regdate'] = gdate($rs['postdate'], 'Y-m-d');
	switch ($rs['gender'])
	{
		case '0':
			$rs['gender_name'] = $u_message['male'];
			break;
		case '1':
			$rs['gender_name'] = $u_message['female'];
			break;
		default:
			$rs['gender_name'] = $u_message['secrecy'];
			break;
	}
	$memberlist[] = $rs;
}

$TPL->assign('mult_page', $mult);
$TPL->assign('memberlist', $memberlist);
$TPL->assign('customer', $customer);
$TPL->assign('seo', $seo);
$TPL->assign('rss_url', $_PBENV['PB_URL'].$rssurl);
unset($mult, $memberlist, $customer, $rs);
PBOutPut('user_list.html');
