Advertisement:

Author Topic: Tracking User Activity  (Read 320967 times)

Offline Mike Bobbitt

  • Full Member
  • ***
  • Posts: 597
    • Army.ca
Re: Tracking User Activity
« Reply #300 on: January 23, 2011, 07:57:49 PM »
Hi Eyesman,

No config page for it unfortunately, but you will want to change the group ID listed in the PHP file to match the group you want to monitor:

Code: [Select]
// Warning group IDs (primary)
$watchlist = "23";

Offline Eyesman

  • Jr. Member
  • **
  • Posts: 264
Re: Tracking User Activity
« Reply #301 on: January 24, 2011, 12:36:29 AM »
Hi Mike,

If I understand correctly I have to change it every time I need to track a user?

Thanx!

Offline Mike Bobbitt

  • Full Member
  • ***
  • Posts: 597
    • Army.ca
Re: Tracking User Activity
« Reply #302 on: January 24, 2011, 09:57:37 AM »
No, you just change the watch list group to the group ID you want to use, then add users to that group (as a secondary membership) and they will appear on the list.

Offline Jeet Chowdhury

  • Jr. Member
  • **
  • Posts: 239
  • Gender: Male
  • Running SMF 2.0.2
    • MuSKiL AShaN
Re: Tracking User Activity
« Reply #303 on: January 28, 2011, 03:34:45 AM »
i got this error,

Fatal error: Call to undefined function db_query() in /home/mobtalk/public_html/tracker.php on line 110

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,993
    • StoryBB/StoryBB on GitHub
Re: Tracking User Activity
« Reply #304 on: January 28, 2011, 03:36:32 AM »
i got this error,

Fatal error: Call to undefined function db_query() in /home/mobtalk/public_html/tracker.php on line 110

You're using 2.0. This does not work on 2.0 and will need to be rewritten to work on 2.0.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Jeet Chowdhury

  • Jr. Member
  • **
  • Posts: 239
  • Gender: Male
  • Running SMF 2.0.2
    • MuSKiL AShaN
Re: Tracking User Activity
« Reply #305 on: January 28, 2011, 04:43:09 AM »
ok thank you arantor for the answer. :)

Offline Masterd

  • SMF Hero
  • ******
  • Posts: 3,917
  • Gender: Male
Re: Tracking User Activity
« Reply #306 on: January 28, 2011, 04:52:00 AM »
This is working with the SMF 2.0.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,993
    • StoryBB/StoryBB on GitHub
Re: Tracking User Activity
« Reply #307 on: January 28, 2011, 05:03:27 AM »
Then why is it calling 1.1.x functions?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Masterd

  • SMF Hero
  • ******
  • Posts: 3,917
  • Gender: Male
Re: Tracking User Activity
« Reply #308 on: January 28, 2011, 01:43:42 PM »
Then he downloaded the wrong file.

Since when $smcFunc is SMF 1.1.x function?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,993
    • StoryBB/StoryBB on GitHub
Re: Tracking User Activity
« Reply #309 on: January 28, 2011, 05:25:32 PM »
It isn't, never has been. $func is the equivalent in SMF 1.1.x, for some things and db_query() for others.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Masterd

  • SMF Hero
  • ******
  • Posts: 3,917
  • Gender: Male
Re: Tracking User Activity
« Reply #310 on: February 09, 2011, 06:41:18 AM »
I know that. I'm just sarcastic.

Offline studiowi33

  • Jr. Member
  • **
  • Posts: 221
Re: Tracking User Activity
« Reply #311 on: July 02, 2011, 02:49:56 PM »
How do u get this to work in 2.0 Gold?

I get a "Fatal error: Call to undefined function db_query() in /home/theozcc1/public_html/tracker.php on line 294".
Thanks for looking.
SMF 2.0.2

Offline Robert.

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,074
  • Gender: Male
    • nedroden on GitHub
Re: Tracking User Activity
« Reply #312 on: July 02, 2011, 03:48:27 PM »
How do u get this to work in 2.0 Gold?

