PDA

View Full Version : Stats In Header


Blindchild02
09-01-2004, 03:53 AM
Threads: X
Posts: X
Members: X
Welcome to our newest member, X
Last Visit: X

and i would also need to know how to get
Username
Avatar
Login/Logout
Total Users Online (like in the "What's Going On?" Box)

i need this info, to show up in the header, and show up on ALL the pages...

please, thanks to anyone who helps!

Doc203
09-01-2004, 03:43 PM
I think that you would have to add this to your header template (This is code from the forumhome template that shows your stats)

<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>

Blindchild02
09-01-2004, 05:10 PM
nope, didnt work. im sure something has to be put into phpinclude or something :|

Doc203
09-01-2004, 10:12 PM
I don't think phpinclude, but you would probably have to edit global.php to make it work.

Zachery
09-01-2004, 10:24 PM
I don't think phpinclude, but you would probably have to edit global.php to make it work.
You need to edit global.php and init.php to get the stats in the header :)

I am not sure of the edits exactly

Blindchild02
09-02-2004, 04:08 AM
Well, i need to know how to do that if any1 knows please help!

and i also edited the 1st post

Logikos
09-02-2004, 01:37 PM
Do this:

In template "phpinclude_start"

Add:

// forum stats start
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=number_format($countposts['posts']);
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=number_format($countthreads['threads']);
// forum stats end

// total online start
$datecut = TIMENOW - $vboptions['cookietimeout'];
$headerguests=$DB_site->query_first("SELECT COUNT(*) AS count FROM session WHERE userid=0 AND lastactivity>$datecut");
$headerusers=$DB_site->query_first("SELECT COUNT(DISTINCT(userid)) AS count FROM session WHERE session.userid>0 AND session.lastactivity>$datecut");
$headerguests=$headerguests[count];
$headerusers=$headerusers[count];
$totalonline=$headerguests+$headerusers;
// total online end


Then use $numbermembers, $totalposts, $totalthreads, $totalonline in the header template for the Total Number of post, threads, members, and total number of who is online.

As for the login/logout. Do this in the header template:


<if condition="$bbuserinfo['userid']">
<a href="login.php?$session[sessionurl]do=logout" onclick="return log_out()">Logout</a>
<else />
<!-- login form -->
<form action="login.php" method="post" onsubmit="md5hash(vb_login_password,vb_login_md5password,vb_ login_md5password_utf)">
<script type="text/javascript" src="clientscript/vbulletin_md5.js"></script>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" valign="bottom">
<tr>
<td class="smallfont">User:</td>
<td><input type="text" class="button" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="1" value="$vbphrase[username]" onfocus="if (this.value == '$vbphrase[username]') this.value = '';" /></td>
<td class="smallfont" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="3" id="cb_cookieuser_navbar" accesskey="c" checked="checked" />$vbphrase[remember_me]</label></td>
</tr>
<tr>
<td class="smallfont">Pass:</td>
<td><input type="password" class="button" name="vb_login_password" size="10" accesskey="p" tabindex="2" /></td>
<td><input type="submit" class="button" value="$vbphrase[log_in]" tabindex="4" title="$vbphrase[enter_username_to_login_or_register]" accesskey="s" /></td>
</tr>
</table>
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="forceredirect" value="1" />
<input type="hidden" name="vb_login_md5password" />
<input type="hidden" name="vb_login_md5password_utf" />
</form>
<!-- / login form -->
</if>


To show the username. Add this in the header template


$bbuserinfo[username]


As for the avatar, i would have to look into that. But there is most of everything you need. No need to hack files.

Blindchild02
09-02-2004, 04:11 PM
Ill give it a try, i hope they show up on all pages.

Blindchild02
09-02-2004, 04:15 PM
Nice, those all work :) thanks.
but i still need...

Newest Member
Last Login
and
Avatar

Blindchild02
09-02-2004, 10:49 PM
Ok.

so i got, last login in the head.

now i still need

Avatar (has to show on all pages)
Newest member

Logikos
09-02-2004, 11:37 PM
I'll see what i can do, im in the middle of prepearing for hurrican frances so i might not be online for a few..

Blindchild02
09-02-2004, 11:48 PM
Thanks, you got AIM?

Logikos
09-03-2004, 12:17 AM
Yes, but its only for personal friends, and family. Not for support on hacks, ect.. Best way to get ahold of me is here, or www.initialz.com

Blindchild02
09-03-2004, 02:08 AM
alrite, well, are u tryin to do this? if so i thank u

Logikos
09-03-2004, 07:13 AM
Sorry man, i just don't have the time at this moment. I have a huge hurrican about 12 hours away from me. I prolly start to do it till monday.

Blindchild02
09-03-2004, 07:31 AM
well, alrite thanks

