Back to vBulletin 3.0 Add-Ons

Live Forum Statistics in Header Template
Mod Version: 1.01, by Neutral Singh

This modification is in the archives.
vB Version: 3.0.9 Rating: (0 vote - 0 average) Installs: 1
Released: 02 Sep 2005 Last Update: 31 Oct 2005 Downloads: 6
Not Supported Template Edits  

Live Forum Statistics in Header Template
Should work in all vB 3.0.x series


I have absolutely no clue, who had originally written this bit of code as i only found this in a post somewhere, a long long times back (can't recollect). I would be more than glad to know the original writer of this useful code to give proper credit.

Requested by :
Myself [img]images/newsm/devious.gif[/img]

Context :
Searched through vb.org but could not find a similar plugin/hack for vB3.5/vB3.0.x. I wanted to show all vital forum stats like total posts, total threads, total members and newest member on each page of http://www.sikhphilosophy.net/ as well as vBa CMPS, in header template and this plugin performs exactly the same function.

What this hack does ?
Stores the desired information from your forum database into php variables and when called in 'header 'template, produces the desired results.

Utility :
Imagine... an unregistered/guest visits your website for the first time via a search engine link (95% of times its not the homepage that is found via a search engines link) and the first thing s/he notices is the forum header information and says wow!! this forum has got xxxx members, xxxxx threads, xxxxxx posts, why not get registered with this community and see what this forum has got in store for me. LOL!! quite true actually. [img]images/newsm/wink.gif[/img]

Demo : http://www.sikhphilosophy.net/

Any Screenshots : Demo is self-explanatory above.

Warning: This hack executes 5 queries per page.

Installation Instructions : (Also attached.)

Code:
Step by Step Instructions: 
1. In the 'header' template:
Find: (ususally at the end of the template file)
<!-- content table -->
$spacer_open
Add Above:
<!-- Forum Stats in Header Template -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	<td>
	  <div align="left">| Discussions: $totalthreads | Messages: $totalposts | Members: $numbermembers | Online: $totalonline  | Newest :
Code:
$newusername(Welcome!)
</span>
	 </td>
  </tr>
</table>
<!-- Forum Stats in Header Template -->
Ofcourse you can customise this code to suit your website setup. ;)
2. In phpinclude_start template add the following code at the end.
// forum stats start 
        $numbersmembers=$DB_site->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " . TABLE_PREFIX . "user"); 
        $numbermembers=number_format($numbersmembers['users']); 
        $countposts=$DB_site->query_first("SELECT COUNT(postid) AS posts, COUNT(threadid) AS threads FROM " . TABLE_PREFIX . "post"); 
        $totalposts=number_format($countposts['posts']); 
        $countthreads=$DB_site->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "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 " . TABLE_PREFIX . "session WHERE userid=0 AND lastactivity>$datecut"); 
        $headerusers=$DB_site->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_site->query_first("SELECT userid, username FROM " . TABLE_PREFIX . "user WHERE " . TABLE_PREFIX . "userid=$numbersmembers[max]"); 
        $newusername = $getnewestmember['username']; 
        $newuserid = $getnewestmember['userid']; 
// get newest member name and userid end


And you are done!!

Please dont forget to click Install

Enjoy !!

Download

This modification is archived and cannot be downloaded.

Similar Mods

Statistics Modifications Live Forum Statistics on All Pages in Forum Header vBulletin 3.6 Add-ons
Statistics Modifications Live Forum Statistics on All Pages in Forum Header vBulletin 3.7 Add-ons
Mini Mods Live Statistics Image 1.0.0 Light vBulletin 3.7 Add-ons
Live Forum Statistics on All Pages in Header vBulletin 3.5 Add-ons

vblts.ru supports vBulletin®, 2022-2024