1

Topic: UserStats 1.0

I just posted a mod/plugin mix that allows to get extended user statistics for the board.

It will show you information on:

- How many and which users visited in a certain period
- Which topics they saw
- The total number of visits per day for a given period
- The most read topics for a given period

I hope this will be useful to some.

Download here

The German PunBB Site:
PunBB-forum.de

Re: UserStats 1.0

That's so invasion of privacy j/k

Nice mod smile

3 (edited by Ataxy 2005-07-06 02:02)

Re: UserStats 1.0

does not work here it install and all but when i click go to see some stat i get a admin page with no css applyed and it says unable to fetch information or something like that

edit here is what i get
http://d-vault.peerforces.com/forum/uploaded/usestat.png

4 (edited by shinko_metsuo 2005-07-06 02:33)

Re: UserStats 1.0

Profile.php give's an sql error (saw it on ataxy's forum)

err and some other stuff

Notice: Undefined variable: current_page_id in /forum/include/functions.php on line 231

Warning: Cannot modify header information - headers already sent by (output started at /forum/profile.php:1) in /forum/header.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at /forum/profile.php:1) in /forum/header.php on line 32

Warning: Cannot modify header information - headers already sent by (output started at /forum/profile.php:1) in /forum/header.php on line 33

Warning: Cannot modify header information - headers already sent by (output started at /forum/profile.php:1) in /forum/header.php on line 34

5

Re: UserStats 1.0

i some time get this also
http://d-vault.peerforces.com/forum/uploaded/ree.png

Re: UserStats 1.0

you really need to change the bits of the plugin that are still from mine, like my name in the copyright and the title block

7 (edited by Tobi 2005-07-06 07:53)

Re: UserStats 1.0

shinko_metsuo wrote:

Profile.php give's an sql error (saw it on ataxy's forum)
err and some other stuff
Notice: Undefined variable: current_page_id in /forum/include/functions.php on line 231

There must be another mod installed. current_page_id does not exist in the standard installation.
Which mod(s) did you install?

Connorhd wrote:

you really need to change the bits of the plugin that are still from mine, like my name in the copyright and the title block

This is exactly the kind of mistake that one hopes never to make smile

Ataxy wrote:

does not work here it install and all but when i click go to see some stat i get a admin page with no css applyed and it says unable to fetch information or something like that

Yes, there is a small bug in the error handling.
However, there must be an error when you try to get data for dates where you have no user data collected.
This I think was the case with you.
I'll fix that now so it looks like a serious error message smile

The German PunBB Site:
PunBB-forum.de

Re: UserStats 1.0

Tobi wrote:
Connorhd wrote:

you really need to change the bits of the plugin that are still from mine, like my name in the copyright and the title block

This is exactly the kind of mistake that one hopes never to make smile

don't worry about it wink i'm quite happy to have copyright tongue

9

Re: UserStats 1.0

Connorhd wrote:

don't worry about it wink i'm quite happy to have copyright tongue

Sure you are - especially for something as incredibly valuable as the userstats plugin smile

The German PunBB Site:
PunBB-forum.de

10

Re: UserStats 1.0

Wrote a fix for the ugly error thing Ataxy found.
Fixes also the wrong Copyright note (sorry Connorhd wink )

Did not fix shinko_metsuos issue because the variable current_page_id is unknown to me.
Does anybody have any ideas where this can come from?

Does not fix Ataxys "unable to insert into user statistics" error.
Can you be a bit more precise on what you mean with "Some time"?
You don't get this error every time then?
If so, is there any recognizable pattern when you get it?
I would like to fix this if I can but I need a clue where to start...

The fix can be downloaded here:
mod_userstats 1.0.1

The German PunBB Site:
PunBB-forum.de

11 (edited by Ataxy 2005-07-06 09:57)

Re: UserStats 1.0

Tobi wrote:

Does not fix Ataxys "unable to insert into user statistics" error.
Can you be a bit more precise on what you mean with "Some time"?
You don't get this error every time then?
If so, is there any recognizable pattern when you get it?
I would like to fix this if I can but I need a clue where to start...

ok it seem to happen when i access the admin panel for now i havent seen it happening anywhere else
but if it does it all i have to do is to do back then go into the admin panel again and thats it it does not do it then if i go from the site and come back it does it again


edit:

ok now it does apply the css ounce i click go but the result are always:

There is no data to show a result for your search.

edit2:

when i search for the most read topic i get the following message under the search result:

Unable to fetch topic information. Maybe you have no corresponding entries in your database

