Posted By

mladoux on 09/21/10


Tagged

php display output formatting posts forum PHPBB3


Versions (?)

PHPBB3 Post Grabber


 / Published in: PHP
 

URL: http://mark.haktstudios.com/

A simple PHPBB3 post grabber script that I wrote for a friend a while back.

  1. <?php
  2.  
  3. /* Stand alone test */
  4.  
  5. define('IN_PHPBB', true);
  6. $phpbb_root_path = './Forum/';
  7. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  8. include($phpbb_root_path . 'common.' . $phpEx);
  9. // Start session management
  10. $user->session_begin();
  11. $auth->acl($user->data);
  12. $user->setup();
  13.  
  14. /* end test section */
  15.  
  16. function post_count($tid)
  17. {
  18.  
  19. mysql_connect('localhost:3306', 'username', 'password');
  20. mysql_select_db('phpbbdb');
  21. $sql = 'SELECT * FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $tid;
  22. $result = mysql_query($sql);
  23. $count = mysql_num_rows($result) - 1;
  24.  
  25. return $count;
  26.  
  27. }
  28.  
  29. $topic_limit = request_var('topic_limit', 1);
  30. $forums = array_unique(array_keys($auth->acl_getf('f_read', true))); //ignored in sql statement to include all topics despite permissions
  31.  
  32. // Select the last topics ignoring permissions
  33. $sql = 'SELECT *
  34. FROM ' . POSTS_TABLE . ' p , ' . USERS_TABLE . ' u
  35. WHERE post_approved = 1
  36. AND u.user_id = p.poster_id
  37. AND p.forum_id = 1
  38. AND p.post_subject NOT LIKE "Re:%"
  39. ORDER BY post_time DESC
  40. LIMIT 0,' . $topic_limit;
  41. $result = $db->sql_query($sql);
  42.  
  43. // Process Data
  44. while ($row = $db->sql_fetchrow($result))
  45. {
  46.  
  47. // variables
  48.  
  49. $fid = $row['forum_id'];
  50. $tid = $row['topic_id'];
  51. $pid = $row['post_id'];
  52. $subject = $row['post_subject'];
  53. $username = ucwords($row['username']);
  54. $date = date("G:i m-d-Y",$row['post_time']);
  55. $text = $row['post_text'];
  56. $bitfield = $row['bbcode_bitfield'];
  57. $bbuid = $row['bbcode_uid'];
  58. $uid = $row['poster_id'];
  59. $url = generate_board_url() . "/viewtopic.{$phpEx}?f={$fid}&amp;t={$tid}&amp;p={$pid}#p{$pid}"; //added topic link to url
  60. $profile = generate_board_url() . "/memberlist.{$phpEx}?mode=viewprofile&amp;u={$uid}"; // added profile link to url
  61. $options = $row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) +
  62. (($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) +
  63. (($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
  64.  
  65. $text = generate_text_for_display($text, $uid, $bitfield, $options);
  66. // display
  67.  
  68. <a target="_blank" href="' . $url . '">' . $subject . '</a>, <a target="_blank" href="' . $profile . '">' . $username . '</a>, ' . $date .' <br />
  69. <br />
  70. ';
  71.  
  72. echo $text;
  73.  
  74. echo '<br /><br /><a target="_blank" href="' . $url . '">' . post_count($tid) . ' comments</a>';
  75.  
  76. }

Report this snippet  

You need to login to post a comment.