vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Trace and log user actions... (https://vborg.vbsupport.ru/showthread.php?t=52300)

Zzed 04-27-2003 10:00 PM

Trace and log user actions...
 
This hack was requested by ossi69 and John Mac.

This is a pretty simple hack that allows you to track and document a user's
actions while they are logged into your board. Every click made by the user
makes a brand new entry in a log file. The log file entries include, username,
IP address, date and time, and the URL clicked on. The user actions are
documented even before the user has a chance to see the page he clicked on.

Templates affected by this hack: none
Tables affected by this hack: user
Files affected by this hack: global.php, admin/user.php

Execute the following query to create a new field in the user table:

alter table user add trace smallint(5) unsigned DEFAULT 0 NOT NULL;

You also need to create a brand new directory in your forums directory by
the name of tracelog. You need to make sure that your give the appropriate\
read/write permissions to this directory so that the http server on your
host can create files in there.

Here is a sample output:
Code:

Zed, 192.168.1.101 , 2003-04-28 18:31:30, /forums/index.php
Zed, 192.168.1.101 , 2003-04-28 18:31:36, /forums/forumdisplay.php?forumid=9
Zed, 192.168.1.101 , 2003-04-28 18:31:42, /forums/showthread.php?threadid=143901
Zed, 192.168.1.101 , 2003-04-28 18:31:51, /forums/rules.php
Zed, 192.168.1.101 , 2003-04-28 18:31:53, /forums/forumdisplay.php?forumid=9
Zed, 192.168.1.101 , 2003-04-28 18:32:07, /forums/showthread.php?threadid=143901
Zed, 192.168.1.101 , 2003-04-28 18:32:11, /forums/index.php
Zed, 192.168.1.101 , 2003-04-28 18:32:15, /forums/forumdisplay.php?forumid=103
Zed, 192.168.1.101 , 2003-04-28 18:32:28, /forums/showthread.php?threadid=225576
Zed, 192.168.1.101 , 2003-04-28 18:32:38, /forums/member.php?action=getinfo&userid=4112

Note:Go to this post to download the directory protection file for this hack.

Boofo 04-28-2003 10:04 PM

Is this supposed to be unsigned?

alter table user add trace smallint(5) unsigned DEFAULT 0 NOT NULL;

Will this also add a line under each user's session so you can tell where one leaves off and one starts?

Zzed 04-28-2003 10:19 PM

Unsigned is fine. The possible values for that field are 0 and 1.

Start times are when the user signs on for the first time. And the leaving time should be between the time of the last entry and the time for the cookie timeouts on your board. ;)

Boofo 04-28-2003 10:23 PM

I see, thanks! ;)

Wouldn't it be better to have a line separate each users session though in case the log gets kind of long? Like this:

Zed, 192.168.1.101 , 2003-04-28 18:31:30, /forums/index.php
Zed, 192.168.1.101 , 2003-04-28 18:31:36, /forums/forumdisplay.php?forumid=9
Zed, 192.168.1.101 , 2003-04-28 18:31:42, /forums/showthread.php?threadid=143901
Zed, 192.168.1.101 , 2003-04-28 18:31:51, /forums/rules.php
Zed, 192.168.1.101 , 2003-04-28 18:31:53, /forums/forumdisplay.php?forumid=9
-------------------------------------------------------------------------
Boofo, 192.168.1.101 , 2003-04-28 18:32:07, /forums/showthread.php?threadid=143901
Boofo, 192.168.1.101 , 2003-04-28 18:32:11, /forums/index.php
Boofo, 192.168.1.101 , 2003-04-28 18:32:15, /forums/forumdisplay.php?forumid=103
-------------------------------------------------------------------------
Test, 192.168.1.101 , 2003-04-28 18:32:28, /forums/showthread.php?threadid=225576
Test, 192.168.1.101 , 2003-04-28 18:32:38, /forums/member.php?action=getinfo&userid=4112

Something like that? And will there be a way to prune the log?

Zzed 04-28-2003 10:28 PM

This hack is activated by user participation on the board. TO do this you would have to take the last activity time by the user and compare it against the current time and if it is greater than your $cookietimeout then you would output a line separator.

As for the pruning, I figured the file entries can just be deleted. or edited manually. They really don't take up that much space to cause real concern. ;)

Boofo 04-28-2003 10:38 PM

Wouldn't comparing the username do the job, too?

Zzed 04-28-2003 10:41 PM

Quote:

Today at 04:38 PM Boofo said this in Post #6
Wouldn't comparing the username do the job, too?

Nope, it is per user. Each user gets his/her own file in the tracelog directory, i.e., username Zzed will have his entries be written to Zzed.log, and username Boofo will have his entries written to Boofo.log. ;)

Boofo 04-28-2003 11:01 PM

I just got it installed and saw that. Sorry. ;)

It looks great! Can it be done by the time line like you mentioned before? Would make it easier on a big log. ;)

Also, is there a way to have it be read form the Admin CP instead of having to go FTP to read it?

Zzed 04-28-2003 11:04 PM

I'll look into the line separator thing. ;)

You can view the file through your browser by going to http://myforum.com/forums/tracelog/Zzed.log

Or you can get a directlry listing by going to: http://myforum.com/forums/tracelog

Boofo 04-28-2003 11:09 PM

Thanks, my friend. Great hack. I like it. ;)

How can I add the link in the user's admin cp profile so you can just click it and read it?

Zzed 04-28-2003 11:12 PM

I'll get that code out along with the line separators. ;)

ossi69 04-28-2003 11:27 PM

phenomenal Zzed. Many thanks again!

Zzed 04-28-2003 11:58 PM