unless i do search for yesterday, 7days, last month wich all give me the same answer but all search result are intitled
"Number of Users visiting from 2005-06-30 - 2005-07-06" when actualy there should be most read topic


anyway hope it help

12 (edited by Tobi 2005-07-06 10:02)

Re: UserStats 1.0

These messages appear because you are looking for something that does not exist.

F.e. let's say you installed the mod yesterday.
Then searching for entries from last week lead to no result.

In other words:
Be patient, let the database collect some entries and have a look then!
smile

Ataxy wrote:

all search result are intitled
"Number of Users visiting from 2005-06-30 - 2005-07-06" when actualy there should be most read topic

I will change that in the next release.
Being a very minor mistake, you can change it meanwhile by
opening AP_User_statistics.php, go to line 281 and change

"Number of Users visiting from"

to "Most read topics from"

The German PunBB Site:
PunBB-forum.de

13

Re: UserStats 1.0

ok thx ill do that and by the way great mod thx

14

Re: UserStats 1.0

Ataxy wrote:

i some time get this also
http://d-vault.peerforces.com/forum/uploaded/ree.png

hey how about this one it happens to me when i go from the index.php to the forum.php since i have installed the mini portal mod

15

Re: UserStats 1.0

Oh,

don't know about the miniportal mod.
First, the file "forum.php" does not exist in the original distribution.
Don't know what it does but there is probably some cookie information tweaked or missing.

Please check if you still have the table YOURBOARDstatuser

Otherwise I have to see what this mod really does... sad

The German PunBB Site:
PunBB-forum.de

16

Re: UserStats 1.0

Ataxy wrote:

i some time get this also
http://d-vault.peerforces.com/forum/uploaded/ree.png

i got the same problem. it only occored when you have timed out, and have been deleted from the online list. all you need to do is put quotes around the remote address value.

just change line 79 to this

$db->query('INSERT INTO '.$db->prefix.'statuser (user_id, user_ip) VALUES('.$pun_user['id'].',\''.$db->escape(get_remote_address()).'\')') or error('Unable to insert into user statistics', __FILE__, __LINE__, $db->error());

17

Re: UserStats 1.0

Gizzmo wrote:

all you need to do is put quotes around the remote address value.

Great!!!

I will upload a fixed version today.
Thanks a lot, I was searching for hours and couldn't find it.....

The German PunBB Site:
PunBB-forum.de

18 (edited by Ataxy 2005-07-08 13:04)

Re: UserStats 1.0

thx giz for pointing the fix but now i am getting this message

Error: Unable to update user visit data.

19

Re: UserStats 1.0

ok i guess the error occur in this line

 $db->query('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user visit data', __FILE__, __LINE__, $db->error());

20

Re: UserStats 1.0

Yeah, looks like... but this line has absolutely nothing to do with my mod.
Not that I knew...

What you can do to make our search easier:

Instead of 'Unable to update user visit data'  copy the sql query on that spot so it looks like

...

or error('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id'], __FILE__, __LINE__, $db->error())

That way you can see what is wrong with the query

The German PunBB Site:
PunBB-forum.de

21

Re: UserStats 1.0

ok by replacing the old "or error..."" by the one you gave me i now get this when i go to my website

Parse error: parse error in /home/vhost/d-vault.peerforces.com/html/forum/include/functions.php on line 88

Fatal error: Call to undefined function: check_cookie() in /home/vhost/d-vault.peerforces.com/html/forum/include/common.php on line 115

line 88 of function.php been:

$pun_user['last_visit'] = $pun_user['logged'];

and line 115 of common.php been:

check_cookie($pun_user);

22

Re: UserStats 1.0

humm i think i may have an idea could it be possible that that since the miniportal mod does not count you as log in the forum when your at the portal page creates that problem

23

Re: UserStats 1.0

Yeah...maybe.
I really don't know a lot about the miniportal.

However, the error you're getting means that you are logged in and have timed out.

As for your parse error: I do not know how this happens.
I always do this for debugging purposes and I never got this error.

Overall I'd say it must have someting to do with a mod you made, if it's the miniportal or not I don't know of course....
So if you take out the mod_userstats changes then all this works like a charm?
This is indeed very strange...

The German PunBB Site:
PunBB-forum.de

24

Re: UserStats 1.0

ok i notice that difference here here is the line in the function.php file as it currently appear

