Top 5 posters
Forumregels
Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.

Top 5 posters
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!
En zo is het!
Na zelf wat gestunteld te hebben en wat info uit de statisticsmod te hebben gehaald heb ik nu een top 10 posters van de dag op mn EzPortal.
portal.php:
Zoek:
Voeg ervoor toe:
portal_body.tpl:
Plaats daar waar je het blok wil:
portal.php:
Zoek:
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
//
Plaats daar waar je het blok wil:
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 />
Laatst gewijzigd door djrandall op 11 feb 2005, 15:09, 1 keer totaal gewijzigd.
En zo is het!
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";
LIMIT 10 verander 10 in 5 voor de top 5
DESC Hij zet de lijst op volgorde van alfabet aflopend! ( ASC = oplopend )
En zo is het!
-
- Berichten: 109
- Lid geworden op: 10 jun 2004, 19:34
Hmm ik krijg een error op line 44: Fatal error: Call to a member function on a non-object in /var/www/html/topposters.php on line 45
Zo ziet mijn code eruit (ik gebruik niet de portal maar een gewone website)
Zo ziet mijn code eruit (ik gebruik niet de portal maar een gewone website)
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'])
);
}
?>
Je maakt een aantal template variabelen aan, maar aan het einde van je file, wijs je geen template aan. Ik mis dus de code:
In mijn geval maakt hij gebruik van template portal_body.tpl
Code: Selecteer alles
$template->set_filenames(array(
'body' => 'portal_body.tpl')
);
//
// code
//
$template->pparse('body');
En zo is het!
-
- Berichten: 109
- Lid geworden op: 10 jun 2004, 19:34
Maar ik heb geen portal....
Ik wil hem namelijk vanuit deze website laden:
http://www.tck-clan.co.uk/13centkillers.php
Hoe moet ik dat dan doen
Ik wil hem namelijk vanuit deze website laden:
http://www.tck-clan.co.uk/13centkillers.php
Hoe moet ik dat dan doen
