Mr. HillBilly |
04-30-2004 09:42 PM |
Here guys, try this.
Edit the lines at the top of the file so they look like this, be sure to include your own changes if you had made any.
PHP Code:
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array('holiday');
// get special data templates from the datastore
$specialtemplates = array(
'userstats',
'birthdaycache',
'maxloggedin',
'iconcache',
'eventcache',
'mailqueue'
);
// pre-cache templates used by all actions
$globaltemplates = array(
'FORUMHOME',
'forumhome_event',
'forumhome_lastpostby',
'forumhome_loggedinuser',
);
// pre-cache templates used by specific actions
$actiontemplates = array(
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once('./includes/functions_bigthree.php');
Add the lines below to your script near the bottom.
PHP Code:
// ### TODAY'S BIRTHDAYS #################################################
if ($vboptions['showbirthdays'])
{
$birthdaystore = unserialize($datastore['birthdaycache']);
if (!is_array($birthdaystore) OR ($today != $birthdaystore['day1'] AND $today != $birthdaystore['day2']))
{
// Need to update!
require_once('./includes/functions_databuild.php');
$birthdaystore = build_birthdays();
DEVDEBUG('Updated Birthdays');
}
switch($today)
{
case $birthdaystore['day1']:
$birthdays = $birthdaystore['users1'];
break;
case $birthdaystore['day2'];
$birthdays = $birthdaystore['users2'];
break;
}
// memory saving
unset($birthdaystore);
$show['birthdays'] = iif ($birthdays, true, false);
}
else
{
$show['birthdays'] = false;
}
// ### TODAY'S EVENTS #################################################
if ($vboptions['showevents'])
{
require_once('./includes/functions_calendar.php');
$future = gmdate('n-j-Y' , TIMENOW + 43200 + (86400 * ($vboptions['showevents'] - 1)));
$eventstore = unserialize($datastore['eventcache']);
if (!is_array($eventstore) OR $future != $eventstore['date'])
{
// Need to update!
require_once('./includes/functions_databuild.php');
$eventstore = build_events();
DEVDEBUG('Updated Events');
}
unset($eventstore['date']);
$events = array();
$eventcount = 0;
foreach ($eventstore AS $eventid => $eventinfo)
{
$offset = iif (!$eventinfo['utc'], $bbuserinfo['tzoffset'], $bbuserinfo['timezoneoffset']);
$eventinfo['dateline_from_user'] = $eventinfo['dateline_from'] + $offset * 3600;
$eventinfo['dateline_to_user'] = $eventinfo['dateline_to'] + $offset * 3600;
$gettime = TIMENOW - $vboptions['hourdiff'];
$iterations = 0;
if ($bbuserinfo['calendarpermissions']["$eventinfo[calendarid]"] & CANVIEWCALENDAR OR $eventinfo['holidayid'])
{
if ($eventinfo['userid'] == $bbuserinfo['userid'] OR $bbuserinfo['calendarpermissions']["$eventinfo[calendarid]"] & CANVIEWOTHERSEVENT OR $eventinfo['holidayid'])
{
while ($iterations < $vboptions['showevents'])
{
$todaydate = getdate($gettime);
if (cache_event_info($eventinfo, $todaydate['mon'], $todaydate['mday'], $todaydate['year']))
{
if (!$vboptions['showeventtype'])
{
$events["$eventinfo[eventid]"][] = $gettime;
}
else
{
$events["$gettime"][] = $eventinfo['eventid'];
}
$eventcount++;
}
$iterations++;
$gettime += 86400;
}
}
}
}
if (!empty($events))
{
ksort($events, SORT_NUMERIC);
foreach($events AS $index => $value)
{
$pastevent = 0;
$pastcount = 0;
unset($eventdates, $comma, $daysevents);
if (!$vboptions['showeventtype'])
{ // Group by Event // $index = $eventid
unset($day);
foreach($value AS $key => $dateline)
{
if (($dateline - 86400) == $pastevent AND !$eventinfo['holidayid'])
{
$pastevent = $dateline;
$pastcount++;
continue;
}
else
{
if ($pastcount)
{
$eventdates = construct_phrase($vbphrase['event_x_to_y'], $eventdates, vbdate($vboptions['dateformat'], $pastevent, false, true, false));
}
$pastcount = 0;
$pastevent = $dateline;
}
if (!$day)
{
$day = vbdate('Y-n-j', $dateline, false, false);
}
$eventdates .= $comma . vbdate($vboptions['dateformat'], $dateline, false, true, false);
$comma = ', ';
$eventinfo = $eventstore["$index"];
}
if ($pastcount)
{
$eventdates = construct_phrase($vbphrase['event_x_to_y'], $eventdates, vbdate($vboptions['dateformat'], $pastevent, false, true, false));
}
if ($eventinfo['holidayid'])
{
$callink = "<a href=\"calendar.php?$session[sessionurl]do=getinfo&day=$day\">" . $vbphrase['holiday_title_' . $eventinfo['varname']] . "</a>";
}
else
{
$callink = "<a href=\"calendar.php?$session[sessionurl]do=getinfo&day=$day&e=$eventinfo[eventid]&c=$eventinfo[calendarid]\">$eventinfo[title]</a>";
}
}
else
{ // Group by Date
$eventdate = vbdate($vboptions['dateformat'], $index, false, true, false);
$day = vbdate('Y-n-j', $index, false, false);
foreach($value AS $key => $eventid)
{
$eventinfo = $eventstore["$eventid"];
if ($eventinfo['holidayid'])
{
$daysevents .= $comma . "<a href=\"calendar.php?$session[sessionurl]do=getinfo&day=$day\">" . $vbphrase['holiday_title_' . $eventinfo['varname']] . "</a>";
}
else
{
$daysevents .= $comma . "<a href=\"calendar.php?$session[sessionurl]do=getinfo&day=$day&e=$eventinfo[eventid]&c=$eventinfo[calendarid]\">$eventinfo[title]</a>";
}
$comma = ', ';
}
}
eval('$upcomingevents .= "' . fetch_template('forumhome_event') . '";');
}
// memory saving
unset($events, $eventstore);
}
$show['upcomingevents'] = iif ($upcomingevents, true, false);
$show['todaysevents'] = iif ($vboptions['showevents'] == 1, true, false);
}
else
{
$show['upcomingevents'] = false;
}
// ### LOGGED IN USERS #################################################
$activeusers = '';
if ($vboptions['displayloggedin'])
{
$datecut = TIMENOW - $vboptions['cookietimeout'];
$numbervisible = 0;
$numberregistered = 0;
$numberguest = 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
ORDER BY " . iif($permissions['genericpermissions'] & CANSEEHIDDEN, 'invisible ASC, ') . "username ASC, lastactivity DESC
");
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,
'musername' => fetch_musername($bbuserinfo, 'joingroupid')
)
);
$numberregistered = 1;
$numbervisible = 1;
fetch_online_status($userinfos["$bbuserinfo[userid]"]);
$loggedin = $userinfos["$bbuserinfo[userid]"];
eval('$activeusers = ", ' . fetch_template('forumhome_loggedinuser') . '";');
}
else
{
$userinfos = array();
}
$inforum = array();
while ($loggedin = $DB_site->fetch_array($forumusers))
{
$userid = $loggedin['userid'];
if (!$userid)
{ // Guest
$numberguest++;
$inforum["$loggedin[inforum]"]++;
}
else if (empty($userinfos["$userid"]['lastactivity']) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
{
$userinfos["$userid"] = $loggedin;
$numberregistered++;
if ($userid != $bbuserinfo['userid'])
{
$inforum["$loggedin[inforum]"]++;
}
$loggedin['musername'] = fetch_musername($loggedin);
if (fetch_online_status($loggedin))
{
$numbervisible++;
eval('$activeusers .= ", ' . fetch_template('forumhome_loggedinuser') . '";');
}
}
}
// memory saving
unset($userinfos, $loggedin);
$activeusers = substr($activeusers , 2); // get rid of initial comma
$DB_site->free_result($loggedins);
$totalonline = $numberregistered + $numberguest;
$numberinvisible = $numberregistered - $numbervisible;
// ### MAX LOGGEDIN USERS ################################
$maxusers = unserialize($datastore['maxloggedin']);
if (intval($maxusers['maxonline']) <= $totalonline)
{
$maxusers['maxonline'] = $totalonline;
$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;
}
// ### BOARD STATISTICS #################################################
// get total threads & posts from the forumcache
$totalthreads = 0;
$totalposts = 0;
if (is_array($forumcache))
{
foreach ($forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);
// get total members and newest member from template
$userstats = unserialize($datastore['userstats']);
$numbermembers = vb_number_format($userstats['numbermembers']);
$newusername = $userstats['newusername'];
$newuserid = $userstats['newuserid'];
// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTA HERE... ###
Save your file and upload it.
Now for the template edits,
place the following code anywhere you want the Whos online to show.
HTML Code:
<!-- 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&day=$today&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 -->
|