Version: 1.00, by cory_booth
Developer Last Online: Jun 2013
Category: vBulletin CMS Widgets -
Version: 4.0.2
Rating:
Released: 02-19-2010
Last Update: Never
Installs: 205
Re-useable Code Is in Beta Stage
No support by the author.
This is a simple widget to display some forum stats.
It would really like to see this combined with the Currently Online and Site Visitor's Widgets...
But until then, I am using this PHP Widget...
Feel free to use/hack/slash the code for your own needs...
Navigate to AdminCP -> CMS -> Widgets.
Create a PHP Type Widget and paste the below code.
PHP Code:
ob_start();
global $vbulletin, $db, $vbphrase;
//Begin Forum Stats
// 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
//End Forum Status
//SideBar - Begin forum Stats
$sb_stats='
<table width="100%" align="center"> <tr> <td class="" align="left"> <div class="smallfont"> <strong>Number of Members: </strong> '.$numbermembers.'<br /> <strong>Total Threads: </strong>'. $totalthreads.'<br /> <strong>Total Posts: </strong>'. $totalposts.'<br /> <strong>Currently Online: </strong>'. $totalonline.'<br /> <br /> <strong>Newest Member:</strong> <a href="'.$vboptions[bburl].'/member.php?u='.$newuserid.'"><b>'.$newusername.'</b></a> </td> </tr> </table>';
//SideBar = End forum Status
echo $sb_stats;
$output=ob_get_contents();
ob_end_clean();
I have implemented this widget on my site, but I seem to have a few issues.
1. The total number of members shown in the widget does not correspond with the total number shown on the forumhome page.
2. The newest member does not correspond with what is on my home page. Does VB4 nowonly show members that are "registered" and not just awaiting email confirmation?
3. The link to the newest member does not point to the forum directory, and clicking on it gives a "page not found" error. Instead, it points to member.php in my root.
Anyway help would sure be appreciated! Thanks in advance.
This widget is not working in my Forum as i am not using CMS, rather i want to use it in side bar of my vBulletin forum but its not working and showing as blank.
Let me know whats the correct code to display it in our forum widget side bar.
How can i edit this widget so that only the members who confirmed their email address show up in the forum stats (just like on the bottom of the forum itself?)
3. The link to the newest member does not point to the forum directory, and clicking on it gives a "page not found" error. Instead, it points to member.php in my root.
i found out how to direct it to the forums folder...it works for me now...here is all the code i have and its just like the first post with the direction edit and the time thing at the top too
ob_start(); global $vbulletin, $db, $vbphrase; //Begin Forum Stats // 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
//End Forum Status //SideBar - Begin forum Stats $sb_stats=' <table width="100%" align="center"> <tr> <td class="" align="left"> <div class="smallfont"> <strong>Number of Members: </strong> '.$numbermembers.'<br /> <strong>Total Threads: </strong>'. $totalthreads.'<br /> <strong>Total Posts: </strong>'. $totalposts.'<br /> <strong>Currently Online: </strong>'. $totalonline.'<br /> <br /> <strong>Newest Member:</strong> <a href="'.$vboptions[bburl].'/forums/member.php?u='.$newuserid.'-'.$newusername.'"><b>'.$newusername.'</b></a> </td> </tr> </table>'; //SideBar = End forum Status echo $sb_stats; $output=ob_get_contents(); ob_end_clean();
How can i edit this widget so that only the members who confirmed their email address show up in the forum stats (just like on the bottom of the forum itself?)