UBB.Dev
This adds a field at the bottom of a user's profile that shows when they were last logged in/online. Very useful

Also updated it to change when someone registered, to when they were last online, in the Userlist

Files Modified:
showprofile.php
templates/default/showprofile.tmpl
---
showmembers.php
templates/default/showmembers.tmpl

--To add it in their profile...

In showprofile.php Find:
Code
 <br />$date = $html -> convert_time($Registered,$toffset); <br />


Below it, add this:
Code
 <br />$query = " <br />    SELECT U_Laston <br />    FROM  {$config['tbprefix']}Users <br />    WHERE U_Number = '$User' <br />   "; <br />   $sth = $dbh -> do_query($query); <br />list($Laston) = $dbh -> fetch_array($sth); <br />$Laston = $html -> convert_time($Laston,$toffset); <br /> 


Now, in templates/default/showprofile.tmpl
Find this:
Code
 <br /><tr> <br /><td valign="top" class="darktable"> <br />{$ubbt_lang['REGGED_ON']} <br /></td> <br /><td colspan="2"> <br />$date &nbsp; <br /></td> <br /></tr> <br /> 


Below it, add this:
Code
 <br /><tr> <br /><td valign="top" class="darktable"> <br />Last Online <br /></td> <br /><td colspan="2"> <br />$Laston &nbsp; <br /></td> <br /></tr> <br /> 


--To change when a user registered, to when they were last online...

In showmembers.php:

1- Find
$RegedS = "";
Change it to
$Lastons = "";

2- Find
$sortreged = 11;
Change it to
$sortlaston = 11;

3- Find
11 => array(0=>"<img src="{$config['images']}/ascend.gif" border="0" alt="" />", 1=> "U_Registered ASC"),
12 => array(0=>"<img src="{$config['images']}/descend.gif" border="0" alt="" />", 1=> "U_Registered DESC")
Change it to
11 => array(0=>"<img src="{$config['images']}/ascend.gif" border="0" alt="" />", 1=> "U_Laston ASC"),
12 => array(0=>"<img src="{$config['images']}/descend.gif" border="0" alt="" />", 1=> "U_Laston DESC")

4- Find
case 11:
$RegedS = $Sorting['11']['0'];
$sortreged = 12;
break;
case 12:
$RegedS = $Sorting['12']['0'];
$sortreged = 11;
break;
Change to
case 11:
$Lastons = $Sorting['11']['0'];
$sortlaston = 12;
break;
case 12:
$LastonS = $Sorting['12']['0'];
$sortlaston = 11;
break;

5- Find
SELECT U_Username,U_Registered,U_Extra1,U_Homepage,U_TotalPosts,U_Status,U_Number
Change to
SELECT U_Username,U_Laston,U_Extra1,U_Homepage,U_TotalPosts,U_Status,U_Number

6- Find
list ($Username,$Reged,$ICQ,$Home,$Posts,$Status,$Uid) = $dbh -> fetch_array($sth);
Change to
list ($Username,$Laston,$ICQ,$Home,$Posts,$Status,$Uid) = $dbh -> fetch_array($sth);

7- Find
$userrow[$i]['Reged'] = $Reged;
Change to
$userrow[$i]['Laston'] = $Laston;

8- Find
$Reged = $html -> convert_time($Reged,$user['U_TimeOffset']);
Change to
$Laston = $html -> convert_time($Laston,$user['U_TimeOffset']);

Finally, in templates/default/showmembers.tmpl...

Code
 <a href="{$config['phpurl']}/showmembers.php?Cat=$Cat&amp;sb=$sortreged&amp;page=$page&amp;like=$like"> <br />{$ubbt_lang['REGGED_ON']} $RegedS 

Change to:
Code
 <a href="{$config['phpurl']}/showmembers.php?Cat=$Cat&amp;sb=$sortlaston&amp;page=$page&amp;like=$like"> <br />Last Online $LastonS 


anddd...

Find:
Code
 <td class="{$userrow[$i]['color']}"> <br />{$userrow[$i]['Reged']} 

Change to:
Code
 <td class="{$userrow[$i]['color']}"> <br />{$userrow[$i]['Laston']} 


...and that *should* do it!


great idea... Gonna wait to see if this is a independent hack before installing. Good job on this.
[]Smilesforu said:
great idea... Gonna wait to see if this is a independent hack before installing. Good job on this. [/]
I just installed this on the HP site and it seems to work, and we're NOT running IIP there. Looks like it's a functional independant hack.
Yes the field U_Laston is a standard .threads field. It's not updated as often as IIP's additional field and therefore not as accurate.
Yeah, it could be changed to last logged in? Seems pretty accurate on my board...was going for the least editing/without having to make a whole new field/script...but as Dave says, IIP Is great
Works great ... thanks
is there some way to replace the registrated on in user list vith this ???

would be nicer to see when a user was last on, instead ;O)

thomas
I've got it...now lemme see if I can catch everything I changed, there is alot lol
Okay, updated the main post for this additional mod
I am missing the benefit on this last add on. .. Wouldn't their last post show when they last on or does this do it in a member search? Thanks
If your forum has a userlist enabled...and you clicj on user list (like here) the far right colum that says "date registered" is changed to when they were last online...so you can sort your entire userlist by who was last online..
Posted By: Slawek_L [6.1.1] - 02/28/2003 2:03 AM
When we change
$toffset to $timeoffset
and
U_Number to U_Username

it will be work, and work on my forum
Posted By: cstaber Re: [6.1.1] - 02/28/2003 2:26 AM
oh for an older version of threads you mean?
Posted By: Slawek_L Re: [6.1.1] - 02/28/2003 2:49 AM
Yes... because I use ubb 6.1.1
Posted By: smilesforu 1.4? - 02/28/2003 10:56 AM
Ok I see the benefit... could we add a ip to this list for the admins... I have occasional trouble in the chat and this would identify who it was instantly.
error

i get this when i do that

[]http://www.4701.dk/online.jpg[/]
ahhh I missed a step, sorry about that...I just started hacking away and wasn't documenting what I was doing...then tried going back and finding all my changes lol
Here...
In showmembers.php Find:
$Reged = $html -> convert_time($Reged,$user['U_TimeOffset']);

Change to

$Laston = $html -> convert_time($Laston,$user['U_TimeOffset']);

and that should do it, I've updated the original post
© UBB.Developers