I get a "Fatal error: Call to undefined function db_query() in /home/theozcc1/public_html/tracker.php on line 294".
Thanks for looking.
This should work:
Code: [Select]
<?php


/*
$Id: tracker.php,v 1.29 2006/02/21 14:11:48 bobbitt Exp $

Written by Mike Bobbitt for Army.ca
*/

// Place this script in the same directory as SSI.php, or set the path below
if (file_exists(dirname(__FILE__).'/SSI.php')) {
$ssifile dirname(__FILE__).'/SSI.php';
} else {
$ssifile "/var/www/html/forums/SSI.php";
}

// Are we running on Army.ca or standalone?
if (preg_match("/army.ca$/i"$_SERVER["HTTP_HOST"])) {
$armyca 1;
} else {
$armyca 0;
}

if (
$armyca) {
include_once "/var/www/html/includes/header.php";
} else {
require ($ssifile);

// Set this to restrict access. Currently only admins are allowed.
$isstaff $user_info['is_admin'];
}

// Make sure we have a DB prefix at least
if (!isset ($db_prefix)) {
$db_prefix "`smf`.smf_";
}

// Database tables
// These are all default values, and should not need to be changed.
$db_member_table "members";
$db_log_topics_table "log_topics";
$db_message_table "messages";
$db_topics_table "topics";
$db_boards_table "boards";
$db_log_boards_table "log_boards";
$db_log_errors_table "log_errors";
$db_log_notify_table "log_notify";
$db_log_online_table "log_online";
$db_log_actions_table "log_actions";

// Make sure table name includes database name
$db_member_table "$db_prefix$db_member_table";
$db_log_topics_table "$db_prefix$db_log_topics_table";
$db_message_table "$db_prefix$db_message_table";
$db_topics_table "$db_prefix$db_topics_table";
$db_boards_table "$db_prefix$db_boards_table";
$db_log_boards_table "$db_prefix$db_log_boards_table";
$db_log_errors_table "$db_prefix$db_log_errors_table";
$db_log_notify_table "$db_prefix$db_log_notify_table";
$db_log_online_table "$db_prefix$db_log_online_table";
$db_log_actions_table "$db_prefix$db_log_actions_table";

if (!
$isstaff) {
echo "ERROR: You are not Army.ca Staff.";
if ($armyca) {
include "$include_dir/footer.php";
}
exit (1);
}

// download variables
if (isset ($_REQUEST["function"])) {
$function $_REQUEST["function"];
}

if (isset (
$_REQUEST["u"])) {
$u $_REQUEST["u"];
}

if (isset (
$_REQUEST["user"])) {
$user $_REQUEST["user"];
}

echo 
"<h1>User Tracker</h1>\n";
echo 
"This script tracks the recent actions of all users in The Watch List.<br /><br />\n";

// Warning group IDs (primary)
$watchlist "23";

// Show "lookup user" form
if (!$function) {
echo<<<HTML
<div class="highlight">Track User</div><br /><br />
<form>
Username, Display Name or User ID #: <input type="text" name="user" />
<input type="hidden" name="function" value="trackuser" />
<br />
<input type="submit" value="Track User">
</form>
<br />
HTML;
}

if (
$function == "trackuser") {
// it's a userid, not a username
if (preg_match("/^\d+$/"$user)) {
$u $user;
} else {
// Generate query
$result mysql_query("SELECT $db_member_table.`ID_MEMBER` FROM $db_member_table WHERE $db_member_table.`memberName` = \"$user\" OR $db_member_table.`realName` = \"$user\""__FILE____LINE__);
$res mysql_fetch_array($result);
$u $res[0];
}

if (!$u) {
echo<<<HTML
<br />
<br />
WARNING: User 
$user not found. Please search again.
<br />
<br />
HTML;
} else {
$function "track";
}
}