Symbian.info
09-05-2004, 06:51 PM
Ok.

Avatar (has to show on all pages)
Newest member

I use this:


require_once('./includes/functions_user.php');
$avatarurl = fetch_avatar_url($bbuserinfo['userid']);
if (!$avatarurl)
{
$avatarurl = $stylevar['imgdir_misc'] . '/noavatar.gif';
}
else
{
$avatarurl = $vboptions['bburl'] . '/' . $avatarurl;
}

$userstats = unserialize($datastore['userstats']);
$newusername = $userstats['newusername'];

$avatarurl=Avatar
$newusername = new user

Blindchild02
09-05-2004, 07:30 PM
do i put that in phpinclude_start?

ok, well i got avatar already, so i dont need the avatar part,
i need newest member in header, and it has to show on all pages.

Symbian.info
09-05-2004, 08:00 PM
do i put that in phpinclude_start?

ok, well i got avatar already, so i dont need the avatar part,
i need newest member in header, and it has to show on all pages.
Can be, I use Advanced portal.. so did it put in one of he modules.. But phpinclude_start wil work also fine

Blindchild02
09-05-2004, 08:25 PM
Can be, I use Advanced portal.. so did it put in one of he modules.. But phpinclude_start wil work also fine
it didnt work for all pages for Newest User

Cyphrix
09-07-2004, 11:48 AM
for newest member add this to phpinclude_start:

// get newest member name and userid start
$getnewestmember=$DB_site->query_first("SELECT userid, username FROM user WHERE userid=$numbersmembers[max]");
$newusername = $getnewestmember['username'];
$newuserid = $getnewestmember['userid'];
// get newest member name and userid end

then in the header use:

<a href="member.php?u=$newuserid">$newusername</a>

Almotmaiz.Net
04-18-2005, 09:36 AM
heloo FREIND ,

Step 1 : open : global.php
Step 2 : Find line 491)
eval('$header = "' . fetch_template('header') . '";');


Step 3 :Repalce with :
$mem=$DB_site->query_first("SELECT COUNT(*) AS users FROM " . TABLE_PREFIX . "user");

$thr=$DB_site->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread");

$post=$DB_site->query_first("SELECT COUNT(*) AS posts FROM " . TABLE_PREFIX . "post");

$line=$DB_site->query_first("SELECT COUNT(*) AS ond FROM " . TABLE_PREFIX . "session");

$getnewestusers=$DB_site->query_first("SELECT userid,username FROM " . TABLE_PREFIX . "user order by userid DESC limit 1");

$newusername=$getnewestusers['username'];

$newuserid=$getnewestusers['userid'];

eval('$header = "' . fetch_template('header') . '";');




Step 4:
threads : $thr[threads]
Posts : $post[posts]
members : $mem[users]
new member : $newusername
finish

Marco van Herwaarden
04-18-2005, 09:55 AM
Was this a reply to someones question? This is a very old thread, and the changes you suggest add more queries then needed to the page.heloo FREIND ,

Step 1 : open : global.php
Step 2 : Find line 491)
eval('$header = "' . fetch_template('header') . '";');


Step 3 :Repalce with :
$mem=$DB_site->query_first("SELECT COUNT(*) AS users FROM " . TABLE_PREFIX . "user");

$thr=$DB_site->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread");

$post=$DB_site->query_first("SELECT COUNT(*) AS posts FROM " . TABLE_PREFIX . "post");

$line=$DB_site->query_first("SELECT COUNT(*) AS ond FROM " . TABLE_PREFIX . "session");

$getnewestusers=$DB_site->query_first("SELECT userid,username FROM " . TABLE_PREFIX . "user order by userid DESC limit 1");

$newusername=$getnewestusers['username'];

$newuserid=$getnewestusers['userid'];

eval('$header = "' . fetch_template('header') . '";');




Step 4:
threads : $thr[threads]
Posts : $post[posts]
members : $mem[users]
new member : $newusername
finish

Princeton
04-18-2005, 11:37 AM
LOL ...

Sjakie
05-08-2007, 09:25 AM
Does this still work for 3.6.4? I can't seem to find the template: phpinclude_start

Logikos
05-08-2007, 05:39 PM
This will not work for 3.6 versions. Instead, you need to use the global_start plugin.

Sjakie
05-12-2007, 08:20 AM
Do I have to create the "golbal_start" plugin? I can't find it?

CycoreFredde
05-16-2008, 10:55 AM
I want to do this aswell!

I'm using 3.7, would appreciate som help here :-)

Marco van Herwaarden
05-16-2008, 12:45 PM
This thread is 4 years old, and contains mostly outdated information.

I suggest you search for a more recent thread or create a new one.

