<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
//v1.6 www.exoops.info 2006/03 
// $Id: online.php,v 1.5 2003/03/19 07:02:18 half-dead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: The Xoops Project
// Author Website : http://www.xoops.org
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
include_once("../../../mainfile.php");
xoops_header();
$isadmin = 0;
echo "
<table width='100%'>
<tr class='bg2'><td colspan='2' align='center'><b><u>"._WHOSONLINE."</u></b></td></tr>
<tr><td colspan='2'>&nbsp;</td></tr>";
if ($xoopsUser) {
	if ($xoopsUser->isAdmin()) {
		$sql = "SELECT uid, username, ip FROM ".$db->prefix("lastseen")." WHERE online=1 ORDER BY time DESC";
		$isadmin = 1;
		} else {
			$sql = "SELECT uid, username FROM ".$db->prefix("lastseen")." WHERE uid>0 AND online=1 ORDER BY time DESC";
		}
	} else {
		$sql = "SELECT uid, username FROM ".$db->prefix("lastseen")." WHERE uid>0 AND online=1 ORDER BY time DESC";
	}
$result = $db->query($sql);
if (!$db->getRowsNum($result)) {
	echo "<tr class='bg3'><td colspan='2'>"._NOUSRONLINE."</td></tr>";
	} else {
		if ($isadmin == 1) {
			while ( list($uid, $username, $ip) = $db->fetchRow($result) ) {
				echo "<tr class='bg3'><td>";
				if ($uid > 0) {
					echo "<a href='javascript:window.opener.location=\"".XOOPS_URL."/userinfo.php?uid=".$uid."\";window.close();'>$username</a>";
					} else {
						echo $bcoosConfig['anonymous'];
					}
			echo "</td><td><a href='http://www.samspade.org/t/lookat?a=$ip' target='_blank'>$ip</a></td></tr>";
			}
		} else {
			while ( list($uid, $username) = $db->fetchRow($result) ) {
				echo "<tr class='bg3'><td colspan='2'><a href='javascript:window.opener.location=\"".XOOPS_URL."/userinfo.php?uid=".$uid."\";window.close();'>$username</a></td></tr>";
			}
		}
	}
echo "<tr><td colspan='2' align='center'><br /><input value='"._CLOSE."' type='button' class='button' onclick='javascript:window.close();' /></td></tr></table>";
xoops_footer(0);
?>
