TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 23, 2024, 06:04:58 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,197
  • Total Topics: 21,221
  • Online today: 67
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 48
  • Total: 48

Who's Online + Action

Started by Fl4meS, August 22, 2007, 05:55:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Fl4meS

Hello all, here I am again with a blabla question :) .

My problem lies here : I'm using pretty much articles as pages, but everytime a user is watching this, you'll see "Viewing the board index of board" or "Is viewing a module".
Sometimes even a message which doesn't know what the user is doing.

My question is, how can I determinate by editing one or more page(s), to show in the 'who's online' what the user(s) currently are doing?

I appreciate any help,
thanks in advance.

~- Flamey :)

Zetan

As far as I'm aware, Articles are defined by a page number.. for example:

index.php?page=1

Currently it is not defined by a title or an action.


There is a script:

<?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 LAB RADIO ADMINISTRATOR.";
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 db_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 db_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 db_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 db_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 db_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 db_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 db_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 db_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 db_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 db_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 db_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 db_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 db_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";
}
?>


That will allow you to view what your members have viewed. But, It will still give the same results that the Who's Online gives regarding articles. It's more of a History View, Action thing.

If you want to use that script, as it's quite usefull.. paste it into a notepad file, and call it "tracker.php" including the quotes. Find the ERROR message and change to what you want it to display.

Upload to your public_html file and direct your browser to it.

This really doesn't achieve what you want it to do though.

Rafferty

I came across the script Zetan and only get numerous error messages for multiple lines. Example:

QuoteUndefined variable: function in /home/www/******.org/forum/tracker.php on line 104

Zetan

Did you call it "tracker.php" and upload to the root of your server?
You then point your browser to it. I gave a brief discription of how it works. I didn't write the script.

http://labradio.co.uk/tracker.php

It works fine on my site using the script I posted.. You can't view it unless you are an Admin and logged into your site.. But, you will see this error message:

ERROR: You are not LAB RADIO ADMINISTRATOR.

Rafferty

OK thanks for for your comments. I think it was conflicting with another mod, I removed the last few mods I added and it worked OK. Another of life's mysteries LOL