<?
require "include/header.php";

dbconn();

//loggedinorreturn();

stdhead("Info");

begin_main_frame();

?>

<? begin_frame("Info");


$dt = gmtime() - 180;
$dt = sqlesc(get_date_time($dt));
$res = mysql_query("SELECT id, username, class, donated FROM users WHERE last_access >= $dt ORDER BY username") or print(mysql_error());
while ($arr = mysql_fetch_assoc($res))
{
  if ($activeusers) $activeusers .= ",\n";
  switch ($arr["class"])
  {
case UC_ADMINISTRATOR:
   $arr["username"] = "<font color=#FF0000>" . $arr["username"] . "</font>";
   break;
case UC_SYSOP:
   $arr["username"] = "<font color=#FF0000>" . $arr["username"] . "</font>";
   break;
case UC_MODERATOR:
   $arr["username"] = "<font color=#0000FF>" . $arr["username"] . "</font>";
   break;
  }
  $donator = $arr["donated"] > 0;
  if ($donator)
    $activeusers .= "<nobr>";
  if ($CURUSER)
    $activeusers .= "<a href=userdetails.php?id=" . $arr["id"] . "><b>" . $arr["username"] . "</b></a>";
  else
    $activeusers .= "<b>$arr[username]</b>";
  if ($donator)
    $activeusers .= "<img src=/pic/star.gif alt='Donated $$arr[donated]'></nobr>";
}
if (!$activeusers)
  $activeusers = "There have been no active users in the last 15 minutes.";

 print("<table width=300 border=1 cellspacing=0 cellpadding=5>\n");

 print("<tr><td class=colhead>Stats</td></tr>\n");

 $registered = number_format(get_row_count("users"));
$donated = number_format(get_row_count("users", "WHERE donor = 'yes'"));

 $a = @mysql_fetch_assoc(@mysql_query("SELECT id,username FROM users WHERE status='confirmed' ORDER BY id DESC LIMIT 1")) or die(mysql_error());
 if ($CURUSER)
 $latestuser = "<a href=userdetails.php?id=" . $a["id"] . ">" . $a["username"] . "</a>";
 else
 $latestuser = $a['username'];

 $totalonline = number_format(get_row_count("users", "WHERE UNIX_TIMESTAMP(" . get_dt_num() . ") - UNIX_TIMESTAMP(last_access) < 900"));

 $topiccount = mysql_query("select sum(topiccount) as topiccount from forums");
 $row1 = mysql_fetch_array($topiccount);
 $topiccount = $row1[topiccount];

 $postcount = mysql_query("select sum(postcount) as postcount from forums");
 $row2 = mysql_fetch_array($postcount);
 $postcount = $row2[postcount];

 print("<tr><td>
 &raquo;&nbsp;Our members have made " . $postcount . " posts in  " . $topiccount . " topics,<BR>
 &raquo;&nbsp;We have " . $registered . " users,<BR>
 &raquo;&nbsp;We have " . $donated . " donors,<BR>
 &raquo;&nbsp;Our latest member is " . $latestuser . ", <BR>
 &raquo;&nbsp;" . $totalonline . " Users online now.</td></tr>\n");

 print("</table>");



end_frame(); ?>

<p align=right><font size=1 color=#004E98><b>( GMT)</b></font></p>

<h2>Active users</h2>
<table width=100% border=1 cellspacing=0 cellpadding=10><tr><td class=text>
<?=$activeusers?>
</td></tr></table>



<?
end_main_frame();
stdfoot(); ?>