// Track a user
if ($function == "track") {
// Get username again
$result mysql_query("SELECT $db_member_table.`realName` FROM $db_member_table WHERE $db_member_table.`ID_MEMBER` = \"$u\""__FILE____LINE__);
$res mysql_fetch_array($result);
$realName $res[0];
mysql_free_result($result);

echo "Tracking <a href=\"$scripturl?action=profile;u=$u\">$realName</a>...<br />\n";

echo "<br />Jump to: <a href=\"#boards\">Boards</a> || <a href=\"#topics\">Topics</a> || <a href=\"#monitor\">Monitored Topics</a> || <a href=\"#admin\">Admin Actions</a> || <a href=\"#errors\">Errors</a>";

echo "<a name=\"boards\"><h2>Current Action</h2></a>";

// Get the user's current action
$result mysql_query("SELECT * FROM $db_log_online_table WHERE $db_log_online_table.`ID_MEMBER` = \"$u\" ORDER BY $db_log_online_table.`logTime` DESC LIMIT 1"__FILE____LINE__);

echo "<table>";

while ($res mysql_fetch_array($result)) {
echo "<tr><td>";

// Decode current action
global $sourcedir;

include_once ("$sourcedir/Who.php");
echo determineActions($res['url']);

echo "</td><td>";
if ($res['logTime']) {
echo $res['logTime'];
}
echo "</td></tr>\n";
}
echo "</table>";
mysql_free_result($result);

echo "<a name=\"boards\"><h2>Recent Boards</h2></a>";

// Get the user's board log
$result mysql_query("SELECT * FROM $db_log_boards_table WHERE $db_log_boards_table.`ID_MEMBER` = \"$u\""__FILE____LINE__);

echo "<table>";

while ($res mysql_fetch_array($result)) {
// Get the board title
$result2 mysql_query("SELECT $db_boards_table.`name` FROM $db_boards_table WHERE $db_boards_table.`ID_BOARD` = \"$res[ID_BOARD]\""__FILE____LINE__);
$res2 mysql_fetch_array($result2);
$name $res2[0];
mysql_free_result($result2);

echo "<tr><td><a href=\"$scripturl/board,$res[ID_BOARD].0.html\">$name</a></td><td>";
if ($res['logTime']) {
echo date("Y/m/d H:i:s"$res['logTime']);
}
echo "</td></tr>\n";
}
echo "</table>";
mysql_free_result($result);

echo "<a name=\"topics\"><h2>Recent Topics</h2></a>";

// Get the user's topic log
$result mysql_query("SELECT * FROM $db_log_topics_table WHERE $db_log_topics_table.`ID_MEMBER` = \"$u\" ORDER BY $db_log_topics_table.`ID_TOPIC` DESC"__FILE____LINE__);

echo "<table>";

while ($res mysql_fetch_array($result)) {
// Get the topic title
$result2 mysql_query("SELECT $db_message_table.`subject` FROM $db_message_table WHERE $db_message_table.`ID_TOPIC` = \"$res[ID_TOPIC]\""__FILE____LINE__);
$res2 mysql_fetch_array($result2);
$subject $res2[0];
mysql_free_result($result2);

echo "<tr><td><a href=\"$scripturl/topic,$res[ID_TOPIC].0.html\">$subject</a></td><td>";
if ($res['logTime']) {
echo date("Y/m/d H:i:s"$res['logTime']);
}
echo "</td></tr>\n";
}
echo "</table>";
mysql_free_result($result);

echo "<a name=\"monitor\"><h2>Monitored Topics/Boards</h2></a>";

// Get the user's notifications list
$result mysql_query("SELECT * FROM $db_log_notify_table WHERE $db_log_notify_table.`ID_MEMBER` = \"$u\""__FILE____LINE__);

while ($res mysql_fetch_array($result)) {
// Get the topic title
if ($res[ID_TOPIC]) {
$result2 mysql_query("SELECT $db_message_table.`subject` FROM $db_message_table WHERE $db_message_table.`ID_TOPIC` = \"$res[ID_TOPIC]\""__FILE____LINE__);
$res2 mysql_fetch_array($result2);
$subject $res2[0];

if (!$subject) {
$subject "Not a valid topic.";
}
mysql_free_result($result2);
echo "<a href=\"$scripturl/topic,$res[ID_TOPIC].0.html\">$subject</a><br />\n";
}

if ($res[ID_BOARD]) {
// Get the board title
$result2 mysql_query("SELECT $db_boards_table.`name` FROM $db_boards_table WHERE $db_boards_table.`ID_BOARD` = \"$res[ID_BOARD]\""__FILE____LINE__);
$res2 mysql_fetch_array($result2);
$subject $res2[0];
mysql_free_result($result2);
echo "<a href=\"$scripturl/board,$res[ID_BOARD].0.html\">$subject</a><br />\n";
}
}
mysql_free_result($result);

echo "<a name=\"admin\"><h2>Admin Actions</h2></a>";

// Get the user's admin actions log
$result mysql_query("SELECT * FROM $db_log_actions_table WHERE $db_log_actions_table.`ID_MEMBER` = \"$u\" ORDER BY $db_log_actions_table.`logTime` ASC"__FILE____LINE__);

echo<<<HTML
<table>
<tr>
<th>Datestamp</th><th>Action</th><th>Details</th><th>IP Address</th>
</tr>
HTML;

while ($res mysql_fetch_array($result)) {
echo "<tr><td>";
echo date("Y/m/d H:i:s"$res['logTime'])."</td><td>";
echo $res['action']."</td><td>";
include_once ("$sourcedir/Who.php");
echo determineActions($res['extra'])."</td><td>";
echo $res['ip']."</td><td>";
echo "</tr>";
}
mysql_free_result($result);
echo "</table>";

echo "<a name=\"errors\"><h2>Recent Errors</h2></a>";

// Get the user's error log
$result mysql_query("SELECT * FROM $db_log_errors_table WHERE $db_log_errors_table.`ID_MEMBER` = \"$u\" ORDER BY $db_log_errors_table.`logTime` DESC"__FILE____LINE__);

echo "<table>";

while ($res mysql_fetch_array($result)) {
echo "<tr><td>$res[message]</td><td>";
echo date("Y/m/d H:i:s"$res[logTime]);
echo "</td></tr>\n";
}
echo "</table>";
mysql_free_result($result);

if ($armyca) {
include_once "$include_dir/footer.php";
}
exit (0);
}