Quote:

Today at 05:27 PM ossi69 said this in Post #12
phenomenal Zzed. Many thanks again!

You're very welcome. Let me know how you like it. :)

vB-Host.com 04-29-2003 12:14 AM

*clicks install* very nice... Could you add to the user log where they came from when the log file startes like another area of my site or a link to the external site they came from?

Zzed 04-29-2003 12:23 AM

Quote:

Today at 06:14 PM vB-Host.com said this in Post #14
*clicks install* very nice... Could you add to the user log where they came from when the log file startes like another area of my site or a link to the external site they came from?
Thank you for your kind words. :)

You can modify the sprintf() statement and add another entry for $url to see their referring URL. ;) But the information will show up on every line along with the rest of the info.

Areku 04-29-2003 08:35 AM

Are ALL users logged or only those you choose?

Boofo 04-29-2003 09:29 AM

Only those you set to be traced from the Admin CP.

Areku 04-29-2003 11:26 AM

Cool!

/me licks install!!!

John Mac 04-29-2003 11:37 AM

Thanks Zzed,

Areku 04-29-2003 11:39 AM

Quote:

Today at 01:04 AM Zzed said this in Post #9
I'll look into the line separator thing. ;)

You can view the file through your browser by going to http://myforum.com/forums/tracelog/Zzed.log

Or you can get a directlry listing by going to: http://myforum.com/forums/tracelog



So virtually ANYONE can see anyone else's activities by just entering someone's nick.log at tracelog subdir?

Any way to prevent this?

Robink 04-29-2003 02:20 PM

Great!!

I can use this to keep an eye on some Mods too.... :D ;)

SmartGnome 04-29-2003 06:06 PM

Hi Zzed, install is clicked :D

Anyone an idea how to protect the directory for unallowed previews ???


Great hack, will help me to find the ones I don't like


Greets

Zzed 04-29-2003 06:32 PM

Thank you everyone for your kind words. :)

I am working on a solution for the protection of that directory.

Zzed 04-29-2003 07:46 PM

Ok, for all of you who expressed your concern about the security and protection of that page, I created an index.php that allows only the Administrators to view the contents of that directory. Anyone else other than administrators will get the No Permission page. ;)

Drop the attached file in your tracelog directory and it will take care of everything. The output generated by the script is in table format that shows filename, size, last modified time and last accessed time.

Hope this helps. ;)

Areku 04-29-2003 07:49 PM

U r00l! ;)

Tu Zzed!

Areku 04-29-2003 08:00 PM

mmmm...errrr... any1 can still see them!

Zzed 04-29-2003 08:02 PM

Quote:

Today at 02:00 PM Areku said this in Post #26
mmmm...errrr... any1 can still see them!

Nope, hit refresh on your browser. It is still sitting in your cache. ;)

Areku 04-29-2003 08:07 PM

U rock!!! ;)

Zzed 04-29-2003 08:10 PM

Quote:

Today at 02:07 PM Areku said this in Post #28
U rock!!! ;)
Thank you. You are too kind. https://vborg.vbsupport.ru/

Mutt 04-29-2003 09:45 PM

a couple suggestions

you should change the log file to userid instead of username. names with odd chars will cause problems.

I just installed, but put the tracelog dir in the admin dir. everyone already has that protected.

nice idea. I look forward to any addons. soem of my members need a little watching.

Areku 04-29-2003 09:52 PM

Nice point!

Is that as simple as adding admin/tracelog/ instead of tracelog/ on the first replacement? I guess that's more secure than the index.php file?

The userid thing may be a good point too...

(Ps. working on vb2.2.0 ;))

Hobbes 04-30-2003 01:53 AM

/me clicks install...

it would be a wicked idea to have the logs viewable in the admin cp....like a link or something!!!

Katana Myronson 04-30-2003 03:07 PM

Great hack! I'm going to install it right away! Thanks, Zzed this is just what i was looking for! :D

TheComputerGuy 04-30-2003 07:56 PM

does this create a lot of queries

Zzed 04-30-2003 08:17 PM

Quote:

Today at 01:56 PM TheComputerGuy said this in Post #34
does this create a lot of queries
There are no queries while a user is being traced. Information is written to a text file. The user information is already populated when the user esablished a session with the board, so there is no need for any further queries.

The only time there is a query is when you try to visit the contents of the tracelog directory.

Morgalis 05-01-2003 09:22 PM

this was just what i was looking for!

thanks :)

Zzed 05-02-2003 05:52 AM

You are welcome. :)

Boofo 05-02-2003 11:36 AM

Quote:

04-28-03 at 07:04 PM Zzed said this in Post #9
I'll look into the line separator thing. ;)

You can view the file through your browser by going to http://myforum.com/forums/tracelog/Zzed.log

Or you can get a directlry listing by going to: http://myforum.com/forums/tracelog

How's this coming along? And Mutt's idea about using the userid as the name of the file instead of the username is a good one, too. ;)

obs 05-02-2003 07:54 PM

hi I'm new here and this is a really nice hack. I was wondering how to automatically track all users instead of having to go into each one and selecting 'track user'?

Zzed 05-02-2003 07:57 PM

Quote:

Today at 01:54 PM obs said this in Post #39
hi I'm new here and this is a really nice hack. I was wondering how to automatically track all users instead of having to go into each one and selecting 'track user'?

Are you sure you want to do that? :confused:

If so then replace this:
Code:

if($bbuserinfo[trace] == 1) {
with this:
Code:

if(1) {


All times are GMT. The time now is 04:43 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01929 seconds
  • Memory Usage 1,819KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (9)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete