Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-06-2005, 09:38 PM
DarkWarriorXII DarkWarriorXII is offline
 
Join Date: Aug 2004
Location: New Jersey, USA
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Users online question

First off I'll say that I'm not the greatest at PHP and all that. Anyway, I was wondering how the forum home gets the current users online list to show up, and say how many users/guests are currently online? I ask this because I have a custom vB page in the same directory as my forum and I want to get that list of online users and the number of online people to show up (Currently Active Users:...), but I can't figure out how to do it. Any help would be appreciated.
Reply With Quote
  #2  
Old 10-12-2005, 11:16 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Open index.php, search for // ### LOGGED IN USERS #################################################
and then take a look at the Code block below, that should get you the idea of how to do it.
Reply With Quote
  #3  
Old 10-12-2005, 11:20 PM
DarkWarriorXII DarkWarriorXII is offline
 
Join Date: Aug 2004
Location: New Jersey, USA
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry but I can't figure it out. I'm not sure what to use, what not to use, how I should add it to my page, etc.
Reply With Quote
  #4  
Old 10-12-2005, 11:22 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's mainly just a copy & paste job ...
Reply With Quote
  #5  
Old 10-12-2005, 11:28 PM
DarkWarriorXII DarkWarriorXII is offline
 
Join Date: Aug 2004
Location: New Jersey, USA
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So basically just copy everything from:

// ### LOGGED IN USERS #################################################

to right before

// ### GET FORUMS & MODERATOR iCACHES ########################

and paste all of that into where I want the list to be displayed?
Reply With Quote
  #6  
Old 10-12-2005, 11:34 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yep. Then you can use $activeusers, $numberguests, $numberregistered, $numberinvisible, $totalonline, $recordusers, $recorddate, $recordtime.
Make sure that you have cached maxloggedin, otherweise you will corrupt this data.
PHP Code:
$specialtemplates = array('maxloggedin'); 
Or leave out the maxlogedin part completely.
Reply With Quote
  #7  
Old 10-12-2005, 11:52 PM
DarkWarriorXII DarkWarriorXII is offline
 
Join Date: Aug 2004
Location: New Jersey, USA
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well I'm confused. :disappointed: Here's my file as of right now:

Code:
<?php 
// ####################### SET PHP ENVIRONMENT ########################### 
error_reporting(E_ALL & ~E_NOTICE); 
// #################### DEFINE IMPORTANT CONSTANTS ####################### 
define('NO_REGISTER_GLOBALS', 1); 
define('THIS_SCRIPT', 'index'); // 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( 
	'online',
); 
// pre-cache templates used by all actions 
$globaltemplates = array( 
	'homepage',
	'online',
	'forumhome_loggedinuser',
	'headinclude',
	'forumhome',
	'maxloggedin',
	'wol_spiders',
); 
// pre-cache templates used by specific actions 
$actiontemplates = array( 
	'online',
); 
// ######################### REQUIRE BACK-END ############################ 
chdir('/home/dwxii/talkcamp.com/');
require('./global.php');
 
// ####################################################################### 
// ######################## START MAIN SCRIPT ############################ 
// ####################################################################### 
$navbits = array(); 
$navbits[$parent] = 'Talk Camp Homepage'; 
$navbits = construct_navbits($navbits); 
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('homepage') . '");'); 
eval('print_output("' . fetch_template('online') . '");'); 
 
