Hi Guys and Gals
Have created this Block for
User Info
Whos on line
Num of Posts
But I would like to add the number of spiders to it as well and also the mini calendar the block code and mini cal code is attached and also a couple of SShots
also I would like to tidy the code up a bit as my PHP skills are very poor and it looks very long winded
If any one has a little time I would most appreciate it
Cheers
Shortie
P.S. Using SMF RC1 and SP 2.1.1
-------------------------------
Block Code
{
global $smcFunc, $memberContext, $context, $user_info, $txt, $scripturl, $modSettings, $settings, $sc;
global $color_profile;
if($context['user']['is_logged'])
{
$member_id = $user_info['id'];
loadMemberData($member_id);
loadMemberContext($member_id);
//If you install the Membercolor Link the colors will be autmaticly set.
if(empty($modSettings['MemberColorLinkInstalled']) && sp_loadColors($member_id) !== false)
$memberContext[$member_id]['colored_name'] = $color_profile[$member_id]['colored_name'];
$memberContext[$member_id]['karma']['total'] = $memberContext[$member_id]['karma']['good'] - $memberContext[$member_id]['karma']['bad'];
}
echo '<div align="center">';
if ($context['user']['is_guest'])
{
echo '<form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '">
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td align="right"><label for="user">', $txt['username'], ':</label></td>
<td><input type="text" id="sp_user" name="user" size="9" value="', !empty($user_info['username']) ? $user_info['username'] : '', '" /></td>
</tr><tr>
<td align="right"><label for="passwrd">', $txt['password'], ':</label></td>
<td><input type="password" name="passwrd" id="sp_passwrd" size="9" /></td>
</tr><tr>
<td>
<select name="cookielength">
<option value="60">', $txt['one_hour'], '</option>
<option value="1440">', $txt['one_day'], '</option>
<option value="10080">', $txt['one_week'], '</option>
<option value="43200">', $txt['one_month'], '</option>
<option value="-1" selected="selected">', $txt['forever'], '</option>
</select>
</td>
<td><input type="submit" value="', $txt['login'], '" /></td>
</tr>
</table>
</form>', sprintf($txt['welcome_guest'], $txt['guest_title']);
}
else
{
echo $txt['hello_member'], ' <b>', (!empty($memberContext[$member_id]['colored_name']) ? $memberContext[$member_id]['colored_name'] : $context['user']['name']), '</b><br /><br />';
if (!empty($context['user']['avatar']))
echo $context['user']['avatar']['image'], '<br /><br />';
if (!empty($memberContext[$member_id]['group']))
echo $memberContext[$member_id]['group'];
else
echo $memberContext[$member_id]['post_group'];
echo '<br />', $memberContext[$member_id]['group_stars'], '<hr /></div>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['posts'], ': ',$memberContext[$member_id]['posts'],'<br />';
if(!empty($modSettings['karmaMode']))
echo '
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-userkarma'], ': ';
if($modSettings['karmaMode'] == '1')
echo $memberContext[$member_id]['karma']['total'],'<br />';
elseif($modSettings['karmaMode'] == '2')
echo '+', $memberContext[$member_id]['karma']['good'],'/-', $memberContext[$member_id]['karma']['bad'], '<br />';
}
if(allowedTo('pm_read'))
echo '
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-usertmessage'], ': <a href="' . $scripturl . '?action=pm">' . $context['user']['messages'], '</a><br />
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-usernmessage'], ': ' . $context['user']['unread_messages'], '<hr />';
if (!$context['user']['is_guest'])
echo '
<div align="center"><img src="' . $settings['images_url'] . '/arrow.gif" alt="', $txt['sp-arrow'], '" /> <a href="'.$scripturl.'?action=profile">', $txt['profile'], '</a> <img src="' . $settings['images_url'] . '/arrow.gif" alt="', $txt['sp-arrow'], '" /> <a href="', $scripturl, '?action=logout;sesc=', $sc, '">', $txt['logout'], '</a>';
echo '</div><hr />';
$totals = array(
'members' => $modSettings['totalMembers'],
'posts' => $modSettings['totalMessages'],
'topics' => $modSettings['totalTopics']
);
$request = $smcFunc['db_query']('','
SELECT COUNT(*)
FROM {db_prefix}boards'
);
list ($totals['boards']) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
$request = $smcFunc['db_query']('','
SELECT COUNT(*)
FROM {db_prefix}categories'
);
list ($totals['categories']) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);;
echo '
<ul style="padding: 0.2em 0.4em 0.2em 0.4em;">
<li>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['gm_total_members'], ': <a href="', $scripturl . '?action=mlist">', $totals['members'], '</a>
</li>
<li>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['gm_total_posts'], ': ', $totals['posts'],'
</li>
<li>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['gm_total_topics'], ': ', $totals['topics'],'
</li>
<li>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['gm_total_cats'], ': ', $totals['categories'],'
</li>
<li>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['gm_total_boards'], ': ', $totals['boards'],'
<hr /></li>
</ul>';
$request = $smcFunc['db_query']('','
SELECT
lo.id_member, lo.log_time, mem.real_name, mem.member_name, mem.show_online,
mg.online_color, 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))'
);
$online['users'] = array();
$online['guests'] = 0;
$online['hidden'] = 0;
$online['buddies'] = 0;
$show_buddies = !empty($user_info['buddies']);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!isset($row['real_name']))
$online['guests']++;
elseif (!empty($row['show_online']) || allowedTo('moderate_forum'))
{
if (!empty($row['online_color']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
if ($show_buddies && in_array($row['id_member'], $user_info['buddies']))
{
$online['buddies']++;
$link = '<b>' . $link . '</b>';
}
$online['users'][$row['log_time'] . $row['member_name']] = array(
'id' => $row['id_member'],
'username' => $row['member_name'],
'name' => $row['real_name'],
'group' => $row['id_group'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => $link,
'hidden' => empty($row['show_online']),
'is_last' => false,
);
}
else
$online['hidden']++;
}
$smcFunc['db_free_result']($request);
if (!empty($online['users']))
{
krsort($online['users']);
$userlist = array_keys($online['users']);
$online['users'][$userlist[count($userlist) - 1]]['is_last'] = true;
}
$online['num_users'] = count($online['users']) + $online['hidden'];
$online['total_users'] = $online['num_users'] + $online['guests'];
echo '
<ul style="padding: 0.2em 0.4em 0.2em 0.4em;">
<li>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-onlineguest'], ': ', $online['guests'],'
</li>
<li>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-onlineuser'], ': ', $online['num_users'],'
</li>
<li>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-onlinehuser'], ': ', $online['hidden'],'
</li>
<li>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-onlinetuser'], ': ', $online['total_users'],'
</li>';
if(!empty($online['users'])) {
echo '
<li>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-onlineouser'], ':
</li>';
foreach ($online['users'] as $user)
echo '
<li style="padding-left: 20px;">
<img src="' . $settings['images_url'] . '/useron.gif" alt="', $txt['user'], '" /> ', $user['hidden'] ? '<em>' . $user['link'] . '</em>' : $user['link'],'
</li>';
}
echo '
</ul>';
}
Mini Cal Code Topic Here
http://simpleportal.net/index.php?topic=89.0
Thanks.
Hi shortie
can we get this for smf 1.1.8 too?
Hmm possible this work in the same way, us a php block and insert:
Work only with Simple Portal 2.2+
sp_userInfo(array(), $id);
echo '<hr />';
sp_boardStats(array(
'averages' => 0
), $id);
echo '<hr />';
sp_whosOnline(array(), $id);
This should be normal output near the same i think ;).
Hey 1031 (prisoner number?)
I know I'm being cheeky but is there any possibility of some help to install this on our forum?
We are on smf 1.1.8 with sp 2.2.1
Would rather be a :) man than a :( man.
Hey 1031 (prisoner number?)
Nope my Nickname in japanese :P.
That's easy create an php block and insert this code.
Save the block and see if it work ;).
Bye
DIN1031
Didn't work.
Parse error: syntax error, unexpected ';', expecting ')' in /home/visionar/public_html/phforum/Sources/SPortal1-1.php(3244) : eval()'d code on line 4
We use 1.1.8 and sp 2.2.1
Quote from: TheListener on May 19, 2009, 02:06:46 PM
Didn't work.
Parse error: syntax error, unexpected ';', expecting ')' in /home/visionar/public_html/phforum/Sources/SPortal1-1.php(3244) : eval()'d code on line 4
We use 1.1.8 and sp 2.2.1
Sorry my mistake <<, made a mistake in the code. (It will normal work with all SP 2.2+ Version and on all SMF Versions ;).
sp_userInfo(array(), $id);
echo '<hr />';
sp_boardStats(array('averages' => 0), $id);
echo '<hr />';
sp_whosOnline(array(), $id);