Page 1 sur 1

[phpBB3] Afficher un message du forum

Posté : mer. 5 oct. 2011 04:49
par Dakin Quelia
» Afficher un message du forum

Ce code vous permet d'afficher un message sur votre site.

Code : Tout sélectionner

<?php
/** 
*
* @package phpBB3
* @version 0.1.0
* @copyright (c) 2011 Dakin Quelia
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include $phpbb_root_path . 'common.' . $phpEx;

// Globals Parameters
$topic_id = 259;

$sql = 'SELECT post_subject, post_text, bbcode_uid, bbcode_bitfield FROM ' . POSTS_TABLE . ' WHERE topic_id =' . $topic_id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

echo generate_text_for_html_display($row['post_text'], $row['bbcode_uid']);

/**
* Display validation results as HTML
*/
function generate_text_for_html_display($text, $uid)
{
    //Replace new
    $text = nl2br($text);

    //BBCode replacement array
    $bbcode = array(
        "/\[b:$uid\](.*?)\[\/b:$uid\]/is"                     => '<span style="font-weight:bold;">$1</span>',
        "/\[u:$uid\](.*?)\[\/u:$uid\]/is"                     => '<span style="text-decoration:underline;">$1</span>',
        "/\[color\=(.*?):$uid\](.*?)\[\/color:$uid\]/is"     => '<span style="color:$1;">$2</span>',
        "/\[code:$uid\](.*?)\[\/code:$uid\]/is"             => '<pre style="padding-left:20px;">$1</pre>',
        '#\[url(=(.*))?:$uid\](.*)\[/url:$uid\]#iUe'         => "validate_url('\$2', '\$3')",
    );
        
    return preg_replace(array_keys($bbcode), array_values($bbcode), $text);
}

?>