// ### LOGGED IN USERS #################################################
$activeusers = '';
if ($vbulletin->options['displayloggedin'] AND !$show['search_engine'])
{
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$numbervisible = 0;
$numberregistered = 0;
$numberguest = 0;
$numberspiders = 0;
$forumusers = $db->query_read("
SELECT
user.username, (user.options & " . $vbulletin->bf_misc_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($vbulletin->options['displayloggedin'] == 1, "ORDER BY username ASC") . "
");
$spiders = $db->query_read("
SELECT user.username, session.useragent,user.userid,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
FROM " . TABLE_PREFIX . "session AS session
". iif($vbulletin->options['WOLguests'], " LEFT JOIN " . TABLE_PREFIX . "user AS user 
USING (userid) ", ", " . TABLE_PREFIX . "user AS user") ."
WHERE session.lastactivity > $datecut
". iif(!$vbulletin->options['WOLguests'], " AND session.userid = user.userid", "") 
."
ORDER BY session.userid
");		 
if ($vbulletin->userinfo['userid'])
{
// fakes the user being online for an initial page view of index.php
$vbulletin->userinfo['joingroupid'] = iif($vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['usergroupid']);
$userinfos = array
(
$vbulletin->userinfo['userid'] => array
(
	'userid' => $vbulletin->userinfo['userid'],
	'username' => $vbulletin->userinfo['username'],
	'invisible' => $vbulletin->userinfo['invisible'],
	'inforum' => 0,
	'lastactivity' => TIMENOW,
	'usergroupid' => $vbulletin->userinfo['usergroupid'],
	'displaygroupid' => $vbulletin->userinfo['displaygroupid'],
)
);
}
else
{
$userinfos = array();
}
$inforum = array();
while ($loggedin = $db->fetch_array($forumusers))
{
$userid = $loggedin['userid'];
if (!$userid)
{ // Guest
$numberguest++;
$inforum["$loggedin[inforum]"]++;
}
else if (empty($userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
{
$userinfos["$userid"] = $loggedin;
}
}
if (!$vbulletin->userinfo['userid'] AND $numberguest == 0)
{
$numberguest++; 
}
foreach ($userinfos AS $userid => $loggedin)
{
$numberregistered++;
if ($userid != $vbulletin->userinfo['userid'])
{
$inforum["$loggedin[inforum]"]++;
}
$loggedin['musername'] = fetch_musername($loggedin);
($hook = vBulletinHook::fetch_hook('forumhome_loggedinuser')) ? eval($hook) : false;
if (fetch_online_status($loggedin))
{
$numbervisible++;
eval('$activeusers .= ", ' . fetch_template('forumhome_loggedinuser') . '";');
}
}
// memory saving 
 
$spiderlist = array();
while ($spidercand = $db->fetch_array($spiders))
{
	$userid = $spidercand['userid'];
	if (!empty($vbulletin->wol_spiders))
	{
	 if (preg_match('#(' . $vbulletin->wol_spiders['spiderstring'] . ')#si', $spidercand['useragent'], $agent))
{
	$agent = strtolower($agent[1]);
	 $spider = $vbulletin->wol_spiders['agents']["$agent"];	 
					$key = $spider['name'];
	 if(array_key_exists($key,$spiderlist))
	{
		$spiderlist[$key] = $spiderlist[$key] + 1;
	}
	else 
	{
		 $spiderlist[$key] = 1;
 
	}
 
}
	}
}
while ($spidername = current($spiderlist)) 
{
	 if ($spidername > 1) {
	 $loggedin['musername'] = trim(key($spiderlist)) . "(" . $spidername.")";
	}
	else 
	{
	 $loggedin['musername'] = trim(key($spiderlist));
	}
	$loggedin['userid'] = 0;
	eval('$activeusers .= ", ' . fetch_template('forumhome_loggedinuser') . '";');
	$numberspiders = $numberspiders + $spidername;
	next($spiderlist);
}
 
unset($userinfos, $loggedin);
$activeusers = substr($activeusers, 2); // get rid of initial comma
$db->free_result($forumusers);
	$numberguest = $numberguest - $numberspiders;
$totalonline = $numberregistered + $numberguest + $numberspiders;
$numberinvisible = $numberregistered - $numbervisible;
}
?>
and if you need the 'homepage' template, here it is:

Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<!-- no cache headers -->
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Cache-Control" content="no-cache" />
<!-- end no cache headers -->
<title>TalkCamp.com Homepage</title>
$headinclude
</head>
<body>
$header
$navbar
 
<TABLE WIDTH="100%" valign="top"><TR><TD WIDTH="75%" valign="top">
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<thead>
<tr>
<td class="tcat" colspan="1">Message</td>
</tr>
		<tr>	
				<td class="thead">We're Under Construction, But Still Open!</td>
		</tr>
<tr>
<td class="alt1" colspan="1">
<p>Thanks for visiting TalkCamp.com! Right now, we're under construction, but check back soon for updates. In the mean time, feel free to <b><a href="register.php">register to our site</a></b> (for free) so you'll be set when we open.</p><p>Thanks,<br>Dave<br>Webmaster, Admin</p>
</td>
</tr>
</thead>
<thead>
<tr>
<td class="tcat" colspan="1">Welcome to Talk Camp!</td>
</tr>
<tr>
<td class="alt1" colspan="1">
<p>Welcome to TalkCamp.com! Talk Camp is an online community and website dedicated to those wonderful people who are known as camp counselors. We also serve other camp staff such as specialists, etc. It's the efforts of these people that allow thousands of kids around the world to have the best summers of their lives at camp! We are here to make your camp counseling experience even better. So please join us, become an active part of our community, and help spread the fun and joy of being a camp counselor!</p>
<center><b><a href="forum.php">Click here to go to the forums!</a></b><if condition="is_member_of($bbuserinfo, 1)"> or <br><b><a href="register.php">register</a></b> / <b><a href="login.php">log-in</a></b>!</if>
</td>
</tr>
</thead>
</table>
</TD><TD WIDTH="25%" valign="top">
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center" valign="top">
<thead valign="top">
<tr>
<td class="tcat" colspan="1">Mission Statement</td>
</tr>
<tr>
<td class="alt1" colspan="1">We are here to provide camp counselors and other camp staff with the best information available, as well as the best place to talk about their passion for camp counseling. We hope to make your camp experience the best it can possibly be!</td>
</tr>
</thead>
<thead>
<if condition="$vbulletin->options['externaljs']">
<!-- show latest active threads -->
<thead>
<tr>
<td class="tcat" colspan="1">
<a href="search.php?$session[sessionurl]do=getnew">Latest Active Threads</a>
</td>
</tr>
</thead>
<thead id="collapseobj_forumhome_external" style="$vbcollapse[collapseobj_forumhome_external]">
<tr>
 
<td class="alt1" width="100%">
 
<div class="smallfont">
<script type="text/javascript" src="external.php?type=js"></script> 
<script language="" type="text/javascript">
<!--
for (x = 0; x < 10; x++)
{
document.writeln("<img class=\"inlineimg\" src=\"$stylevar[imgdir_button]/lastpost.gif\" alt=\"\" border=\"0\" /> <a href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a> <span class=\"time\">($vbphrase[posted_by]: "+threads[x].poster+")</span><br />");
}
//-->
</script></div>
 
</td>
</tr>
</thead>
<!-- show latest active threads -->
</if>
</thead>
<thead>
<tr>
<td class="tcat" colspan="1">Users Online</td>
</tr>
<tr>
<td class="alt1" colspan="1">$online
</td>
</tr>
</thead>
</table>
</TD>
</TR>
</TABLE>
$footer
</body>
</html>
The 'online' template is just $activeusers because I have no idea.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:49 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06009 seconds
  • Memory Usage 2,260KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete