Extension:PHPBB ShowForum

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: experimental
Implementation Tag
Description Show your PHPbb post inside Mediawiki's Pages
Author(s) Marcolino (Marcolino7talk)
Latest version 0.2
License No license specified
Download Extension:PHPBB_ShowForum#Code
Thos Version is Tested on PHPbb 2.x
0.1 - Basic support to PHPbb 2.x, 0.2 Disabled Cache and Icon Path
Example see Gestione Acquario's Wiki
Translate the PHPBB ShowForum extension if it is available at translatewiki.net
Check usage and version matrix.

What can this extension do?[edit]

This extension can show PHPbb's List of Topic with Username and Datetime.



  • a = Forum ID
  • b = Number of post to show
  • c = Backgound Color ie: FEFAF3

You can also view multiple forum. This make possible with parameter a. In example to show forum 1, 4 and 5 the tag is:


In this case a = '1','4','5'

Download instructions[edit]

Please cut and paste the code found below and place it in $IP/extensions/PHPBB_ShowForum/PHPBB_ShowForum.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.


To install this extension, add the following to LocalSettings.php:


Configuration parameters[edit]

Inside PHPBB_ShowForum.php you have to change this parameter in according with your forum configuration:

  $phpbbDBSERVER= MySQL Host
  $phpbbDBUSER= MySQL User
  $phpbbDBUSERPW= MySQL Password
  $phpbbDBNAME= MySQL Database Name
  $phpbbDBPrefix="phpbb_" PHPbb's Table prefix (Usually no changes needed)

  $phpbb_home = "http://www.yoursite.com/forum/" Full Address of your forum
  $phpbb_icon_path = "templates/subSilver/images/folder.gif" path of the icon


 * Installation:
 * 	require_once("extensions/PHPBB_ShowForum/PHPBB_ShowForum.php"); in LocalSettings.php
 *      update  $phpbbDBSERVER,  $phpbbDBUSER,  $phpbbDBUSERPW,  $phpbbDBNAME, $phpbb_home, $phpbb_icon_path
 * Usage:
 *      <phpbb_forum>forumID|Number of post|Background Color</phpbb_forum>
 * @version 0.2 marcolino7
 * 0.2 - Added Path for the Icon
 *		 Disabled Caching
 * 0.1 - Initial Release
 * http://www.mediawiki.org/wiki/Extension:PHPBB_ShowForum
if( !defined( 'MEDIAWIKI' ) ) {
        echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" );
        die( -1 );
// Extension credits that will show up on Special:Version
$wgExtensionCredits['parserhook']['PHPBB_ShowForum'] = array(
        'name'         => 'PHPBB Show Forum',
        'version'      => '0.2',
        'author'       => 'marcolino7, [http://www.mediawiki.org/wiki/User:Marcolino7]',
        'description'  => 'Link to Show PHPBB Forum in MediaWiki',
        'url'          => ''
$wgExtensionFunctions[] = "wfPHPBBExtension";
function wfPHPBBExtension() {
        global $wgParser;
        $wgParser->setHook( "phpbb_forum", "showForum" );
function showForum( $input, $argv, &$parser) {
   $phpbbDBSERVER="Database Address";
   $phpbbDBNAME="Database Name";
   $phpbb_home = "http://www.yoursite.org/forum/";
   $phpbb_icon_path = "templates/subSilver/images/folder.gif";
    # --------------------------------------------
 	//Disabling Cache
 	//Split input in 2 Parameters
	list($forumID, $postLimit,$bgColor) = split('[|.-]', $input);
    $link = mysql_connect($phpbbDBSERVER,$phpbbDBUSER ,$phpbbDBUSERPW);
    if ( !$link ) { return "<hr><b>Error while connecting to host \"$phpbbDBSERVER\" !</b><hr>"; }
    $db_selected = mysql_select_db($phpbbDBNAME, $link);
    if (!$db_selected) {return "<hr><b>Error while selecting database \"$phpbbDBNAME\" !</b><hr>"; }
	$sql = "SELECT t.topic_title, p.topic_id, t.topic_last_post_id, p.post_time, f.forum_name, f.forum_id,
               	u.username, u.user_id, p.post_username, u2.username as user2, u2.user_id as id2  
         		FROM ". $phpbbDBPrefix ."topics AS t, 
              	". $phpbbDBPrefix ."forums AS f, 
              	". $phpbbDBPrefix  ."posts AS p,
              	". $phpbbDBPrefix . "users AS u,
              	". $phpbbDBPrefix . "users AS u2
         		WHERE f.forum_id       = t.forum_id 
        	 	AND t.topic_poster   = u.user_id
           		AND p.post_id        = t.topic_last_post_id 
           		AND p.poster_id      = u2.user_id
           		AND t.topic_moved_id = 0 
           		AND f.forum_id in ( $forumID )
         		ORDER BY t.topic_last_post_id DESC 
         		LIMIT 0, $postLimit"; 

    $qryres = mysql_query($sql);
    if (!$qryres) { return "<hr><b>Error while MySQL Query :". mysql_error() ;}
	$out = "<table width=\"80%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"1\">";
	$row_count = 0;
	//Cycle inside recordset and populate page
		while ($row = mysql_fetch_row($qryres))
			$out = $out . " <tr style=\"background-color: #$bgColor\">
    							<td width=\"2%\" valign=\"top\"><img src=\"".$phpbb_home.$phpbb_icon_path."\" width=\"19\" height=\"18\" ></td>
							    <td width=\"80%\"><strong>
										<a href=\"".$phpbb_home."viewtopic.php?t=".$row[1]."#".$row[2]."\" class=\"external text\" >".$row[0]."</a>
							   	 <div style=\"font-size: x-small; font-family: \"Courier New\", Courier, monospace;\">from 
								 	<a href=\"profile.php?mode=viewprofile&u=".$row[7]."\">".$row[6]."</a> on ".date("D, d M Y H:i",$row[3])."</div>		
		}  //End While
		$out = $out . "</table>";

	return $out;


See also[edit]