Advertisement
Black_heart

forumposts.php

May 23rd, 2011
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.68 KB | None | 0 0
  1. <?php
  2.  if ($user->user)
  3.  {
  4. require_once "include/functions_phpBB3.php";
  5.  if (isset($user->id))$pmbtuser=$user;
  6.  $pmbtdb = $db;
  7.  
  8. define("folder", $forumbase);
  9. define("basefile2", "./".$phpbb2_basefile);
  10. define("basefile", "./".$phpbb2_basefile."?");
  11. define("basefile3", $phpbb2_basefile);
  12.     define( 'IN_PHPBB', true );
  13.     $phpbb_root_path = './'.$forumbase.'/'; // change in your own root path.
  14.     $phpEx = substr(strrchr(__FILE__, '.'), 1);
  15.     include($phpbb_root_path . 'common.' . $phpEx);
  16.     include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  17.     include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
  18.    
  19.     $user->session_begin();
  20.     $auth->acl( $user->data );
  21.     $user->setup();
  22. define('BT_SHARE', true);
  23.  
  24.     //-- Fetch the data from the specified fora
  25.     $bbcode = new bbcode();
  26.     $news_fora_id = array( 25,22,29,16); // Change in the fora id's you need
  27.     $output = '';
  28.    
  29.     $topic_count = '10'; // Change in the number of topics you want to show.
  30.     $query = "
  31.        SELECT p.topic_id, p.forum_id, p.post_time, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid,
  32.            u.user_id, u.user_email, u.username, u.user_posts, u.user_rank, u.user_colour, u.user_allow_viewonline, u.user_allow_viewemail,
  33.            t.topic_title,
  34.                (
  35.                    SELECT COUNT( post_id )
  36.                    FROM " . POSTS_TABLE . "
  37.                        WHERE topic_id = p.topic_id
  38.                ) AS aantal_posts
  39.        FROM " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . TOPICS_TABLE . " AS t
  40.            WHERE  u.user_id = p.poster_id
  41.                AND t.topic_id = p.topic_id
  42.        GROUP BY topic_id
  43.        ORDER BY t.topic_last_post_time DESC
  44.        LIMIT 0, {$topic_count}
  45.    ";
  46.  
  47.     //die('<pre>' . $query );
  48.     $result = $db->sql_query( $query )or btsqlerror($query);
  49.         $output .= "<table class=\"torrenttable\" border=\"0\" cellpadding=\"3\" width=\"100%\">";
  50.         $output .="<thead>\n<tr><th><p>Topics</p></th>";
  51.         $output .="<th><p>Replies</p></th>";
  52.         $output .="<th><p>Views</p></th>";
  53.  
  54.         $output .= "</tr></thead>\n";
  55.  
  56.     while( $row = $db->sql_fetchrow($result) )
  57.     {
  58.     $sql_view ="SELECT * FROM " . TOPICS_TABLE . " WHERE topic_id = ". $row['topic_id'] . "";
  59. $res_views = $db->sql_query($sql_view);
  60. $row_views = $db->sql_fetchrow($res_views);
  61.         // Parse the message and subject
  62.         $message = censor_text($row['post_text']);
  63.  
  64.         // Second parse bbcode here
  65.         if ($row['bbcode_bitfield'])
  66.         {
  67.             $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
  68.         }
  69.  
  70.         //$message = bbcode($message);
  71.         $message = smiley_text($message);
  72.        
  73.         // Send data to output var
  74.         $output .= "<tbody>\n";
  75.         $output .="<td class=\"torrenttable\">";
  76.         $output .= "<a href=\"phpBB.php?page=viewtopic&amp;f={$row['forum_id']}&amp;t={$row['topic_id']}\" title=\""  . censor_text($row['post_subject']) . "\">".censor_text($row['post_subject'])."</a>      <br>By <a href=\"phpBB.php?page=memberlist&mode=viewprofile&u=" . $row['user_id'] . "\"  style='color:#9E8DA7'>" . $row['username'] ."</a> on \n";
  77.         $output .= $user->format_date($row['post_time'])."\n" ;
  78.         $output .= "</td>\n" ;
  79.         $output .="<td>";
  80.         $output .= $row['aantal_posts']-1 ."\n";
  81.         $output .="</td>";
  82.         $output .="<td>";
  83.         $output .= $row_views['topic_views']."\n";
  84.         $output .="</td>";
  85.         $output .="</tbody>\n";
  86.     }
  87.         $output .="</table>\n";
  88.  
  89.     // print the output
  90. OpenTable('Recent Forum Posts');
  91.     print( $output);
  92. CloseTable();  
  93. }
  94.  $db = $pmbtdb;
  95.  
  96. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement