PDA

View Full Version : blending 2 modules?


JohnBee
11-13-2004, 12:50 PM
I have been working hard on a total overhaul frontpage using vBadvance
so far I have been able to work through most of it thanks to some very
helpfull people at vBadvance.

I have come to a part where I would like to "combine" the stats and online
modules into 1 module to display

or...

display them side by side in one column wichever.

I have moved the php calls from the stats into the online module
and vice versa, obviously there are some references lost when I do
this because whichever module will miss data when merged.

Can anyone help me accomplish this?

Fargo
11-13-2004, 01:03 PM
This should help ya out:

http://www.vbadvanced.com/membersarea.php?do=viewmanual&productid=4&pageid=5

scroll down to "2 modules - 1 file" section.

Our Sponsors
 

JohnBee
11-13-2004, 01:54 PM
Wow that is exactly what I wanted to know! :D

I am such a moron for php coding though, so please tell me this.
is it possible... to merge both onlineusers.php and stats.php
without to many problems then call the single "newly merged" file from the
edit template section?

forgive my noobeness but if this is possible I would prefer to do it
this way since my aim is to get stats & whosonline together in the
same module.

thanks for your help

JohnBee
11-13-2004, 02:29 PM
Okay!

I did it, it aint pretty but it works :D

I copied and pasted snippets of the online.php and stats.php
together and generated a onlinestats.php file which I called
from my custom page.

it works but like I said its a patehtic hack job :cool:
heres a view of the work (for laughing purposes) please feel free to
comment on cleaning it up :rolleyes:

<?php
// ++=========================================================================++
// || vBadvanced CMPS 1.0.0 ||
// || © 2003-2004 vBadvanced.com & PlurPlanet, LLC - All Rights Reserved ||
// || This file may not be redistributed in whole or significant part. ||
// || http://vbadvanced.com ||
// ++ ========================================================================++

include_once('./includes/functions_forumlist.php');
cache_ordered_forums(1, 0, 0);
if (is_array($forumcache))
{
foreach ($forumcache AS $forum)
{
$nthreads += $forum['threadcount'];
$nposts += $forum['replycount'];
$totalthreads = number_format($nthreads);
$totalposts = number_format($nposts);
}
}

$topposter = $DB_site->query_first('SELECT username, posts, userid FROM ' . TABLE_PREFIX . 'user ORDER BY posts DESC LIMIT 1');
$userstats = unserialize($datastore['userstats']);
$numbermembers = number_format($userstats['numbermembers']);
$newusername = $userstats['newusername'];
$newuserid = $userstats['newuserid'];

$tdate = vbdate('Y-m-d', TIMENOW);
$birthdaystore = unserialize($datastore['birthdaycache']);
if (!is_array($birthdaystore) OR ($tdate != $birthdaystore['day1'] AND $tdate != $birthdaystore['day2']))
{
include_once('./includes/functions_databuild.php');
$birthdaystore = build_birthdays();
}
switch($tdate)
{
case $birthdaystore['day1']:
$birthdays = $birthdaystore['users1'];
break;

case $birthdaystore['day2'];
$birthdays = $birthdaystore['users2'];
break;
}
$birthdays = str_replace(array('member.php', ','), array($vboptions['bburl'] . '/member.php', '<br />'), $birthdays);

$doneusers = array();
$activeusers = '';

foreach ($modules AS $omods)
{
if ($omods['identifier'] == 'buddylist' AND in_array($omods['modid'], explode(',', $pages['modules'])))
{
$showbuddies = true;
$buddyid = $omods['modid'];
}
if ($omods['identifier'] == 'onlineusers' AND in_array($omods['modid'], explode(',', $pages['modules'])))
{
$showonline = true;
$onlineid = $omods['modid'];
}
}

unset($omods);

