Add total time spent online to users profile

Started by Ivan Minic, February 12, 2006, 09:58:23 PM

Previous topic - Next topic

Ivan Minic

Open: Profile.template.php
Find:
// If the person looking is an admin they can check the members IP address and hostname.
if ($user_info['is_admin'])
{
echo '
<tr>
<td width="40%">
<b>', $txt[512], ': </b>
</td><td>
<a href="', $scripturl, '?action=trackip;searchip=', $context['member']['ip'], '" target="_blank">', $context['member']['ip'], '</a>
</td>
</tr><tr>
<td width="40%">
<b>', $txt['hostname'], ': </b>
</td><td width="55%">
<div title="', $context['member']['hostname'], '" style="width: 100%; overflow: hidden; font-style: italic;">', $context['member']['hostname'], '</div>
</td>
</tr>


Replace with:
// If the person looking is an admin they can check the members IP address and hostname.
if ($user_info['is_admin'])
{
echo '
<tr>
<td width="40%" align="right">
<b>', $txt[512], ': </b>
</td><td>
<a href="', $scripturl, '?action=trackip;searchip=', $context['member']['ip'], '" target="_blank">', $context['member']['ip'], '</a>
</td>
</tr>';
}
echo '
<tr>
<td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>
</tr>
<tr>
<td align="right"><b>', $txt['statPanel_total_time_online'], ':</b></td>
<td>', $context['member']['time_logged_in'], '</td>
</tr>';

Add to Profile.english.php in language files:
$txt['statPanel_total_time_online'] = 'Total Time Spent Online';

husmen73 (Gulhin)

', $context['member']['time_logged_in'], '

this code dont work :S

There isn't describe
-Kurumsal Kimlik Web Tasarım Hizmeti.
Gülhin Portal Sistemi hakkında yorumlarınızı bekliyorum.
SMF
Referanslar --> http://www.gulhin.com/referanslar-portfoy/
-Web Tasarımı ve Tema Tasarımı Sitesi www.gulhin.com
-TOPLU MAİL GÖNDERİMİ --> http://www.toplumailsms.com
E-Ticaret Sistemi yaptırmak mı istiyorsunuz?

dannbass

#2
One thing that worked for me is this... but only if they are registered users... otherwise is a 0 minutes displayed... instead of the last part of the replace code.

If anybody has a better solution... please feel free to post it!
<tr>';
// Show the total time logged in?
if (!empty($context['user']['total_time_logged_in']))
{
echo '
<td><b>', $txt['totalTimeLogged1'], '</b></td>
<td>';

// If days is just zero, don't bother to show it.
if ($context['user']['total_time_logged_in']['days'] > 0)
echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];

// Same with hours - only show it if it's above zero.
if ($context['user']['total_time_logged_in']['hours'] > 0)
echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];

// But, let's always show minutes - Time wasted here: 0 minutes ;).
echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '<br />';
}
echo'
</td>
</tr>

Bulakbol

Here's my share.  Day or days, hour or hours, minute or minutes.

// Show the total time logged in?
if (!empty($context['user']['total_time_logged_in']))
{
echo '
', $txt['totalTimeLogged1'];

// If days is just zero, don't bother to show it.
if ($context['user']['total_time_logged_in']['days'] > 0)
echo $context['user']['total_time_logged_in']['days'], ' ',
$context['user']['total_time_logged_in']['days'] > 1 ? $txt['totalTimeLogged2'] : 'day, ';

// Same with hours - only show it if it's above zero.
if ($context['user']['total_time_logged_in']['hours'] > 0)
echo $context['user']['total_time_logged_in']['hours'], ' ',
$context['user']['total_time_logged_in']['hours'] == 1 ? 'hour and ' : $txt['totalTimeLogged3'];

// But, let's always show minutes - Time wasted here: 0 minutes ;).
echo $context['user']['total_time_logged_in']['minutes'],
$context['user']['total_time_logged_in']['minutes'] == 1 ? 'minute.' : $txt['totalTimeLogged4'], '<br />';
}
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Sabre™

Hey there Johny,
your code shows whoevers time logged, no matter what profile theyre looking at.
eg..  I see my time logged if Im looking at anyones profile.
Is this supposed to do that, or show you that persons time logged in their profile?

Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


Advertisement: