Top 5 posters
Geplaatst: 15 sep 2004, 09:53
Ik zoek een MOD voor de EzPortal.
Top 5 posters algemeen en Top 5 posters of the day!
Top 5 posters algemeen en Top 5 posters of the day!
Code: Selecteer alles
//
// Wat hier ook moge staan
//
$template->pparse('body');
Code: Selecteer alles
//
// BEGIN TOP 10 POSTERS
//
$current_time = time();
$minutes = date('is', $current_time);
$hour_now = $current_time - (60*($minutes[0].$minutes[1])) - ($minutes[2].$minutes[3]);
$date = date('H');
$time_today = $hour_now - (3600 * $date);
//$time_thisweek = $time_today - ((date('w', $time_today)-1)*86400); //Indien je top x van de week wilt gebruiken
$time_yesterday = $time_yesterday = $time_today - 86400;
$sql = "select u.user_id, u.username, count(u.user_id) as user_posts
FROM " .USERS_TABLE. " u, " . POSTS_TABLE . " p
WHERE (u.user_id = p.poster_id) AND (p.post_time > '" . $time_today . "') AND (u.user_id <> " . ANONYMOUS . ")
GROUP BY user_id, username
ORDER BY user_posts DESC
LIMIT 10";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't retrieve topposters data", "", __LINE__, __FILE__, $sql);
}
$total_posts_thisweek = 0;
$user_count = $db->sql_numrows($result);
$user_data = $db->sql_fetchrowset($result);
$firstcount = $user_data[0]['user_posts'];
for ($i = 0; $i < $user_count; $i++)
{
$total_posts_thisweek += $user_data[$i]['user_posts'];
}
for ($i = 0; $i < $user_count; $i++)
{
$class = ($i % 2) ? $theme['td_class2'] : $theme['td_class1'];
$template->assign_block_vars('top_posters_day', array(
'RANK' => $i+1,
'CLASS' => $class,
'USERNAME' => $user_data[$i]['username'],
'URL' => append_sid($phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $user_data[$i]['user_id']),
'POSTS' => $user_data[$i]['user_posts'])
);
}
// winner yesterday
$sql = "select u.user_id, u.username, count(u.user_id) as user_posts
FROM " .USERS_TABLE. " u, " . POSTS_TABLE . " p
WHERE (u.user_id = p.poster_id) AND (p.post_time <= '" . $time_today . "') AND (p.post_time > '" . $time_yesterday . "') AND (u.user_id <> " . ANONYMOUS . ")
GROUP BY user_id, username
ORDER BY user_posts DESC
LIMIT 1";
//print($sql);
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't retrieve topposters data", "", __LINE__, __FILE__, $sql);
}
$user_data = $db->sql_fetchrow($result);
$template->assign_vars(array(
'Y_RANK' => "1",
'Y_USERNAME' => $user_data['username'],
'Y_URL' => append_sid($phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $user_data['user_id']),
'Y_POSTS' => $user_data['user_posts'],
// end winner yesterday
'L_MODULE_WINNER' => "Winnaar van Gisteren!",
'L_MODULE_NAME' => "Top 10 van vandaag!")
);
//
// EINDE TOP 10 POSTERS
//
Code: Selecteer alles
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catHead" height="25" colspan="2"><span class="genmed"><b>{L_MODULE_NAME}</b></span></td>
</tr>
<!-- BEGIN top_posters_day -->
<tr>
<td class="{top_posters_day.CLASS}" align="left" width="10%"><span class="gen">{top_posters_day.RANK}</span></td>
<td class="{top_posters_day.CLASS}" align="left" width="90%"><span class="gen"><a href="{top_posters_day.URL}" title="{top_posters_day.POSTS} Posts">{top_posters_day.USERNAME} ({top_posters_day.POSTS})</a></span></td>
</tr>
<!-- END top_posters_day -->
<tr>
<td class="catHead" height="25" colspan="2"><span class="genmed"><b>{L_MODULE_WINNER}</b></span></td>
</tr>
<tr>
<td class="row1" align="left" width="10%"><span class="gen">{Y_RANK}</span></td>
<td class="row1" align="left" width="90%"><span class="gen"><a href="{Y_URL}" title="{Y_POSTS} Posts">{Y_USERNAME} ({Y_POSTS})</a></span></td>
</tr>
</table>
<br />
Code: Selecteer alles
$sql = "select u.user_id, u.username, count(u.user_id) as user_posts
FROM " . USERS_TABLE . " u, " . POSTS_TABLE . " p
WHERE (u.user_id = p.poster_id) AND (p.post_time > '" . $time_thisweek . "') AND (u.user_id <> " . ANONYMOUS . ")GROUP BY user_id, username
ORDER BY user_posts DESC
LIMIT 10";
Je kunt het blok plaatsen in de portal waar je maar wil.Eefjuh schreef:Waar komt dit te staan?
(niet de mod maar het uiteindelijke restutaat)
Code: Selecteer alles
<?
//Hier het pad naar je phpBB folder
$phpbb_root_path = './phpBB2/';
define('IN_PHPBB', true);
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//De variabelen declareren
$current_time = time();
$minutes = date('is', $current_time);
$hour_now = $current_time - (60*($minutes[0].$minutes[1])) - ($minutes[2].$minutes[3]);
$date = date('H');
$time_today = $hour_now - (3600 * $date);
$time_thisweek = $time_today - ((date('w', $time_today)-1)*86400);
$time_yesterday = $time_yesterday = $time_today - 86400;
//De Query uitvoeren
$sql = "select u.user_id, u.username, count(u.user_id) as user_posts
FROM " .USERS_TABLE. " u, " . POSTS_TABLE . " p
WHERE (u.user_id = p.poster_id) AND (p.post_time > '" . $time_thisweek . "') AND (u.user_id <> " . ANONYMOUS . ")
GROUP BY user_id, username
ORDER BY user_posts DESC
LIMIT 5";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't retrieve topposters data", "", __LINE__, __FILE__, $sql);
}
$total_posts_thisweek = 0;
$user_count = $db->sql_numrows($result);
$user_data = $db->sql_fetchrowset($result);
$firstcount = $user_data[0]['user_posts'];
for ($i = 0; $i < $user_count; $i++)
{
$total_posts_thisweek += $user_data[$i]['user_posts'];
}
for ($i = 0; $i < $user_count; $i++)
{
$class = ($i % 2) ? $theme['td_class2'] : $theme['td_class1'];
$template->assign_block_vars('top_posters_day', array(
'RANK' => $i+1,
'CLASS' => $class,
'USERNAME' => $user_data[$i]['username'],
'URL' => append_sid($phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $user_data[$i]['user_id']),
'POSTS' => $user_data[$i]['user_posts'])
);
}
?>
Code: Selecteer alles
$template->set_filenames(array(
'body' => 'portal_body.tpl')
);
//
// code
//
$template->pparse('body');