PDA

View Full Version : Who's online on top of forumhome and forumdisplay


ericgtr
02-06-2005, 10:00 PM
This was requested here https://vborg.vbsupport.ru/showthread.php?t=75809

What it does:
Moves the What's going on box from the bottom to the top on the index page. It also duplicates the Who's online portion and places it at the top of the forumdisplay.

In this template we are simply re-arranging the code to move it from the bottom to the top.

In the FORUMHOME template find everything between these two statements:

<!-- what's going on box -->

<!-- end what's going on box -->


Example:

<!-- what's going on box -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<thead>
<tr>
<td class="tcat" colspan="2">$vbphrase[whats_going_on]</td>
</tr>
</thead>
<if condition="$show['loggedinusers']">
<!-- logged-in users -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_activeusers].gif" alt="" border="0" /></a>
<a href="online.php?$session[sessionurl]">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_activeusers" style="$vbcollapse[collapseobj_forumhome_activeusers]">
<tr>
<td class="alt2"><a href="online.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="$vbphrase[view_whos_online]" border="0" /></a></td>
<td class="alt1" width="100%">
<div class="smallfont">
<div style="white-space: nowrap"><phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
<div>$activeusers</div>
</div>
</td>
</tr>
</tbody>
<!-- end logged-in users -->
</if>
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_stats')"><img id="collapseimg_forumhome_stats" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_stats].gif" alt="" border="0" /></a>
<phrase 1="$vboptions[bbtitle]">$vbphrase[x_statistics]</phrase>
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_stats" style="$vbcollapse[collapseobj_forumhome_stats]">
<tr>
<td class="alt2"><img src="$stylevar[imgdir_misc]/stats.gif" alt="<phrase 1="$vboptions[bbtitle]">$vbphrase[x_statistics]</phrase>" border="0" /></td>
<td class="alt1" width="100%">
<div class="smallfont">
<div>$vbphrase[threads]: $totalthreads, $vbphrase[posts]: $totalposts, $vbphrase[members]: $numbermembers</div>
<div><phrase 1="member.php?$session[sessionurl]u=$newuserid" 2="$newusername">$vbphrase[welcome_to_our_newest_member_x]</phrase></div>
</div>
</td>
</tr>
</tbody>
<if condition="$show['birthdays']">
<!-- today's birthdays -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_birthdays')"><img id="collapseimg_forumhome_birthdays" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_birthdays].gif" alt="" border="0" /></a>
$vbphrase[todays_birthdays]
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_birthdays" style="$vbcollapse[collapseobj_forumhome_birthdays]">
<tr>
<td class="alt2"><a href="calendar.php?$session[sessionurl]do=getday&amp;day=$today&amp;sb=1"><img src="$stylevar[imgdir_misc]/birthday.gif" alt="$vbphrase[view_birthdays]" border="0" /></a></td>
<td class="alt1" width="100%"><div class="smallfont">$birthdays</div></td>
</tr>
</tbody>
<!-- end today's birthdays -->
</if>
<if condition="$show['upcomingevents']">
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_events')"><img id="collapseimg_forumhome_events" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_events].gif" alt="" border="0" /></a>
<if condition="$show['todaysevents']">$vbphrase[todays_events]<else /><phrase 1="$vboptions[showevents]">$vbphrase[upcoming_events_for_the_next_x_days]</phrase></if>
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_events" style="$vbcollapse[collapseobj_forumhome_events]">
<tr>
<td class="alt2"><a href="calendar.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/calendar.gif" alt="$vbphrase[calendar]" border="0" /></a></td>
<td class="alt1" width="100%"><div class="smallfont">$upcomingevents</div></td>
</tr>
</tbody>
</if>
</table>
<br />
<!-- end what's going on box -->


Cut the above and past it just below this:


$header
$navbar


================================================== ========
================================================== ========

In your forumdisplay template find:


$header
$navbar


Add this just below:


<!-- logged-in users mod -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<thead>
<if condition="$show['loggedinusers']">
<!-- logged-in users -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_activeusers].gif" alt="" border="0" /></a>
<a href="online.php?$session[sessionurl]">$vbphrase[currently_active_users]</a>: $totalonline1 (<phrase 1="$numberregistered1" 2="$numberguest1">$vbphrase[x_members_and_y_guests]</phrase>)
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_activeusers" style="$vbcollapse[collapseobj_forumhome_activeusers]">
<tr>
<td class="alt2"><a href="online.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="$vbphrase[view_whos_online]" border="0" /></a></td>
<td class="alt1" width="100%">
<div class="smallfont">
<div style="white-space: nowrap"><phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
<div>$activeusers1</div>
</div>
</td>
</tr>
</tbody>
<!-- end logged-in users mod -->
</if>


================================================== ========
================================================== ========

In your forumdisplay.php find:


// ### BUILD FORUMS LIST #################################################


Add this just above:


