ericgtr |
01-09-2005 03:58 PM |
I see someone else has made a variation of this, I did also and I will share it here. Basically, I like the idea of it showing how many users are online today but not the names on my forumhome, I want that in a new page. The other modification for this does this but has never worked on my site, the numbers were different when you clicked on it. So I made it so this will work in a new page.
Create a new php page called online_today.php add all of the following code to it and save:
PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'online_today'); // change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(
);
// get special data templates from the datastore
$specialtemplates = array(
);
// pre-cache templates used by all actions
$globaltemplates = array(
'online_today',
);
// pre-cache templates used by specific actions
$actiontemplates = array(
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$navbits = array();
$navbits[$parent] = 'Online Today';
$now = TIMENOW ;
require_once('./includes/functions_misc.php');
$cutoff = vbmktime(0, 0, 0, vbdate('m', $now. false, false), vbdate('d', $now. false, false), vbdate('Y', $now. false, false));
//$cutoff = $now - 86400 ; // Uncomment this line if you don't have vB 3.0.3 and all users are showing.
$todaysusers = $DB_site->query("SELECT userid, lastactivity, options, username, opentag, closetag
FROM " . TABLE_PREFIX . "user as user
LEFT JOIN " . TABLE_PREFIX . "usergroup as usergroup ON(user.usergroupid = usergroup.usergroupid)
WHERE lastactivity > " .$cutoff. " ORDER BY username" );
$totaltoday = 0;
while ($today = $DB_site->fetch_array($todaysusers))
{
$today[visible] = 1 ;
$totaltoday += 1;
if ($today[options] & $_USEROPTIONS[invisible])
{
$today[visible] = 0 ;
if (($permissions['genericpermissions'] & CANSEEHIDDEN) OR $today['userid'] == $bbuserinfo['userid'])
{
$today[visible] = 2 ;
}
}
if ($today[visible])
{
$wrdate = vbdate($vboptions['timeformat'], $today['lastactivity']);
$whotoday .= "<a href='member.php?u=$today[userid]' title='$wrdate' >";
if ($today[visible] == 2)
{
$whotoday .= $today['opentag'].$today[username].$today['closetag']."</a>*, ";
}
else
{
$whotoday .= $today['opentag'].$today[username].$today['closetag']."</a>, ";
}
}
}
if ($whotoday)
{
$whotoday = substr($whotoday, 0, strlen($whotoday)-2);
}
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('online_today') . '");');
?>
Upload to your vb directory
Create a new template called online_today
PHP Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header
$navbar
<!-- Todays active users -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_todayusers')"><img id="collapseimg_forumhome_todayusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_todayusers].gif" alt="" border="0" /></a>
Total users that have visited today: $totaltoday
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_todayusers" style="$vbcollapse[collapseobj_forumhome_todayusers]">
<tr>
<td class="alt2"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="Users online today" border="0" /></td>
<td class="alt1" width="100%"><div class="smallfont">$whotoday</div></td>
</tr>
</tbody>
<!-- Todays active users -->
</if>
$footer
</body>
</html>
NOTE: This is a change to the existing modification.
Now in your FORUMHOME template find:
PHP Code:
<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 -->
<!-- Todays active users -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_todayusers')"><img id="collapseimg_forumhome_todayusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_todayusers].gif" alt="" border="0" /></a>
Total users that have visited today: $totaltoday
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_todayusers" style="$vbcollapse[collapseobj_forumhome_todayusers]">
<tr>
<td class="alt2"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="Users online today" border="0" /></td>
<td class="alt1" width="100%"><div class="smallfont">$whotoday</div></td>
</tr>
</tbody>
<!-- Todays active users -->
</if>
Change to:
PHP Code:
<if condition="$show['loggedinusers']">
<!-- Todays active users -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_todayusers')"><img id="collapseimg_forumhome_todayusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_todayusers].gif" alt="" border="0" /></a>
<a href="online_today.php?$session[sessionurl]">Total users that have visited today</a>: $totaltoday
</td>
</tr>
</tbody>
<!-- Todays active users -->
</if>
|