/// MOD USERSTATS CHANGE
            if (!$pun_user['logged'])  {
                $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
                $db->query('INSERT INTO '.$db->prefix.'statuser (user_id, user_ip) VALUES('.$pun_user['id'].',\''.$db->escape(get_remote_address()).'\')') or error('Unable to insert into user statistics', __FILE__, __LINE__, $db->error());
                }
// END MOD USERSTATS CHANGE
            {
                // Special case: We've timed out, but no other user has browsed the forums since we timed out
                if ($pun_user['logged'] < ($now-$pun_config['o_timeout_visit']))
                {
                    $db->query('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user visit data', __FILE__, __LINE__, $db->error());
                    $pun_user['last_visit'] = $pun_user['logged'];
                }
                // MOD USERSTATS CHANGE
            if ($pun_user['idle'] == 1)  {
                $db->query('INSERT INTO '.$db->prefix.'statuser (user_id, user_ip) VALUES('.$pun_user['id'].',"'.$db->escape(get_remote_address()).'")') or error('Could not insert into statistics', __FILE__, __LINE__, $db->error());
                }
// END MOD USERSTATS CHANGE

in your read me file you say this

#---------[ 5. FIND (line:76) ]---------------------------------------------------
#
            // Update the online list
            if (!$pun_user['logged'])
                $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
                }

#
#---------[ 6. CHANGE TO ]---------------------------------------------------
#
            // Update the online list
// MOD USERSTATS CHANGE
            if (!$pun_user['logged'])  {
                $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
                $db->query('INSERT INTO'.$db->prefix.'statuser (user_id, user_ip) VALUES('.$pun_user['id'].','.$db->escape(get_remote_address()).')') or error('Unable to insert into user statistics', __FILE__, __LINE__, $db->error());
                }
// END MOD USERSTATS CHANGE

the thing is that me in my original file the line

// Update the online list
            if (!$pun_user['logged'])
                $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
                }

is a bit different

// Update the online list
            if (!$pun_user['logged'])
                $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged, color) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.', \''.$db->escape($pun_user['g_color']).'\')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
            else
            {

25

Re: UserStats 1.0

ok i think i got it i changed back and forth some of the line so it came down to this

the way you line appear:

/// MOD USERSTATS CHANGE
            if (!$pun_user['logged'])  {
                $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
                $db->query('INSERT INTO '.$db->prefix.'statuser (user_id, user_ip) VALUES('.$pun_user['id'].',\''.$db->escape(get_remote_address()).'\')') or error('Unable to insert into user statistics', __FILE__, __LINE__, $db->error());
                }
// END MOD USERSTATS CHANGE
            {
                // Special case: We've timed out, but no other user has browsed the forums since we timed out
                if ($pun_user['logged'] < ($now-$pun_config['o_timeout_visit']))
                {
                    $db->query('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user visit data', __FILE__, __LINE__, $db->error());
                    $pun_user['last_visit'] = $pun_user['logged'];
                }
                // MOD USERSTATS CHANGE
            if ($pun_user['idle'] == 1)  {
                $db->query('INSERT INTO '.$db->prefix.'statuser (user_id, user_ip) VALUES('.$pun_user['id'].',"'.$db->escape(get_remote_address()).'")') or error('Could not insert into statistics', __FILE__, __LINE__, $db->error());
                }
// END MOD USERSTATS CHANGE

and the change i had to make i guess and i hope those will solve the problem

// Update the online list
/// MOD USERSTATS CHANGE
            if (!$pun_user['logged'])  {
                $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged, color) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.', \''.$db->escape($pun_user['g_color']).'\')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
                $db->query('INSERT INTO '.$db->prefix.'statuser (user_id, user_ip) VALUES('.$pun_user['id'].',\''.$db->escape(get_remote_address()).'\')') or error('Unable to insert into user statistics', __FILE__, __LINE__, $db->error());
                } 
                else
// END MOD USERSTATS CHANGE
            {
                // Special case: We've timed out, but no other user has browsed the forums since we timed out
                if ($pun_user['logged'] < ($now-$pun_config['o_timeout_visit']))
                {
                    $db->query('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user visit data', __FILE__, __LINE__, $db->error());
                    $pun_user['last_visit'] = $pun_user['logged'];
                }
                // MOD USERSTATS CHANGE
            if ($pun_user['idle'] == 1)  {
                $db->query('INSERT INTO '.$db->prefix.'statuser (user_id, user_ip) VALUES('.$pun_user['id'].',"'.$db->escape(get_remote_address()).'")') or error('Could not insert into statistics', __FILE__, __LINE__, $db->error());
                }
// END MOD USERSTATS CHANGE