login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Fora/Discussieborden > Laatste 10 Actieve Topics voor phpBB

Laatste 10 Actieve Topics voor phpBB

Auteur: Anoniem - 25 augustus 2006 - 21:25 - Gekeurd door: Maarten - Hits: 8732 - Aantal punten: 3.50 (1 stem)




Uitleg
Omdat er geen script was voor het bekende phpbb dat uitgebreid de laatste active topics toonde, heb ik er zelf een gemaakt. Dit script sorteert dan ook (echt) op de tijd van de laatste reactie! Zodat je het zelfde idee krijgt als hier op sitemasters.be.

Gebruik
Om het gemakkelijk te maken, heb ik het in een functie gezet. Deze heeft een aantal variabelen nodig:
$datum_formaat: het formaat waarmee je de tijd van de laatste reactie wilt weergeven,
bijv. d-m-Y H:i:s wordt DD-MM-JJJJ UU:MM:SS
$pad_naar_forum: het pad naar de map waarin het forum staat,
bijv. phpbb Geen backslash!
$limit: hoeveel actieve topics je wil laten zien,
bijv 10 Zonder quotes!

Aanroepen van de functie
Je roept de functie bijv. zo aan (Let op de variabelen!)
  1. <?php
  2. include 'laatste_active_topics.php';
  3. laatste_active_topics('d-m-Y H:i:s', 'phpbb', 10);
  4. ?>


Code:
  1. <?php
  2. /*
  3. * (c) Rien van Hulten
  4. * (w) rienvanhulten.nl
  5. */
  6. function laatste_active_topics ($datum_formaat, $pad_naar_forum, $limit)
  7. {
  8. include_once $pad_naar_forum . '/config.php';
  9. mysql_connect($dbhost, $dbuser, $dbpasswd) or die ("<p>Het verbinden met de database is mislukt. Onze excuses hiervoor. Neem indien nodig contact op via het contactformulier.</p>");
  10. mysql_select_db ($dbname) or die ("<p>Het verbinden met de database is mislukt. Onze excuses hiervoor. Neem indien nodig contact op via het contactformulier.</p>");
  11.  
  12. $query = mysql_query("SELECT " . $table_prefix . "_topics.topic_id, " . $table_prefix . "_topics.topic_title, " . $table_prefix . "_topics.topic_poster, " . $table_prefix . "_topics.topic_replies, " . $table_prefix . "_users.username, " . $table_prefix . "_users.user_id, " . $table_prefix . "_posts.post_time, " . $table_prefix . "_topics.topic_last_post_id
  13. FROM " . $table_prefix . "_topics
  14. INNER JOIN " . $table_prefix . "_users ON ( " . $table_prefix . "_topics.topic_poster = " . $table_prefix . "_users.user_id )
  15. INNER JOIN " . $table_prefix . "_posts ON ( " . $table_prefix . "_topics.topic_last_post_id = " . $table_prefix . "_posts.post_id )
  16. ORDER BY " . $table_prefix . "_posts.post_time DESC
  17. LIMIT 0," . $limit);
  18. echo '<p>';
  19. while($array = mysql_fetch_array($query))
  20. {
  21. $array['topic_replies'] = $array['topic_replies'] == 0 ? '<span style="color: orange">(' . $array['topic_replies'] . ')</span>' : '(' . $array['topic_replies'] . ')';
  22. ?>
  23. [<?=date($datum_formaat, $array['post_time'])?>] <a href="<?=$pad_naar_forum?>/viewtopic.php?t=<?=$array['topic_id']?>#<?=$array['topic_last_post_id']?>"><?=$array['topic_title']?></a> <?=$array['topic_replies']?>, gestart door <a href="<?=$pad_naar_forum?>/profile.php?mode=viewprofile&u=<?=$array['user_id']?>"><?=$array['username']?></a>.<br />
  24. <?php
  25. }
  26. echo '</p>';
  27. }
  28. laatste_active_topics('d-m-Y H:i:s', 'phpbb', 10)
  29. ?>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (10)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.036s