if ($showonline OR ($showbuddies AND trim($bbuserinfo['buddylist'])))
{
$getonline = $DB_site->query("
SELECT session.userid, username, usergroupid, (user.options & $_USEROPTIONS[invisible]) AS invisible
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user USING (userid)
WHERE session.lastactivity > " . (TIMENOW - $vboptions['cookietimeout']) . "
ORDER BY invisible ASC, username ASC
");

if ($bbuserinfo['userid'] AND $showonline)
{
$bbuser = array(
$bbuserinfo['userid'] => array(
'userid' => $bbuserinfo['userid'],
'username' => $bbuserinfo['username'],
'invisible' => $bbuserinfo['invisible'],
'musername' => fetch_musername($bbuserinfo)
)
);

$loggedin = $bbuser[$bbuserinfo['userid']];
if ($bbuserinfo['invisible'])
{
$loggedin['invisiblemark'] = '*';
}
eval('$activeusers = "' . fetch_template('forumhome_loggedinuser') . '";');
$doneusers[] = $bbuserinfo['userid'];
$numberregistered++;
}
if ($DB_site->num_rows($getonline))
{
while ($loggedin = $DB_site->fetch_array($getonline))
{
if (!$loggedin['userid'])
{
$numberguest++;
}
else
{
if (!in_array($loggedin['userid'], $doneusers))
{
$doneusers[] = $loggedin['userid'];
$numberregistered++;

$loggedin['musername'] = fetch_musername($loggedin);
$loggedin['invisiblemark'] = '';
$loggedin['buddymark'] = '';

if ($loggedin['invisible'])
{
if (($permissions['genericpermissions'] & CANSEEHIDDEN) OR $loggedin['userid'] == $bbuserinfo['userid'])
{
$loggedin['invisiblemark'] = '*';
}
else
{
$dontshow = 1;
}
}

$buddylist = array();
if (trim($bbuserinfo['buddylist']))
{
$buddylist = explode(' ', $bbuserinfo['buddylist']);
}

if (in_array($loggedin['userid'], $buddylist))
{
$loggedin['buddymark'] = '+';
if ($showbuddies AND !$dontshow)
{
$numberbuddy++;
$getbgrow = getrowcolor();
eval('$onlineusers .= "' . fetch_template('adv_portal_buddylistbits') . '";');
}
}

if ($showonline)
{
if (!$dontshow)
{
if ($activeusers)
{
$com = ', ';
}
eval('$activeusers .= "$com ' . fetch_template('forumhome_loggedinuser') . '";');
$activeusers = str_replace('"member.php', '"' . $vboptions['bburl'] . '/member.php', $activeusers);
}
}
}
}
}
}
}
$DB_site->free_result($getonline);
unset($loggedin);

if ($showbuddies)
{
if (!$numberbuddy)
{
$onlineusers = construct_phrase($vbphrase['no_x_online'], $vbphrase['buddies']);
}
eval('$home[$buddyid][\'content\'] = "' . fetch_template('adv_portal_buddylist') . '";');
}

if ($showonline)
{
if (!$activeusers)
{
$activeusers = construct_phrase($vbphrase['no_x_online'], $vbphrase['members']);
}

$totalonline = $numberregistered + $numberguest;
$numberregistered = number_format($numberregistered);
$numberguest = number_format($numberguest);

$maxusers = unserialize($datastore['maxloggedin']);
if ($maxusers['maxonline'] <= $totalonline)
{
$maxusers['maxonline'] = $totalonline;
$maxusers['maxonlinedate'] = TIMENOW;
$DB_site->query("UPDATE " . TABLE_PREFIX . "datastore SET data='" . addslashes(serialize($maxusers)) . "' WHERE title = 'maxloggedin'");
}

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

eval('$home[$onlineid][\'content\'] = "' . fetch_template('adv_portal_onlineusers') . '";');
}

unset($activeusers, $onlineusers, $doneusers,$userstats, $birthdays, $birthdaystore, $topposter);


?>
<?php
// ++=========================================================================++
// || vBadvanced CMPS 1.0.0 ||
// || © 2003-2004 vBadvanced.com & PlurPlanet, LLC - All Rights Reserved ||
// || This file may not be redistributed in whole or significant part. ||
// || http://vbadvanced.com ||
// ++ ========================================================================++

// ######################### Forum Stats #########################
include_once('./includes/functions_forumlist.php');
cache_ordered_forums(1, 0, 0);
if (is_array($forumcache))
{
foreach ($forumcache AS $forum)
{
$nthreads += $forum['threadcount'];
$nposts += $forum['replycount'];
$totalthreads = number_format($nthreads);
$totalposts = number_format($nposts);
}
}

$topposter = $DB_site->query_first('SELECT username, posts, userid FROM ' . TABLE_PREFIX . 'user ORDER BY posts DESC LIMIT 1');
$userstats = unserialize($datastore['userstats']);
$numbermembers = number_format($userstats['numbermembers']);
$newusername = $userstats['newusername'];
$newuserid = $userstats['newuserid'];

$tdate = vbdate('Y-m-d', TIMENOW);
$birthdaystore = unserialize($datastore['birthdaycache']);
if (!is_array($birthdaystore) OR ($tdate != $birthdaystore['day1'] AND $tdate != $birthdaystore['day2']))
{
include_once('./includes/functions_databuild.php');
$birthdaystore = build_birthdays();
}
switch($tdate)
{
case $birthdaystore['day1']:
$birthdays = $birthdaystore['users1'];
break;

case $birthdaystore['day2'];
$birthdays = $birthdaystore['users2'];
break;
}
$birthdays = str_replace(array('member.php', ','), array($vboptions['bburl'] . '/member.php', '<br />'), $birthdays);

eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_stats') . '";');

?>