function bdd_commentaire($commentaire, $what) { // ENREGISTREMENT D'UN NOUVEAU COMMENTAIRE. if ($what == 'enregistrer-nouveau') { try { $req = $GLOBALS['db_handle']->prepare('INSERT INTO commentaires ( bt_type, bt_id, bt_article_id, bt_content, bt_wiki_content, bt_author, bt_link, bt_webpage, bt_email, bt_subscribe, bt_statut ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'); $req->execute(array('comment', $commentaire['bt_id'], $commentaire['bt_article_id'], $commentaire['bt_content'], $commentaire['bt_wiki_content'], $commentaire['bt_author'], $commentaire['bt_link'], $commentaire['bt_webpage'], $commentaire['bt_email'], $commentaire['bt_subscribe'], $commentaire['bt_statut'])); // remet à jour le nombre de commentaires associés à l’article. $nb_comments_art = liste_elements_count("SELECT count(*) AS nbr FROM commentaires WHERE bt_article_id=? and bt_statut=1", array($commentaire['bt_article_id'])); $req2 = $GLOBALS['db_handle']->prepare('UPDATE articles SET bt_nb_comments=? WHERE bt_id=?'); $req2->execute(array($nb_comments_art, $commentaire['bt_article_id'])); return TRUE; } catch (Exception $e) { return 'Erreur : ' . $e->getMessage(); } } elseif ($what == 'editer-existant') { // ÉDITION D'UN COMMENTAIRE DÉJÀ EXISTANT. (ou activation) try { $req = $GLOBALS['db_handle']->prepare('UPDATE commentaires SET bt_article_id=?, bt_content=?, bt_wiki_content=?, bt_author=?, bt_link=?, bt_webpage=?, bt_email=?, bt_subscribe=?, bt_statut=? WHERE ID=?'); $req->execute(array($commentaire['bt_article_id'], $commentaire['bt_content'], $commentaire['bt_wiki_content'], $commentaire['bt_author'], $commentaire['bt_link'], $commentaire['bt_webpage'], $commentaire['bt_email'], $commentaire['bt_subscribe'], $commentaire['bt_statut'], $commentaire['ID'])); // remet à jour le nombre de commentaires associés à l’article. $nb_comments_art = liste_elements_count("SELECT count(*) AS nbr FROM commentaires WHERE bt_article_id=? and bt_statut=1", array($commentaire['bt_article_id'])); $req2 = $GLOBALS['db_handle']->prepare('UPDATE articles SET bt_nb_comments=? WHERE bt_id=?'); $req2->execute(array($nb_comments_art, $commentaire['bt_article_id'])); return TRUE; } catch (Exception $e) { return 'Erreur : ' . $e->getMessage(); } } elseif ($what == 'supprimer-existant') { try { $req = $GLOBALS['db_handle']->prepare('DELETE FROM commentaires WHERE ID=?'); $req->execute(array($commentaire['ID'])); // remet à jour le nombre de commentaires associés à l’article. $nb_comments_art = liste_elements_count("SELECT count(*) AS nbr FROM commentaires WHERE bt_article_id=? and bt_statut=1", array($commentaire['bt_article_id'])); $req2 = $GLOBALS['db_handle']->prepare('UPDATE articles SET bt_nb_comments=? WHERE bt_id=?'); $req2->execute(array($nb_comments_art, $commentaire['bt_article_id'])); return TRUE; } catch (Exception $e) { return 'Erreur : ' . $e->getMessage(); } } elseif ($what == 'activer-existant') { try { $req = $GLOBALS['db_handle']->prepare('UPDATE commentaires SET bt_statut=ABS(bt_statut-1) WHERE ID=?'); $req->execute(array($commentaire['ID'])); // remet à jour le nombre de commentaires associés à l’article. $nb_comments_art = liste_elements_count("SELECT count(*) AS nbr FROM commentaires WHERE bt_article_id=? and bt_statut=1", array($commentaire['bt_article_id'])); $req2 = $GLOBALS['db_handle']->prepare('UPDATE articles SET bt_nb_comments=? WHERE bt_id=?'); $req2->execute(array($nb_comments_art, $commentaire['bt_article_id'])); return TRUE; } catch (Exception $e) { return 'Erreur : ' . $e->getMessage(); } } }
$query = "SELECT c.*, a.bt_title FROM commentaires c LEFT JOIN articles a ON a.bt_id=c.bt_article_id WHERE c.bt_author=? ORDER BY c.bt_id DESC"; $commentaires = liste_elements($query, array($search), 'commentaires'); } else { $query = "SELECT c.*, a.bt_title FROM commentaires c LEFT JOIN articles a ON a.bt_id=c.bt_article_id ORDER BY c.bt_id DESC LIMIT " . $GLOBALS['max_comm_admin']; $commentaires = liste_elements($query, array(), 'commentaires'); } } elseif (!empty($_GET['q'])) { $query = "SELECT c.*, a.bt_title FROM commentaires c LEFT JOIN articles a ON a.bt_id=c.bt_article_id WHERE c.bt_content LIKE ? ORDER BY c.bt_id DESC"; $commentaires = liste_elements($query, array('%' . htmlspecialchars($_GET['q']) . '%'), 'commentaires'); } else { // no filter, so list'em all $query = "SELECT c.*, a.bt_title FROM commentaires c LEFT JOIN articles a ON a.bt_id=c.bt_article_id ORDER BY c.bt_id DESC LIMIT " . $GLOBALS['max_comm_admin']; // die($query); $commentaires = liste_elements($query, array(), 'commentaires'); } $nb_total_comms = liste_elements_count("SELECT count(*) AS nbr FROM commentaires", array()); $param_makeup['show_links'] = '1'; } function afficher_commentaire($comment, $with_link) { afficher_form_commentaire($comment['bt_article_id'], 'admin', '', $comment); echo '<div class="commentbloc' . (!$comment['bt_statut'] ? ' privatebloc' : '') . '" id="' . article_anchor($comment['bt_id']) . '">' . "\n"; if ($comment['bt_statut'] == '0') { echo '<img class="img_inv_flag" src="style/deny.png" title="' . $GLOBALS['lang']['comment_is_invisible'] . '" alt="icon"/>'; } echo '<span onclick="reply(\'[b]@[' . str_replace('\'', '\\\'', $comment['bt_author']) . '|#' . article_anchor($comment['bt_id']) . '] :[/b] \'); ">@</span> '; echo '<h3 class="titre-commentaire">' . $comment['auteur_lien'] . '</h3>' . "\n"; echo '<p class="email"><a href="mailto:' . $comment['bt_email'] . '">' . $comment['bt_email'] . '</a></p>' . "\n"; echo $comment['bt_content']; echo '<p class="p-edit-button">' . "\n"; echo $GLOBALS['lang']['le'] . ' ' . date_formate($comment['bt_id']) . ', ' . heure_formate($comment['bt_id']);
foreach ($tab as $i => $month) { if (isset($table_months[$month['date']])) { $table_months[$month['date']] = $month['idbydate']; } } } catch (Exception $e) { die('Erreur 86459: ' . $e->getMessage()); } return $table_months; } /* Une recherche a été faite : affiche la recherche */ if (!empty($_GET['q'])) { $q = htmlspecialchars($_GET['q']); $nb_commentaires = liste_elements_count("SELECT count(ID) AS nbr FROM commentaires WHERE bt_content LIKE ?", array('%' . $q . '%')); $nb_articles = liste_elements_count("SELECT count(ID) AS nbr FROM articles WHERE ( bt_content LIKE ? OR bt_title LIKE ? )", array('%' . $q . '%', '%' . $q . '%')); $nb_liens = liste_elements_count("SELECT count(ID) AS nbr FROM links WHERE ( bt_content LIKE ? OR bt_title LIKE ? OR bt_link LIKE ? )", array('%' . $q . '%', '%' . $q . '%', '%' . $q . '%')); $nb_files = sizeof(liste_base_files('recherche', urldecode($_GET['q']), '')); echo '<h2>' . $GLOBALS['lang']['recherche'] . ' "<span style="font-style: italic">' . htmlspecialchars($_GET['q']) . '</span>" :</h2>' . "\n"; echo '<ul id="resultat-recherche">'; echo "\t" . '<li><a href="commentaires.php?q=' . htmlspecialchars($_GET['q']) . '">' . nombre_commentaires($nb_commentaires) . '</a></li>'; echo "\t" . '<li><a href="articles.php?q=' . htmlspecialchars($_GET['q']) . '">' . nombre_articles($nb_articles) . '</a></li>'; echo "\t" . '<li><a href="links.php?q=' . htmlspecialchars($_GET['q']) . '">' . nombre_liens($nb_liens) . '</a></li>'; echo "\t" . '<li><a href="fichiers.php?q=' . htmlspecialchars($_GET['q']) . '">' . nombre_fichiers($nb_files) . '</a></li>'; echo '</ul>'; } else { // print sur chaque div pour les articles. echo '<div id="graphs">' . "\n"; $nothingyet = 0; if (!$total_artic == 0) { echo '<div class="graphique" id="articles"><h3>' . ucfirst($GLOBALS['lang']['label_articles']) . ' :</h3>' . "\n"; $table = scaled_size(get_tableau_date('articles'), 130);
$query = "SELECT * FROM articles WHERE bt_categories LIKE ? OR bt_categories LIKE ? OR bt_categories LIKE ? OR bt_categories LIKE ? ORDER BY bt_date DESC"; $tableau = liste_elements($query, array($search, $search . ',%', '%, ' . $search, '%, ' . $search . ', %'), 'articles'); } else { $query = "SELECT * FROM articles ORDER BY bt_date DESC LIMIT 0, " . $GLOBALS['max_bill_admin']; $tableau = liste_elements($query, array(), 'articles'); } } else { $query = "SELECT * FROM articles ORDER BY bt_date DESC LIMIT 0, " . $GLOBALS['max_bill_admin']; $tableau = liste_elements($query, array(), 'articles'); } afficher_top($GLOBALS['lang']['mesarticles']); echo '<div id="top">' . "\n"; afficher_msg($GLOBALS['lang']['mesarticles']); echo moteur_recherche($GLOBALS['lang']['search_in_articles']); afficher_menu(pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME)); echo '</div>' . "\n"; echo '<div id="axe">' . "\n"; // SUBNAV echo '<div id="subnav">' . "\n"; if (isset($_GET['filtre'])) { afficher_form_filtre('articles', htmlspecialchars($_GET['filtre'])); } else { afficher_form_filtre('articles', ''); } echo '</div>' . "\n"; echo '<div id="page">' . "\n"; echo '<p class="nombre-elem">' . "\n"; echo ucfirst(nombre_articles(count($tableau))) . ' ' . $GLOBALS['lang']['sur'] . ' ' . liste_elements_count("SELECT count(*) AS nbr FROM articles", array()); echo '</p>' . "\n"; afficher_liste_articles($tableau); footer('', $begin);
afficher_menu(pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME)); echo '</div>' . "\n"; echo '<div id="axe">' . "\n"; // SUBNAV echo '<div id="subnav">' . "\n"; // Affichage formulaire filtrage liens if (isset($_GET['filtre'])) { afficher_form_filtre('links', htmlspecialchars($_GET['filtre'])); } else { afficher_form_filtre('links', ''); } echo '</div>' . "\n"; echo '<div id="page">' . "\n"; if ($step == 'edit' and !empty($tableau[0])) { // edit un lien : affiche le lien au dessus du champ d’édit afficher_liens($tableau[0]); echo afficher_form_link($step, $erreurs_form, $tableau[0]); } elseif ($step == 2) { // lien donné dans l’URL echo afficher_form_link($step, $erreurs_form); } else { // aucun lien à ajouter ou éditer : champ nouveau lien + listage des liens en dessus. echo afficher_form_link(1, $erreurs_form); echo "\t" . '<p class="nombre-elem">'; echo "\t\t" . ucfirst(nombre_liens($nb_links_displayed)) . ' ' . $GLOBALS['lang']['sur'] . ' ' . liste_elements_count("SELECT count(*) AS nbr FROM links", array(), 'links') . "\n"; echo "\t" . '</p>' . "\n"; foreach ($tableau as $link) { afficher_liens($link); } } footer('', $begin);