MyBB Community Forums

Full Version: Users Online Today...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
Hello..How do I make this? Exactly as in the Screenshot below.

[Image: test20ef.gif]
hello there,

open index.php

find

PHP Code:
eval("\$whosonline = \"".$templates->get("index_whosonline")."\";"); 

above it add

PHP Code:
    $todaycount 0;
    
$countinv 0;
    
$stime time()-(60*60*24);
����$query $db->query("SELECT u.* FROM ".TABLE_PREFIX."users u LEFT JOIN ".TABLE_PREFIX."usergroups g ON (g.gid=u.usergroup) WHERE u.lastactive > $stime ORDER BY u.lastactive DESC");
����$todaycomma '';
����$onlinetoday '';
����while($online $db->fetch_array($query))
����{
��������if($online['invisible'] != "yes" || $mybb->usergroup['canviewwolinvis'] == "yes")
��������{
������������if($online['invisible'] == "yes")
������������{
����������������$invisiblemark "*";
                
$countinv++;
������������}
������������else
������������
{
����������������$invisiblemark "";
������������}
            
$todaycount++;
������������$onlinetoday .= $todaycomma.formatname($online['username'], $online['usergroup'], $online['displaygroup']).$invisiblemark;
������������$todaycomma ', ';
��������}
����

then in Admin CP >Templates > Modify / delete > expand > index page templates > index_whosonline
modify it to have a new row, and use $onlinetoday to display usernames . use $todaycount to display the total, use $countinv to dispaly how many invisible
regards
What if I want a link to their profile from their names at there ?

and what if I want to have how many Guests?
xiaozhu Wrote:What if I want a link to their profile from their names at there ?
Replace the line
$onlinetoday .= $todaycomma.formatname($online['username'], $online['usergroup'], $online['displaygroup']).$invisiblemark;
with
$onlinetoday .= $todaycomma."<a href=\"member.php?action=profile&amp;uid=".$online['uid']."\">".formatname($online['username'], $online['usergroup'], $online['displaygroup']).$invisiblemark."</a>";
xiaozhu Wrote:and what if I want to have how many Guests?
Open the file index.php and search for
    eval("\$whosonline = \"".$templates->get("index_whosonline")."\";");
Above add:
    $num_visitors = $db->num_rows($db->query("SELECT * FROM ".TABLE_PREFIX."sessions WHERE time > ".$stime.""));
    if($num_visitors == "0")
    {
    $visitors_online_today = "";
    }
    else
    {
    $visitors_online_today = "We had ".$num_visitors." visitors in the last 24 hours";
    }
After that you can insert the variable $visitors_online_today into the template index_whosonline where you want to display the number of visitors.
Thxs alot
I am getting this error anyway...

Parse error: parse error, unexpected ';' in /home/habbo/public_html/index.php on line 140
Can you please post the lines 130 - 150 of your index.php?
hmm..maybe its here..
		$guestbit = $lang->online_guest_singular;
	}
	$lang->online_note = sprintf($lang->online_note, mynumberformat($onlinecount), $onlinebit, $mybb->settings['wolcutoffmins'], mynumberformat($membercount), $memberbit, mynumberformat($anoncount), $anonbit, mynumberformat($guestcount), $guestbit);
$todaycount = 0;
    $countinv = 0;
    $stime = time()-(60*60*24);
    $query = $db->query("SELECT u.* FROM ".TABLE_PREFIX."users u LEFT JOIN ".TABLE_PREFIX."usergroups g ON (g.gid=u.usergroup) WHERE u.lastactive > $stime ORDER BY u.lastactive DESC");
    $todaycomma = '';
    $onlinetoday = '';
    while($online = $db->fetch_array($query))
    {
        if($online['invisible'] != "yes" || $mybb->usergroup['canviewwolinvis'] == "yes")
        {
            if($online['invisible'] == "yes")
            {
                $invisiblemark = "*";
                $countinv++;
            }
            else
            {
                $invisiblemark = "";
            }
            $todaycount++;
            $onlinetoday .= $todaycomma.formatname($online['username'], $online['usergroup'], $online['displaygroup']).$invisiblemark;
            $todaycomma = ', ';
        }
    }
$num_visitors = $db->num_rows($db->query("SELECT * FROM ".TABLE_PREFIX."sessions WHERE time > ".$stime.""));
    if($num_visitors == "0")
    {
    $visitors_online_today = "";
    }
    else
    {
    $visitors_online_today = "We had ".$num_visitors." visitors in the last 24 hours";
    }
eval("\$whosonline = \"".$templates->get("index_whosonline")."\";");
ok but when i try to add the line to my portal nothing comes up.

http://www.jdmfloridascene.com/mybb/portal.php

here is what i have in my portal_whosonline
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td class="tborder">
<table border="0" cellspacing="$theme[borderwidth]" cellpadding="$theme[tablespace]" width="100%">
<tr>
<td class="thead"><strong>$lang->online</strong></td>
</tr>
<tr>
<td class="trow1">
<span class="smalltext">
$lang->online_users<br /><strong>&raquo;</strong> $lang->online_counts<br />$onlinemembers
</span>
</td>
</tr>
[color=red]<tr>
<td class="trow1">
<span class="smalltext">
$todaycount &nbsp Users Online Today ($todaycount Members, and $countinv &nbsp Invisible)
$onlinetoday
</span>
</td>
</tr>[/color]
</table>
</td></tr></table>
<br />

And here is the snip from the code that i entered in portal.php that was from originally from index.php

$todaycount = 0;
    $countinv = 0;
    $stime = time()-(60*60*24);
    $query = $db->query("SELECT u.* FROM ".TABLE_PREFIX."users u LEFT JOIN ".TABLE_PREFIX."usergroups g ON (g.gid=u.usergroup) WHERE u.lastactive > $stime ORDER BY u.lastactive DESC");
    $todaycomma = '';
    $onlinetoday = '';
    while($online = $db->fetch_array($query))
    {
        if($online['invisible'] != "yes" || $mybb->usergroup['canviewwolinvis'] == "yes")
        {
            if($online['invisible'] == "yes")
            {
                $invisiblemark = "*";
                $countinv++;
            }
            else
            {
                $invisiblemark = "";
            }
            $todaycount++;
            $onlinetoday .= $todaycomma."<a href=\"member.php?action=profile&amp;uid=".$online['uid']."\">".formatname($online['username'], $online['usergroup'], $online['displaygroup']).$invisiblemark."</a>";
            $todaycomma = ', ';
        }
    }
Quote:ok but when i try to add the line to my portal nothing comes up.

make sure you are putting the php code in portal.php above
 eval("\$whosonline = \"".$templates->get("portal_whosonline")."\";");


xiaozhu could you send the whole php file

thanks
Pages: 1 2 3 4 5