Topic: PunBB and BBClone

BBClone is a PHP statistics system. While it isn't lightweight like PunBB, overall it is very high quality. Anyway, I use it to get more detailed statistics on visits to my forums. To use it with your forums, download and install it, then insert the following code in a file such as header.php (I have it below the <title> tags):

// Edits to use BBclone
define("_BBC_PAGE_NAME", $page_title);
define("_BBCLONE_DIR", "bbclone/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);

Be sure that it's between <?php and ?>. Change "bbclone/" on the second line with respect to where BBClone is installed on your server.

That's simply the code have BBClone start logging visits; I'll post how to use it to add some extra stats to your index page later on.

Looking for a certain modification for your forum? Please take a look here before posting.

2 (edited by pogenwurst 2005-09-03 19:20)

Re: PunBB and BBClone

Adding extra statistics to your forum via BBClone in index.php (to see how they look, click the link in my sig and scroll to the bottom - EDIT: I just upgraded to 1.2.7 and am re-modding everything, so the statistics may or may not show up!):

Find (around line 184):

while ($pun_user_online = $db->fetch_assoc($result))
        {
                if ($pun_user_online['user_id'] > 1)
                        $users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
                else
                        ++$num_guests;
        }

After, add

// Fetch BBlone Stats
require("bbclone/var/access.php");
$totalvisits   = $access["stat"]["totalvisits"];
$totalcount    = $access["stat"]["totalcount"];
$visitorsmonth = $access["time"]["month"][date("n")-1];
$visitorstoday = $access["time"]["wday"][date("w")];

Change the second line with respect to where BBClone is installed.

Then find (it should be right after what you just pasted):

$num_users = count($users);
echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";

Replace it with:

$num_users = count($users);
echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd><dd>Total Hits : <strong>'.$totalvisits.'</strong></dd><dd>Total Unique Visits: <strong>'.$totalcount.'</strong></dd><dd>Total Visits This Month: <strong>'.$visitorsmonth.'</strong></dd><dd>Total Visits Today: <strong>'.$visitorstoday.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";

Go to the BBClone website's documentation if you want to experiment with adding other stats. Good luck!

BTW, if you use Google's Blogger, I wrote a weblog post on using BBClone with Blogger.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: PunBB and BBClone

This was really useful. I had to made a minor tweak to the bbclone logging, since my page_title was excessively long and getting truncated in the bbclone display. This will use the $page_title as a last resort, otherwise it will use the current forum name or the current forum with current topic.

// Edits to use BBclone
if (!empty($cur_forum['forum_name']))
    $bbclone_page_title = $cur_forum['forum_name'];
else if (!empty($cur_topic['subject']))
    $bbclone_page_title = (!empty($cur_topic['forum_name'])?$cur_topic['forum_name'].'/':'') . $cur_topic['subject'];
else
    $bbclone_page_title = $page_title;
define("_BBC_PAGE_NAME", $bbclone_page_title);
define("_BBCLONE_DIR", "../bbclone/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);
I'm only here because of Textpattern. ;)

Re: PunBB and BBClone

Thanks Manfre! I'm glad you found my post useful.

Good idea with your edits. I've had that problem before too.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: PunBB and BBClone

Manfre,
for some reason I've links logged without id=...

Example:
music (section name) links to viewforum.php (should be viewforum.php?id=9),
depeche mode (topic name in some section) leads to viewtopic.php (should be viewtopic.php?id=28).

?

Re: PunBB and BBClone

Kraeved wrote:

Manfre,
for some reason I've links logged without id=...

Example:
music (section name) links to viewforum.php (should be viewforum.php?id=9),
depeche mode (topic name in some section) leads to viewtopic.php (should be viewtopic.php?id=28).

?

Links.... where? Can you give me a screenshot or something? I'm not sure what you're talking about.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: PunBB and BBClone

Great tool for PunBB

Is there a way using .htaccess authentification in BBClone directory to restrict access only for the PunBB administrator ?

Re: PunBB and BBClone

Personally I'd say just to stick with manually creating .htaccess & .htpassword (or .htpswd or whatever I can't remember) and not bother with integration with the PunBB user system. It sounds like more trouble than it's worth.

If you don't know how to set that up the BBClone forum should have instructions somewhere, or you can do a web search for generic instructions (tip - for some reason or another many sections of the BBClone forum are only visible to registered users).

Looking for a certain modification for your forum? Please take a look here before posting.

Re: PunBB and BBClone

Found a solution for me perhaps not the perfect one but it works.

Renamed original index.php to stats.php

Created a new index.php with this code inside :

<? header("location:../index.php"); ?>

Added after the first <?php of every of those files : stats.php , show_detailed.php , show_views.php , show_global.php this code :

define('PUN_ROOT',
'Link_to_Forum'
);

require PUN_ROOT.'include/common.php';

if ($pun_user['g_id'] > PUN_ADMIN) exit;

And finally added a navink to stats.php in /include/functions.php only for admins.

I'm not a php specialist,maybe there is some mistakes (don't blame me !) but it works fine for me.

Re: PunBB and BBClone

I was going to suggest something similar, but got lazy. tongue

Nice job.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: PunBB and BBClone

Using bbclone for a long time, and it's great.
Look at post #2 from Pogenwurst, instead of having extra statistics in index.php, i would like to have it centered in in the last line of footer.
I've tried to make the same modifications in footer.php, but result gives nothing acceptable.
Any one for a solution ?

Regards

Re: PunBB and BBClone

use it in header smile

Re: PunBB and BBClone

fantasma wrote:

use it in header smile

???  hmm

Re: PunBB and BBClone

Unfortunately I don't have the time to write code for you, but if you start with this chunk I posted

// Fetch BBlone Stats
require("bbclone/var/access.php");
$totalvisits   = $access["stat"]["totalvisits"];
$totalcount    = $access["stat"]["totalcount"];
$visitorsmonth = $access["time"]["month"][date("n")-1];
$visitorstoday = $access["time"]["wday"][date("w")];

you should be able to echo() the variables wherever you'd like them to show up.

Just FYI I posted this quite some time ago and I no longer use BBClone.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: PunBB and BBClone

Thank you, i'll do that wink