Does anyone know what the code would be to add this to a block. Right now it is a mod for SMF.
I haven't taken a real good look. I'm not even sure if this will work. If you have the mod working currently in the theme you're using. Try adding this code to a phpbox.
global $context, $settings, $options, $scripturl, $txt;
echo '<table>
<tr>
<td class="catbg" colspan="2">', $txt['uot_users_online_today_title'], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
<img src="', $settings['images_url'], '/icons/online.gif" alt="', $txt[158], ' ', $txt['uot_users_online_today_title'], '" border="0" />
</td>
<td class="windowbg2" width="100%">';
echo '
<div class="smalltext">';
echo $context['num_users_online_today'], ' ', $context['num_users_online_today'] == 1 ? $txt['uot_user_online_today'] : $txt['uot_users_online_today'];
if (!empty($context['users_online_today']))
echo ':<br />', implode(', ', $context['list_users_online_today']);
echo '
<br />', $context['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>
</td>
</tr></table>';
That doesn't work
it does work... but only on forum pages
what do we need to change to make it work on all TP pages?
ok, this be be done a # of ways...
oh ya, i tested on 1.1rc2 :P
ALWAYS MAKE BACKUPS OF FILES :)
/SSI.php
re-write the function "function ssi_whosOnline" to what's below
// Shows a list of online users: YY Guests, ZZ Users and then a list...
function ssi_whosOnline($output_method = 'echo')
{
global $txt, $scripturl, $db_prefix, $ID_MEMBER, $user_info, $sourcedir;
global $modSettings, $context, $settings;
// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}log_online AS lo
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);
$return['users'] = array();
$return['guests'] = 0;
$return['hidden'] = 0;
$return['buddies'] = 0;
$show_buddies = !empty($user_info['buddies']);
while ($row = mysql_fetch_assoc($result))
{
if (!isset($row['realName']))
$return['guests']++;
elseif (!empty($row['showOnline']) || allowedTo('moderate_forum'))
{
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
// Bold any buddies.
if ($show_buddies && in_array($row['ID_MEMBER'], $user_info['buddies']))
{
$return['buddies']++;
$link = '<b>' . $link . '</b>';
}
$return['users'][$row['logTime'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'hidden' => empty($row['showOnline']),
'is_last' => false,
);
}
else
$return['hidden']++;
}
mysql_free_result($result);
if (!empty($return['users']))
{
krsort($return['users']);
$userlist = array_keys($return['users']);
$return['users'][$userlist[count($userlist) - 1]]['is_last'] = true;
}
$return['num_users'] = count($return['users']) + $return['hidden'];
$return['total_users'] = $return['num_users'] + $return['guests'];
if ($output_method != 'echo')
return $return;
echo '
<div class="smalltext">';
echo '
', $return['guests'], ' ', $return['guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', $return['num_users'], ' ', $return['num_users'] == 1 ? $txt['user'] : $txt['users'];
// Hidden users, or buddies?
if ($return['hidden'] > 0 || $show_buddies)
echo '
(' . ($show_buddies ? ($return['buddies'] . ' ' . ($return['buddies'] == 1 ? $txt['buddy'] : $txt['buddies'])) : '') . ($show_buddies && $return['hidden'] ? ', ' : '') . (!$return['hidden'] ? '' : $return['hidden'] . ' ' . $txt['hidden']) . ')';
echo '<br />';
foreach ($return['users'] as $user)
echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'], $user['is_last'] ? '' : ', ';
echo'</div><br /><hr>';
// Load the users online today.
$nowdate = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $nowdate['mon'], $nowdate['mday'], $nowdate['year']) - ($modSettings['time_offset'] * 3600);
$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
$time_fmt = '%I:%M' . $s . ' %p';
else
$time_fmt = '%H:%M' . $s;
$result = db_query("
SELECT
mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE mem.lastLogin >= $midnight", __FILE__, __LINE__);
$context['users_online_today'] = array();
$context['list_users_online_today'] = array();
while ($row = mysql_fetch_assoc($result))
{
$userday = strftime('%d', forum_time(true));
$loginday = strftime('%d', forum_time(true, $row['lastLogin']));
$yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];
$lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
$title = (allowedTo('moderate_forum') || !empty($row['showOnline'])) ? ' title="' . $lastLogin . '"' : '';
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . ' style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . '>' . $row['realName'] . '</a>';
$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
{
$link = '<b>' . $link . '</b>';
}
$context['users_online_today'][$row['lastLogin'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'hidden' => empty($row['showOnline']),
);
$context['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = (empty($row['showOnline']) && allowedTo('moderate_forum')) ? '<i>' . $link . '</i>' : $link;
}
mysql_free_result($result);
krsort($context['users_online_today']);
krsort($context['list_users_online_today']);
$context['num_users_online_today'] = count($context['users_online_today']);
$context['num_users_online'] = count($context['users_online']) + $context['num_users_hidden'];
echo '
<div class="smalltext">';
echo $context['num_users_online_today'], ' ', $context['num_users_online_today'] == 1 ? strtolower($txt['user']) : strtolower($txt['users']);
// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online_today']))
echo '
', 'online today', ':<br />', implode(', ', $context['list_users_online_today']);
echo '
<br />', $context['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>';
}
then in a phpbox add:
require("/home/********PATH_TO_YOUR_FILE/public_html/forum/SSI.php");
ssi_whosOnline();
:o
[attachment deleted by admin]
Or if you want to keep any existing modifications to the SSI.php file (ie: Googlebot) just add another function by renaming function ssi_whosOnline($output_method = 'echo')
to function ssi_whosOnline_tp($output_method = 'echo')
and then add that function to the bottom of the SSI.php file and save it to your server
Then do the last step that snork13 suggested at the bottom of his post.
yes, as houston said, you could just add a new function if you wanted too.
great stuff! works great thanks!!!!!
I'm not sure what I am doing wrong but I cannot get this to work...
I got my forum upgraded to RC2, so that is not the problem anymore.
I'm not real familiar with SMF so the instructions above are pretty confusing to me.
Is there any way I can have better/detailed instructions for this?
Thank you in advance.
aloha!
bad news about above code by Snork... I have been clearing up errors in the forum error log and I found 3 SSI errors wich come from above code!
errors:
8: Undefined index: show_stats
File: /home/resellers/841289/841289/corenation.com/www/smf/SSI.php
Line: 1711
8: Undefined index: num_users_hidden
File: /home/resellers/841289/841289/corenation.com/www/smf/SSI.php
Line: 1698
8: Undefined index: users_online
File: /home/resellers/841289/841289/corenation.com/www/smf/SSI.php
Line: 1698
as soon as I turn the block off - no errors!
please help resolve!
cheers,
core
Users Online Today
An Error Has Occurred!
Unknown(/public_html/whiplash/SSI.php): failed to open stream: No such file or directory
Back
Notice: Array to string conversion in /home/whiplash/public_html/whiplash/Sources/Subs.php on line 1876
Notice: Undefined offset: 1 in /home/whiplash/public_html/whiplash/Sources/Subs.php on line 1878
Users Online Today
Warning: Unknown(/public_html/whiplash/SSI.php): failed to open stream: No such file or directory in /home/whiplash/public_html/whiplash/Sources/Load.php(1040) : eval()'d code(34) : eval()'d code on line 1
Warning: Unknown(/public_html/whiplash/SSI.php): failed to open stream: No such file or directory in /home/whiplash/public_html/whiplash/Sources/Load.php(1040) : eval()'d code(34) : eval()'d code on line 1
Fatal error: (null)(): Failed opening required '/public_html/whiplash/SSI.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/whiplash/public_html/whiplash/Sources/Load.php(1040) : eval()'d code(34) : eval()'d code on line 1 this is what i am getting??
Quote from: core on March 05, 2006, 02:31:29 AM
aloha!
bad news about above code by Snork... I have been clearing up errors in the forum error log and I found 3 SSI errors wich come from above code!
errors:
8: Undefined index: show_stats
File: /home/resellers/841289/841289/corenation.com/www/smf/SSI.php
Line: 1711
8: Undefined index: num_users_hidden
File: /home/resellers/841289/841289/corenation.com/www/smf/SSI.php
Line: 1698
8: Undefined index: users_online
File: /home/resellers/841289/841289/corenation.com/www/smf/SSI.php
Line: 1698
as soon as I turn the block off - no errors!
please help resolve!
cheers,
core
i just don't have the time to look into this week, but have you check the language files, would be my first look
Quote from: Alan S on March 06, 2006, 09:43:27 AM
Users Online Today
An Error Has Occurred!
Unknown(/public_html/whiplash/SSI.php): failed to open stream: No such file or directory
Back
Notice: Array to string conversion in /home/whiplash/public_html/whiplash/Sources/Subs.php on line 1876
Notice: Undefined offset: 1 in /home/whiplash/public_html/whiplash/Sources/Subs.php on line 1878
Users Online Today
Warning: Unknown(/public_html/whiplash/SSI.php): failed to open stream: No such file or directory in /home/whiplash/public_html/whiplash/Sources/Load.php(1040) : eval()'d code(34) : eval()'d code on line 1
Warning: Unknown(/public_html/whiplash/SSI.php): failed to open stream: No such file or directory in /home/whiplash/public_html/whiplash/Sources/Load.php(1040) : eval()'d code(34) : eval()'d code on line 1
Fatal error: (null)(): Failed opening required '/public_html/whiplash/SSI.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/whiplash/public_html/whiplash/Sources/Load.php(1040) : eval()'d code(34) : eval()'d code on line 1 this is what i am getting??
your link to your ssi.php is wrong or not there
erm, I tried this with both 1.1 RC2 and on 1.0.6 using TP and well yeah it's great, it's just another users online, not users online today. On both boards I've tested this with, it's shown only the current users online
Quote from: snork13 on March 06, 2006, 03:39:07 PM
Quote from: core on March 05, 2006, 02:31:29 AM
aloha!
bad news about above code by Snork... I have been clearing up errors in the forum error log and I found 3 SSI errors wich come from above code!
errors:
8: Undefined index: show_stats
File: /home/resellers/841289/841289/corenation.com/www/smf/SSI.php
Line: 1711
8: Undefined index: num_users_hidden
File: /home/resellers/841289/841289/corenation.com/www/smf/SSI.php
Line: 1698
8: Undefined index: users_online
File: /home/resellers/841289/841289/corenation.com/www/smf/SSI.php
Line: 1698
as soon as I turn the block off - no errors!
please help resolve!
cheers,
core
i just don't have the time to look into this week, but have you check the language files, would be my first look
Any news about these errors ? I cant find anything wrong on my language files...
bump...
which language file should change ??
I'm also using 1.1rc2
PLEASE PLEASE PLEASE ALWAYS BACKUP FILES BEFORE CHANGING THEM!!!
Okay I played around with this idea some today. I tried the PHPbox method and noticed that the regular Stats Box wasn't showing Online Today. I wanted to show the Users that were online today within the Stats Box and Light an Icon if they were also currently online. I also wanted a nice way to see what time they were online.
These are the changes I made. They worked for me without generating errors.
in SSI.PHP add before the ?> at the end, add this:
// Shows a list of online users: YY Guests, ZZ Users and then a list... Also shows who was online TODAY
function ssi_whosOnline_today($output_method = 'echo')
{
global $txt, $scripturl, $db_prefix, $ID_MEMBER, $user_info, $sourcedir;
global $modSettings, $settings;
//global $context;
// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}log_online AS lo
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);
$return['users'] = array();
$return['guests'] = 0;
$return['hidden'] = 0;
$return['buddies'] = 0;
$show_buddies = !empty($user_info['buddies']);
while ($row = mysql_fetch_assoc($result))
{
if (!isset($row['realName']))
$return['guests']++;
elseif (!empty($row['showOnline']) || allowedTo('moderate_forum'))
{
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
// Bold any buddies.
if ($show_buddies && in_array($row['ID_MEMBER'], $user_info['buddies']))
{
$return['buddies']++;
$link = '<b>' . $link . '</b>';
}
$return['users'][$row['logTime'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'hidden' => empty($row['showOnline']),
'is_last' => false,
);
}
else
$return['hidden']++;
}
mysql_free_result($result);
if (!empty($return['users']))
{
krsort($return['users']);
$userlist = array_keys($return['users']);
$return['users'][$userlist[count($userlist) - 1]]['is_last'] = true;
}
$return['num_users'] = count($return['users']) + $return['hidden'];
$return['total_users'] = $return['num_users'] + $return['guests'];
// echo to screen?
if ($output_method == 'echo')
{
echo '
<div class="smalltext">';
echo '
', $return['guests'], ' ', $return['guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', $return['num_users'], ' ', $return['num_users'] == 1 ? $txt['user'] : $txt['users'];
// Hidden users, or buddies?
if ($return['hidden'] > 0 || $show_buddies)
echo '
(' . ($show_buddies ? ($return['buddies'] . ' ' . ($return['buddies'] == 1 ? $txt['buddy'] : $txt['buddies'])) : '') . ($show_buddies && $return['hidden'] ? ', ' : '') . (!$return['hidden'] ? '' : $return['hidden'] . ' ' . $txt['hidden']) . ')';
echo '<br />';
foreach ($return['users'] as $user)
echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'], $user['is_last'] ? '' : ', ';
echo'</div><br /><hr>';
}
// Load the users online today.
$nowdate = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $nowdate['mon'], $nowdate['mday'], $nowdate['year']) - ($modSettings['time_offset'] * 3600);
$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
$time_fmt = '%I:%M' . $s . ' %p';
else
$time_fmt = '%H:%M' . $s;
$result = db_query("
SELECT
mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE mem.lastLogin >= $midnight", __FILE__, __LINE__);
$return['users_online_today'] = array();
$return['list_users_online_today'] = array();
while ($row = mysql_fetch_assoc($result))
{
$userday = strftime('%d', forum_time(true));
$loginday = strftime('%d', forum_time(true, $row['lastLogin']));
$yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];
$lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
$title = (allowedTo('moderate_forum') || !empty($row['showOnline'])) ? ' title="' . $lastLogin . '"' : '';
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . ' style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . '>' . $row['realName'] . '</a>';
$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
{
$link = '<b>' . $link . '</b>';
}
$is_online = false;
if ($return['num_users']>0)
{
foreach($return['users'] as $user)
{
if ($user['id'] == $row['ID_MEMBER'])
{
$is_online = true;
}
}
}
$return['users_online_today'][$row['lastLogin'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'is_online' => $is_online,
'hidden' => empty($row['showOnline']),
);
$return['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = (empty($row['showOnline']) && allowedTo('moderate_forum')) ? '<i>' . $link . '</i>' : $link;
}
mysql_free_result($result);
krsort($return['users_online_today']);
krsort($return['list_users_online_today']);
$return['num_users_online_today'] = count($return['users_online_today']);
// echo to screen?
if ($output_method == 'echo')
{
echo '
<div class="smalltext">';
echo $return['num_users_online_today'], ' ', $return['num_users_online_today'] == 1 ? strtolower($txt['user']) : strtolower($txt['users']);
// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($return['users_online_today']))
echo '
', 'online today', ':<br />', implode(', ', $return['list_users_online_today']);
echo '
<br />', $return['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>';
}
else
return $return;
}
and in the TPortalBlocks.template.php find the TPortal_statsbox() function:
just after this:
// TPortal stats box
function TPortal_statsbox()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
add this:
$bullet_on = '<img src="'.$settings['images_url'].'/useron.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet_off = '<img src="'.$settings['images_url'].'/useroff.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
and just after this:
if(isset($context['TPortal']['userbox']['online']))
{
// add online users
echo '<hr /><img src="'.$settings['images_url'].'/icons/online.gif" style="margin: 0;" align="bottom" alt="" />
<a href="'.$scripturl.'?action=who"><b>'.$txt[158].'</b></a><br />';
$online = ssi_whosOnline('array');
echo $bullet.$txt['tp-users'].': '.$online['num_users'];
echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
//echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />
echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'
<div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'"><br />';
foreach($online['users'] as $user)
{
echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
}
echo '</div>';
add this:
// add online today
echo '<br /><b>Online Today</b><br />';
$online = ssi_whosOnline_today('array');
echo $bullet.$txt['tp-total'].': '.$online['num_users_online_today'].'
<div style="width: 100%; ' , $online['num_users_online_today']>14 ? 'height: 23ex;overflow: auto;' : '' ,'"><br />';
foreach($online['users_online_today'] as $user)
{
if ($user['is_online'])
echo $bullet_on, $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
else
echo $bullet_off, $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
}
echo '</div>';
also works from a PHP block with this code:
require("/home/********PATH_TO_YOUR_FILE/public_html/smf/SSI.php");
ssi_whosOnline_today();
I am still pretty new to PHP, but I'm learning. If you know a better and/or more efficient way to do this, please by all means tell us about it.
Very cool! :up:
Gabo Gabo (Thank you in venutian) :D
hey just wanted to ask is there a way i can have a "horizontal layout" as opposed to a vertical one?
Cos my page blocks are sure piling up and its looking crazy now :P
You could also try something like this in a php block: It will list all the users horizonally, not in a list format. Best of all you don't need to change any code in the templates.
without a image
echo '
<span class="smalltext">';
ssi_whosOnline();
echo '</span>';
with a image:
echo '<a href="'.$scripturl.'?action=who"><img src="'.$settings['actual_images_url'].'/icons/online.gif'.'" /> <b>'.$txt[158].'</b></a><br>
<span class="smalltext">';
ssi_whosOnline();
echo '</span>';
who me?
:coolsmiley: Anyone who wants to use it ;)
oohhh lol
i was just askin cos i wanted a horizontal lay out
the vertical one is getting a bit crowded on my site
Well give it a shot in a horizontal layout and see if you like it.
Quote from: Haiduk on October 08, 2006, 05:27:00 PM
I'm also using 1.1rc2
PLEASE PLEASE PLEASE ALWAYS BACKUP FILES BEFORE CHANGING THEM!!!
Okay I played around with this idea some today. I tried the PHPbox method and noticed that the regular Stats Box wasn't showing Online Today. I wanted to show the Users that were online today within the Stats Box and Light an Icon if they were also currently online. I also wanted a nice way to see what time they were online.
These are the changes I made. They worked for me without generating errors.
in SSI.PHP add before the ?> at the end, add this:
// Shows a list of online users: YY Guests, ZZ Users and then a list... Also shows who was online TODAY
function ssi_whosOnline_today($output_method = 'echo')
{
global $txt, $scripturl, $db_prefix, $ID_MEMBER, $user_info, $sourcedir;
global $modSettings, $settings;
//global $context;
// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}log_online AS lo
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);
$return['users'] = array();
$return['guests'] = 0;
$return['hidden'] = 0;
$return['buddies'] = 0;
$show_buddies = !empty($user_info['buddies']);
while ($row = mysql_fetch_assoc($result))
{
if (!isset($row['realName']))
$return['guests']++;
elseif (!empty($row['showOnline']) || allowedTo('moderate_forum'))
{
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
// Bold any buddies.
if ($show_buddies && in_array($row['ID_MEMBER'], $user_info['buddies']))
{
$return['buddies']++;
$link = '<b>' . $link . '</b>';
}
$return['users'][$row['logTime'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'hidden' => empty($row['showOnline']),
'is_last' => false,
);
}
else
$return['hidden']++;
}
mysql_free_result($result);
if (!empty($return['users']))
{
krsort($return['users']);
$userlist = array_keys($return['users']);
$return['users'][$userlist[count($userlist) - 1]]['is_last'] = true;
}
$return['num_users'] = count($return['users']) + $return['hidden'];
$return['total_users'] = $return['num_users'] + $return['guests'];
// echo to screen?
if ($output_method == 'echo')
{
echo '
<div class="smalltext">';
echo '
', $return['guests'], ' ', $return['guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', $return['num_users'], ' ', $return['num_users'] == 1 ? $txt['user'] : $txt['users'];
// Hidden users, or buddies?
if ($return['hidden'] > 0 || $show_buddies)
echo '
(' . ($show_buddies ? ($return['buddies'] . ' ' . ($return['buddies'] == 1 ? $txt['buddy'] : $txt['buddies'])) : '') . ($show_buddies && $return['hidden'] ? ', ' : '') . (!$return['hidden'] ? '' : $return['hidden'] . ' ' . $txt['hidden']) . ')';
echo '<br />';
foreach ($return['users'] as $user)
echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'], $user['is_last'] ? '' : ', ';
echo'</div><br /><hr>';
}
// Load the users online today.
$nowdate = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $nowdate['mon'], $nowdate['mday'], $nowdate['year']) - ($modSettings['time_offset'] * 3600);
$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
$time_fmt = '%I:%M' . $s . ' %p';
else
$time_fmt = '%H:%M' . $s;
$result = db_query("
SELECT
mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE mem.lastLogin >= $midnight", __FILE__, __LINE__);
$return['users_online_today'] = array();
$return['list_users_online_today'] = array();
while ($row = mysql_fetch_assoc($result))
{
$userday = strftime('%d', forum_time(true));
$loginday = strftime('%d', forum_time(true, $row['lastLogin']));
$yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];
$lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
$title = (allowedTo('moderate_forum') || !empty($row['showOnline'])) ? ' title="' . $lastLogin . '"' : '';
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . ' style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . '>' . $row['realName'] . '</a>';
$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
{
$link = '<b>' . $link . '</b>';
}
$is_online = false;
if ($return['num_users']>0)
{
foreach($return['users'] as $user)
{
if ($user['id'] == $row['ID_MEMBER'])
{
$is_online = true;
}
}
}
$return['users_online_today'][$row['lastLogin'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'is_online' => $is_online,
'hidden' => empty($row['showOnline']),
);
$return['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = (empty($row['showOnline']) && allowedTo('moderate_forum')) ? '<i>' . $link . '</i>' : $link;
}
mysql_free_result($result);
krsort($return['users_online_today']);
krsort($return['list_users_online_today']);
$return['num_users_online_today'] = count($return['users_online_today']);
// echo to screen?
if ($output_method == 'echo')
{
echo '
<div class="smalltext">';
echo $return['num_users_online_today'], ' ', $return['num_users_online_today'] == 1 ? strtolower($txt['user']) : strtolower($txt['users']);
// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($return['users_online_today']))
echo '
', 'online today', ':<br />', implode(', ', $return['list_users_online_today']);
echo '
<br />', $return['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>';
}
else
return $return;
}
and in the TPortalBlocks.template.php find the TPortal_statsbox() function:
just after this:
// TPortal stats box
function TPortal_statsbox()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
add this:
$bullet_on = '<img src="'.$settings['images_url'].'/useron.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet_off = '<img src="'.$settings['images_url'].'/useroff.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
and just after this:
if(isset($context['TPortal']['userbox']['online']))
{
// add online users
echo '<hr /><img src="'.$settings['images_url'].'/icons/online.gif" style="margin: 0;" align="bottom" alt="" />
<a href="'.$scripturl.'?action=who"><b>'.$txt[158].'</b></a><br />';
$online = ssi_whosOnline('array');
echo $bullet.$txt['tp-users'].': '.$online['num_users'];
echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
//echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />
echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'
<div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'"><br />';
foreach($online['users'] as $user)
{
echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
}
echo '</div>';
add this:
// add online today
echo '<br /><b>Online Today</b><br />';
$online = ssi_whosOnline_today('array');
echo $bullet.$txt['tp-total'].': '.$online['num_users_online_today'].'
<div style="width: 100%; ' , $online['num_users_online_today']>14 ? 'height: 23ex;overflow: auto;' : '' ,'"><br />';
foreach($online['users_online_today'] as $user)
{
if ($user['is_online'])
echo $bullet_on, $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
else
echo $bullet_off, $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
}
echo '</div>';
also works from a PHP block with this code:
require("/home/********PATH_TO_YOUR_FILE/public_html/smf/SSI.php");
ssi_whosOnline_today();
I am still pretty new to PHP, but I'm learning. If you know a better and/or more efficient way to do this, please by all means tell us about it.
hey i tired this code on rc3 work ok. but i cant find TPortalBlocks.template.php. i just edited SSI.php and copied this into phpbox "ssi_whosOnline_today(); ". can someone tell me how to do like he told. am using smf 1.1 rc3 and tp v0.9.5
regards
If the theme you edit the code in doesent have it's own TPortalBlock.template.php file, it fetch the one from the default themes folder instead.
So if you missing out on some code, thats where you have to add the code in.
Quote from: G6 on October 17, 2006, 07:26:57 AM
If the theme you edit the code in doesent have it's own TPortalBlock.template.php file, it fetch the one from the default themes folder instead.
So if you missing out on some code, thats where you have to add the code in.
G6 am sorry i dint understand
If the othet theme you have installed dosent have the TPortalBlocks.template.php, the theme will look for the file in the default theme directory instead.
So if you add code in that TPortalBlocks.template.php need (if it doesent have it already as all mods installs to the default theme directory) you have to add it in the file in the default directory
Thanks G6 i found it...i really starting fallin love with TP
Glad to hear im not the only one :)
Quote from: Haiduk on October 08, 2006, 05:27:00 PM
I'm also using 1.1rc2
PLEASE PLEASE PLEASE ALWAYS BACKUP FILES BEFORE CHANGING THEM!!!
Okay I played around with this idea some today. I tried the PHPbox method and noticed that the regular Stats Box wasn't showing Online Today. I wanted to show the Users that were online today within the Stats Box and Light an Icon if they were also currently online. I also wanted a nice way to see what time they were online.
These are the changes I made. They worked for me without generating errors.
Cool thanks for sharing just used it works perfect ;)
can some one help me in add this code in to this.
to add a scroll bar. i mean if the members online today goes beyond 7 then the scroll bar will be activated. like we have here in the "Some stats.."
Quote from: Haiduk on October 08, 2006, 05:27:00 PM
I'm also using 1.1rc2
PLEASE PLEASE PLEASE ALWAYS BACKUP FILES BEFORE CHANGING THEM!!!
Okay I played around with this idea some today. I tried the PHPbox method and noticed that the regular Stats Box wasn't showing Online Today. I wanted to show the Users that were online today within the Stats Box and Light an Icon if they were also currently online. I also wanted a nice way to see what time they were online.
These are the changes I made. They worked for me without generating errors.
in SSI.PHP add before the ?> at the end, add this:
// Shows a list of online users: YY Guests, ZZ Users and then a list... Also shows who was online TODAY
function ssi_whosOnline_today($output_method = 'echo')
{
global $txt, $scripturl, $db_prefix, $ID_MEMBER, $user_info, $sourcedir;
global $modSettings, $settings;
//global $context;
// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}log_online AS lo
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);
$return['users'] = array();
$return['guests'] = 0;
$return['hidden'] = 0;
$return['buddies'] = 0;
$show_buddies = !empty($user_info['buddies']);
while ($row = mysql_fetch_assoc($result))
{
if (!isset($row['realName']))
$return['guests']++;
elseif (!empty($row['showOnline']) || allowedTo('moderate_forum'))
{
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
// Bold any buddies.
if ($show_buddies && in_array($row['ID_MEMBER'], $user_info['buddies']))
{
$return['buddies']++;
$link = '<b>' . $link . '</b>';
}
$return['users'][$row['logTime'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'hidden' => empty($row['showOnline']),
'is_last' => false,
);
}
else
$return['hidden']++;
}
mysql_free_result($result);
if (!empty($return['users']))
{
krsort($return['users']);
$userlist = array_keys($return['users']);
$return['users'][$userlist[count($userlist) - 1]]['is_last'] = true;
}
$return['num_users'] = count($return['users']) + $return['hidden'];
$return['total_users'] = $return['num_users'] + $return['guests'];
// echo to screen?
if ($output_method == 'echo')
{
echo '
<div class="smalltext">';
echo '
', $return['guests'], ' ', $return['guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', $return['num_users'], ' ', $return['num_users'] == 1 ? $txt['user'] : $txt['users'];
// Hidden users, or buddies?
if ($return['hidden'] > 0 || $show_buddies)
echo '
(' . ($show_buddies ? ($return['buddies'] . ' ' . ($return['buddies'] == 1 ? $txt['buddy'] : $txt['buddies'])) : '') . ($show_buddies && $return['hidden'] ? ', ' : '') . (!$return['hidden'] ? '' : $return['hidden'] . ' ' . $txt['hidden']) . ')';
echo '<br />';
foreach ($return['users'] as $user)
echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'], $user['is_last'] ? '' : ', ';
echo'</div><br /><hr>';
}
// Load the users online today.
$nowdate = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $nowdate['mon'], $nowdate['mday'], $nowdate['year']) - ($modSettings['time_offset'] * 3600);
$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
$time_fmt = '%I:%M' . $s . ' %p';
else
$time_fmt = '%H:%M' . $s;
$result = db_query("
SELECT
mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE mem.lastLogin >= $midnight", __FILE__, __LINE__);
$return['users_online_today'] = array();
$return['list_users_online_today'] = array();
while ($row = mysql_fetch_assoc($result))
{
$userday = strftime('%d', forum_time(true));
$loginday = strftime('%d', forum_time(true, $row['lastLogin']));
$yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];
$lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
$title = (allowedTo('moderate_forum') || !empty($row['showOnline'])) ? ' title="' . $lastLogin . '"' : '';
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . ' style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . '>' . $row['realName'] . '</a>';
$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
{
$link = '<b>' . $link . '</b>';
}
$is_online = false;
if ($return['num_users']>0)
{
foreach($return['users'] as $user)
{
if ($user['id'] == $row['ID_MEMBER'])
{
$is_online = true;
}
}
}
$return['users_online_today'][$row['lastLogin'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'is_online' => $is_online,
'hidden' => empty($row['showOnline']),
);
$return['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = (empty($row['showOnline']) && allowedTo('moderate_forum')) ? '<i>' . $link . '</i>' : $link;
}
mysql_free_result($result);
krsort($return['users_online_today']);
krsort($return['list_users_online_today']);
$return['num_users_online_today'] = count($return['users_online_today']);
// echo to screen?
if ($output_method == 'echo')
{
echo '
<div class="smalltext">';
echo $return['num_users_online_today'], ' ', $return['num_users_online_today'] == 1 ? strtolower($txt['user']) : strtolower($txt['users']);
// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($return['users_online_today']))
echo '
', 'online today', ':<br />', implode(', ', $return['list_users_online_today']);
echo '
<br />', $return['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>';
}
else
return $return;
}
and in the TPortalBlocks.template.php find the TPortal_statsbox() function:
just after this:
// TPortal stats box
function TPortal_statsbox()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
add this:
$bullet_on = '<img src="'.$settings['images_url'].'/useron.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet_off = '<img src="'.$settings['images_url'].'/useroff.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
and just after this:
if(isset($context['TPortal']['userbox']['online']))
{
// add online users
echo '<hr /><img src="'.$settings['images_url'].'/icons/online.gif" style="margin: 0;" align="bottom" alt="" />
<a href="'.$scripturl.'?action=who"><b>'.$txt[158].'</b></a><br />';
$online = ssi_whosOnline('array');
echo $bullet.$txt['tp-users'].': '.$online['num_users'];
echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
//echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />
echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'
<div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'"><br />';
foreach($online['users'] as $user)
{
echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
}
echo '</div>';
add this:
// add online today
echo '<br /><b>Online Today</b><br />';
$online = ssi_whosOnline_today('array');
echo $bullet.$txt['tp-total'].': '.$online['num_users_online_today'].'
<div style="width: 100%; ' , $online['num_users_online_today']>14 ? 'height: 23ex;overflow: auto;' : '' ,'"><br />';
foreach($online['users_online_today'] as $user)
{
if ($user['is_online'])
echo $bullet_on, $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
else
echo $bullet_off, $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
}
echo '</div>';
also works from a PHP block with this code:
require("/home/********PATH_TO_YOUR_FILE/public_html/smf/SSI.php");
ssi_whosOnline_today();
I am still pretty new to PHP, but I'm learning. If you know a better and/or more efficient way to do this, please by all means tell us about it.
Worked like a charm , Thank you
Can some one help me followed everything and this is what I got: When more than one person is logged in it dupilcates everything
ok what did I due wrong Because I can't see anything wrong, I have one for each person. added files if anyone can look
could someone take a look at this again, it doesnt seem to work with the 1.1 final upgrade
Nevermind , I got it. Thanks
OK... I have 2 questions.
1. is there a way to only put on online users today and not online users. See it looks stuipid to have to online users and I like using the one in the stats box cause I can use the view online users link. I tryed to see if I could do it myself and I locked up the site. Thank goodness of backed up files.
2. I'm also getting a forum error:
Site Admin Today at 09:25 AM
caderothwelllodge.org/forum/index.php?action=tpadmin;sa=blocks
8: Undefined index: show_stats
File: /var/www/html/forum/SSI.php
Line: 1803
line 1803:
', $return['show_stats'] & !$settings['show_sp1_info'] ? '
any ideas?
Please help, I'm using RC3 1.1 and I ahve downloaded twice this mod and there are test failed on the files:
Installing this package will perform the following actions:
Type Action Description
1. Execute Modification ./Sources/BoardIndex.php Test successful
2. Execute Modification ./Sources/Stats.php Test successful
3. Execute Modification ./Themes/default/BoardIndex.template.php Test successful
4. Execute Modification ./Themes/default/Stats.template.php Test failed
5. Execute Modification ./Themes/default/languages/Modifications.english.php Test successful
6. Execute Modification ./Themes/default/languages/Stats.english.php Test failed
Still the same even if I reset to default theme.
Help pls
Do you have any other mods installed that touches those two files ?
Manual Installation of Mods
http://docs.simplemachines.org/index.php?topic=402
I gave mariz26 the same link with an explaination of how to fix it on smfhelper.info. I think he/she wants someone to do it for him/her.
Quote from: Haiduk on October 08, 2006, 05:27:00 PM
I'm also using 1.1rc2
PLEASE PLEASE PLEASE ALWAYS BACKUP FILES BEFORE CHANGING THEM!!!
Okay I played around with this idea some today. I tried the PHPbox method and noticed that the regular Stats Box wasn't showing Online Today. I wanted to show the Users that were online today within the Stats Box and Light an Icon if they were also currently online. I also wanted a nice way to see what time they were online.
These are the changes I made. They worked for me without generating errors.
in SSI.PHP add before the ?> at the end, add this:
// Shows a list of online users: YY Guests, ZZ Users and then a list... Also shows who was online TODAY
function ssi_whosOnline_today($output_method = 'echo')
{
global $txt, $scripturl, $db_prefix, $ID_MEMBER, $user_info, $sourcedir;
global $modSettings, $settings;
//global $context;
// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}log_online AS lo
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);
$return['users'] = array();
$return['guests'] = 0;
$return['hidden'] = 0;
$return['buddies'] = 0;
$show_buddies = !empty($user_info['buddies']);
while ($row = mysql_fetch_assoc($result))
{
if (!isset($row['realName']))
$return['guests']++;
elseif (!empty($row['showOnline']) || allowedTo('moderate_forum'))
{
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
// Bold any buddies.
if ($show_buddies && in_array($row['ID_MEMBER'], $user_info['buddies']))
{
$return['buddies']++;
$link = '<b>' . $link . '</b>';
}
$return['users'][$row['logTime'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'hidden' => empty($row['showOnline']),
'is_last' => false,
);
}
else
$return['hidden']++;
}
mysql_free_result($result);
if (!empty($return['users']))
{
krsort($return['users']);
$userlist = array_keys($return['users']);
$return['users'][$userlist[count($userlist) - 1]]['is_last'] = true;
}
$return['num_users'] = count($return['users']) + $return['hidden'];
$return['total_users'] = $return['num_users'] + $return['guests'];
// echo to screen?
if ($output_method == 'echo')
{
echo '
<div class="smalltext">';
echo '
', $return['guests'], ' ', $return['guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', $return['num_users'], ' ', $return['num_users'] == 1 ? $txt['user'] : $txt['users'];
// Hidden users, or buddies?
if ($return['hidden'] > 0 || $show_buddies)
echo '
(' . ($show_buddies ? ($return['buddies'] . ' ' . ($return['buddies'] == 1 ? $txt['buddy'] : $txt['buddies'])) : '') . ($show_buddies && $return['hidden'] ? ', ' : '') . (!$return['hidden'] ? '' : $return['hidden'] . ' ' . $txt['hidden']) . ')';
echo '<br />';
foreach ($return['users'] as $user)
echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'], $user['is_last'] ? '' : ', ';
echo'</div><br /><hr>';
}
// Load the users online today.
$nowdate = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $nowdate['mon'], $nowdate['mday'], $nowdate['year']) - ($modSettings['time_offset'] * 3600);
$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
$time_fmt = '%I:%M' . $s . ' %p';
else
$time_fmt = '%H:%M' . $s;
$result = db_query("
SELECT
mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE mem.lastLogin >= $midnight", __FILE__, __LINE__);
$return['users_online_today'] = array();
$return['list_users_online_today'] = array();
while ($row = mysql_fetch_assoc($result))
{
$userday = strftime('%d', forum_time(true));
$loginday = strftime('%d', forum_time(true, $row['lastLogin']));
$yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];
$lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
$title = (allowedTo('moderate_forum') || !empty($row['showOnline'])) ? ' title="' . $lastLogin . '"' : '';
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . ' style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . '>' . $row['realName'] . '</a>';
$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
{
$link = '<b>' . $link . '</b>';
}
$is_online = false;
if ($return['num_users']>0)
{
foreach($return['users'] as $user)
{
if ($user['id'] == $row['ID_MEMBER'])
{
$is_online = true;
}
}
}
$return['users_online_today'][$row['lastLogin'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'is_online' => $is_online,
'hidden' => empty($row['showOnline']),
);
$return['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = (empty($row['showOnline']) && allowedTo('moderate_forum')) ? '<i>' . $link . '</i>' : $link;
}
mysql_free_result($result);
krsort($return['users_online_today']);
krsort($return['list_users_online_today']);
$return['num_users_online_today'] = count($return['users_online_today']);
// echo to screen?
if ($output_method == 'echo')
{
echo '
<div class="smalltext">';
echo $return['num_users_online_today'], ' ', $return['num_users_online_today'] == 1 ? strtolower($txt['user']) : strtolower($txt['users']);
// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($return['users_online_today']))
echo '
', 'online today', ':<br />', implode(', ', $return['list_users_online_today']);
echo '
<br />', $return['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>';
}
else
return $return;
}
and in the TPortalBlocks.template.php find the TPortal_statsbox() function:
just after this:
// TPortal stats box
function TPortal_statsbox()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
add this:
$bullet_on = '<img src="'.$settings['images_url'].'/useron.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet_off = '<img src="'.$settings['images_url'].'/useroff.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
and just after this:
if(isset($context['TPortal']['userbox']['online']))
{
// add online users
echo '<hr /><img src="'.$settings['images_url'].'/icons/online.gif" style="margin: 0;" align="bottom" alt="" />
<a href="'.$scripturl.'?action=who"><b>'.$txt[158].'</b></a><br />';
$online = ssi_whosOnline('array');
echo $bullet.$txt['tp-users'].': '.$online['num_users'];
echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
//echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />
echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'
<div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'"><br />';
foreach($online['users'] as $user)
{
echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
}
echo '</div>';
add this:
// add online today
echo '<br /><b>Online Today</b><br />';
$online = ssi_whosOnline_today('array');
echo $bullet.$txt['tp-total'].': '.$online['num_users_online_today'].'
<div style="width: 100%; ' , $online['num_users_online_today']>14 ? 'height: 23ex;overflow: auto;' : '' ,'"><br />';
foreach($online['users_online_today'] as $user)
{
if ($user['is_online'])
echo $bullet_on, $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
else
echo $bullet_off, $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
}
echo '</div>';
also works from a PHP block with this code:
require("/home/********PATH_TO_YOUR_FILE/public_html/smf/SSI.php");
ssi_whosOnline_today();
I am still pretty new to PHP, but I'm learning. If you know a better and/or more efficient way to do this, please by all means tell us about it.
Damn it looks nice, haha! :D:D THANKS
Heya,
I am using SMF 1.1.2 and TP 0.9.7 and I have this mod installed,
but all the data before talks about 1.1RC2, pretty old don't you think? ;)
So are there any major changes in the code's for the new version of SMF and TP? if yes could you please tell me, I'm not a professional coder ;)
Thanks :)
I would like to know it too, hope somebody tells it here :up:
Damn people, how about starting to read on SMf and whats in here already ?
Yes, there are a LOT of changes from rc2 to smf 1.1.2 and TP V095 tp TP V.0983
If you use outdated mods on your sites, dont expect us to give you all the support on them.
Seek the help from the mod author, and if he/she doesent give you help, then dont use them.
We dont support any other mods here besides what this site is all about TinyPortal.
This thread is now locked.