GameWizard
05-17-2008, 08:13 AM
Displaying Avatar in Header Plugin:

Hook Location: global_start
Code:
if ($vbulletin->userinfo['userid'])
{
require_once('./includes/functions_user.php'); //make sure we have the function we need
$header_avatar = fetch_avatar_url($vbulletin->userinfo['userid']);
if (!is_array($header_avatar))
{
$header_avatar[] = $vbulletin->options['bburl'] . "/images/misc/unknown.gif";
}
}Then place $header_avatar where you'd like the users avatar to appear. Mind you the /images/misc/unknown.gif is the location of the image if the user does not have an avatar.
---------
Showing user stats in the header Plugin:

Hook Location: global_start
Code:
// forum stats start
$numbersmembers = $db->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " . TABLE_PREFIX . "user");
$numbermembers = number_format($numbersmembers['users']);
$counter = $db->query_first("SELECT COUNT(postid) AS posts, COUNT(threadid) AS threads FROM " . TABLE_PREFIX . "post");
$totalposts=number_format($counter['posts']);
$countthreads = $db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread");
$totalthreads=number_format($countthreads['threads']);
// forum stats end

// total online start
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$headerguests=$db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "session WHERE userid=0 AND lastactivity>$datecut");
$headerusers=$db->query_first("SELECT COUNT(DISTINCT(userid)) AS count FROM " . TABLE_PREFIX . "session WHERE " . TABLE_PREFIX . "session.userid>0 AND " . TABLE_PREFIX . "session.lastactivity>$datecut");
$headerguests=$headerguests[count];
$headerusers=$headerusers[count];
$totalonline=$headerguests+$headerusers;
// total online end

// get newest member name and userid start
$getnewestmember=$db->query_first("SELECT userid, username FROM " . TABLE_PREFIX . "user WHERE userid=$numbersmembers[max]");
$newusername = $getnewestmember['username'];
$newuserid = $getnewestmember['userid'];
// get newest member name and userid end
Use the following variables:
$totalonline = Total Users Online
$numbermembers = Total Members Registered

Unfortunately I don't have any other variables, so you'll need to find code for the other ones you'd like to display.

carteretpeople
05-22-2008, 12:06 PM
where do i post this.. what page template. is there a template named phpinclude_start?




Do this:

In template "phpinclude_start"

Add:

// forum stats start
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=number_format($countposts['posts']);
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=number_format($countthreads['threads']);
// forum stats end

// total online start
$datecut = TIMENOW - $vboptions['cookietimeout'];
$headerguests=$DB_site->query_first("SELECT COUNT(*) AS count FROM session WHERE userid=0 AND lastactivity>$datecut");
$headerusers=$DB_site->query_first("SELECT COUNT(DISTINCT(userid)) AS count FROM session WHERE session.userid>0 AND session.lastactivity>$datecut");
$headerguests=$headerguests[count];
$headerusers=$headerusers[count];
$totalonline=$headerguests+$headerusers;
// total online end


Then use $numbermembers, $totalposts, $totalthreads, $totalonline in the header template for the Total Number of post, threads, members, and total number of who is online.

As for the login/logout. Do this in the header template:


<if condition="$bbuserinfo['userid']">
<a href="login.php?$session[sessionurl]do=logout" onclick="return log_out()">Logout</a>
<else />
<!-- login form -->
<form action="login.php" method="post" onsubmit="md5hash(vb_login_password,vb_login_md5password,vb_ login_md5password_utf)">
<script type="text/javascript" src="clientscript/vbulletin_md5.js"></script>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" valign="bottom">
<tr>
<td class="smallfont">User:</td>
<td><input type="text" class="button" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="1" value="$vbphrase[username]" onfocus="if (this.value == '$vbphrase[username]') this.value = '';" /></td>
<td class="smallfont" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="3" id="cb_cookieuser_navbar" accesskey="c" checked="checked" />$vbphrase[remember_me]</label></td>
</tr>
<tr>
<td class="smallfont">Pass:</td>
<td><input type="password" class="button" name="vb_login_password" size="10" accesskey="p" tabindex="2" /></td>
<td><input type="submit" class="button" value="$vbphrase[log_in]" tabindex="4" title="$vbphrase[enter_username_to_login_or_register]" accesskey="s" /></td>
</tr>
</table>
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="forceredirect" value="1" />
<input type="hidden" name="vb_login_md5password" />
<input type="hidden" name="vb_login_md5password_utf" />
</form>
<!-- / login form -->
</if>


To show the username. Add this in the header template


$bbuserinfo[username]


As for the avatar, i would have to look into that. But there is most of everything you need. No need to hack files.

GameWizard
05-23-2008, 07:46 AM
Read my last post on page 2. phpinclude_start is no longer a valid hook, you must use another.