login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Overige scripts > phpBB3.x RSS: 10 nieuwste berichten

phpBB3.x RSS: 10 nieuwste berichten

Auteur: tomie94 - 21 november 2007 - 19:25 - Gekeurd door: Stijn - Hits: 5809 - Aantal punten: 1.58 (6 stemmen)



Met dit script kun je in een rss feed de 10 nieuwste berichten van phpBB3.x bekijken

Uitleg:

sla het bestand op als .php!!

Code:
sla het bestand op als .php!!
  1. <?php
  2. header("Content-Type: text/xml; charset=UTF-8");
  3. mysql_connect("localhost", "gbnaam", "wwoord"); //Connect
  4. mysql_select_db("forum"); //Database Connect
  5. $url = ''; //De url van je forum. LET OP: ook de slash op het einde
  6. $prefix= 'phpbb_'; //Wat voor elke tabel staat meestal phpbb_ als je wat anders hebt kun je het hier wijzigen!
  7. $max = '10'; //Het aantal wat je wilt laten weergeven
  8. echo '<?xml version="1.0"?>';
  9. ?>
  10. <rss version="2.0">
  11.  
  12. <channel>
  13.  
  14. <title>De nieuwste Forum Berichten</title>
  15. <link><?php echo $url; ?></link>
  16. <description>
  17.  
  18.  
  19.  
  20. De nieuwste forum berichten</description>
  21. <?php
  22. $res = mysql_query("SELECT * FROM ".$prefix."posts ORDER BY post_time DESC LIMIT 0,".$max);
  23. while ($arr = mysql_fetch_assoc($res)) {
  24. ?>
  25.  
  26. <item>
  27. <title><?php
  28. $titel = htmlentities($arr["post_subject"]);
  29. echo $titel;
  30. ?>
  31. </title>
  32. <link><?php
  33. echo $url."viewtopic.php?f=".$arr['forum_id']."&t=".$arr['topic_id'];
  34. ?>
  35. </link>
  36. <description>
  37. <?php
  38.  
  39. $text = $arr['post_text'];
  40.  
  41. $tempArray = explode(' ',$text,11);
  42. $aantal = count($tempArray);
  43. if($aantal>10){ //101>100 ;)
  44. //te veel woorden
  45. array_pop($tempArray);
  46. $text = implode(' ',$tempArray);
  47. $text .= ' ...';
  48. }
  49. echo $text;
  50. ?>
  51. </description>
  52. </item>
  53. <?php
  54. }
  55. ?>
  56.  
  57.  
  58.  
  59. </channel>
  60.  
  61. </rss>

Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

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