Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: Ivan Minic in Februar 12, 2006, 09:58:23 NACHMITTAGS

Titel: Add total time spent online to users profile
Beitrag von: Ivan Minic in Februar 12, 2006, 09:58:23 NACHMITTAGS
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';
Titel: Re: Add total time spent online to users profile
Beitrag von: husmen73 (Gulhin) in Oktober 05, 2006, 10:52:58 VORMITTAG
', $context['member']['time_logged_in'], '

this code dont work :S

There isn't describe
Titel: Re: Add total time spent online to users profile
Beitrag von: dannbass in Januar 17, 2008, 07:25:45 NACHMITTAGS
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>
Titel: Re: Add total time spent online to users profile
Beitrag von: Bulakbol in Januar 22, 2008, 01:16:15 VORMITTAG
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 />';
}
Titel: Re: Add total time spent online to users profile
Beitrag von: Sabre™ in November 05, 2008, 06:05:27 VORMITTAG
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?