// Get list of users in The Watch List
if ($armyca) {
$result mysql_query("SELECT * FROM $db_member_table WHERE $db_member_table.`additionalGroups` LIKE \"%$watchlist%\""__FILE____LINE__);

echo "Select the user you want to track:<br /><br />\n";

while ($res mysql_fetch_array($result)) {
echo "<a href=\"$scripturl?action=profile;u=$res[ID_MEMBER]\"><img align=\"middle\" src=\"http://army.ca/forums/Themes/Armyca/images/icons/profile_sm.gif\" border=\"0\"></a> <a href=\"?function=track;u=$res[ID_MEMBER]\">$res[realName]</a><br />\n";
}

mysql_free_result($result);

include "$include_dir/footer.php";
}
?>
Software Engineering student
DraiWiki | Project Alpha

Offline studiowi33

  • Jr. Member
  • **
  • Posts: 221
Re: Tracking User Activity
« Reply #313 on: July 02, 2011, 10:01:29 PM »
thanks Doc, but(!)...

It doesn't show who's online (like it used to,) so i imputted my own user ID and got these:
Code: [Select]
User Tracker
This script tracks the recent actions of all users in The Watch List.


Warning: Wrong parameter count for mysql_query() in /home/theozcc1/public_html/Ztracker.php on line 131

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 132

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 134
Tracking ...

Jump to: Boards || Topics || Monitored Topics || Admin Actions || Errors
Current Action

Warning: Wrong parameter count for mysql_query() in /home/theozcc1/public_html/Ztracker.php on line 143

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 147

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 163
Recent Boards

Warning: Wrong parameter count for mysql_query() in /home/theozcc1/public_html/Ztracker.php on line 168

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 172

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 186
Recent Topics

Warning: Wrong parameter count for mysql_query() in /home/theozcc1/public_html/Ztracker.php on line 191

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 195

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 209
Monitored Topics/Boards

Warning: Wrong parameter count for mysql_query() in /home/theozcc1/public_html/Ztracker.php on line 214

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 216

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 239
Admin Actions

Warning: Wrong parameter count for mysql_query() in /home/theozcc1/public_html/Ztracker.php on line 244

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 253

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 262
Datestamp Action Details IP Address
Recent Errors

Warning: Wrong parameter count for mysql_query() in /home/theozcc1/public_html/Ztracker.php on line 268

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 272

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/theozcc1/public_html/Ztracker.php on line 278

I appreciate the effort Doc, just isn't working :(

EDIT: After reverting to the original tracker.php file, this is the contents of line 289...

Code: [Select]
$result = db_query("SELECT $db_member_table.realName, $db_member_table.ID_MEMBER FROM $db_log_online_table, $db_member_table WHERE $db_log_online_table.ID_MEMBER = $db_member_table.ID_MEMBER ORDER BY $db_log_online_table.`logTime` DESC", __FILE__, __LINE__);
I can't see any online users to track and before upgrading to 2.0, I was able to simply click on the name. It kinda works now, but I have to manually enter a User ID into the "Track User" form.

(Sorry if I'm dense about this, it's a great feature.)



Uploaded with ImageShack.us
« Last Edit: July 14, 2011, 01:01:02 PM by studiowi33 »
SMF 2.0.2

Offline Martine M

  • Full Member
  • ***
  • Posts: 532
  • Gender: Female
    • Unlimited PSP Fun
Re: Tracking User Activity
« Reply #314 on: August 19, 2011, 04:41:37 PM »
Thanks for the script I installed it, will let you know how it works.
Running SMF 2.09 - Diego Andrés Theme Elegant Mind - TP 1.0 - Main Forum language English - Browser Firefox 33


Offline Justin se

  • Semi-Newbie
  • *
  • Posts: 14
Re: Tracking User Activity
« Reply #315 on: August 24, 2011, 07:50:19 AM »
nice script.
i'll install it later to my website...

Offline Martine M

  • Full Member
  • ***
  • Posts: 532
  • Gender: Female
    • Unlimited PSP Fun
Re: Tracking User Activity
« Reply #316 on: August 24, 2011, 07:52:06 AM »
It works great. :)
Running SMF 2.09 - Diego Andrés Theme Elegant Mind - TP 1.0 - Main Forum language English - Browser Firefox 33


Offline tacosfitnessblog

  • Newbie
  • *
  • Posts: 1
Re: Tracking User Activity
« Reply #317 on: August 27, 2011, 08:27:53 AM »
works great, thx ::)

Offline Astarta

  • Semi-Newbie
  • *
  • Posts: 46
  • Gender: Female
    • Крысиный Бум
Re: Tracking User Activity
« Reply #318 on: January 02, 2012, 06:05:25 PM »
The mod is great! Thank you for your work!
I've tested it with 2.0.2 and it works like a charm!
I've only one question still...
Is it possible to log topic's views only it certain board?
I've looked on tvl_log function (in Sources/TopicViewLog.php), but I do not see the way to accomplish this task. I know the board ID, but how to use it...
with best regards,
Astarta

http://rat.ru/forum/index.php

Offline kasparh

  • Semi-Newbie
  • *
  • Posts: 34
Re: Tracking User Activity
« Reply #319 on: January 15, 2012, 10:51:02 AM »
i'm givingv a try on my forum, and it works great doing the job, but i have this error displayed



any idea ?

sorry for the link on imagebam, but i can't attach files