<?php
    
/**
     *    Online Users List for Mambo portal
     *    Retrieving data from mySQL table
     *    19-12-2001
      *
     *    Copyright (C) 2000 - 2001 Emir Sakic
     *    Distributed under the terms of the GNU General Public License
     *    This software may be used without warranty provided and these statements are left intact.
     *    This source is available at http://www.superbosna.com/mambo_hacks
     *
     *    Mambo is Copyright (C) 2000-2001 Miro Construct Pty Ltd
     *    Source is available at http://sourceforge.net/projects/mambo
     *    Site Name: Mambo Open Source Edition Version 3.0.6
     *    File Name: online.php
     *    Developer: Emir Sakic - saka@hotmail.com
     *    Date: 19/12/2001
     *     Version #: 1.0.0
     *    Comments: This script displays list of online registrated users on your Mambo portal and forum.
     *            Just set the variables below, upload anywhere on the site with Mambo and execute.
     *            Demo can be viewed at http://www.superbosna.com/clanovi
    **/

/* SET YOUR VARIABLES HERE */
$db_host "localhost";                // database host
$db_user "username";                // database username
$db_pass "password";                // database password
$db_name "mambodb_name";            // mambo database name
$site_name "YourSite.Com";            // name of your site

/* NO CHANGES BELOW THIS LINE (unless you know what you are doing) */

?>

<html>
<head>
<title>OnLine users on <? echo $site_name?></title>
<style>
<!--
body { color: #000000; font: 7.5pt verdana; font-weight: none; text-decoration: none }
a:link { color: #000000; font-weight: none; text-decoration: underline; font-family: verdana; font-size: 7.5pt}
a:visited { color: #000000; font: 7.5pt verdana; font-weight: none; text-decoration: underline }
a:active { color: #000000; font: 7.5pt verdana; font-weight: none; text-decoration: underline }
a:hover { color: #999999; font-weight: none; font-family: verdana; font-size: 7.5pt; text-decoration: none }
td { color: #000000; font: 7.5pt verdana; font-weight: none; text-decoration: none; }
-->
</style>
</head>
<body>

<?
// Connecting, selecting database
$link mysql_connect($db_host$db_user$db_pass)
    or die(
"Could not connect");
//print "Connected successfully<br>";
mysql_select_db($db_name)
    or die(
"Could not select database");

// Performing SQL query
$query "SELECT * FROM session LIMIT 0, 10000";
$result mysql_query($query)
    or die(
"Query failed");

// Make sure that we recieved some data from our query
$num_of_rows mysql_num_rows ($result)
or die (
"The query: '$query' did not return any data");

// Printing results in HTML
print "<table width=100%>
    <tr bgcolor=#D3D3BC>
        <td align=center colspan=2>
            <b>OnLine users on $site_name</b>
        </td>
    </tr>\n"
;

print 
"\t<tr bgcolor=#EEEEE0>
        <td align=left>
            Script&nbsp;made&nbsp;by:&nbsp;<a href=\"http://www.sakic.org\" target=_blank>Saka</a>
        </td>
        <td align=right width=100%><b>Total OnLine: $num_of_rows </b>
        </td>
    </tr>
</table>\n\n"
;

print 
"<table width=100%>\n";
print 
"\t<tr bgcolor=#D3D3BC>\n";
print 
"\t\t<td align=center><b>#</b></td>\n";
print 
"\t\t<td align=center><b>Nick</b></td>\n";
print 
"\t</tr>\n";

$usercount 0//will count online users

// Use mysql_fetch_row to retrieve the results
for ($count 1$row mysql_fetch_row ($result); ++$count)
{

    if ((
$row[5] == "user") OR ($row[5] == "forum")) {
        
$usercount++;    //increment online users count
        
if ($row[5] == "forum") {
            print 
"\t<tr bgcolor=#F5F5EF><td align=right>$usercount.</td>\n\t\t<td align=center width=100%><b>$row[0]</b> - $row[5]</td>\n\t</tr>\n";
        } else {
            print 
"\t<tr bgcolor=#F5F5EF><td align=right>$usercount.</td>\n\t\t<td align=center width=100%><b>$row[0]</b></td>\n\t</tr>\n";
        }
    }
}

print 
"</table>\n";

// Closing connection
mysql_close($link);
?>

</body>
</html>