All pastes #950638 Raw Edit

Mine

public text v1 · immutable
·published 2008-03-20 18:55 UTC
rendered paste body
<?php
    //-- Fetch the data from the specified fora
    $bbcode = new bbcode();
    $news_fora_id = array( '4' ); // Change in the fora id's you need

    $topic_count = '9'; // Change in the number of topics you want to show.
    $query = "
            SELECT p.topic_id, p.forum_id, p.post_time, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, 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, t.topic_replies, t.topic_title,
                  (
                        SELECT COUNT( post_id )
                        FROM " . POSTS_TABLE . "
                            WHERE topic_id = p.topic_id
                  ) AS aantal_posts
            FROM " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . TOPICS_TABLE . " AS t
                WHERE " . $db->sql_in_set( 'p.forum_id', $news_fora_id ) . "
                    AND u.user_id = p.poster_id
                    AND t.topic_id = p.topic_id
            GROUP BY topic_id
            ORDER BY topic_id DESC
            LIMIT 0, {$topic_count}
            ";
  
    //die('<pre>' . $query );
$result = $db->sql_query( $query );


while( $row = $db->sql_fetchrow($result) )
{

        // Parse the message and subject
        $message = censor_text($row['post_text']);


        // Second parse bbcode here
        if ($row['bbcode_bitfield'])
        {
            $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
        }
      
      $phpbb_root_path = '../../../forums/'; //      
        $message = bbcode_nl2br($message);
        $message = smiley_text($message);
      
         
        // Send data to output var
		
        //Subject
        $output .= "<h2 class='title'><a href=\"" . $phpbb_root_path . "viewtopic.php?f={$row['forum_id']}&amp;t={$row['topic_id']}\" title=\""  . censor_text($row['post_subject']) . "\">".censor_text($row['post_subject'])."</a></h2>\n";
     
        //Date
		$output .= "<h4 class='date'>";
        $output .= " by " . $row['username'] . " on " . date("M d, Y - g:ia", $row['post_time']);
        $output .= "</h4>";


      //Main portion      
        $output .= "<div class='mainnews'>" . $message;
        $output .= "</div>";

      //Footer
        $output .= "<div class='postbottom'><p>";
		$output .= "<a href=\"http://www.e-peenery.com/forums/" . "viewtopic.php?f={$row['forum_id']}&amp;t={$row['topic_id']}\" title=\""  . censor_text($row['post_subject']) . "\">"; 
        $output .= "Comments: (";
        $output .= $row['topic_replies'];
        $output .= ")</a>";
        $output .= "</p></div>";
}

    // print the output
    	print( $output );

?>