Forum de discussions pour les webmasters et les web developpeurs. (PHP, SQL, XHTML, JavaScript, Référencement, Positionnement,...)
Vous n'êtes pas identifié.
Bonjour
J'ai un script qui m'aide a afficher les news de mon forum sur la page d'accueil, le script marche bien, juste que le BBCode [url]s'affiche sur le forum, et sur la page du site non
pour le script c'est ici
Hors ligne
bonjour
voila mon script
<?php
define('IN_PHPBB', true);
define('IN_SITE', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'phpBB3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
// Start session management
// $user->session_begin();
// $auth->acl($user->data);
// $user->setup('viewtopic', 0);
$host = 'localhost';
$user = 'root'; //nom d'utilisateur
$pass = ''; //mot de pass
$bdd = 'phpBB3'; // votre base de donnée
mysql_connect($host, $user, $pass);
mysql_select_db($bdd) or die('Impossible de se connecter');
function obtain_word_list()
{
global $config, $user, $db;
$sql = 'SELECT word, replacement FROM ' . WORDS_TABLE;
$result = $db->sql_query($sql);
$censors = array();
while ($row = $db->sql_fetchrow($result))
{
$censors['match'][] = '#(?<!\w)(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')(?!\w)#i';
$censors['replace'][] = $row['replacement'];
}
$db->sql_freeresult($result);
return $censors;
}
function smiley_msg($text)
{
global $config, $phpbb_root_path;
return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img src="' . $phpbb_root_path . $config['smilies_path'] . '/\2 />', $text);
}
function nl2br_msg($text)
{
$text = str_replace(array("\n", "\r"), array('<br clear="all"/>', "\n"), $text);
return $text;
}
function censor_msg($text)
{
if (!isset($censors) || !is_array($censors))
{
$censors = obtain_word_list();
}
if (sizeof($censors))
{
return preg_replace($censors['match'], $censors['replace'], $text);
}
return $text;
}
$table_prefix = 'forums_';
$sql = "SELECT p.*, t.topic_replies, t.topic_first_poster_name
FROM forums_posts p, forums_forums f, forums_topics t
WHERE f.forum_id=2
AND p.topic_id = t.topic_id
AND p.forum_id = f.forum_id
AND f.forum_id = t.forum_id
AND p.post_id = t.topic_first_post_id
ORDER BY topic_time DESC";
$req = mysql_query($sql);
//Initialisation de la variable "qui compte les news"
$j = 1;
// Instantiate BBCode if need be
if ($bbcode_bitfield !== '')
{
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
while($data = @mysql_fetch_array($req))
{
$subject = $data['post_subject'];
$subject = censor_msg($subject);
$subject = smiley_msg($subject);
//Affichage du titre
echo '<div class="entry"><h1>'.$subject.'</h1>';
$message = $data['post_text'];
$message = censor_msg($message);
if ($data['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $data['bbcode_uid'], $data['bbcode_bitfield']);
}
$message = nl2br_msg($message);
$message = smiley_msg($message);
//Affichage du contenu de la news
echo '<div class="text">'.$message.'</div>';
// if ($ok!=1) echo '<p class="titre">'.$message.'</p>';
//Affichage de l'auteur
echo '<div class="source">Posté par <a href="'.$phpbb_root_path.'memberlist.php?mode=viewprofile&u='.$data['poster_id'].'">'.(strtolower($data['topic_first_poster_name'])) .'</a> le '.date('d/m/y à H\hi', $data['post_time']).' - ';
//Des commentaires
echo '<a href="'.$phpbb_root_path.'viewtopic.php?t='.$data['topic_id'].'"> '.$data['topic_replies'].' commentaire(s)</a></div></div>';
$ok=2;
//Si on atteints 5 news, on arrête
if($j >= 5)
{
break;
}
$j++;
}
@mysql_free_result($req);
?>et aussi le fichié includes/bbcode.php a été modifié :
TROUVER
$this->template_filename = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template/bbcode.html';
REMPLACER PAR
if (!IN_SITE)
{
$this->template_filename = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template/bbcode.html';
}
else
{
$this->template_filename = $phpbb_root_path . 'styles/prosilver/template/bbcode.html';
}
TROUVER
if ($user->optionget('viewimg'))
{
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'#\[img:$uid\](.*?)\[/img:$uid\]#s' => $this->bbcode_tpl('img', $bbcode_id),
)
);
}
else
{
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'#\[img:$uid\](.*?)\[/img:$uid\]#s' => str_replace('$2', '[ img ]', $this->bbcode_tpl('url', $bbcode_id, true)),
)
);
}
REMPLACER PAR
if (!IN_SITE)
{
if ($user->optionget('viewimg'))
{
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'#\[img:$uid\](.*?)\[/img:$uid\]#s' => $this->bbcode_tpl('img', $bbcode_id),
)
);
}
else
{
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'#\[img:$uid\](.*?)\[/img:$uid\]#s' => str_replace('$2', '[ img ]', $this->bbcode_tpl('url', $bbcode_id, true)),
)
);
}
}
else
{
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'#\[img:$uid\](.*?)\[/img:$uid\]#s' => $this->bbcode_tpl('img', $bbcode_id),
)
);
}
TROUVER
if ($user->optionget('viewflash'))
{
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#' => $this->bbcode_tpl('flash', $bbcode_id),
)
);
}
else
{
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#' => str_replace('$1', '$3', str_replace('$2', '[ flash ]', $this->bbcode_tpl('url', $bbcode_id, true)))
)
);
}
REMPLACER PAR
if (!IN_SITE)
{
if ($user->optionget('viewflash'))
{
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#' => $this->bbcode_tpl('flash', $bbcode_id),
)
);
}
else
{
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#' => str_replace('$1', '$3', str_replace('$2', '[ flash ]', $this->bbcode_tpl('url', $bbcode_id, true)))
)
);
}
}
else
{
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
'#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#' => $this->bbcode_tpl('flash', $bbcode_id),
)
);
}Le script marche super bien, le problème c'est quand je post un message avec des lien, sa ne s'affiche pas sur la page d'accueil.
Hors ligne