Jump to content

[RESOLU] Script news phpbb


Recommended Posts

Bonjour,

j'ai trouver ce scrip sur le net : http://www.j0k3r.net/php-des-news-sur-votr...a-phpbb-24.html

Je l'ai adapter a mon site ( mdp etc ) mais j'ai un probleme, il en maffiche qu'une news, et j'ai une ereur dans la requete, pourtant, quand j'execute la requete dans phpmyadminn tout vas bien. Voici le script:

<?
define('IN_PHPBB', true);
$phpbb_root_path = '../forum/';
$theme = 'subSilver';
include_once($phpbb_root_path.'includes/template.php');
include($phpbb_root_path.'includes/functions.php');
$template = new Template($phpbb_root_path.'templates/'.$theme);
include_once($phpbb_root_path.'includes/bbcode.php'); 

$host = 'localhost';
$user = 'teamdeclick_1';
$pass = 'XXX';
$bdd = 'teamdeclick_forum'; // votre base de donnée 

mysql_connect($host, $user, $pass);
mysql_select_db($bdd) or die('Impossible de se connecter'); 

$table_prefix = 'phpbb_';
$sql = "SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_time, t.topic_replies, t.topic_last_post_id, t.topic_views, t.topic_vote, u.username, u.user_id, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_allowsmile, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid
FROM " . $table_prefix. "forums f, " . $table_prefix. "topics t, " . $table_prefix. "posts p, " . $table_prefix. "users u, " . $table_prefix. "posts_text pt 
WHERE f.forum_news = '" . TRUE . "' 
	AND t.forum_id = f.forum_id 
	AND p.topic_id = t.topic_id 
	AND p.post_id = t.topic_first_post_id 
	AND pt.post_id = p.post_id 
	AND u.user_id = p.poster_id 
	AND t.topic_type = '0'
ORDER BY topic_time DESC";
echo $sql;
$req = mysql_query($sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>j0k3r.n3t - Des news sur votre site grace à phpBB</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Language" content="fr" />
<link rel="StyleSheet" type="text/css" href="style.css" />
</head>
<div id="conteneur">		
<h1 id="header">
	<a href="http://www.j0k3r.net" onclick="window.open(this.href);return(false);"><img src="http://www.j0k3r.net/img/jok/logo_jok_big.jpg" alt="" style="border: 0px;" /></a>
</h1>
<div id="contenu">
<?
//Initialisation de la variable "qui compte les news"
$j = 1;
while($data = mysql_fetch_array($req)) ****************************************************Ligne 49*****************
{
//Affichage du titre
echo '<h2>'.$data['topic_title'].'</h2>';
//On parse la news pour y interprété le BBcode
$message = bbencode_second_pass($data['post_text'], $data['bbcode_uid']);
$message = str_replace("\n\r", "\n", $message);
$message = str_replace("\n", "<br />\n", $message);
//On s'occupe des smileys
$req_smilies = mysql_query('SELECT smilies_id, code, smile_url, emoticon FROM '.$table_prefix.'smilies'); 
$k = 0;
while($data_smilies = mysql_fetch_array($req_smilies))
{			
	$smilies[$k]['code'] = $data_smilies['code'];
	$smilies[$k]['smile_url'] = $data_smilies['smile_url'];
	$smilies[$k]['emoticon'] = $data_smilies['emoticon'];
	$k ++;
}
if (count($smilies))
{
	usort($smilies, 'smiley_sort');
}
for ($i = 0; $i < count($smilies); $i++)
{
	$orig[] = "/(?<=.\W|\W.|^\W)".phpbb_preg_quote($smilies[$i]['code'], "/")."(?=.\W|\W.|\W$)/";
	$repl[] = '<img src="'.$phpbb_root_path.'images/smiles/'.$smilies[$i]['smile_url'].'" alt="'.$smilies[$i]['emoticon'].'" />';
}
$message = preg_replace($orig, $repl, ' '.$message.' ');
$message = substr($message, 1, -1);
//Affichage du contenu de la news
echo '<p>'.$message.'</p>';
//Affichage de l'auteur
echo '<h3>Posté par <a href="'.$phpbb_root_path;
echo 'profile.php?mode=viewprofile&u='.$data['user_id'].'">'.$data['username'].'</a>';
//De l'heure
echo ' le '.date('d/m/y à H:i', $data['topic_time']).' - ';
//Des commentaires
echo '<a href="'.$phpbb_root_path.'viewtopic.php?t=';
echo $data['topic_id'].'">['.$data['topic_replies'].'] commentaire(s)</a></h3>';
//Si on atteinds 5 news, on arrete
if($j >= 5)
{
	break;
}
$j++;
mysql_free_result($req); 
}
?>
</div>
</div>
<p id="footer">
<a href="http://www.j0k3r.net" onclick="window.open(this.href);return(false);">j0k3r_n0ir</a> © 2005
</p>
</body>
</html>

Et voici le lien pour voir le resultat : http://team-declick.societeg.com/new/news.php ( je vous ai afficher la requete )

Je precise que j'ai bien 2 news dans le forum, mais juste une s'affiche.

J'ai aussi vu que ce script n'est pas tres propre, notament le coup de $j++ a la place de LIMIT, mais j'aimerais d'abord qu'il marche comme ça.

Merci d'avance

Guillaume

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...