Ads

Member Activity

Simple code on how to view what your members are doing in real time on your website. To get this working with your own user system, you will probably have to modify it a little bit, im sure the members here wouldnt mind helping your out.

First you need to create this in the `users` table:

CODE
ALTER TABLE `users` ADD page varchar(225);



Next insert this into your config.php file anywhere.

CODE
if($logged[username])
{
$updatepage = mysql_query("UPDATE `users` SET `page` = '".$_SERVER['REQUEST_URI']."' WHERE `username` = '$logged[username]'"); 
}


This is the code that records what page your user is viewing. It inserts Request URI and then displays it in activity.php which is next!


This is the page that displays what your members are viewing and doing. Name this whatever you want, I named it activity.php
Remember to change 5 to whatever level you want them to be able to view it. I have mine set for 5 or admin.

CODE
<?php
include("config.php");

if(
$logged[username] && $logged[level] >= 5)
{
$offline2 300;
$current2 time();
$offline2 = ($current2-$offline2);
$getusers2 mysql_query("SELECT * from users where online >= '$offline2'");
while (
$m mysql_fetch_array($getusers2))
{
echo (
"$m[username] - $m[page]");
}
echo 
"";
}
else
{
include 
"error.php";
}
?>



Now your all set.
Next addition to this will be to display what the guest's are doing! But until then Good Luck...

Sunday May 27, 2007 - 161 reads