vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Stats In Header (https://vborg.vbsupport.ru/showthread.php?t=68941)

Blindchild02 09-01-2004 02:53 AM

Stats In Header
 
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 02: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)

Code:

<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 04:10 PM

nope, didnt work. im sure something has to be put into phpinclude or something :|

Doc203 09-01-2004 09:12 PM

I don't think phpinclude, but you would probably have to edit global.php to make it work.

Zachery 09-01-2004 09:24 PM

Quote:

Originally Posted by Doc203
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 03: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 12:37 PM

Do this:

In template "phpinclude_start"

Add:
PHP Code:

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

HTML Code:

<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

HTML Code:

$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 03:11 PM

Ill give it a try, i hope they show up on all pages.

Blindchild02 09-02-2004 03:15 PM

Nice, those all work :) thanks.
but i still need...

Newest Member
Last Login
and
Avatar

Blindchild02 09-02-2004 09: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 10: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 10:48 PM

Thanks, you got AIM?

Logikos 09-02-2004 11:17 PM

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 01:08 AM

alrite, well, are u tryin to do this? if so i thank u

Logikos 09-03-2004 06: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 06:31 AM

well, alrite thanks

Symbian.info 09-05-2004 05:51 PM

Quote:

Originally Posted by Blindchild02
Ok.

Avatar (has to show on all pages)
Newest member

I use this:


PHP Code:

    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 06: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 07:00 PM

Quote:

Originally Posted by Blindchild02
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 07:25 PM

Quote:

Originally Posted by Symbian.info
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 10:48 AM

for newest member add this to phpinclude_start:
PHP Code:

// 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:
HTML Code:

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

Almotmaiz.Net 04-18-2005 08:36 AM

heloo FREIND ,

Step 1 : open : global.php
Step 2 : Find line 491)
Code:

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

Step 3 :Repalce with :
Code:

$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 08: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.
Quote:

Originally Posted by Almotmaiz.Net
heloo FREIND ,

Step 1 : open : global.php
Step 2 : Find line 491)
Code:

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

Step 3 :Repalce with :
Code:

$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 10:37 AM

LOL ...

Sjakie 05-08-2007 08:25 AM

Does this still work for 3.6.4? I can't seem to find the template: phpinclude_start

Logikos 05-08-2007 04:39 PM

This will not work for 3.6 versions. Instead, you need to use the global_start plugin.

Sjakie 05-12-2007 07:20 AM

Do I have to create the "golbal_start" plugin? I can't find it?

CycoreFredde 05-16-2008 09:55 AM

I want to do this aswell!

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

Marco van Herwaarden 05-16-2008 11:45 AM

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 07:13 AM

Displaying Avatar in Header Plugin:

Hook Location: global_start
Code:
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:
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 11:06 AM

where do i post this.. what page template. is there a template named phpinclude_start?




Quote:

Originally Posted by Ken Iovino (Post 549024)
Do this:

In template "phpinclude_start"

Add:
PHP Code:

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

HTML Code:

<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

HTML Code:

$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 06:46 AM

Read my last post on page 2. phpinclude_start is no longer a valid hook, you must use another.


All times are GMT. The time now is 03:21 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02737 seconds
  • Memory Usage 1,888KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (5)bbcode_html_printable
  • (4)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (32)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete