نام:آموزش قرار دادن 10 کاربر برتر امروز و هفته گذشته
نام آموزش دهنده:سعید افسری نژاد
منبع:موبایل سافت
اینم یک آموزش بسیار جالب،تقدیم به مامبو لرن.
خوب مستقیم میریم برای آموزش:
به این مسیر بروید: /Sources/Stats.php
حالا Stats.php را باز نموده و به دنبال کد زیر بگردید:
کد:
// Try to cache this when possible, because it's a little unavoidably slow.
if (($members = cache_get_data('stats_top_starters', 360)) == null)
قبل از آن این کد را وارد نمایید:
کد:
// Top 10 Posters so far today
// Change the time depending on server time offset
list($year, $month, $day) = explode('-', date('Y-m-d'));
$starttime = mktime(0, 0, 0, $month, $day, $year);
// Offset based on forum time
$starttime = forum_time(false, $starttime);
$request = db_query("
SELECT me.ID_MEMBER, me.realName, COUNT(*) as count_posts
FROM {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS me ON (me.ID_MEMBER = m.ID_MEMBER)
WHERE m.posterTime > " . $starttime . "
AND m.ID_MEMBER != 0
GROUP BY me.ID_MEMBER
ORDER BY count_posts DESC
LIMIT 10", __FILE__, __LINE__);
$context['top_posters_day'] = array();
$max_num_posts = 1;
while ($row_members = mysql_fetch_assoc($request))
{
$context['top_posters_day'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_posts' => $row_members['count_posts'],
'href' => $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'] . '">' . $row_members['realName'] . '</a>'
);
if ($max_num_posts < $row_members['count_posts'])
$max_num_posts = $row_members['count_posts'];
}
mysql_free_result($request);
foreach ($context['top_posters_day'] as $i => $j)
$context['top_posters_day'][$i]['post_percent'] = round(($j['num_posts'] * 100) / $max_num_posts);
// Tidy up
unset($max_num_posts, $row_members, $j, $i);
// Top 10 Posters so far this week (starts sunday)
$starttime = mktime(0, 0, 0, date("n"), date("j"), date("Y")) - (date("N")*3600*24);
// Offset based on forum time
$starttime = forum_time(false, $starttime);
$request = db_query("
SELECT me.ID_MEMBER, me.realName, COUNT(*) as count_posts
FROM {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS me ON (me.ID_MEMBER = m.ID_MEMBER)
WHERE m.posterTime > " . $starttime . "
AND m.ID_MEMBER != 0
GROUP BY me.ID_MEMBER
ORDER BY count_posts DESC
LIMIT 10", __FILE__, __LINE__);
$context['top_posters_week'] = array();
$max_num_posts = 1;
while ($row_members = mysql_fetch_assoc($request))
{
$context['top_posters_week'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_posts' => $row_members['count_posts'],
'href' => $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'] . '">' . $row_members['realName'] . '</a>'
);
if ($max_num_posts < $row_members['count_posts'])
$max_num_posts = $row_members['count_posts'];
}
mysql_free_result($request);
foreach ($context['top_posters_week'] as $i => $j)
$context['top_posters_week'][$i]['post_percent'] = round(($j['num_posts'] * 100) / $max_num_posts);
// Tidy up
unset($max_num_posts, $row_members, $j, $i);
خوب ذخیره کنید و دنبال این مسیر بروید: Themes/default/Stats.template.php
فایل Stats.template.php را باز نموده و به دنبال کد زیر بگردید:
کد:
<td class="catbg" colspan="2" width="50%"><b>', $txt['smf_stats_15'], '</b></td>
<td class="catbg" colspan="2" width="50%"><b>', $txt['smf_stats_16'], '</b></td>
قبل از آن این کد را وارد نمایید:
کد:
<td class="catbg" colspan="2" width="50%"><b>', $txt['top_posters_day'], '</b></td>
<td class="catbg" colspan="2" width="50%"><b>', $txt['top_posters_week'], '</b></td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_posters.gif" width="20" height="20" alt="" /></td>
<td class="windowbg2" width="50%" valign="top">
<table border="0" cellpadding="1" cellspacing="0" width="100%">';
foreach ($context['top_posters_day'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['num_posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
<td width="20%" align="left" valign="top">', $poster['num_posts'], '</td>
</tr>';
echo '
</table>
</td>
<td class="windowbg" width="20" valign="middle" align="center" nowrap="nowrap"><img src="', $settings['images_url'], '/stats_posters.gif" width="20" height="20" alt="" /></td>
<td class="windowbg2" width="50%" valign="top">
<table border="0" cellpadding="1" cellspacing="0" width="100%">';
foreach ($context['top_posters_week'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['num_posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
<td width="20%" align="left" valign="top">', $poster['num_posts'], '</td>
</tr>';
echo '
</table>
</td>
</tr><tr>
این مسیر را دنبال کنید: /Themes/default/languages/Modifications.persian.php
حالا در فایل Modifications.persian.php دنبال کد زیر بگردید:
قبل از آن این کد را قرار دهید:
کد:
$txt['top_posters_day'] = '10 کاربر برتر امروز';
$txt['top_posters_week'] = '10 کاربر برتر این هفته';
اینم نمونه:
[img width=640 height=325]http://i37.tinypic.com/2z3qts0.jpg[/img]
بدرود...
موفق باشید.
علاقه مندی ها (Bookmarks)