Пример #1
0
function display_post()
{
    $privileges = user_privilege_level();
    if ($privileges > 1) {
        // Titre et messages éventuels
        echo '<h1>Consultation des propositions :</h1>
		<h2>Pour voter, il faut s\'inscrire <a href="index.php?action=create_account" title="inscription">ICI</a></h2>';
        if (isset($_SESSION['transient_display'])) {
            echo $_SESSION['transient_display'];
            unset($_SESSION['transient_display']);
        }
        // ******************************************************************* //
        // Formulaire pour gérer le filtrage/l'ordonnancement des propositions //
        // ******************************************************************* //
        // Menu de sélection des idées
        $tail = '<div class="enlarge_lowresol">
			<form method="post" action="?action=post_filter_change">
				<table class="tab_form_close">
					<tr>';
        // Choix de catégorie
        $tail .= '<td>
							Cat&eacute;gorie :
						</td>
						<td>
							<select name="category_filter">
								<option value="0">Toutes</option>';
        $result = @mysql_query("SELECT category_id,category_name FROM thread_category");
        // Menu déroulant de choix de catégorie en fonction de ce qui est disponible en base
        if ($result) {
            while ($row = mysql_fetch_assoc($result)) {
                if (isset($_SESSION["thread_category_filter"]) && $row["category_id"] == $_SESSION["thread_category_filter"]) {
                    $tail .= '<option value="' . htmlentities($row["category_id"]) . '" selected="selected">' . htmlentities($row["category_name"]) . '</option>';
                } else {
                    $tail .= '<option value="' . htmlentities($row["category_id"]) . '">' . htmlentities($row["category_name"]) . '</option>';
                }
            }
            @mysql_free_result($result);
        }
        $tail .= '</select></td>';
        // Menu de filtrage pour les utilisateurs loggés
        if (is_logged()) {
            $tail .= '<td>
				Filtre :
			</td>
			<td>
				<select name="admin_filter">
					<option value="0">Aucun</option>';
            if ($privileges > 3) {
                if (isset($_SESSION["thread_admin_filter"])) {
                    switch ($_SESSION["thread_admin_filter"]) {
                        case 1:
                            $tail .= '<option value="1" selected="selected">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>
								<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                            break;
                        case 2:
                            $tail .= '<option value="1">Mes propositions</option><option value="2" selected="selected">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>
								<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                            break;
                        case 3:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3" selected="selected">Propositions sans mon vote</option>
								<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                            break;
                        case 4:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>
								<option value="4" selected="selected">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                            break;
                        case 5:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>
								<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5" selected="selected">Commentaires non mod&eacute;r&eacute;s</option>';
                            break;
                        default:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>
								<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                    }
                } else {
                    $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>
						<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                }
            } else {
                if (isset($_SESSION["thread_admin_filter"])) {
                    switch ($_SESSION["thread_admin_filter"]) {
                        case 1:
                            $tail .= '<option value="1" selected="selected">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>';
                            break;
                        case 2:
                            $tail .= '<option value="1">Mes propositions</option><option value="2" selected="selected">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>';
                            break;
                        case 3:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3" selected="selected">Propositions sans mon vote</option>';
                            break;
                        default:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>';
                    }
                } else {
                    $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>';
                }
            }
            $tail .= '</select></td>';
        }
        // Menu pour le tri des résultats
        if (isset($_SESSION["thread_ordering"])) {
            if (isset($_SESSION["thread_admin_filter"]) && $_SESSION["thread_admin_filter"] == 5) {
                $tail .= '<td>
							Trier par :
						</td>
						<td>
							<select name="sorting" disabled="disabled">
								<option value="1" selected="selected">Date</option><option value="2">Nombre de votes favorables</option><option value="3">Proportion de votes favorables</option><option value="4">Nombre total de votes</option>"';
            } else {
                $tail .= '<td>
							Trier par :
						</td>
						<td>
							<select name="sorting">';
                switch ($_SESSION["thread_ordering"]) {
                    case 1:
                        $tail .= "<option value=\"1\" selected=\"selected\">Date</option><option value=\"2\">Nombre de votes favorables</option><option value=\"3\">Proportion de votes favorables</option><option value=\"4\">Nombre total de votes</option>";
                        break;
                    case 2:
                        $tail .= "<option value=\"1\">Date</option><option value=\"2\" selected=\"selected\">Nombre de votes favorables</option><option value=\"3\">Proportion de votes favorables</option><option value=\"4\">Nombre total de votes</option>";
                        break;
                    case 3:
                        $tail .= "<option value=\"1\">Date</option><option value=\"2\">Nombre de votes favorables</option><option value=\"3\" selected=\"selected\">Proportion de votes favorables</option><option value=\"4\">Nombre total de votes</option>";
                        break;
                    case 4:
                        $tail .= "<option value=\"1\">Date</option><option value=\"2\">Nombre de votes favorables</option><option value=\"3\">Proportion de votes favorables</option><option value=\"4\" selected=\"selected\">Nombre total de votes</option>";
                        break;
                    default:
                        $tail .= "<option value=\"1\">Date</option><option value=\"2\">Nombre de votes favorables</option><option value=\"3\">Proportion de votes favorables</option><option value=\"4\">Nombre total de votes</option>";
                }
            }
        } else {
            if (isset($_SESSION["thread_admin_filter"]) && $_SESSION["thread_admin_filter"] == 4) {
                $tail .= '<td>
							Trier par :
						</td>
						<td>
							<select name="sorting" disabled="disabled">
								<option value="1">Date</option><option value="2">Nombre de votes favorables</option><option value="3">Proportion de votes favorables</option><option value="4">Nombre total de votes</option>"';
            } else {
                $tail .= '<td>
							Trier par :
						</td>
						<td>
							<select name="sorting">
								<option value="1">Date</option><option value="2">Nombre de votes favorables</option><option value="3">Proportion de votes favorables</option><option value="4">Nombre total de votes</option>';
            }
        }
        echo $tail . '
						</select>
					</td>
					<td>
						<input type="hidden" name="form_name" value="thread_display_param" />
					</td>
					<td>
						<input type="submit" value="Valider" />
					</td>
				</tr>
			</table>
		</form></div>';
        $is_admin = $privileges > 3;
        // ****************************************************************************** //
        // Affichage des résultats selon les paramètres définis dans les menus précédents //
        // ****************************************************************************** //
        if (isset($_SESSION["thread_admin_filter"]) && $_SESSION["thread_admin_filter"] == 5) {
            affichage_comments(-1, true);
            // Affichage "brutal" des commentaires confié à une autre fonction
        } else {
            $current_mod = isset($_SESSION["thread_admin_filter"]) && $_SESSION["thread_admin_filter"] == 4;
            // Mode modération
            $vote_filt = isset($_SESSION["thread_admin_filter"]) && $_SESSION["thread_admin_filter"] == 3;
            // Filtrage selon les votes
            // ************************************************************ //
            // Construction de la requête de rappatriement des propositions //
            // ************************************************************ //
            $recherche = "(T.text LIKE '%" . mysql_real_escape_string($_SESSION['thread_admin_recherche']) . "%' OR T.title LIKE '%" . mysql_real_escape_string($_SESSION['thread_admin_recherche']) . "%') AND";
            // Requête de base (deux parties pour prendre en comptes les propositions sans votes)
            $query_p1 = "(SELECT T.thread_id, T.rand_prop, T.hash_prop, T.title, T.text, T.date, T.is_valid, T.possibly_name, T.already_mod, G.category_name,\n\t\t\t\t\tSUM(V.vote) AS pro_vote, COUNT(V.vote) AS total_vote\n\t\t\t\t\tFROM thread T, thread_category G, vote V\n\t\t\t\t\tWHERE " . $recherche . " V.thread_id=T.thread_id AND G.category_id=T.category";
            $query_p2 = "(SELECT T.thread_id, T.rand_prop, T.hash_prop, T.title, T.text, T.date, T.is_valid, T.possibly_name, T.already_mod, G.category_name,\n\t\t\t\t\t0 AS pro_vote, 0 AS total_vote\n\t\t\t\t\tFROM thread T, thread_category G\n\t\t\t\t\tWHERE " . $recherche . " T.thread_id <> ALL (SELECT thread_id FROM vote) AND G.category_id=T.category";
            $query_count = "SELECT COUNT(T.thread_id) AS NUM_RES FROM thread T, thread_category G WHERE G.category_id=T.category";
            // Requête à part pour déterminer préalablement le nombre de résultats
            if (isset($_SESSION["thread_admin_filter"])) {
                switch ($_SESSION["thread_admin_filter"]) {
                    case 0:
                        // Aucune contrainte si ce n'est une question de droits d'affichage
                        if (is_logged()) {
                            if (!$is_admin) {
                                $query_p1 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_p2 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_count .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))))=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            }
                        } else {
                            $query_p1 .= " AND FALSE";
                            $query_p2 .= " AND FALSE";
                            $query_count .= " AND FALSE";
                        }
                        break;
                    case 1:
                        // Posts propriétaires
                        if (is_logged()) {
                            $query_p1 .= sprintf(" AND (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop)", mysql_real_escape_string($_SESSION['login_c']));
                            $query_p2 .= sprintf(" AND (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop)", mysql_real_escape_string($_SESSION['login_c']));
                            $query_count .= sprintf(" AND (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))))=T.hash_prop)", mysql_real_escape_string($_SESSION['login_c']));
                        } else {
                            $query_p1 .= " AND FALSE";
                            $query_p2 .= " AND FALSE";
                            $query_count .= " AND FALSE";
                        }
                        break;
                    case 2:
                        // Posts commentés
                        if (is_logged()) {
                            $query_p1 .= sprintf(" AND T.thread_id IN (SELECT DISTINCT thread_id FROM comment WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            $query_p2 .= sprintf(" AND T.thread_id IN (SELECT DISTINCT thread_id FROM comment WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            $query_count .= sprintf(" AND T.thread_id IN (SELECT DISTINCT thread_id FROM comment WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            if (!$is_admin) {
                                $query_p1 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_p2 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_count .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))))=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            }
                        } else {
                            $query_p1 .= " AND FALSE";
                            $query_p2 .= " AND FALSE";
                            $query_count .= " AND FALSE";
                        }
                        break;
                    case 3:
                        // Posts pour lesquels je n'ai pas voté
                        if (is_logged()) {
                            $query_p1 .= sprintf(" AND T.thread_id NOT IN (SELECT DISTINCT thread_id FROM vote WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            $query_p2 .= sprintf(" AND T.thread_id NOT IN (SELECT DISTINCT thread_id FROM vote WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            $query_count .= sprintf(" AND T.thread_id NOT IN (SELECT DISTINCT thread_id FROM vote WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            if (!$is_admin) {
                                $query_p1 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_p2 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_count .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))))=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            }
                        } else {
                            $query_p1 .= " AND FALSE";
                            $query_p2 .= " AND FALSE";
                            $query_count .= " AND FALSE";
                        }
                        break;
                    case 4:
                        // Propositions non modérées
                        if ($is_admin) {
                            $query_p1 .= " AND T.already_mod=0";
                            $query_p2 .= " AND T.already_mod=0";
                            $query_count .= " AND T.already_mod=0";
                        } else {
                            $query_p1 .= " AND FALSE";
                            $query_p2 .= " AND FALSE";
                            $query_count .= " AND FALSE";
                        }
                        break;
                    default:
                        // Dans le doute
                        $query_p1 .= " AND FALSE";
                        $query_p2 .= " AND FALSE";
                        $query_count .= " AND FALSE";
                }
            } else {
                if (!$is_admin) {
                    if (is_logged()) {
                        $query_p1 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                        $query_p2 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                        $query_count .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))))=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                    } else {
                        $query_p1 .= " AND T.is_valid=1";
                        $query_p2 .= " AND T.is_valid=1";
                        $query_count .= " AND T.is_valid=1";
                    }
                }
            }
            // Filtrage éventuel selon la catégorie
            if (isset($_SESSION["thread_category_filter"]) && $_SESSION["thread_category_filter"] > 0) {
                $category_searched = mysql_real_escape_string($_SESSION["thread_category_filter"]);
                $query_p1 .= " AND T.category={$category_searched}";
                $query_p2 .= " AND T.category={$category_searched}";
                $query_count .= " AND T.category={$category_searched}";
            }
            // Regroupement propositions avec/sans votes
            $query = $query_p1 . ' GROUP BY T.thread_id, T.rand_prop, T.hash_prop, T.title, T.text, T.date, T.is_valid, T.possibly_name, G.category_name) UNION ' . $query_p2 . ')';
            // Détermination du nombre résultats potentiellement retournés, pour connaître la répartition par pages
            $num_res = -1;
            // Valeur par défaut en cas d'échec
            $res = @mysql_query($query_count);
            if ($res) {
                if ($num_res = mysql_fetch_assoc($res)) {
                    $num_res = $num_res["NUM_RES"];
                }
                @mysql_free_result($res);
            }
            // Suite de la construction de la requête, GROUP et ORDER BY
            if (isset($_SESSION["thread_ordering"])) {
                switch ($_SESSION["thread_ordering"]) {
                    case 2:
                        $query .= " ORDER BY pro_vote DESC";
                        break;
                    case 3:
                        $query .= " ORDER BY pro_vote/total_vote DESC";
                        break;
                    case 4:
                        $query .= " ORDER BY total_vote DESC";
                        break;
                    default:
                        $query .= " ORDER BY date DESC";
                        break;
                }
            } else {
                $query .= " ORDER BY date DESC";
            }
            // Fin de la construction de la requête, LIMIT selon la page affichée
            $page_to_display = 1;
            if (!isset($_SESSION["thread_page"])) {
                $_SESSION["thread_page"] = 1;
            } else {
                $page_to_display = $_SESSION["thread_page"];
                if (!is_numeric($page_to_display) || $page_to_display < 1) {
                    $_SESSION["thread_page"] = 1;
                    $page_to_display = 1;
                }
            }
            if ($num_res > -1) {
                $offset = round(10 * ($page_to_display - 1));
                if ($offset >= $num_res) {
                    $offset = 0;
                    $_SESSION["thread_page"] = 1;
                }
                $query .= " LIMIT {$offset},10";
            }
            // ********************************************************************* //
            // Menu de changement de page, sauvegardé pour affichage en base de page //
            // ********************************************************************* //
            $change_page = "";
            if ($num_res > 10) {
                $change_page .= '<div class="bottom_page_choice">';
                for ($i = 1; $i < ceil($num_res / 10) + 1; $i++) {
                    if ($i == $_SESSION["thread_page"]) {
                        $change_page .= "{$i}&nbsp;&nbsp;";
                    } else {
                        $change_page .= '<a href="?action=change_thread_page&amp;num_page=' . $i . '">' . $i . '</a>&nbsp;&nbsp;';
                    }
                }
                $change_page .= '</div><br/>';
                echo $change_page;
            } else {
                echo '<br />';
            }
            ////////////////////////////////////////////////////////
            // Exécution de la requête et affichage des résultats //
            ////////////////////////////////////////////////////////
            $result = @mysql_query($query);
            if ($result) {
                $result_returned = false;
                $need_separator = false;
                while ($row = mysql_fetch_assoc($result)) {
                    // Informations diverses sur le post
                    $result_returned = true;
                    $thread_id = $row["thread_id"];
                    $thread_id_affiche = htmlentities($thread_id);
                    $is_proprio = check_property($row["rand_prop"], $row["hash_prop"]);
                    $is_valid = $row["is_valid"];
                    $already_mod = $row["already_mod"];
                    $check_vote = get_votes_from_thread($thread_id);
                    $pro_vote = $check_vote["pro_votes"];
                    $agt_vote = $check_vote["against_votes"];
                    $per_vote = $check_vote["choice"];
                    // Hormis l'auteur ou un administrateur, affichage uniquement si le post a été modéré
                    if ($is_valid || $is_proprio || $privileges > 3) {
                        if ($need_separator) {
                            echo '<div class="newsterminator">
									<hr />
								</div>';
                        }
                        $need_separator = true;
                        // Titre et état de modération
                        echo '<span class="newstitle" id="' . $thread_id_affiche . '">
								' . htmlentities(stripslashes($row["title"])) . ' [#' . $thread_id_affiche . ']
							</span>';
                        if ($privileges > 3) {
                            if ($already_mod) {
                                if ($is_valid) {
                                    echo '<img src="rep_img/modere.png" alt="Mod&eacute;r&eacute;" class="imgtitlenews" />';
                                } else {
                                    echo '<img src="rep_img/masque.png" alt="Masqu&eacute;" class="imgtitlenews" />';
                                }
                            } else {
                                echo '<img src="rep_img/n_modere.png" alt="Non mod&eacute;r&eacute;" class="imgtitlenews" />';
                            }
                        } elseif ($is_proprio) {
                            if ($already_mod) {
                                if (!$is_valid) {
                                    echo '<img src="rep_img/masque.png" alt="Masqu&eacute;" class="imgtitlenews" />';
                                }
                            } else {
                                echo '<img src="rep_img/n_modere.png" alt="Non mod&eacute;r&eacute;" class="imgtitlenews" />';
                            }
                        }
                        // Votes
                        if ($privileges >= 2) {
                            echo '<span class="vote">';
                            if ($per_vote > 0) {
                                echo '<a href="?action=vote_post&amp;order=0&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '"><img src="rep_img/bright_votepro.png" alt="+1" class="imgvote" /></a>';
                            } else {
                                if ($vote_filt) {
                                    echo '<a href="?action=vote_post&amp;order=1&amp;thread_id=' . $thread_id_affiche . '"><img src="rep_img/pale_votepro.png" alt="+1" class="imgvote" /></a>';
                                } else {
                                    echo '<a href="?action=vote_post&amp;order=1&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '"><img src="rep_img/pale_votepro.png" alt="+1" class="imgvote" /></a>';
                                }
                            }
                            if ($per_vote < 0) {
                                echo '<a href="?action=vote_post&amp;order=0&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '"><img src="rep_img/bright_voteneg.png" alt="-1" class="imgvote" /></a>';
                            } else {
                                if ($vote_filt) {
                                    echo '<a href="?action=vote_post&amp;order=-1&amp;thread_id=' . $thread_id_affiche . '"><img src="rep_img/pale_voteneg.png" alt="-1" class="imgvote" /></a>';
                                } else {
                                    echo '<a href="?action=vote_post&amp;order=-1&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '"><img src="rep_img/pale_voteneg.png" alt="-1" class="imgvote" /></a>';
                                }
                            }
                            echo '</span>';
                        }
                        // Contexte
                        echo '<div class="newsundertitle">
								' . htmlentities(transfo_date($row["date"])) . '&nbsp;-&nbsp;' . htmlentities($row["category_name"]);
                        if (!empty($row["possibly_name"])) {
                            echo '&nbsp;-&nbsp;' . htmlentities($row["possibly_name"]);
                        }
                        echo '</div>
						<div class="votebar">';
                        // Etat des votes
                        if ($pro_vote == 0) {
                            if ($agt_vote == 0) {
                                echo '<span class="neutralvote">
										<span class="votebarannotation">
											+0
										</span>
									</span>
								</div>';
                            } else {
                                echo '<span class="againstvote" style="height:100%;width:8px;">
										<span class="votebarannotation">
											-' . htmlentities($agt_vote) . '
										</span>
									</span>
								</div>';
                            }
                        } else {
                            if ($agt_vote == 0) {
                                echo '<span class="provote" style="height:100%;width:8px;">
										<span class="votebarannotation_pro">
											+' . htmlentities($pro_vote) . '
										</span>
									</span>
								</div>';
                            } else {
                                $prop_pro = round(100 * $pro_vote / ($agt_vote + $pro_vote));
                                echo '<span class="provote" style="height:' . $prop_pro . '%;width:8px;">
										<span class="votebarannotation_pro">
											+' . htmlentities($pro_vote) . '
										</span>
									</span>
									<span class="againstvote" style="height:' . (100 - $prop_pro) . '%;width:8px;">
										<span class="votebarannotation">
											-' . htmlentities($agt_vote) . '
										</span>
									</span>
								</div>';
                            }
                        }
                        // Corps
                        echo '<div class="newscontent">' . text_display_prepare($row["text"]) . '</div>';
                        echo '<div class="newsendlinks">';
                        if ($is_proprio || $privileges > 4) {
                            echo '
								<a href="?action=edit_post&amp;thread_id=' . $thread_id_affiche . '">Editer</a>
								<a href="?action=remove_post&amp;thread_id=' . $thread_id_affiche . '">Supprimer</a>';
                            if ($is_proprio) {
                                if (!empty($row["possibly_name"])) {
                                    echo '<a href="?action=anonymization&amp;order=0&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '">Masquer mon nom</a>';
                                } else {
                                    echo '<a href="?action=anonymization&amp;order=1&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '">Afficher mon nom</a>';
                                }
                            }
                        }
                        if ($is_admin) {
                            if ($is_valid || !$already_mod) {
                                if ($current_mod) {
                                    echo '<a href="?action=moderation&amp;order=0&amp;thread_id=' . $thread_id_affiche . '">Refuser</a>';
                                } else {
                                    echo '<a href="?action=moderation&amp;order=0&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '">Refuser</a>';
                                }
                            }
                            if (!$is_valid || !$already_mod) {
                                if ($current_mod) {
                                    echo '<a href="?action=moderation&amp;order=1&amp;thread_id=' . $thread_id_affiche . '">Accepter</a>';
                                } else {
                                    echo '<a href="?action=moderation&amp;order=1&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '">Accepter</a>';
                                }
                            }
                        }
                        // Affichage des commentaires - ferme le div newsendlinks
                        affichage_comments($thread_id, false);
                    }
                }
                // Affichage vide / d'un cadre de choix de page / d'un avertissement sur le nombre de résultats / selon les cas
                if ($result_returned) {
                    echo $change_page . '<div class="newsterminator"><hr />' . NOM_ECOLE . ' </div>';
                } else {
                    echo '<div class="warning">Aucune proposition n\'est disponible selon les critères choisis</div>';
                }
                @mysql_free_result($result);
            } else {
                echo '<div class="warning">Erreur lors de la requ&ecirc;te</div>';
            }
        }
    } else {
        need_ecole_member_privilege(2);
    }
}
Пример #2
0
function display_documents()
{
    $rights = user_privilege_level();
    if ($rights > 0) {
        echo '<h1>Documentation :</h1>';
        if (is_logged() || isset($_SESSION['confirmation_agreement']) && $_SESSION['confirmation_agreement'] == "ok") {
            if (isset($_SESSION['transient_display'])) {
                echo $_SESSION['transient_display'];
                unset($_SESSION['transient_display']);
            }
            // Formulaire de tri/filtrage des documents
            echo '<div class="enlarge_lowresol"><form method="post" action="?action=docs_filter_change">
			<table class="tab_form_close">
			<tr>
				<td>
					Cat&eacute;gorie :
				</td>
				<td>
					<select name="category_filter">';
            $tail = "<option value=\"0\">Toutes</option>";
            $result = @mysql_query("SELECT category_id,category_name FROM document_category");
            if ($result) {
                while ($row = @mysql_fetch_assoc($result)) {
                    // Autant se prémunir contre une corruption des données en base, ça ne coûte rien (sauf du CPU ^^)
                    if (isset($_SESSION["document_category_filter"]) && $row["category_id"] == $_SESSION["document_category_filter"]) {
                        $tail .= '<option value="' . htmlentities($row["category_id"]) . '" selected="selected">' . htmlentities($row["category_name"]) . '</option>';
                    } else {
                        $tail .= '<option value="' . htmlentities($row["category_id"]) . '">' . htmlentities($row["category_name"]) . '</option>';
                    }
                }
                @mysql_free_result($result);
            }
            echo $tail . '</select></td>
					<td>
						Rechercher :
					</td>
					<td>';
            if (isset($_SESSION["document_search"]) && !empty($_SESSION["document_search"])) {
                echo '<input type="text" name="docsearch" value="' . htmlentities($_SESSION["document_search"]) . '" />';
            } else {
                echo '<input type="text" name="docsearch" />';
            }
            echo '</td>
					<td>
						Trier par :
					</td>
					<td>
						<select name="sorting">';
            $tail = "";
            if (isset($_SESSION["documents_ordering"])) {
                $thread_ordering = $_SESSION["documents_ordering"];
                if ($thread_ordering == 1) {
                    $tail = "<option value=\"1\" selected=\"selected\">Date</option><option value=\"2\">Pertinence</option>";
                } elseif ($thread_ordering == 2) {
                    $tail = "<option value=\"1\">Date</option><option value=\"2\" selected=\"selected\">Pertinence</option>";
                }
            } else {
                $tail = "<option value=\"1\">Date</option><option value=\"2\">Pertinence</option>";
            }
            echo $tail . '</select></td>
				<td><input type="hidden" name="form_name" value="document_display_param" /></td>
				<td><input type="submit" value="Valider" /></td>
				</tr>
			</table></form></div>';
            // Construction de la recherche
            $need_to_search = false;
            $string_search = "";
            if (isset($_SESSION["document_search"]) && !empty($_SESSION["document_search"])) {
                $need_to_search = true;
                $string_search = mysql_real_escape_string($_SESSION["document_search"]);
                $query = "SELECT D.document_id, D.name, D.description, D.filedate, C.category_name, MATCH(D.description) AGAINST ('{$string_search}' IN BOOLEAN MODE) AS score\n\t\t\t\t\tFROM document D, document_category C\n\t\t\t\t\tWHERE D.category=C.category_id";
                $query_count = "SELECT COUNT(*) AS NUM_RES\n\t\t\t\t\tFROM document\n\t\t\t\t\tWHERE MATCH(description) AGAINST ('{$string_search}')";
            } else {
                $query = "SELECT D.document_id,D.name,D.description,D.filedate,C.category_name FROM document D, document_category C\n\t\t\t\t\tWHERE D.category=C.category_id";
                $query_count = "SELECT COUNT(*) AS NUM_RES FROM document";
            }
            if (isset($_SESSION["document_category_filter"]) && $_SESSION["document_category_filter"] > 0) {
                $id_categ = mysql_real_escape_string($_SESSION["document_category_filter"]);
                $query .= " AND C.category_id={$id_categ}";
                if ($need_to_search) {
                    $query_count .= " AND category={$id_categ}";
                } else {
                    $query_count .= " WHERE category={$id_categ}";
                }
            }
            $res = @mysql_query($query_count);
            $num_res = -1;
            if ($res && ($num_res = @mysql_fetch_assoc($res))) {
                $num_res = $num_res["NUM_RES"];
                @mysql_free_result($res);
            }
            $mandatory_post_tri = false;
            if ($need_to_search) {
                $query .= " AND MATCH(D.description) AGAINST ('{$string_search}' IN BOOLEAN MODE)";
            }
            if ($need_to_search && $_SESSION["documents_ordering"] == 2) {
                $query .= " ORDER BY score DESC";
            } else {
                $query .= " ORDER BY filedate DESC";
            }
            if ($num_res > -1) {
                if (!isset($_SESSION["document_page"]) || !is_numeric($_SESSION["document_page"])) {
                    $_SESSION["document_page"] = 1;
                }
                if (!($_SESSION["document_page"] > 0)) {
                    $_SESSION["document_page"] = 1;
                }
                $offset = round(10 * ($_SESSION["document_page"] - 1));
                if ($offset >= $num_res) {
                    $offset = 0;
                    $_SESSION["document_page"] = 1;
                }
                $query .= " LIMIT {$offset},10";
            } else {
                $_SESSION["document_page"] = 1;
            }
            $change_page = "";
            if ($num_res > 10) {
                $change_page .= '<div class="bottom_page_choice">';
                for ($i = 1; $i < ceil($num_res / 10) + 1; $i++) {
                    if ($i == $_SESSION["document_page"]) {
                        $change_page .= "{$i}&nbsp;&nbsp;";
                    } else {
                        $change_page .= '<a href="?action=change_document_page&amp;num_page=' . $i . '">' . $i . '</a>&nbsp;&nbsp;';
                    }
                }
                $change_page .= '</div><br/>';
                echo $change_page;
            } else {
                echo '<br />';
            }
            $result = @mysql_query($query);
            //	Exécution de la requête de recherche des documents proprement dite
            if ($result) {
                $compteur = 0;
                while ($row = mysql_fetch_assoc($result)) {
                    if ($compteur > 0) {
                        echo '<div class="newsterminator">
								<hr />
						</div>';
                    }
                    $doc_id = htmlentities($row["document_id"]);
                    $name = htmlentities(stripslashes($row["name"]));
                    $description = nl2br(htmlentities(stripslashes($row["description"])));
                    $date = htmlentities(transfo_date($row["filedate"]));
                    $category = htmlentities($row["category_name"]);
                    echo '
					<div class="newstitle">
						<a href="pdf_display.php?document_id=' . $doc_id . '" target="_blank">' . $name . ' [#' . $doc_id . ']' . '</a>
					</div>
					<div class="newsundertitle">
						' . $date . '&nbsp;-&nbsp;' . $category . '
					</div>
					<div class="newscontent">
						' . transfo_url($description) . '
					</div>';
                    if ($rights > 3) {
                        echo '<div class="newsendlinks">
							<a href="?action=edit_doc&amp;document_id=' . $doc_id . '">Editer</a>
							<a href="?action=remove_doc&amp;document_id=' . $doc_id . '">Supprimer</a>
						</div>';
                    }
                    $compteur++;
                }
                if ($compteur == 0) {
                    echo '<div class="warning">Aucun document correspondant aux crit&egrave;res fix&eacute;s n\'est disponible pour le moment</div>';
                } else {
                    echo $change_page . '<div class="newsterminator"><hr />' . NOM_ECOLE . '</div>';
                }
                @mysql_free_result($result);
            } else {
                echo '<div class="warning">Erreur lors du chargement</div>';
            }
        } else {
            echo '<div class="warning">Il est n&eacute;cessaire d\'approuver au pr&eacute;alable les <a href="index.php?action=display_useterms&amp;allow_direct_accept=true">conditions d\'utilisation</a></div>';
        }
    } else {
        need_ecole_member_privilege(1);
    }
}
Пример #3
0
function display_post()
{
    $privileges = user_privilege_level();
    if ($privileges > 1) {
        // Titre et messages éventuels
        if (isset($_SESSION['transient_display'])) {
            echo $_SESSION['transient_display'];
            unset($_SESSION['transient_display']);
        }
        // ******************************************************************* //
        // Formulaire pour gérer le filtrage/l'ordonnancement des propositions //
        // ******************************************************************* //
        // Menu de sélection des idées
        $tail = '<form class="row" method="post" action="?action=post_filter_change">
			<div class="tab_form_close">
					';
        // Champ de recherche
        $tail .= '<input class="span2" placeholder="' . _('Search...') . '"…" type="text" name="admin_recherche" value="' . $_SESSION["thread_admin_recherche"] . '">';
        // Choix de catégorie
        $tail .= '<select class="span2" name="category_filter">
				<option value="0">' . _('Cat&eacute;gories') . '</option>';
        $result = @mysql_query("SELECT category_id,category_name FROM thread_category");
        // Menu déroulant de choix de catégorie en fonction de ce qui est disponible en base
        if ($result) {
            while ($row = mysql_fetch_assoc($result)) {
                if (isset($_SESSION["thread_category_filter"]) && $row["category_id"] == $_SESSION["thread_category_filter"]) {
                    $tail .= '<option value="' . htmlentities($row["category_id"]) . '" selected="selected">' . htmlentities($row["category_name"]) . '</option>';
                } else {
                    $tail .= '<option value="' . htmlentities($row["category_id"]) . '">' . htmlentities($row["category_name"]) . '</option>';
                }
            }
            @mysql_free_result($result);
        }
        $tail .= '</select>';
        // Menu de filtrage pour les utilisateurs loggés
        if (is_logged()) {
            $tail .= '<select class="span2" name="admin_filter">
					<option value="0">' . _('No filter') . '</option>';
            if ($privileges > 3) {
                if (isset($_SESSION["thread_admin_filter"])) {
                    switch ($_SESSION["thread_admin_filter"]) {
                        case 1:
                            $tail .= '<option value="1" selected="selected">' . _('My posts') . '</option><option value="2">' . _('Posts with my comments') . '</option><option value="3">Propositions sans mon vote</option> 
								<option value="4">' . _('Not moderated posts') . '</option><option value="5">' . _('Not moderated comments') . '</option>';
                            break;
                        case 2:
                            $tail .= '<option value="1">Mes propositions</option><option value="2" selected="selected">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option> 
								<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                            break;
                        case 3:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3" selected="selected">Propositions sans mon vote</option> 
								<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                            break;
                        case 4:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option> 
								<option value="4" selected="selected">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                            break;
                        case 5:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option> 
								<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5" selected="selected">Commentaires non mod&eacute;r&eacute;s</option>';
                            break;
                        default:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option> 
								<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                    }
                } else {
                    $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option> 
						<option value="4">Propositions non mod&eacute;r&eacute;es</option><option value="5">Commentaires non mod&eacute;r&eacute;s</option>';
                }
            } else {
                if (isset($_SESSION["thread_admin_filter"])) {
                    switch ($_SESSION["thread_admin_filter"]) {
                        case 1:
                            $tail .= '<option value="1" selected="selected">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>';
                            break;
                        case 2:
                            $tail .= '<option value="1">Mes propositions</option><option value="2" selected="selected">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>';
                            break;
                        case 3:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3" selected="selected">Propositions sans mon vote</option>';
                            break;
                        default:
                            $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>';
                    }
                } else {
                    $tail .= '<option value="1">Mes propositions</option><option value="2">Propositions avec mes commentaires</option><option value="3">Propositions sans mon vote</option>';
                }
            }
            $tail .= '</select></td>';
        }
        // Menu pour le tri des résultats
        if (isset($_SESSION["thread_ordering"])) {
            if (isset($_SESSION["thread_admin_filter"]) && $_SESSION["thread_admin_filter"] == 5) {
                $tail .= _('Sort by') . '
					<select name="sorting" class="span2" disabled="disabled">
								<option value="1" selected="selected">Date</option><option value="2">Upvotes number</option><option value="3">Upvotes ratio</option><option value="4">' . _('Votes total') . '</option>"';
            } else {
                $tail .= _('Sort by') . '
							<select class="span2" name="sorting">';
                switch ($_SESSION["thread_ordering"]) {
                    case 1:
                        $tail .= "<option value=\"1\" selected=\"selected\">Date</option><option value=\"2\">Upvotes number</option><option value=\"3\">Upvotes ratio</option><option value=\"4\">" . _('Votes total') . "</option>";
                        break;
                    case 2:
                        $tail .= "<option value=\"1\">Date</option><option value=\"2\" selected=\"selected\">Upvotes number</option><option value=\"3\">Upvotes ratio</option><option value=\"4\">" . _('Votes total') . "</option>";
                        break;
                    case 3:
                        $tail .= "<option value=\"1\">Date</option><option value=\"2\">Upvotes number</option><option value=\"3\" selected=\"selected\">Upvotes ratio</option><option value=\"4\">" . _('Votes total') . "</option>";
                        break;
                    case 4:
                        $tail .= "<option value=\"1\">Date</option><option value=\"2\">Upvotes number</option><option value=\"3\">Upvotes ratio</option><option value=\"4\" selected=\"selected\">" . _('Votes total') . "</option>";
                        break;
                    default:
                        $tail .= "<option value=\"1\">Date</option><option value=\"2\">Upvotes number</option><option value=\"3\">Upvotes ratio</option><option value=\"4\">" . _('Votes total') . "</option>";
                }
            }
        } else {
            if (isset($_SESSION["thread_admin_filter"]) && $_SESSION["thread_admin_filter"] == 4) {
                $tail .= _('Sort by') . '
							<select  class="span2" name="sorting" disabled="disabled">
								<option value="1">Date</option><option value="2">Upvotes number</option><option value="3">Upvotes ratio</option><option value="4">' . _('Votes total') . '</option>"';
            } else {
                $tail .= _('Sort by') . '
							<select  class="span2" name="sorting">
								<option value="1">Date</option><option value="2">Upvotes number</option><option value="3">Upvotes ratio</option><option value="4">' . _('Votes total') . '</option>';
            }
        }
        echo $tail . '			
				</select>
				<input type="hidden" name="form_name" value="thread_display_param" />
				<input type="submit" value="Valider" />
			</div>
		</form>';
        $is_admin = $privileges > 3;
        // ****************************************************************************** //
        // Affichage des résultats selon les paramètres définis dans les menus précédents //
        // ****************************************************************************** //
        if (isset($_SESSION["thread_admin_filter"]) && $_SESSION["thread_admin_filter"] == 5) {
            affichage_comments(-1, true);
            // Affichage "brutal" des commentaires confié à une autre fonction
        } else {
            $current_mod = isset($_SESSION["thread_admin_filter"]) && $_SESSION["thread_admin_filter"] == 4;
            // Mode modération
            $vote_filt = isset($_SESSION["thread_admin_filter"]) && $_SESSION["thread_admin_filter"] == 3;
            // Filtrage selon les votes
            // ************************************************************ //
            // Construction de la requête de rappatriement des propositions //
            // ************************************************************ //
            $recherche = "(T.text LIKE '%" . mysql_real_escape_string($_SESSION['thread_admin_recherche']) . "%' OR T.title LIKE '%" . mysql_real_escape_string($_SESSION['thread_admin_recherche']) . "%') AND";
            // Requête de base (deux parties pour prendre en comptes les propositions sans votes)
            $query_p1 = "(SELECT T.thread_id, T.rand_prop, T.hash_prop, T.title, T.text, T.date, T.is_valid, T.possibly_name, T.already_mod, G.category_name,\n\t\t\t\t\tSUM(V.vote) AS pro_vote, COUNT(V.vote) AS total_vote\n\t\t\t\t\tFROM thread T, thread_category G, vote V\n\t\t\t\t\tWHERE " . $recherche . " V.thread_id=T.thread_id AND G.category_id=T.category";
            $query_p2 = "(SELECT T.thread_id, T.rand_prop, T.hash_prop, T.title, T.text, T.date, T.is_valid, T.possibly_name, T.already_mod, G.category_name,\n\t\t\t\t\t0 AS pro_vote, 0 AS total_vote\n\t\t\t\t\tFROM thread T, thread_category G \n\t\t\t\t\tWHERE " . $recherche . " T.thread_id <> ALL (SELECT thread_id FROM vote) AND G.category_id=T.category";
            $query_count = "SELECT COUNT(T.thread_id) AS NUM_RES FROM thread T, thread_category G WHERE G.category_id=T.category";
            // Requête à part pour déterminer préalablement le nombre de résultats
            if (isset($_SESSION["thread_admin_filter"])) {
                switch ($_SESSION["thread_admin_filter"]) {
                    case 0:
                        // Aucune contrainte si ce n'est une question de droits d'affichage
                        if (is_logged()) {
                            if (!$is_admin) {
                                $query_p1 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_p2 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_count .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))))=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            }
                        } else {
                            $query_p1 .= " AND FALSE";
                            $query_p2 .= " AND FALSE";
                            $query_count .= " AND FALSE";
                        }
                        break;
                    case 1:
                        // Posts propriétaires
                        if (is_logged()) {
                            $query_p1 .= sprintf(" AND (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop)", mysql_real_escape_string($_SESSION['login_c']));
                            $query_p2 .= sprintf(" AND (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop)", mysql_real_escape_string($_SESSION['login_c']));
                            $query_count .= sprintf(" AND (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))))=T.hash_prop)", mysql_real_escape_string($_SESSION['login_c']));
                        } else {
                            $query_p1 .= " AND FALSE";
                            $query_p2 .= " AND FALSE";
                            $query_count .= " AND FALSE";
                        }
                        break;
                    case 2:
                        // Posts commentés
                        if (is_logged()) {
                            $query_p1 .= sprintf(" AND T.thread_id IN (SELECT DISTINCT thread_id FROM comment WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            $query_p2 .= sprintf(" AND T.thread_id IN (SELECT DISTINCT thread_id FROM comment WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            $query_count .= sprintf(" AND T.thread_id IN (SELECT DISTINCT thread_id FROM comment WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            if (!$is_admin) {
                                $query_p1 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_p2 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_count .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))))=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            }
                        } else {
                            $query_p1 .= " AND FALSE";
                            $query_p2 .= " AND FALSE";
                            $query_count .= " AND FALSE";
                        }
                        break;
                    case 3:
                        // Posts pour lesquels je n'ai pas voté
                        if (is_logged()) {
                            $query_p1 .= sprintf(" AND T.thread_id NOT IN (SELECT DISTINCT thread_id FROM vote WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            $query_p2 .= sprintf(" AND T.thread_id NOT IN (SELECT DISTINCT thread_id FROM vote WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            $query_count .= sprintf(" AND T.thread_id NOT IN (SELECT DISTINCT thread_id FROM vote WHERE (CAST(SHA1(CONCAT('%s',CAST(rand_prop AS CHAR))) AS CHAR)=hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            if (!$is_admin) {
                                $query_p1 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_p2 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                                $query_count .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))))=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                            }
                        } else {
                            $query_p1 .= " AND FALSE";
                            $query_p2 .= " AND FALSE";
                            $query_count .= " AND FALSE";
                        }
                        break;
                    case 4:
                        // Propositions non modérées
                        if ($is_admin) {
                            $query_p1 .= " AND T.already_mod=0";
                            $query_p2 .= " AND T.already_mod=0";
                            $query_count .= " AND T.already_mod=0";
                        } else {
                            $query_p1 .= " AND FALSE";
                            $query_p2 .= " AND FALSE";
                            $query_count .= " AND FALSE";
                        }
                        break;
                    default:
                        // Dans le doute
                        $query_p1 .= " AND FALSE";
                        $query_p2 .= " AND FALSE";
                        $query_count .= " AND FALSE";
                }
            } else {
                if (!$is_admin) {
                    if (is_logged()) {
                        $query_p1 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                        $query_p2 .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))) AS CHAR)=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                        $query_count .= sprintf(" AND (T.is_valid=1 OR (CAST(SHA1(CONCAT('%s',CAST(T.rand_prop AS CHAR))))=T.hash_prop))", mysql_real_escape_string($_SESSION['login_c']));
                    } else {
                        $query_p1 .= " AND T.is_valid=1";
                        $query_p2 .= " AND T.is_valid=1";
                        $query_count .= " AND T.is_valid=1";
                    }
                }
            }
            // Filtrage éventuel selon la catégorie
            if (isset($_SESSION["thread_category_filter"]) && $_SESSION["thread_category_filter"] > 0) {
                $category_searched = mysql_real_escape_string($_SESSION["thread_category_filter"]);
                $query_p1 .= " AND T.category={$category_searched}";
                $query_p2 .= " AND T.category={$category_searched}";
                $query_count .= " AND T.category={$category_searched}";
            }
            // Regroupement propositions avec/sans votes
            $query = $query_p1 . ' GROUP BY T.thread_id, T.rand_prop, T.hash_prop, T.title, T.text, T.date, T.is_valid, T.possibly_name, G.category_name) UNION ' . $query_p2 . ')';
            // Détermination du nombre résultats potentiellement retournés, pour connaître la répartition par pages
            $num_res = -1;
            // Valeur par défaut en cas d'échec
            $res = @mysql_query($query_count);
            if ($res) {
                if ($num_res = mysql_fetch_assoc($res)) {
                    $num_res = $num_res["NUM_RES"];
                }
                @mysql_free_result($res);
            }
            // Suite de la construction de la requête, GROUP et ORDER BY
            if (isset($_SESSION["thread_ordering"])) {
                switch ($_SESSION["thread_ordering"]) {
                    case 2:
                        $query .= " ORDER BY pro_vote DESC";
                        break;
                    case 3:
                        $query .= " ORDER BY pro_vote/total_vote DESC";
                        break;
                    case 4:
                        $query .= " ORDER BY total_vote DESC";
                        break;
                    default:
                        $query .= " ORDER BY date DESC";
                        break;
                }
            } else {
                $query .= " ORDER BY date DESC";
            }
            // Fin de la construction de la requête, LIMIT selon la page affichée
            $page_to_display = 1;
            if (!isset($_SESSION["thread_page"])) {
                $_SESSION["thread_page"] = 1;
            } else {
                $page_to_display = $_SESSION["thread_page"];
                if (!is_numeric($page_to_display) || $page_to_display < 1) {
                    $_SESSION["thread_page"] = 1;
                    $page_to_display = 1;
                }
            }
            if ($num_res > -1) {
                $offset = round(10 * ($page_to_display - 1));
                if ($offset >= $num_res) {
                    $offset = 0;
                    $_SESSION["thread_page"] = 1;
                }
                $query .= " LIMIT {$offset},10";
            }
            // ********************************************************************* //
            // Menu de changement de page, sauvegardé pour affichage en base de page //
            // ********************************************************************* //
            $change_page = "";
            if ($num_res > 10) {
                $change_page .= '<div class="bottom_page_choice">';
                for ($i = 1; $i < ceil($num_res / 10) + 1; $i++) {
                    if ($i == $_SESSION["thread_page"]) {
                        $change_page .= "{$i}&nbsp;&nbsp;";
                    } else {
                        $change_page .= '<a href="?action=change_thread_page&amp;num_page=' . $i . '">' . $i . '</a>&nbsp;&nbsp;';
                    }
                }
                $change_page .= '</div><br/>';
                echo $change_page;
            } else {
                echo '<br />';
            }
            ////////////////////////////////////////////////////////
            // Exécution de la requête et affichage des résultats //
            ////////////////////////////////////////////////////////
            $result = @mysql_query($query);
            if ($result) {
                $result_returned = false;
                $need_separator = false;
                while ($row = mysql_fetch_assoc($result)) {
                    // Informations diverses sur le post
                    $result_returned = true;
                    $thread_id = $row["thread_id"];
                    $thread_id_affiche = htmlentities($thread_id);
                    $is_proprio = check_property($row["rand_prop"], $row["hash_prop"]);
                    $is_valid = $row["is_valid"];
                    $already_mod = $row["already_mod"];
                    $check_vote = get_votes_from_thread($thread_id);
                    $pro_vote = $check_vote["pro_votes"];
                    $agt_vote = $check_vote["against_votes"];
                    $per_vote = $check_vote["choice"];
                    // Hormis l'auteur ou un administrateur, affichage uniquement si le post a été modéré
                    if ($is_valid || $is_proprio || $privileges > 3) {
                        if ($need_separator) {
                            echo '<hr />';
                        }
                        $need_separator = true;
                        echo '
						<article class="feed_item row" id="item-' . $thread_id_affiche . '"">
						<div class="span2">
						';
                        // Etat de modération
                        if ($privileges > 3) {
                            if ($already_mod) {
                                if ($is_valid) {
                                    echo '<img src="img/modere.png" alt="Mod&eacute;r&eacute;" class="imgtitlenews" />';
                                } else {
                                    echo '<img src="img/masque.png" alt="Masqu&eacute;" class="imgtitlenews" />';
                                }
                            } else {
                                echo '<img src="img/n_modere.png" alt="Non mod&eacute;r&eacute;" class="imgtitlenews" />';
                            }
                        } elseif ($is_proprio) {
                            if ($already_mod) {
                                if (!$is_valid) {
                                    echo '<img src="img/masque.png" alt="Masqu&eacute;" class="imgtitlenews" />';
                                }
                            } else {
                                echo '<img src="img/n_modere.png" alt="Non mod&eacute;r&eacute;" class="imgtitlenews" />';
                            }
                        }
                        // Catégories avec images
                        echo '
						<img src="img/placeholder_100x100.gif" alt="icon" class="avatar bordered"/>
						';
                        // Votes
                        if ($privileges > 2) {
                            echo '<span class="vote">';
                            if ($per_vote > 0) {
                                echo '<a href="?action=vote_post&amp;order=0&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '"><img src="img/bright_votepro.png" alt="+1" class="imgvote" /></a>';
                            } else {
                                if ($vote_filt) {
                                    echo '<a href="?action=vote_post&amp;order=1&amp;thread_id=' . $thread_id_affiche . '"><img src="img/pale_votepro.png" alt="+1" class="imgvote" /></a>';
                                } else {
                                    echo '<a href="?action=vote_post&amp;order=1&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '"><img src="img/pale_votepro.png" alt="+1" class="imgvote" /></a>';
                                }
                            }
                            if ($per_vote < 0) {
                                echo '<a href="?action=vote_post&amp;order=0&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '"><img src="img/bright_voteneg.png" alt="-1" class="imgvote" /></a>';
                            } else {
                                if ($vote_filt) {
                                    echo '<a href="?action=vote_post&amp;order=-1&amp;thread_id=' . $thread_id_affiche . '"><img src="img/pale_voteneg.png" alt="-1" class="imgvote" /></a>';
                                } else {
                                    echo '<a href="?action=vote_post&amp;order=-1&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '"><img src="img/pale_voteneg.png" alt="-1" class="imgvote" /></a>';
                                }
                            }
                            echo '</span>';
                        }
                        //close-open columns
                        echo '
						    </div>
						    <div class="span6">';
                        //add gravatar
                        echo '
						       <header class="row">
							  <div class="span1">
							     <img src="img/placeholder_50x50.gif" alt="icon" class="avatar bordered"/>
							  </div>
						';
                        //start meta
                        echo '
							 <div class="span5">
							  <p class="meta">
							   <small>
							   Posted by :
						';
                        // name + link to profile
                        if (!empty($row["possibly_name"])) {
                            echo '<a href="#">' . htmlentities($row["possibly_name"]) . '</a>';
                        }
                        // tags
                        echo '
							with tags : <a href="#">' . htmlentities($row["category_name"]) . '</a>';
                        //close meta
                        echo '
						</small>
						  </p>';
                        // Titre
                        echo '
						<h3>' . htmlentities(stripslashes($row["title"])) . '</h3>';
                        //share sns buttons + close header
                        echo '
						  <section class="sns"><!-- AddThis Button BEGIN -->
							<div class="addthis_toolbox addthis_default_style ">
							<a class="addthis_button_preferred_1"></a>
							<a class="addthis_button_preferred_2"></a>
							<a class="addthis_button_preferred_3"></a>
							</div>
							<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f3e39a4223675c7"></script>
						  </section><!-- AddThis Button END -->
						</div><!--span5 -->
					       </header>
					       ';
                        /*
                        echo('
                        <div class="votebar">');
                        
                        // Etat des votes
                        if ($pro_vote==0)
                        {
                        	if($agt_vote==0)
                        	{
                        		echo('<span class="neutralvote">
                        				<span class="votebarannotation">
                        					+0
                        				</span>
                        			</span>
                        		</div>');
                        	}
                        	else
                        	{
                        		echo('<span class="againstvote" style="height:100%;width:8px;">
                        				<span class="votebarannotation">
                        					-'.htmlentities($agt_vote).'
                        				</span>
                        			</span>
                        		</div>');
                        	}
                        }
                        else
                        {
                        	if($agt_vote==0)
                        	{
                        		echo('<span class="provote" style="height:100%;width:8px;">
                        				<span class="votebarannotation_pro">
                        					+'.htmlentities($pro_vote).'
                        				</span>
                        			</span>
                        		</div>');
                        	}
                        	else
                        	{
                        		$prop_pro=round(100*$pro_vote/($agt_vote+$pro_vote));
                        		echo('<span class="provote" style="height:'.$prop_pro.'%;width:8px;">
                        				<span class="votebarannotation_pro">
                        					+'.htmlentities($pro_vote).'
                        				</span>
                        			</span>
                        			<span class="againstvote" style="height:'.(100-$prop_pro).'%;width:8px;">
                        				<span class="votebarannotation">
                        					-'.htmlentities($agt_vote).'
                        				</span>
                        			</span>
                        		</div>');
                        	}
                        }
                        */
                        // Corps du texte
                        echo '<div class="content"><p>' . text_display_prepare($row["text"]) . '</p></div>';
                        // utils
                        echo '<footer class="">';
                        //upvote
                        echo '<a class="" href="?action=vote_post&amp;order=' . '1' . '&amp;thread_id=' . $thread_id_affiche . '">' . _('Upvote') . '<i class="icon-thumbs-up"></i>' . '</a>';
                        echo " - ";
                        // downvote
                        echo '<a class="" href="?action=vote_post&amp;order=' . '-1' . '&amp;thread_id=' . $thread_id_affiche . '">' . _('Downvote') . '<i class="icon-thumbs-down"></i>' . '</a>';
                        echo " - ";
                        // Date
                        echo '<time class="" datetime="' . htmlentities(transfo_date($row["date"])) . '">' . htmlentities(transfo_date($row["date"])) . '</time>';
                        echo " - ";
                        // comments
                        affichage_comments($thread_id, false);
                        // utils delete/edite/anonymize
                        if ($is_proprio || $privileges > 4) {
                            echo ' | 
								<a class="adminutil" href="?action=edit_post&amp;thread_id=' . $thread_id_affiche . '">' . _('Edit') . '</a>
								 - 
								<a class="adminutil" href="?action=remove_post&amp;thread_id=' . $thread_id_affiche . '">' . _('Delete') . '</a>';
                            // hide name
                            if ($is_proprio) {
                                if (!empty($row["possibly_name"])) {
                                    echo ' - <a href="?action=anonymization&amp;order=0&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '">' . _('Hide my name') . '</a>';
                                } else {
                                    echo ' - <a href="?action=anonymization&amp;order=1&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '">' . _('Show my name') . '</a>';
                                }
                            }
                        }
                        if ($is_admin) {
                            if ($is_valid || !$already_mod) {
                                if ($current_mod) {
                                    echo '<a href="?action=moderation&amp;order=0&amp;thread_id=' . $thread_id_affiche . '">Refuser</a>';
                                } else {
                                    echo '<a href="?action=moderation&amp;order=0&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '">Refuser</a>';
                                }
                            }
                            if (!$is_valid || !$already_mod) {
                                if ($current_mod) {
                                    echo '<a href="?action=moderation&amp;order=1&amp;thread_id=' . $thread_id_affiche . '">Accepter</a>';
                                } else {
                                    echo '<a href="?action=moderation&amp;order=1&amp;thread_id=' . $thread_id_affiche . '#' . $thread_id_affiche . '">Accepter</a>';
                                }
                            }
                        }
                        echo '</small></footer>';
                        // COMMENTS
                        echo '<div class="commentbox">
					
					<article class="comment clearfix">
						<header class="span1">
							<img src="img/placeholder_50x50.gif" alt="icon" class="avatar bordered"/>
						</header>
						<div class="com-content span4">
						Lorem Ipsum
						</div>
						<footer>';
                        //upvote
                        echo '<a class="" href="?action=vote_post&amp;order=' . '1' . '&amp;thread_id=' . $thread_id_affiche . '">' . _('Upvote') . '<i class="icon-thumbs-up"></i>' . '</a>';
                        echo " - ";
                        // downvote
                        echo '<a class="" href="?action=vote_post&amp;order=' . '-1' . '&amp;thread_id=' . $thread_id_affiche . '">' . _('Downvote') . '<i class="icon-thumbs-down"></i>' . '</a>';
                        echo " - ";
                        // timestamp
                        echo '<time datetime="2010-12-16T11:15Z">16/12/2010 11:15</time>
						</footer>

					</article>
					
					</div><!-- .commentbox-->
					</article><!-- .feeditem -->';
                    }
                }
                // Affichage vide / d'un cadre de choix de page / d'un avertissement sur le nombre de résultats / selon les cas
                if ($result_returned) {
                    echo $change_page . '<div class="newsterminator"><hr />' . NOM_ECOLE . ' REFRESH</div>';
                } else {
                    echo '<div class="warning">Aucune proposition n\'est disponible selon les critères choisis</div>';
                }
                @mysql_free_result($result);
            } else {
                echo '<div class="warning">Erreur lors de la requ&ecirc;te</div>';
            }
        }
    } else {
        need_ecole_member_privilege(2);
    }
}
Пример #4
0
function display_comment($row, $is_logged, $privileges, $unique_mode)
{
    $is_proprio = check_property($row["rand_prop"], $row["hash_prop"]);
    $is_valid = $row["is_valid"];
    $already_mod = $row["already_mod"];
    $comment_id = $row["comment_id"];
    $ancre = htmlentities($row["comment_id"]);
    $date = $row['date'];
    $possibly_name = $row['possibly_name'];
    $sec_cid = htmlentities($row["comment_id"]);
    $thread_tmp = htmlentities($row["thread_id"]);
    $text = text_display_prepare(trim($row["text"]));
    $my_vote = $row['my_vote'];
    $my_provote = $row['my_provote'];
    $pro_vote = $row['pro_vote'];
    $total_vote = $row['total_vote'];
    $is_admin = $privileges > 3;
    // display context
    echo '<div class="newscomment row" id="' . $ancre . '"><a name="b' . $sec_cid . '" id="b' . $sec_cid . '"></a>';
    // display author name if not anonymized
    if (!empty($possibly_name)) {
        // display user avatar
        echo '
		<div class="span1">
		<img src="img/placeholder_50x50.gif" alt="icon" class="avatar bordered"/>
		</div>';
        // display name
        echo '<a href=#>' . htmlentities($possibly_name) . '</a>';
    } else {
        // display default avatar
        echo '
		<div class="span1">
		<img src="img/placeholder_50x50.gif" alt="icon" class="avatar bordered"/>
		</div>';
        // display name
        echo _('Anonymous');
    }
    if ($is_logged) {
        // take care of the vote buttons
        $pro = 1;
        // vote pro button
        $agt = -1;
        // vote against button
        if ($my_vote > 0) {
            if ($my_provote > 0) {
                $pro = 0;
            } else {
                $agt = 0;
            }
        }
        // if I already voted against I can unvote
        // display votes on comment
        echo '&nbsp;-&nbsp;[
			<a class="ntl" href="?action=vote_comment&amp;order=' . $pro . '&amp;comment_id=' . htmlentities($comment_id) . '#b' . $ancre . '">+' . htmlentities($pro_vote) . '</a>
			/
			<a class="ntl" href="?action=vote_comment&amp;order=' . $agt . '&amp;comment_id=' . htmlentities($comment_id) . '#b' . $ancre . '">-' . htmlentities($total_vote - $pro_vote) . '</a>]</span>';
    } else {
        echo '&nbsp;-&nbsp;[
			+' . htmlentities($pro_vote) . '
			/
			-' . htmlentities($total_vote - $pro_vote) . ']</span>';
    }
    // Etat de modération
    if ($privileges > 3) {
        if ($already_mod) {
            if ($is_valid) {
                echo '<img src="img/modere.png" alt="Mod&eacute;r&eacute;" class="imgtitlecomment" />';
            } else {
                echo '<img src="img/masque.png" alt="Masqu&eacute;" class="imgtitlecomment" />';
            }
        } else {
            echo '<img src="img/n_modere.png" alt="Non mod&eacute;r&eacute;" class="imgtitlecomment" />';
        }
    } elseif ($is_proprio) {
        if ($already_mod) {
            if (!$is_valid) {
                echo '<img src="img/masque.png" alt="Masqu&eacute;" class="imgtitlecomment" />';
            }
        } else {
            echo '<img src="img/n_modere.png" alt="Non mod&eacute;r&eacute;" class="imgtitlecomment" />';
        }
    }
    // Corps du commentaire
    echo '<div class="newscommentcontent">' . $text . '</div>';
    // Comments utils
    echo '<div class="btn-group">';
    // upvote /downvote links
    if ($is_logged) {
        // take care of the vote buttons
        $pro = 1;
        // vote pro button
        $agt = -1;
        // vote against button
        if ($my_vote > 0) {
            if ($my_provote > 0) {
                $pro = 0;
            } else {
                $agt = 0;
            }
        }
        // if I already voted against I can unvote
        // display votes on comment
        echo '	<a class="btn btn-mini" href="?action=vote_comment&amp;order=' . $pro . '&amp;comment_id=' . htmlentities($comment_id) . '#b' . $ancre . '">' . _('Upvote') . '<i class="icon-thumbs-up"></i>' . '</a>
			
		<a class="btn btn-mini" href="?action=vote_comment&amp;order=' . $agt . '&amp;comment_id=' . htmlentities($comment_id) . '#b' . $ancre . '">' . _('Downvote') . '<i class="icon-thumbs-down"></i>' . '</a>';
    } else {
        echo '&nbsp;-&nbsp;[
			+' . htmlentities($my_provote) . '
			/
			-' . htmlentities($total_vote - $my_provote) . ']</span>';
    }
    // Date with permalink
    echo '<a class="btn btn-mini" href="?action=display_post&amp;unique=' . $thread_tmp . '<span class="newsundertitle">' . htmlentities(transfo_date($date)) . '</a></span>';
    // close utils
    echo '</div>';
    // Liens administratifs sur le commentaire
    if ($is_proprio || $is_admin) {
        echo '<div class="newsendlinks">';
        if ($is_proprio || $privileges > 4) {
            echo '<a href="?action=edit_post&amp;comment_id=' . htmlentities($comment_id) . '">Editer</a>
			<a href="?action=remove_post&amp;comment_id=' . htmlentities($comment_id) . '">Supprimer</a>';
            if ($is_proprio) {
                if (!empty($possibly_name)) {
                    echo '<a href="?action=anonymization' . ($unique_mode ? '&amp;unique=' . $ancre : '') . '&amp;order=0&amp;comment_id=' . htmlentities($comment_id) . '#b' . $sec_cid . '">Masquer mon nom</a>';
                } else {
                    echo '<a href="?action=anonymization' . ($unique_mode ? '&amp;unique=' . $ancre : '') . '&amp;order=1&amp;comment_id=' . htmlentities($comment_id) . '#b' . $sec_cid . '">Afficher mon nom</a>';
                }
            }
        }
        if ($is_admin) {
            if ($is_valid || !$already_mod) {
                echo '<a href="?action=moderation' . ($unique_mode ? '&amp;unique=' . $ancre : '') . '&amp;order=0&amp;comment_id=' . htmlentities($comment_id) . '#b' . $sec_cid . '">Refuser</a>';
            }
            if (!$is_valid || !$already_mod) {
                echo '<a href="?action=moderation' . ($unique_mode ? '&amp;unique=' . $ancre : '') . '&amp;order=1&amp;comment_id=' . htmlentities($comment_id) . '#b' . $sec_cid . '">Accepter</a>';
            }
        }
        echo '</div>';
    }
    echo '</div>';
}