Je me suis dit que ça pourrait intéresser du monde.
Si c'est le cas, j'aimerais en faire un mod.
J'aurai pour cela besoin de vos yeux avertis (je suis loin d'être un expert et j'ai surement laissé passer des failles, voire, fait des trucs stupides ou susceptible d'être améliorés) pour détecter tout pb éventuel, ainsi que pour m'aider à mettre tout ça sous forme de mod présentable.
L'objectif est à terme de pouvoir distribuer ce mod sur les sites habituels.
- A ceux qui seraient tentés de l'utiliser : je ne m'y connais pas en licences, mais je sais ce que je veux; j'aimerais
- être averti (ça fait plaisir)
- disposer d'un lien en retour, même discret (ça me permet de booster mon site) : je publierai l'url du lien à faire un peu plus tard.
D'autre part, c'est une version préliminaire, donc si vous l'utilisez tel quel, c'est à vos risques et périls.
Voici déjà ce qu'il y'a à savoir, + le code.
Scores
Afin de permettre aux membres de voir la valeur de leurs interventions reconnue, et ainsi, de s'auto-discipliner, j'ai mis en place un système de scores.
Le principe est simple : chaque membre peut désormais noter les posts du forum.
Cette note peut aller de 3 à -3, en fonction de la pertinence et de la qualité du message en question.
La note ainsi attribuée au post contribue à faire évoluer à la hausse ou à la baisse le score global du post, de son auteur et du topic concerné.
Son score reflète directement la valeur des contributions d'un membre à la communauté.Note : Le score du topic est calculé en additionnant les scores de tous les posts qui le composent, ce qui vous permet d'évaluer la valeur globale du topic, et ainsi, de vous décider s'il vaut le coup d'être lu ou pas.
A savoir :
- le score d'un post, d'un topic et d'un membre peut évoluer à la hausse ou à la baisse de manière illimitée : il n'y a ni score maximal, ni score minimal.
- on ne peut noter qu'une fois un même post, donc ne vous trompez pas
- un membre ne peut pas noter ses propres posts
- tout acharnement scoristique dans le but de faire baisser (ou grimper) le score d'un membre sera détecté sans aucun problème, je me suis pris la tête là dessus, mais je dispose de moyens fiables pour détecter ce genre d'abus, lesquels seront sanctionnés avec la plus grande rigueur.
Les règles du jeu
- ne notez pas pour régler vos comptes ou faire plaisir à vos potes
- c'est pas le membre que vous notez, mais la pertinence et la qualité de son intervention (et rien d'autre).
- tout abus sera facilement détecté et puni d'un ban, marre des malhonnêtes et des abrutis.
- si votre score total est moins bon que ce que vous pensiez, peut être devriez vous relire votre historique et réfléchir un peu à ce que vous posterez la prochaine fois.
- votre score ne reflète pas votre cote de popularité, mais la pertinence de vos interventions en général. Toute jalousie serait donc puérile.
Les liens qui font plaisir
- les membres ayant les meilleurs scores
- les membres ayant les plus mauvais scores
Pour vous servir,
FK.
ps : pour réagir, c'est ici.
Dans viewtopic :
Après
- Code: Tout sélectionner
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
}
Ajouter
- Code: Tout sélectionner
// MOD SCORE / NOTE ----------------------------------------------------------------
$sql = "SELECT * FROM FTS_motifs_notes ORDER BY motif ASC";
$resultat = $db->sql_query($sql);
$row_motifs = $db->sql_fetchrow($resultat);
$liste_motifs = "<option value=\"\">Motif</option>";
do {
$liste_motifs .= "<option value=\"".$row_motifs['id_motif']."\">".$row_motifs['motif']."</option>";
} while($row_motifs = $db->sql_fetchrow($resultat));
// FIN MOD SCORE / NOTE ----------------------------------------------------------------
Après
- Code: Tout sélectionner
//
// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...
//
for($i = 0; $i < $total_posts; $i++)
{
Ajouter
- Code: Tout sélectionner
// MOD SCORE / NOTE ----------------------------------------------------------------
$id_post = $postrow[$i]['post_id'];
$poster_id = $postrow[$i]['user_id'];
$sql = "SELECT note FROM phpbb_users WHERE user_id = $poster_id";
$resultat = $db->sql_query($sql);
$row_note = $db->sql_fetchrow($resultat);
$poster_note = $row_note['note'];
// Indiquer ci-dessous les forums sur lesquels on souhaite désactiver la notation
$forums_sans_notation = array('87','59','65','3','102','97');
if (!in_array($forum_id, $forums_sans_notation))
{
$post_note = "<br />Ce post : ".$postrow[$i]['note'];
// définir les éléments de notation
$notation = "<form action=\"/board/note.php\" method=\"post\">
<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" >
<tr>
<td valign=\"middle\"><select name=\"note\">
<option value=\"3\">3</option>
<option value=\"2\">2</option>
<option value=\"1\">1</option>
<option value=\"0\" selected=\"selected\">0</option>
<option value=\"-1\">-1</option>
<option value=\"-2\">-2</option>
<option value=\"-3\">-3</option>
</select></td>
<td valign=\"middle\">
<select name=\"motif\">";
$notation .= $liste_motifs;
$notation .= "</select>
</td>
<td valign=\"middle\"><input name=\"Envoyer\" type=\"submit\" value=\"ok\" />
<input name=\"id_post\" type=\"hidden\" value=\"".$id_post."\" />
<input name=\"test_note\" type=\"hidden\" value=\"testtest21test\" />
<input name=\"id_poster\" type=\"hidden\" value=\"".$poster_id."\" />
<input name=\"id_topic\" type=\"hidden\" value=\"".$topic_id."\" /></td>
</tr>
</table>
</form>";
// Afficher les notations du post en cours
$noteurs = "";
$sql_noteurs = "SELECT n.note, n.motif, u.username, m.motif FROM phpbb_notes n, phpbb_users u, FTS_motifs_notes m WHERE n.id_post = '$id_post' AND u.user_id = n.id_auteur AND m.id_motif = n.motif";
if ( !($resultats_noteurs = $db->sql_query($sql_noteurs)) )
{
message_die(GENERAL_ERROR, "Impossible de recuperer les notes du post.", '', __LINE__, __FILE__, $sql_noteurs);
}
$row_noteurs = mysql_fetch_assoc($resultats_noteurs);
// Voir si le post a déjà des notes où pas
$sql_test = "SELECT count(note) as notes FROM phpbb_notes WHERE id_post = '$id_post' GROUP BY id_post";
if ( !($resultats_test = $db->sql_query($sql_test)) )
{
message_die(GENERAL_ERROR, "Impossible de compter les notes du post.", '', __LINE__, __FILE__, $sql_test);
}
$row_test = mysql_fetch_assoc($resultats_test);
if( $row_test['notes'] != '')
{
$noteurs = "<strong>Qui a noté ce post :</strong>";
do {
$noteurs .= "<br /><strong>".$row_noteurs['note']."</strong> : ".$row_noteurs['username'];
if ($row_noteurs['motif'] != "") { $noteurs .= " (".$row_noteurs['motif'].")"; }
} while($row_noteurs = mysql_fetch_assoc($resultats_noteurs));
}
}
else // les mettre à vide
{
$post_note = "";
$notation = "<small><em>Vous ne pouvez pas noter les posts de ce forum</em></small>";
$noteurs = "";
}
// FIN MOD SCORE / NOTE ----------------------------------------------------------------
Après
- Code: Tout sélectionner
'POSTER_ID' => $poster_id,
Ajouter
- Code: Tout sélectionner
// MOD SCORE / NOTE ----------------------------------------------------------------
'NOTATION' => $notation,
'NOTEURS' => $noteurs,
'POSTER_NOTE' => $poster_note,
'POST_NOTE' => $post_note,
// FIN MOD SCORE / NOTE ----------------------------------------------------------------
Dans viewforum.php:
Après
- Code: Tout sélectionner
//
// Okay, lets dump out the page ...
//
if( $total_topics )
{
for($i = 0; $i < $total_topics; $i++)
{
Ajouter
- Code: Tout sélectionner
$topic_id = $topic_rowset[$i]['topic_id'];
$topic_note = $topic_rowset[$i]['note'];
Après
- Code: Tout sélectionner
'FORUM_ID' => $forum_id,
'TOPIC_ID' => $topic_id,
Ajouter
- Code: Tout sélectionner
'SCORE' => $topic_note,
Dans memberlist.php :
Après
- Code: Tout sélectionner
, $lang['Sort_Top_Ten']
Ajouter
- Code: Tout sélectionner
// MOD SCORE / NOTE ----------------------------------------------------------------
, 'Score'
// FIN MOD SCORE / NOTE ----------------------------------------------------------------
Après
- Code: Tout sélectionner
$mode_types = array('joined', 'username', 'location', 'posts', 'email', 'website', 'topten'
Ajouter
- Code: Tout sélectionner
// MOD SCORE / NOTE ----------------------------------------------------------------
, 'note'
// FIN MOD SCORE / NOTE ----------------------------------------------------------------
Après
- Code: Tout sélectionner
case 'topten':
$order_by = "user_posts $sort_order LIMIT 10";
break;
Ajouter
- Code: Tout sélectionner
// MOD SCORE / NOTE ----------------------------------------------------------------
case 'note':
$order_by = "note $sort_order LIMIT $start, " . $board_config['topics_per_page'];
break;
// FIN MOD SCORE / NOTE ----------------------------------------------------------------
Après
- Code: Tout sélectionner
$sql = "SELECT username, user_id, user_viewemail, user_posts, user_regdate, user_from, user_website, user_email, user_icq, user_aim, user_yim, user_msnm, user_avatar, user_avatar_type, user_allowavatar
Ajouter
- Code: Tout sélectionner
, note
Après
- Code: Tout sélectionner
$i = 0;
do
{
$username = $row['username'];
$user_id = $row['user_id'];
Ajouter
- Code: Tout sélectionner
// MOD SCORE / NOTE ----------------------------------------------------------------
$note = $row['note'];
// FIN MOD SCORE / NOTE ----------------------------------------------------------------
Après
- Code: Tout sélectionner
'FROM' => $from,
'JOINED' => $joined,
'POSTS' => $posts,
Ajouter
- Code: Tout sélectionner
// MOD SCORE / NOTE ---------------------------------
'SCORE' => $note,
// FIN MOD SCORE / NOTE ---------------------------------
Viewtopic_body.tpl
- Code: Tout sélectionner
<td width="150" align="center" valign="top" class="{postrow.ROW_CLASS}">
<p><a name="{postrow.U_POST_ID}"></a>
<span class="name"><strong>{postrow.POSTER_NAME}</strong></span></p>
<p class="postdetails">
<strong class="statut">{postrow.GRADE}</strong>
<br />{postrow.POSTER_RANK}</p>
<p>{postrow.POSTER_AVATAR}</p>
<p>{postrow.POSTER_JOINED}<br />
<br /><strong><a href="a-propos-des-scores-membres-posts-et-topics-vt13948.html" title="Explications">Score total : {postrow.POSTER_NOTE}</a></strong>
{postrow.POST_NOTE}</p>
<p><span class="little">{postrow.POSTER_FROM}<br />
<a href="search.php?search_author={postrow.POSTER_NAME}" class="postdetails">{postrow.POSTER_POSTS}</a></span>
</p>
</td>
- Code: Tout sélectionner
<td colspan="2"><hr style="margin:5px 0;" />
<div class="postbody" style="margin-top:0px; padding:5 10 10 10">
{postrow.MESSAGE}{postrow.SIGNATURE}</div>
<div class="gensmall" align="right">{postrow.EDITED_MESSAGE}</div>
<div class="histonotes">{postrow.NOTEURS}</div></td>
- Code: Tout sélectionner
<td nowrap="nowrap">{postrow.PROFILE_IMG} {postrow.PM_IMG} {postrow.EMAIL_IMG} {postrow.WWW_IMG} {postrow.AIM_IMG} {postrow.YIM_IMG} {postrow.MSN_IMG} {postrow.ICQ_IMG}</td>
<td align="right">{postrow.NOTATION}</td>
Viewforum_body.tpl
- Code: Tout sélectionner
<table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
<tr>
<th colspan="2" align="center" height="25" class="thCornerL" nowrap="nowrap"> {L_TOPICS} </th>
<th width="50" align="center" class="thTop" nowrap="nowrap"> {L_REPLIES} </th>
<th width="100" align="center" class="thTop" nowrap="nowrap"> {L_AUTHOR} </th>
<th width="50" align="center" class="thTop" nowrap="nowrap">Score</th>
<th width="50" align="center" class="thTop" nowrap="nowrap"> {L_VIEWS} </th>
<th align="center" class="thCornerR" nowrap="nowrap"> {L_LASTPOST} </th>
</tr>
<!-- BEGIN topicrow -->
<tr>
<td class="row4" align="center" valign="middle" width="20"><img src="{topicrow.TOPIC_FOLDER_IMG}" width="19" height="18" alt="{topicrow.L_TOPIC_FOLDER_ALT}" title="{topicrow.L_TOPIC_FOLDER_ALT}" /></td>
<td class="row3" width="100%"><span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall"><br />
{topicrow.GOTO_PAGE}</span></td>
<td class="row3" align="center" valign="middle"><span class="postdetails">{topicrow.REPLIES}</span></td>
<td class="row3" align="center" valign="middle"><span class="name">{topicrow.TOPIC_AUTHOR}</span></td>
<td class="row3" align="center" valign="middle">{topicrow.SCORE}</td>
<td class="row3" align="center" valign="middle"><span class="postdetails">{topicrow.VIEWS}</span></td>
<td class="row3" align="center" valign="middle" nowrap="nowrap"><span class="postdetails">{topicrow.LAST_POST_TIME}<br />{topicrow.LAST_POST_AUTHOR} {topicrow.LAST_POST_IMG}</span></td>
</tr>
<!-- END topicrow -->
<!-- BEGIN switch_no_topics -->
<tr>
<td class="row1" colspan="7" height="30" align="center" valign="middle"><span class="gen">{L_NO_TOPICS}</span></td>
</tr>
<!-- END switch_no_topics -->
<tr>
<td class="catBottom" align="center" valign="middle" colspan="7" height="28"><span class="genmed">{L_DISPLAY_TOPICS}: {S_SELECT_TOPIC_DAYS}
<input type="submit" class="liteoption" value="{L_GO}" name="submit" />
</span></td>
</tr>
</table>
Memberlist_body.tpl
- Code: Tout sélectionner
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
<tr>
<th height="25" class="thCornerL" nowrap="nowrap">#</th>
<th class="thTop" nowrap="nowrap"> </th>
<th class="thTop" nowrap="nowrap">{L_USERNAME}</th>
<th class="thTop" nowrap="nowrap">{L_EMAIL}</th>
<th class="thTop" nowrap="nowrap">{L_FROM}</th>
<th class="thTop" nowrap="nowrap">{L_JOINED}</th>
<th class="thTop" nowrap="nowrap">{L_POSTS}</th>
<th class="thCornerR" nowrap="nowrap">Score</th>
<th class="thCornerR" nowrap="nowrap">{L_WEBSITE}</th>
</tr>
<!-- BEGIN memberrow -->
<tr>
<td class="{memberrow.ROW_CLASS}" align="center"><span class="gen"> {memberrow.ROW_NUMBER} </span></td>
<td class="{memberrow.ROW_CLASS}" align="center"> {memberrow.PM_IMG} </td>
<td class="{memberrow.ROW_CLASS}" align="center"><span class="gen"><a href="{memberrow.U_VIEWPROFILE}" class="gen">{memberrow.USERNAME}</a></span></td>
<td class="{memberrow.ROW_CLASS}" align="center" valign="middle"> {memberrow.EMAIL_IMG} </td>
<td class="{memberrow.ROW_CLASS}" align="center" valign="middle"><span class="gen">{memberrow.FROM}</span></td>
<td class="{memberrow.ROW_CLASS}" align="center" valign="middle"><span class="gensmall">{memberrow.JOINED}</span></td>
<td class="{memberrow.ROW_CLASS}" align="center" valign="middle"><span class="gen">{memberrow.POSTS}</span></td>
<td class="{memberrow.ROW_CLASS}" align="center"><span class="gen">{memberrow.SCORE}</span></td>
<td class="{memberrow.ROW_CLASS}" align="center"> {memberrow.WWW_IMG} </td>
</tr>
<!-- END memberrow -->
<tr>
<td class="catBottom" colspan="9" height="28"> </td>
</tr>
</table>
Note.php
A placer dans le répertoire du forum.
- Code: Tout sélectionner
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
if ( !empty($_POST['test_note']))
{
$id_post = strip_tags($_POST['id_post']);
$id_topic = strip_tags($_POST['id_topic']);
$id_poster = strip_tags($_POST['id_poster']);
$motif = strip_tags($_POST['motif']);
$note = strip_tags($_POST['note']);
if($note == '0' && $motif == '')
{
message_die(GENERAL_ERROR, "Vous ne pouvez pas mettre une note nulle sans faire de commentaire.", '', __LINE__, __FILE__, $sql);
}
if ( $userdata['user_id'] == $id_poster)
{
message_die(GENERAL_ERROR, "Vous ne pouvez pas noter vos propres posts, tricheur.", '', __LINE__, __FILE__, $sql);
}
if ( $id_poster == "" || $id_poster == 0 || $id_poster == -1 )
{
message_die(GENERAL_ERROR, "Vous ne pouvez pas noter ce membre ;)", '', __LINE__, __FILE__, $sql);
}
if ( $userdata['session_logged_in'] )
{
$id_auteur = $userdata['user_id'];
$sql = "SELECT id_note FROM phpbb_notes WHERE id_post = $id_post AND id_auteur = '$id_auteur'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible de récupérer les données", '', __LINE__, __FILE__, $sql);
}
if (mysql_num_rows($result) == 0 )
{
// INSERTION SQL
$sql = "INSERT INTO phpbb_notes (id_topic, id_post, id_poster, note, motif, id_auteur) VALUES ($id_topic, $id_post, $id_poster, '$note', '$motif', $id_auteur)";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible d'enregistrer la note", '', __LINE__, __FILE__, $sql);
}
// MISE A JOUR NOTE GLOBALE DU POST
// => la somme de toutes les notes du post
$sql = "SELECT SUM(note) AS Note FROM phpbb_notes WHERE id_post = $id_post";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible de calculer la note du post", '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$note_post = $row['Note'];
$sql = "UPDATE phpbb_posts SET note = $note_post WHERE post_id = '$id_post'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible de mettre à jour la note du post", '', __LINE__, __FILE__, $sql);
}
}
// MISE A JOUR NOTE GLOBALE DU TOPIC
// => somme de toutes les notes GLOBALES des posts du topic
$sql = "SELECT SUM(note) AS Note FROM phpbb_posts WHERE topic_id = '$id_topic'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible de calculer la note du topic", '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$note_topic = $row['Note'];
$sql = "UPDATE phpbb_topics SET note = $note_topic WHERE topic_id = '$id_topic'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible de mettre à jour la note du topic", '', __LINE__, __FILE__, $sql);
}
}
// MISE A JOUR NOTE GLOBALE USER
$sql = "SELECT SUM(note) AS Note FROM phpbb_notes WHERE id_poster = '$id_poster'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible de calculer la note du membre", '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$note_membre = $row['Note'];
$sql = "UPDATE phpbb_users SET note = $note_membre WHERE user_id = '$id_poster'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Impossible de mettre à jour la note du membre", '', __LINE__, __FILE__, $sql);
}
}
header("Location:viewtopic.php?p=".$id_post); exit();
}
else
{
// déjà noté ce post !
message_die(GENERAL_ERROR, "Vous avez déjà noté ce post !", '', __LINE__, __FILE__);
}
}
else
{
message_die(GENERAL_ERROR, "Pour noter un post, vous devez être membre du forum et connecté.", '', __LINE__, __FILE__, $sql);
}
}
?>
SQL
** note : ici vous pouvez, bien évidemment, modifier le nom des tables, mais ça suppose de les changer dans votre code aussi.
CTRL+F : rechercher / remplacer est votre ami
- Code: Tout sélectionner
CREATE TABLE `FTS_motifs_notes` (
`id_motif` int(11) NOT NULL auto_increment,
`motif` varchar(255) NOT NULL default '',
PRIMARY KEY (`id_motif`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=85 ;
--
-- Contenu de la table `FTS_motifs_notes`
--
INSERT INTO `FTS_motifs_notes` (`id_motif`, `motif`) VALUES (82, 'Bienvenue !'),
(3, 'Intéressant'),
(4, 'Très intéressant'),
(5, 'Pertinent'),
(6, 'Post de qualité'),
(7, 'Post responsable'),
(8, 'A lire'),
(9, 'Etonnant'),
(11, 'Instructif'),
(12, 'Constructif'),
(13, 'Tout à fait !'),
(14, '+1'),
(15, 'Encore!'),
(16, 'Plus de details'),
(17, 'Developpe stp'),
(18, 'Ca va mieux en le disant'),
(19, '100% d''accord'),
(20, 'J''allais le dire'),
(21, 'Tout ça pour dire quoi ?'),
(22, 'Presente mieux stp'),
(23, 'Des exemples ?'),
(24, 'Sympa :)'),
(25, 'Merci ! :)'),
(26, 'Yep ! :)'),
(27, 'lol'),
(28, 'Yesssss!'),
(29, 'mdr !!'),
(30, 'CQFD !'),
(31, 'OMG'),
(32, 'De rien ! ;-)'),
(34, 'Quelle patience !'),
(35, 'Déjà vu'),
(36, 'Moi moi moi moi'),
(37, 'Pas drôle'),
(38, 'Lis le règlement !'),
(39, '=> Chercher'),
(40, 'Troll'),
(41, 'Spam'),
(42, 'Pas convaincu'),
(43, 'Peu crédible / mytho...'),
(44, 'Foutage de merde'),
(45, 'Mauvais esprit'),
(46, 'Post commercial'),
(47, 'Pub déguisée'),
(48, 'Témoignage bidon'),
(49, 'C''est de la lèche...'),
(50, 'Sans intérêt'),
(51, 'Dont feed the troll'),
(52, 'Inutile'),
(53, 'Limite'),
(54, 'Petit'),
(55, 'Mesquin'),
(56, 'Gratuit'),
(57, 'Innaceptable !'),
(58, 'Irresponsable'),
(59, 'Immature'),
(60, 'Indigne de FTS'),
(61, 'Demande d''aide perso'),
(62, 'Et puis quoi encore ?'),
(63, 'Du grand n''importe quoi'),
(64, 'Un peu (trop) dogmatique'),
(65, 'Et la marmotte ...'),
(66, 'Prends un peu de recul'),
(67, 'Sujet interdit'),
(68, 'Hors sujet'),
(69, 'T''es lourd'),
(70, 'Du calme'),
(71, '36 15 My Life'),
(72, 'Pourquoi tant de haine ?'),
(73, 'Faut apprendre à lire'),
(74, 'Faut apprendre à écrire'),
(75, 'Boulet'),
(76, 'Super boulet...'),
(77, 'Pffff.....'),
(78, 'Hum...'),
(79, 'Tss ...'),
(80, '???'),
(81, '...'),
(83, 'Bonne idée !'),
(84, 'Pourquoi tant de haine... ?');
- Code: Tout sélectionner
CREATE TABLE `phpbb_notes` (
`id_note` int(11) NOT NULL auto_increment,
`id_topic` int(11) NOT NULL default '0',
`id_post` int(11) NOT NULL default '0',
`id_poster` int(11) NOT NULL default '0',
`note` int(11) NOT NULL default '0',
`motif` int(2) NOT NULL default '0',
`id_auteur` int(11) NOT NULL default '0',
PRIMARY KEY (`id_note`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1363 ;
Qui note qui ?
Pour monitorer tout ça.
Créer un nouveau fichier
- Code: Tout sélectionner
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './board/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
if (!empty($_GET['user_id']))
{
if ($_GET['mode'] == "notes") // qui a noté le membre
{
$sql = "SELECT n.*, u.username AS pseudo, m.motif AS motif
FROM phpbb_notes n, phpbb_users u, FTS_motifs_notes m
WHERE n.id_auteur = ".$_GET['user_id']."
AND n.id_poster = u.user_id
AND m.id_motif = n.motif
ORDER BY id_poster";
$titre = "Qui ".$_GET['user_id']." a noté ?";
}
elseif ($_GET['mode'] == "noteurs") // qui le membre a noté
{
$sql = "SELECT n.*, u.username AS pseudo, m.motif AS motif FROM phpbb_notes n, phpbb_users u , FTS_motifs_notes m
WHERE n.id_poster = ".$_GET['user_id']." AND n.id_auteur = u.user_id AND m.id_motif = n.motif
ORDER BY id_auteur";
$titre = "Qui a noté ".$_GET['user_id'];
}
else
{
$sql = "SELECT note, username, user_id FROM phpbb_users
WHERE note <> '' ORDER BY note DESC";
$titre = "Les membres les mieux notés";
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Erreur SQL", '', __LINE__, __FILE__, $sql);
}
$row = mysql_fetch_assoc($result);
}
else
{
if (empty($_GET['mode']))
{
$sql = "SELECT note, username, user_id FROM phpbb_users
WHERE note <> '' ORDER BY note DESC";
$titre = "Les membres les mieux notés";
}
elseif($_GET['mode'] == "noteurs_fous") // qui sont les plus gros noteurs
{
$sql = "SELECT count(n.note) AS notes, avg(n.note) AS moyenne, n.id_auteur, u.username AS pseudo FROM phpbb_notes n, phpbb_users u
WHERE u.user_id = n.id_auteur
GROUP BY n.id_auteur ORDER BY notes DESC";
$titre = "Les noteurs fous";
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Erreur SQL", '', __LINE__, __FILE__, $sql);
}
$row = mysql_fetch_assoc($result);
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $titre; ?></title>
</head>
<body>
<h1><?php echo $titre; ?></h1>
<?php
if($_GET['mode'] == "noteurs_fous") // noteurs fous
{
do {
echo "<li><strong>".$row['pseudo']."</strong> : ".$row['notes']." notes attribuées au total (note moyenne : ".round($row['moyenne']).") - <a href=\"mod_quinotequi.php?mode=notes&user_id=".$row['id_auteur']."\">voir</a></li>";
} while($row = mysql_fetch_assoc($result));
}
elseif($_GET['mode'] == "noteurs" || $_GET['mode'] == "notes")
{
if (mysql_num_rows($result) != 0 )
{
do {
$current = $row['pseudo'];
if ($previous != $current) { echo "</ul><strong>".$current."</strong><ul>"; }
echo "<li>".$row['note']." (".$row['motif'].") : <a href=\"board/viewtopic.php?p=".$row['id_post']."\">voir</a></li>";
$previous = $current;
} while($row = mysql_fetch_assoc($result));
}
}
else // liste globale
{
echo "<ul>";
do {
echo "<li><strong>".$row['username']."</strong> (".$row['note'].") : <a href=\"mod_quinotequi.php?user_id=".$row['user_id']."&mode=notes\">Qui ce membre a-t-il note ?</a> - <a href=\"mod_quinotequi.php?user_id=".$row['user_id']."&mode=noteurs\">Qui a mis quelle note à ce membre ?</a></li>";
} while($row = mysql_fetch_assoc($result));
echo "</ul>";
}
?>
</body>
</html>
Posts par motif
Pour sortir la liste des tous les topics commentés "intéressants", ou "boulet", ou "inutile", ...
Créer un nouveau fichier
- Code: Tout sélectionner
<?php
require_once('Connections/cnx_fo.php');
mysql_select_db($database_cnx, $cnx);
$id_motif = $_GET['id_motif'];
$sql = "SELECT DISTINCT n.id_post, m.motif, u.username AS auteur, t.topic_title AS topic, t.topic_id
FROM phpbb_notes n, FTS_motifs_notes m, phpbb_users u, phpbb_topics t, phpbb_posts p
WHERE m.id_motif ='$id_motif'
AND m.id_motif = n.motif
AND u.user_id = n.id_poster
AND t.topic_id = p.topic_id
AND p.post_id = n.id_post
ORDER BY n.id_post DESC";
$query = mysql_query($sql, $cnx) or die(mysql_error());
$row = mysql_fetch_assoc($query);
$total = mysql_num_rows($query);
// liste motifs
$sql_motifs = "SELECT * FROM FTS_motifs_notes ORDER BY motif ASC";
$query_motifs = mysql_query($sql_motifs, $cnx) or die(mysql_error());
$row_motifs = mysql_fetch_assoc($query_motifs);
function format_url( $url, $type = 'topic' ) {
$url = preg_replace("(\[.*\])U","",$url);
$find = array('"','&','<','>','\r\n','\n',);
$url = str_replace ($find, '-', $url);
$url = str_replace ('ß', 'ss', $url);
$url = str_replace (array('ö','Ö'), 'oe', $url);
$url = str_replace (array('ä','Ä'), 'ae', $url);
$url = str_replace (array('ü','Ü'), 'ue', $url);
$find = "ÀÁÂÃÅàáâãåÒÓÔÕØòóôõøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛùúûÿÑñ";
$replace = "aaaaaaaaaaooooooooooeeeeeeeecciiiiiiiiuuuuuuynn";
$url = strtr($url,$find,$replace);
$url = strtolower($url);
$url = ereg_replace("[^a-zA-Z0-9]", "-", $url);
$url = preg_replace("`([\-])+`", "\\1", $url);
$url = trim($url, '-');
$url = ( $url == "" ) ? $type : $url;
return $url;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Les posts "<?php echo $row['motif']; ?>"</title>
<style type="text/css">
<!--
#liste li { display:inline; padding-left:1em; border-left:1px solid #CCC; margin-right:1em; }
-->
</style>
</head>
<body>
<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="id_motif">
<?php do { ?>
<option value="<?php echo $row_motifs['id_motif']; ?>"><?php echo $row_motifs['motif']; ?></option>
<?php } while ($row_motifs = mysql_fetch_assoc($query_motifs)); ?>
</select>
<label>
<input type="submit" name="Submit" value="Envoyer" />
</label>
</form>
<p>Choisissez un commentaire dans cette liste pour afficher tous les posts qui ont été marqués ainsi par les membres. </p>
<h2>Les posts "<?php echo $row['motif']; ?>"</h2>
<ul>
<?php do { ?>
<li><strong><a href="../board/<?php echo format_url($row['topic']); ?>-vt<?php echo $row['topic_id']; ?>.html#<?php echo $row['id_post']; ?>"><?php echo $row['topic']; ?></a></strong> (par <?php echo $row['auteur']; ?>)</li>
<?php } while($row = mysql_fetch_assoc($query)) ; ?>
</ul>
</body>
</html>
Ouf, c'est fini
Suggestions et critiques sont les bienvenues !

Français |
Anglais