// ### ALL LOGGED IN USERS #################################################
$activeusers1 = '';
if ($vboptions['displayloggedin'])
{
$datecut = TIMENOW - $vboptions['cookietimeout'];
$numbervisible = 0;
$numberregistered1 = 0;
$numberguest1 = 0;

$forumusers = $DB_site->query("
SELECT
user.username, (user.options & $_USEROPTIONS[invisible]) AS invisible, user.usergroupid,
session.userid, session.inforum, session.lastactivity,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
" . iif($vboptions['displayloggedin'] == 1, "ORDER BY username ASC") . "
");

if ($bbuserinfo['userid'])
{
// fakes the user being online for an initial page view of index.php
$bbuserinfo['joingroupid'] = iif($bbuserinfo['displaygroupid'], $bbuserinfo['displaygroupid'], $bbuserinfo['usergroupid']);
$userinfos = array
(
$bbuserinfo['userid'] => array
(
'userid' => $bbuserinfo['userid'],
'username' => $bbuserinfo['username'],
'invisible' => $bbuserinfo['invisible'],
'inforum' => 0,
'lastactivity' => TIMENOW,
'usergroupid' => $bbuserinfo['usergroupid'],
'displaygroupid' => $bbuserinfo['displaygroupid'],
)
);
}
else
{
$userinfos = array();
}
$inforum = array();

while ($loggedin = $DB_site->fetch_array($forumusers))
{
$userid = $loggedin['userid'];
if (!$userid)
{ // Guest
$numberguest1++;
$inforum["$loggedin[inforum]"]++;
}
else if (empty($userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
{
$userinfos["$userid"] = $loggedin;
}
}

foreach($userinfos AS $userid => $loggedin)
{
$numberregistered1++;
if ($userid != $bbuserinfo['userid'])
{
$inforum["$loggedin[inforum]"]++;
}
$loggedin['musername'] = fetch_musername($loggedin);

if (fetch_online_status($loggedin))
{
$numbervisible++;
eval('$activeusers1 .= ", ' . fetch_template('forumhome_loggedinuser') . '";');
}
}

// memory saving
unset($userinfos, $loggedin);

$activeusers1 = substr($activeusers1 , 2); // get rid of initial comma

$DB_site->free_result($loggedins);

$totalonline1 = $numberregistered1 + $numberguest1;
$numberinvisible = $numberregistered1 - $numbervisible;

// ### MAX LOGGEDIN USERS ################################
$maxusers = unserialize($datastore['maxloggedin']);
if (intval($maxusers['maxonline']) <= $totalonline1)
{
$maxusers['maxonline'] = $totalonline1;
$maxusers['maxonlinedate'] = TIMENOW;
build_datastore('maxloggedin', serialize($maxusers));
}

$recordusers = $maxusers['maxonline'];
$recorddate = vbdate($vboptions['dateformat'], $maxusers['maxonlinedate'], true);
$recordtime = vbdate($vboptions['timeformat'], $maxusers['maxonlinedate']);

$show['loggedinusers'] = true;
}
else
{
$show['loggedinusers'] = false;
}
// ### ALL LOGGED IN USERS #################################################


That's it! :)

Tekton
02-07-2005, 05:30 PM
Isn't this just sorta a template edit and not really anything to beta?

AN-net
02-07-2005, 05:40 PM
this is really already possible for forumdisplay by visting index.php?f=xx

ericgtr
02-07-2005, 06:32 PM
If you guys have an easier way, please post it I am sure the person who requested it would appreciate it. :)

@Tekton, 2 templates and 1 file

PamelaE
02-07-2005, 08:10 PM
That worked great. Thanks. :)

dndog
02-08-2005, 04:21 AM
This is just simple template work...hmm...

Lt. Dan
02-08-2005, 08:46 AM
I did the first part - modifying the template - and it seemed to work fine.

What does editing the forumdisplay.php file do?

ericgtr
02-08-2005, 12:22 PM
It places who's online (for the entire site) at the top of the forumdisplay.

ericgtr
02-08-2005, 12:44 PM
This is just simple template work...hmm...
2 Templates
1 File

All I did with this (obviously) is moved the what's going on box in the forumhome template from the bottom to the top.

Then I directly copied the code from index.php, renamed a few variables with a '1' at the end and added it to the forumdisplay.php file, adding the same functionality. I thought it might be useful to others so I posted it up as a mod, I don't get why this is questioned? Am I cheating somewhere?

Lt. Dan
02-10-2005, 08:48 AM
OK, I installed this and it works great BUT... Now the 'Most users ever online was...' no longer shows the single highest amount of users, but rather shows the current number of users and the current time.

How do I fix this?

For instance, I am currently the only person on my forum and this is what is displayed:

Most users ever online was 1, Today at 04:37 AM.

Before this hack it used to say 267 on (whatever the date was)

Any ideas?

Second problem...

The What's going on table only shows up on the Forum Home, not in the individual forums...

I'm using 3.0.6