Neutral Singh
09-01-2005, 04:10 AM
Hi
There used to be smart little Forum stats hack which enabled me to show some important forum stats like no. of members, posts, threads etc in the header template to be shown on each forum page. In vB3.0.7, i could do it simply by putting the following code in the phpinclude_start template and then call the variables in header template.
Now with the advent of vB3.5, phpinclude_start has been removed and global_start hook has taken its place. I tried to create a plugin by using global_start hook and putting exactly the same code (below) in that plugin but as expected it resulted in an error.
How can use the plugin system to show the information in the header template? I believe some minor changes in the following code would do the trick but my expertise in PHP are pretty novice. Please guide me.
Thanks.
// 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
// 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
There used to be smart little Forum stats hack which enabled me to show some important forum stats like no. of members, posts, threads etc in the header template to be shown on each forum page. In vB3.0.7, i could do it simply by putting the following code in the phpinclude_start template and then call the variables in header template.
Now with the advent of vB3.5, phpinclude_start has been removed and global_start hook has taken its place. I tried to create a plugin by using global_start hook and putting exactly the same code (below) in that plugin but as expected it resulted in an error.
How can use the plugin system to show the information in the header template? I believe some minor changes in the following code would do the trick but my expertise in PHP are pretty novice. Please guide me.
Thanks.
// 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
// 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