/iGal/admin/index.php
PHP | 9779 lines | 7691 code | 1197 blank | 891 comment | 2156 complexity | fd1afe512abb4dae58fa5536711cd26c MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /********************************************************************
- iGalerie - script de galerie d'images
- Copyright (C) 2006-2007 - http://www.igalerie.org/
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- ********************************************************************/
- error_reporting(E_ALL);
- if (@extension_loaded('zlib')
- && !@ini_get('zlib.output_compression')) {
- @ob_start('ob_gzhandler');
- }
- ignore_user_abort(TRUE);
- if (function_exists('set_time_limit')) {
- @set_time_limit(30);
- }
- // On mémorise l'heure exacte du début du script.
- global $TIME_START;
- $TIME_START = explode(' ', microtime());
- // Debug : requętes SQL.
- global $_MYSQL;
- $_MYSQL = array();
- $_MYSQL['debug'] = 0;
- $_MYSQL['mysql_requetes'] = 0;
- $_MYSQL['nb_requetes'] = 0;
- // Paramčtres de langue.
- setlocale(LC_ALL, 'fr');
- setlocale(LC_ALL, 'fr_FR');
- setlocale(LC_ALL, 'french');
- setlocale(LC_ALL, 'fr_FR.ISO8859-1');
- setlocale(LC_NUMERIC, 'en');
- setlocale(LC_NUMERIC, 'en_US');
- setlocale(LC_NUMERIC, 'english');
- setlocale(LC_NUMERIC, 'en_US.ISO8859-1');
- // On annule la fonction magic_quotes_gpc.
- function strip_magic_quotes(&$valeur) {
- if (is_array($valeur)) {
- array_walk($valeur, 'strip_magic_quotes');
- } else {
- $valeur = stripslashes($valeur);
- }
- }
- if (get_magic_quotes_gpc()) {
- array_walk($_GET, 'strip_magic_quotes');
- array_walk($_POST, 'strip_magic_quotes');
- array_walk($_COOKIE, 'strip_magic_quotes');
- array_walk($_REQUEST, 'strip_magic_quotes');
- }
- // On désactive la fonction magic_quotes_runtime
- if (get_magic_quotes_runtime() &&
- function_exists('set_magic_quotes_runtime')) {
- set_magic_quotes_runtime(0);
- }
- // Chargement de la config.
- if (file_exists(dirname(__FILE__) . '/../config/conf.php')) {
- require_once(dirname(__FILE__) . '/../config/conf.php');
- } else {
- define('GALERIE_INSTALL', 0);
- }
- // La galerie est-elle installée ?
- if (!defined('GALERIE_INSTALL') || !GALERIE_INSTALL) {
- header('Location:../install/');
- exit;
- }
- require_once(dirname(__FILE__) . '/../includes/classes/class.mysql.php');
- require_once(dirname(__FILE__) . '/../includes/classes/class.cookie.php');
- require_once(dirname(__FILE__) . '/../includes/classes/class.outils.php');
- require_once(dirname(__FILE__) . '/../includes/classes/class.files.php');
- // Filtrage des paramčtres GET et REQUEST.
- $gets = array('img', 'alb', 'cat', 'startnum', 'obj', 'sub_obj',
- 'str');
- for ($i = 0; $i < count($gets); $i++) {
- verif_gets($gets[$i], '`^\d{1,12}$`');
- }
- function verif_gets($p, $re) {
- if (isset($_GET[$p]) && !preg_match($re, $_GET[$p])) {
- unset($_GET[$p]);
- }
- if (isset($_REQUEST[$p]) && !preg_match($re, $_REQUEST[$p])) {
- unset($_REQUEST[$p]);
- }
- }
- // Si une section parmis celle existantes est demandée, on la traite...
- if (isset($_REQUEST['section'])) {
- // Création de l'objet "admin", avec initialisation de paramčtres communs.
- $admin = new admin();
- switch ($_REQUEST['section']) {
- case 'ftp' :
- require_once(dirname(__FILE__) . '/../includes/classes/class.upload.php');
- if (isset($_REQUEST['action'])) {
- switch ($_REQUEST['action']) {
- case 'enregistrement' :
- $admin->ftp();
- break;
- }
- }
- break;
- case 'galerie' :
- if (!empty($_FILES)) {
- require_once(dirname(__FILE__) . '/../includes/classes/class.upload.php');
- }
- if (isset($_REQUEST['page'])) {
- switch ($_REQUEST['page']) {
- case 'gestion' :
- $admin->galerie_action();
- $admin->galerie();
- break;
- default :
- header('Location: index.php?section=galerie&page=gestion');
- exit;
- }
- } else {
- header('Location: index.php?section=galerie&page=gestion');
- exit;
- }
- break;
- case 'representant' :
- if (isset($_REQUEST['cat']) && isset($_REQUEST['str'])) {
- $admin->galerie_representant();
- } else {
- header('Location: index.php?section=galerie&page=gestion');
- exit;
- }
- break;
- case 'votes' :
- $admin->display_votes();
- break;
- case 'tags' :
- $admin->display_tags();
- break;
- case 'utilisateurs' :
- if (isset($_REQUEST['page'])) {
- switch ($_REQUEST['page']) {
- case 'general' :
- $admin->users_general();
- break;
- case 'membres' :
- $admin->users_membres_action();
- $admin->users_membres();
- break;
- case 'groupes' :
- $admin->users_groupes();
- break;
- case 'modif_groupe' :
- $admin->users_modif_groupe();
- break;
- case 'modif_user' :
- $admin->users_modif_user();
- break;
- case 'images' :
- $admin->users_images_action();
- $admin->users_images();
- break;
- default :
- header('Location: index.php?section=utilisateurs&page=general');
- exit;
- }
- } else {
- header('Location: index.php?section=utilisateurs&page=general');
- exit;
- }
- break;
- case 'commentaires' :
- if (isset($_REQUEST['page'])) {
- switch ($_REQUEST['page']) {
- case 'display' :
- $admin->comments_action();
- $admin->comments();
- break;
- case 'options' :
- $admin->comments_options();
- break;
- case 'bans' :
- $admin->comments_bans();
- break;
- default :
- header('Location: index.php?section=commentaires&page=display');
- exit;
- }
- } else {
- header('Location: index.php?section=commentaires&page=display');
- exit;
- }
- break;
- case 'options' :
- if (isset($_REQUEST['page'])) {
- switch ($_REQUEST['page']) {
- case 'general' :
- $admin->options_general();
- break;
- case 'images' :
- $admin->options_images();
- break;
- case 'itext_params' :
- $admin->options_itext();
- break;
- case 'infos_exif' :
- $admin->options_exif();
- break;
- case 'infos_iptc' :
- $admin->options_iptc();
- break;
- case 'vignettes' :
- $admin->options_vignettes();
- break;
- case 'textes' :
- $admin->options_textes();
- break;
- case 'fonctions' :
- $admin->options_fonctions();
- break;
- case 'perso' :
- $admin->options_perso();
- break;
- default :
- header('Location: index.php?section=options&page=general');
- exit;
- }
- } else {
- header('Location: index.php?section=options&page=general');
- exit;
- }
- break;
- case 'infos' :
- $admin->infos();
- break;
- case 'outils' :
- if (isset($_REQUEST['page'])) {
- switch ($_REQUEST['page']) {
- case 'images' :
- $admin->outils_images();
- break;
- default :
- header('Location: index.php?section=outils&page=images');
- exit;
- }
- } else {
- header('Location: index.php?section=outils&page=images');
- exit;
- }
- break;
- break;
- case 'config' :
- if (isset($_REQUEST['page'])) {
- switch ($_REQUEST['page']) {
- case 'conf' :
- $admin->config_conf();
- break;
- case 'infos_sys' :
- $admin->config_infosys();
- break;
- default :
- header('Location: index.php?section=config&page=conf');
- exit;
- }
- } else {
- header('Location: index.php?section=config&page=conf');
- exit;
- }
- break;
- default :
- header('Location: index.php?section=galerie&page=gestion');
- exit;
- }
- // Fermeture de la connexion.
- $admin->mysql->fermer();
- // On démmarre la classe de template.
- $tpl = new template($admin->template);
- // On appelle le template.
- require('template/' . $admin->config['admin_template'] . '/index.php');
- // ...sinon on redirige vers la section 'albums'.
- } else {
- header('Location: index.php?section=galerie&page=gestion');
- }
- /*
- * ========== class.admin
- */
- class admin {
- var $config; // Configuration générale de la galerie.
- var $template; // Informations brutes ŕ destination des fonctions de template.
- var $mysql; // Connexion MySQL.
- var $galerie_dir; // Chemin relatif du répertoire des albums;
- /*
- * Constructeur.
- */
- function admin() {
- // Connexion ŕ la base de données.
- $this->mysql = new connexion(MYSQL_SERV, MYSQL_USER, MYSQL_PASS, MYSQL_BASE);
- // Récupération des paramčtres de configuration.
- $mysql_requete = 'SELECT parametre,valeur FROM ' . MYSQL_PREF . 'config';
- $this->config = $this->mysql->select($mysql_requete, 3);
- if (empty($this->config)) {
- die ('La base de données est vide.<br />' . mysql_error());
- }
- // Si l'identifiant de session du cookie est incorrect, on renvoie vers la console de connexion.
- $session = new cookie(0, 'galerie_sessionid', GALERIE_PATH . '/' . basename(dirname(__FILE__)));
- $session_id = $session->lire('session_id');
- $this->config['session_id'] = $session_id;
- if (empty($session_id)) {
- header('Location: connexion.php?t=cookie');
- exit;
- }
- if ($session_id != $this->config['admin_session_id']) {
- header('Location: connexion.php?t=session');
- exit;
- }
- // Si l'identifiant de session a expiré, on renvoie vers la console de connexion.
- if (time() > $this->config['admin_session_expire']) {
- header('Location: connexion.php?t=expire');
- exit;
- }
- // On génčre un nouveau VID.
- $this->template['new_vid'] = outils::gen_key(32);
- $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'config
- SET valeur = "' . $this->template['new_vid'] . '"
- WHERE parametre = "admin_vid"';
- if (!$this->mysql->requete($mysql_requete)) {
- die('Impossible de générer le VID.');
- exit;
- }
- // Vérification du VID dans les formulaires.
- if (!empty($_POST)) {
- if (empty($this->config['admin_vid']) || empty($_POST['igalvid'])
- || $_POST['igalvid'] != $this->config['admin_vid']) {
- $params = '';
- $params .= (isset($_REQUEST['section'])) ? '?section=' . $_REQUEST['section'] : '';
- $params .= (isset($_REQUEST['page'])) ? '&page=' . $_REQUEST['page'] : '';
- $params .= (isset($_REQUEST['cat'])) ? '&cat=' . $_REQUEST['cat'] : '';
- $params .= (isset($_REQUEST['groupe'])) ? '&groupe=' . $_REQUEST['groupe'] : '';
- $params .= (isset($_REQUEST['user'])) ? '&user=' . $_REQUEST['user'] : '';
- header('Location: index.php' . $params);
- exit;
- }
- }
- // Deconnexion.
- if (isset($_GET['igal_admin_deconnect'])) {
- $this->verifVID();
- $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'config SET valeur = ""
- WHERE parametre = "admin_session_id"';
- $this->mysql->requete($mysql_requete);
- header('Location: connexion.php');
- exit;
- }
- // Activation/désactivation de la galerie.
- if (!empty($_REQUEST['gal_desactive'])) {
- $this->verifVID();
- $this->update_option('active_galerie', 0);
- header('Location:index.php?' . preg_replace('`&gal_desactive=\d`', '', $_SERVER['QUERY_STRING']));
- }
- if (!empty($_REQUEST['gal_active'])) {
- $this->verifVID();
- $this->update_option('active_galerie', 1);
- header('Location:index.php?' . preg_replace('`&gal_active=\d`', '', $_SERVER['QUERY_STRING']));
- }
- $this->config['admin_template'] = 'defaut';
- switch ($_REQUEST['section']) {
- case 'ftp' :
- $this->template['infos']['title'] = 'upload FTP';
- break;
- }
- $this->galerie_dir = dirname(dirname(__FILE__)) . '/' . GALERIE_ALBUMS . '/';
- // Configuration.
- $this->template['config'] = $this->config;
- $this->template['config']['galerie_url'] = GALERIE_URL;
- $this->config['admin_comment_ban'] = unserialize($this->config['admin_comment_ban']);
- $this->config['img_resize_gd'] = IMG_RESIZE_GD;
- $this->config['galerie_template'] = GALERIE_THEME;
- $this->config['galerie_style'] = GALERIE_STYLE;
- $this->config['galerie_url_type'] = GALERIE_URL_TYPE;
- $this->config['galerie_url'] = GALERIE_URL;
- $this->config['galerie_path'] = GALERIE_PATH;
- $this->config['galerie_integrated'] = GALERIE_INTEGRATED;
- include(dirname(__FILE__) . '/../template/' . GALERIE_THEME . '/_fonctions.php');
- $this->template['enabled'] = $f;
- }
- /*
- * Vérification de l'identifiant de session pour chaque action sur la galerie.
- */
- function verifVID() {
- if (empty($this->config['admin_vid']) || empty($_GET['igalvid'])
- || $_GET['igalvid'] != $this->config['admin_vid']) {
- $params = '';
- $params .= (isset($_REQUEST['section'])) ? '?section=' . $_REQUEST['section'] : '';
- $params .= (isset($_REQUEST['page'])) ? '&page=' . $_REQUEST['page'] : '';
- $params .= (isset($_REQUEST['cat'])) ? '&cat=' . $_REQUEST['cat'] : '';
- $params .= (isset($_REQUEST['groupe'])) ? '&groupe=' . $_REQUEST['groupe'] : '';
- $params .= (isset($_REQUEST['user'])) ? '&user=' . $_REQUEST['user'] : '';
- header('Location: index.php' . $params);
- exit;
- }
- }
- /*
- * UPDATE des options.
- */
- function update_option($option, $valeur, $r = 1) {
- $valeur_mysql = outils::protege_mysql($valeur, $this->mysql->lien);
- $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'config SET valeur = "' . $valeur_mysql . '"
- WHERE parametre = "' . $option . '"';
- if ($this->mysql->requete($mysql_requete)) {
- if ($r) {
- $this->config[$option] = $valeur;
- }
- return true;
- }
- return false;
- }
- /*
- * Fonction d'upload FTP.
- */
- function ftp() {
- // Recherche et ajout ŕ la base de données de nouvelles images et albums.
- $upload = new upload($this->mysql, $this->config);
- $upload->recup_albums();
- // Contrôle du temps d'exécution.
- if ($upload->arret) {
- $this->template['infos']['info']['ftp_trop'] = 'Il y a trop d\'images : cliquez ŕ nouveau sur le bouton pour scanner les répertoires restants...';
- }
- // Rapport.
- $rapport_resume = '';
- $rapport_details = '';
- // Erreurs.
- if ($upload->rapport['erreurs']) {
- if (count($upload->rapport['erreurs']) > 1) {
- $upload_verbes = ' se sont';
- $s = 's';
- } else {
- $upload_verbes = ' s\'est';
- $s = '';
- }
- $rapport_resume .= '<div class="rapport_msg rapport_erreur"><div><span>' . count($upload->rapport['erreurs']) . ' erreur' . $s . $upload_verbes . ' produite' . $s . '.</span></div></div>' . "\n";
- }
- // Ajouts.
- if ((count($upload->rapport['alb_ajouts']) + $upload->rapport['img_ajouts']) > 0) {
- $e = ($upload->rapport['alb_ajouts']) ? '' : 'e';
- $ajout_verbes = ((count($upload->rapport['alb_ajouts']) + $upload->rapport['img_ajouts']) > 1) ? ' ont été ajouté' . $e . 's' : ' a été ajouté' . $e;
- $et = ($upload->rapport['alb_ajouts']) ? ' et ' : '';
- $as = (count($upload->rapport['alb_ajouts']) > 1) ? 's' : '';
- $is = ($upload->rapport['img_ajouts'] > 1) ? 's' : '';
- $albs = ($upload->rapport['alb_ajouts']) ? count($upload->rapport['alb_ajouts']) . ' album' . $as : '';
- $imgs = ($upload->rapport['img_ajouts']) ? $et . $upload->rapport['img_ajouts'] . ' image' . $is : '';
- $rapport_resume .= '<div class="rapport_msg rapport_succes"><div><span>' . $albs . $imgs . $ajout_verbes . ' ŕ la base de données.</span></div></div>' . "\n";
- } else {
- $rapport_resume .= '<div class="rapport_msg rapport_infos"><div><span>Aucun nouvel album et aucune nouvelle image n\'a été détecté.</span></div></div>' . "\n";
- }
- // Mises ŕ jour.
- if ($upload->rapport['alb_maj']) {
- if (count($upload->rapport['alb_maj']) > 1) {
- $upload_verbes = ' ont';
- $s = 's';
- } else {
- $upload_verbes = ' a';
- $s = '';
- }
- $rapport_resume .= '<div class="rapport_msg rapport_succes"><div><span>' . count($upload->rapport['alb_maj']) . ' album' . $s . $upload_verbes . ' été mis ŕ jour.</span></div></div>' . "\n";
- } else {
- $rapport_resume .= '<div class="rapport_msg rapport_infos"><div><span>Aucun album n\'a été mis ŕ jour.</span></div></div>' . "\n";
- }
- // Update Exif.
- if ($upload->images_update_exif) {
- $s = ($upload->images_update_exif > 1) ? 's' : '';
- $rapport_resume .= '<div class="rapport_msg rapport_succes"><div><span>Les meta-données Exif ont été ajoutées pour ' . $upload->images_update_exif . ' image' . $s . '.</span></div></div>' . "\n";
- }
- // Rejets.
- if ((count($upload->rapport['cat_rejets']) + count($upload->rapport['img_rejets'])) > 0) {
- $e = ($upload->rapport['cat_rejets']) ? '' : 'e';
- $ajout_verbes = ((count($upload->rapport['cat_rejets']) + count($upload->rapport['img_rejets'])) > 1) ? ' ont été rejeté' . $e . 's' : ' a été rejeté' . $e;
- $et = ($upload->rapport['cat_rejets']) ? ' et ' : '';
- $as = ($upload->rapport['cat_rejets'] > 1) ? 's' : '';
- $is = (count($upload->rapport['img_rejets']) > 1) ? 's' : '';
- $albs = ($upload->rapport['cat_rejets']) ? count($upload->rapport['cat_rejets']) . ' catégorie' . $as . ' ou album' . $as : '';
- $imgs = ($upload->rapport['img_rejets']) ? $et . count($upload->rapport['img_rejets']) . ' image' . $is : '';
- $rapport_resume .= '<div class="rapport_msg rapport_avert"><div><span>' . $albs . $imgs . $ajout_verbes . '.</span></div></div>' . "\n";
- }
- // Détails du rapport.
- if ($upload->rapport['erreurs']) {
- $rapport_details .= '<table id="ftp_details_erreur" class="ftp_details">' . "\n" . '<tr><th>Objet</th><th>Erreur</th></tr>' . "\n";
- foreach ($upload->rapport['erreurs'] as $v) {
- $rapport_details .= '<tr><td>' . wordwrap($v[0], 50, '<br />', 1) . '</td><td>' . $v[1] . '</td></tr>';
- }
- $rapport_details .= '</table><br />' . "\n";
- }
- if ($upload->rapport['alb_ajouts']) {
- $rapport_details .= '<table class="ftp_details">' . "\n" . '<tr><th>Album ajouté</th><th>Nb. d\'images</th><th>Poids</th></tr>' . "\n";
- foreach ($upload->rapport['alb_ajouts'] as $v) {
- $rapport_details .= '<tr><td>' . wordwrap($v[0], 50, '<br />', 1) . '</td><td>' . $v[1] . '</td><td>' . $v[2] . '</td></tr>';
- }
- $rapport_details .= '</table><br />' . "\n";
- }
- if ($upload->rapport['alb_maj']) {
- $rapport_details .= '<table class="ftp_details">' . "\n" . '<tr><th>Album mis ŕ jour</th><th>Nb. d\'images supp.</th><th>Poids supp.</th></tr>' . "\n";
- foreach ($upload->rapport['alb_maj'] as $v) {
- $rapport_details .= '<tr><td>' . wordwrap($v[0], 50, '<br />', 1) . '</td><td>' . $v[1] . '</td><td>' . $v[2] . '</td></tr>';
- }
- $rapport_details .= '</table><br />' . "\n";
- }
- if ($upload->rapport['cat_rejets']) {
- $rapport_details .= '<table class="ftp_details">' . "\n" . '<tr><th>Catégorie rejetée</th><th>Cause</th></tr>' . "\n";
- foreach ($upload->rapport['cat_rejets'] as $v) {
- $rapport_details .= '<tr><td>' . wordwrap($v[0], 50, '<br />', 1) . '</td><td>' . $v[1] . '</td></tr>';
- }
- $rapport_details .= '</table><br />' . "\n";
- }
- if ($upload->rapport['img_rejets']) {
- $rapport_details .= '<table class="ftp_details">' . "\n" . '<tr><th>Image rejetée</th><th>Album</th><th>Cause</th></tr>' . "\n";
- foreach ($upload->rapport['img_rejets'] as $v) {
- $rapport_details .= '<tr><td>' . wordwrap($v[0], 50, '<br />', 1) . '</td><td>' . wordwrap($v[1], 50, '<br />', 1) . '</td><td>' . $v[2] . '</td></tr>';
- }
- $rapport_details .= '</table><br />' . "\n";
- }
- // On ajoute le rapport finalisé au tableau destiné au template.
- $this->template['rapport'] = '<div id="ftp_rapport_resume"><span class="ftp_rapport_titre">Rapport résumé</span><br /><br />' . $rapport_resume . '</div>' . "\n";
- if (!empty($rapport_details)) {
- $this->template['rapport'] .= '<p id="ftp_rapport_details"><span class="ftp_rapport_titre">Rapport détaillé</span></p>' . "\n";
- $this->template['rapport'] .= $rapport_details;
- }
- // Template.
- $this->template['config'] = $this->config;
- }
- /*
- * Désactivation d'un commentaire.
- */
- function comment_action_desactive() {
- $mysql_requete = 'SELECT commentaire_visible FROM ' . MYSQL_PREF . 'commentaires
- WHERE commentaire_id = "' . $_REQUEST['desactive'] . '"';
- $visible = $this->mysql->select($mysql_requete, 5);
- if (!empty($visible)) {
- $this->comments_update_nb('desactive', 0, '-');
- $this->template['action_maj'] = 1;
- }
- }
- /*
- * Désactivation d'un commentaire.
- */
- function comment_action_active() {
- $mysql_requete = 'SELECT commentaire_visible FROM ' . MYSQL_PREF . 'commentaires
- WHERE commentaire_id = "' . $_REQUEST['active'] . '"';
- $visible = $this->mysql->select($mysql_requete, 5);
- if (empty($visible)) {
- $this->comments_update_nb('active', 1, '+');
- $this->template['action_maj'] = 1;
- }
- }
- /*
- * Suppression d'un commentaire.
- */
- function comment_action_delete($mass = 0) {
- static $ids_nb = 0;
- static $ids;
- $ids = $ids . ', ' . $_REQUEST['supprime'];
- $ids_nb++;
- $mysql_requete = 'SELECT ' . MYSQL_PREF . 'images.image_chemin,
- ' . MYSQL_PREF . 'commentaires.commentaire_visible
- FROM ' . MYSQL_PREF . 'commentaires INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)
- WHERE ' . MYSQL_PREF . 'commentaires.commentaire_id = "' . $_REQUEST['supprime'] . '"';
- $i_co = $this->mysql->select($mysql_requete, 11);
- $path = $i_co['image_chemin'];
- // On vérifie si le commentaire existe.
- if ($i_co == 'vide') {
- return;
- }
- // On supprime le commentaire.
- $mysql_requete = 'DELETE FROM ' . MYSQL_PREF . 'commentaires
- WHERE commentaire_id = "' . $_REQUEST['supprime'] . '"';
- if ($this->mysql->requete($mysql_requete)) {
- // On UPDATE le nombre de commentaires de l'image et des catégories parentes,
- // mais seulement si le commentaire n'est pas désactivé !
- if ($i_co['commentaire_visible']) {
- $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images SET
- image_commentaires = image_commentaires - 1
- WHERE image_chemin = "' . $path . '"';
- $this->mysql->requete($mysql_requete);
- while ($path != '.') {
- $path = dirname($path);
- $path = ($path == '.') ? $path : $path . '/' ;
- $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET
- categorie_commentaires = categorie_commentaires - 1
- WHERE categorie_chemin = "' . $path . '"';
- $this->mysql->requete($mysql_requete);
- }
- }
- $comment_ids = substr($ids, 2);
- if (strstr($comment_ids, ',')) {
- $this->template['infos']['action']['co_supprime'] = 'Les commentaires ' . preg_replace('`, (\d+)$`', ' et $1', $comment_ids) . ' ont été supprimés.';
- } else {
- $this->template['infos']['action']['co_supprime'] = 'Le commentaire ' . $_REQUEST['supprime'] . ' a été supprimé.';
- }
- $_REQUEST['startnum'] = 0;
- }
- }
- /*
- * Bannissement d'un auteur.
- */
- function comments_action_ban_auteur() {
- $mysql_requete = 'SELECT commentaire_auteur FROM ' . MYSQL_PREF . 'commentaires
- WHERE commentaire_id = "' . $_REQUEST['ban_auteur'] . '"';
- $auteur = $this->mysql->select($mysql_requete, 5);
- $this->config['admin_comment_ban']['auteurs'][$auteur] = 1;
- $this->template['action_maj'] = 1;
- $bans = $this->config['admin_comment_ban'];
- $this->update_option('admin_comment_ban', serialize($bans), 0);
- }
- /*
- * Unban d'un auteur.
- */
- function comments_action_unban_auteur() {
- $mysql_requete = 'SELECT commentaire_auteur FROM ' . MYSQL_PREF . 'commentaires
- WHERE commentaire_id = "' . $_REQUEST['unban_auteur'] . '"';
- $auteur = $this->mysql->select($mysql_requete, 5);
- if (isset($this->config['admin_comment_ban']['auteurs'][$auteur])) {
- unset($this->config['admin_comment_ban']['auteurs'][$auteur]);
- }
- $this->template['action_maj'] = 1;
- $bans = $this->config['admin_comment_ban'];
- $this->update_option('admin_comment_ban', serialize($bans), 0);
- }
- /*
- * Bannissement d'une IP.
- */
- function comments_action_ban_ip() {
- $mysql_requete = 'SELECT commentaire_ip FROM ' . MYSQL_PREF . 'commentaires
- WHERE commentaire_id = "' . $_REQUEST['ban_ip'] . '"';
- $IP = $this->mysql->select($mysql_requete, 5);
- $this->config['admin_comment_ban']['IP'][$IP] = 1;
- //$this->template['infos']['action']['co_rb_ip'] = 'L\'IP ' . $IP . ' a été bannie.';
- $this->template['action_maj'] = 1;
- $bans = $this->config['admin_comment_ban'];
- $this->update_option('admin_comment_ban', serialize($bans), 0);
- }
- /*
- * Unban d'une IP.
- */
- function comments_action_unban_ip() {
- $mysql_requete = 'SELECT commentaire_ip FROM ' . MYSQL_PREF . 'commentaires
- WHERE commentaire_id = "' . $_REQUEST['unban_ip'] . '"';
- $IP = $this->mysql->select($mysql_requete, 5);
- if (isset($this->config['admin_comment_ban']['IP'][$IP])) {
- unset($this->config['admin_comment_ban']['IP'][$IP]);
- }
- //$this->template['infos']['action']['co_ru_ip'] = 'Les commentaires en provenance de l\'IP ' . $IP . ' sont de nouveau autorisés.';
- $this->template['action_maj'] = 1;
- $bans = $this->config['admin_comment_ban'];
- $this->update_option('admin_comment_ban', serialize($bans), 0);
- }
- /*
- * Action sur les commentaires, les auteurs et les IP.
- */
- function comments_action() {
- // Traitement par lot.
- if (isset($_GET['mass']) && isset($_POST['co_mass_action']) && isset($_POST['comment_id'])) {
- foreach ($_POST['comment_id'] as $id => $e) {
- switch ($_POST['co_mass_action']) {
- case 'desactiver' :
- $_REQUEST['desactive'] = $id;
- $this->comment_action_desactive();
- break;
- case 'activer' :
- $_REQUEST['active'] = $id;
- $this->comment_action_active();
- break;
- case 'supprimer' :
- $_REQUEST['supprime'] = $id;
- $this->comment_action_delete();
- break;
- case 'ban_auteurs' :
- $_REQUEST['ban_auteur'] = $id;
- $this->comments_action_ban_auteur();
- break;
- case 'aut_auteurs' :
- $_REQUEST['unban_auteur'] = $id;
- $this->comments_action_unban_auteur();
- break;
- case 'ban_ip' :
- $_REQUEST['ban_ip'] = $id;
- $this->comments_action_ban_ip();
- break;
- case 'aut_ip' :
- $_REQUEST['unban_ip'] = $id;
- $this->comments_action_unban_ip();
- break;
- }
- }
- unset($_REQUEST['desactive']);
- unset($_REQUEST['active']);
- unset($_REQUEST['supprime']);
- unset($_REQUEST['ban_auteur']);
- unset($_REQUEST['unban_auteur']);
- unset($_REQUEST['ban_ip']);
- unset($_REQUEST['unban_ip']);
- }
- // Désactivation du commentaire.
- if (isset($_REQUEST['desactive']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['desactive'])) {
- $this->verifVID();
- $this->comment_action_desactive();
- // Activation du commentaire.
- } elseif (isset($_REQUEST['active']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['active'])) {
- $this->verifVID();
- $this->comment_action_active();
- // Suppression du commentaire.
- } elseif (isset($_REQUEST['supprime']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['supprime'])) {
- $this->verifVID();
- $this->comment_action_delete();
- // Bannissement d'un auteur.
- } elseif (isset($_REQUEST['ban_auteur']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['ban_auteur'])) {
- $this->verifVID();
- $this->comments_action_ban_auteur();
- // Unban d'un auteur.
- } elseif (isset($_REQUEST['unban_auteur']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['unban_auteur'])) {
- $this->verifVID();
- $this->comments_action_unban_auteur();
- // Bannissement d'une IP.
- } elseif (isset($_REQUEST['ban_ip']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['ban_ip'])) {
- $this->verifVID();
- $this->comments_action_ban_ip();
- // Unban d'une IP.
- } elseif (isset($_REQUEST['unban_ip']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['unban_ip'])) {
- $this->verifVID();
- $this->comments_action_unban_ip();
- }
- }
- /*
- * UPDATE des informations sur l'activation/désactivation d'un commentaire.
- */
- function comments_update_nb($e, $n, $i) {
- // On UPDATE l'état 'visible' du commentaire.
- $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'commentaires SET
- commentaire_visible = "' . $n . '"
- WHERE commentaire_id = "' . $_REQUEST[$e] . '"';
- if ($this->mysql->requete($mysql_requete)) {
- // On UPDATE le nombre de commentaires de l'image et des catégories parentes.
- $mysql_requete = 'SELECT ' . MYSQL_PREF . 'images.image_chemin
- FROM ' . MYSQL_PREF . 'commentaires INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)
- WHERE ' . MYSQL_PREF . 'commentaires.commentaire_id = "' . $_REQUEST[$e] . '"';
- $path = $this->mysql->select($mysql_requete, 5);
- $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images SET
- image_commentaires = image_commentaires ' . $i . ' 1
- WHERE image_chemin = "' . $path . '"';
- $this->mysql->requete($mysql_requete);
- while ($path != '.') {
- $path = dirname($path);
- $path = ($path == '.') ? $path : $path . '/' ;
- $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET
- categorie_commentaires = categorie_commentaires ' . $i . ' 1
- WHERE categorie_chemin = "' . $path . '"';
- $this->mysql->requete($mysql_requete);
- }
-
- }
- }
- /*
- * Affichage des commentaires.
- */
- function comments() {
- $this->template['infos']['title'] = 'gestion des commentaires';
- // Trie des commentaires : ordre.
- if (isset($_REQUEST['sort']) && preg_match('`^commentaire_(auteur|date|mail|ip|web)|image_chemin$`', $_REQUEST['sort']) && $_REQUEST['sort'] != $this->config['admin_comment_ordre']) {
- $this->template['infos']['comment_sort'] = $_REQUEST['sort'];
- $this->update_option('admin_comment_ordre', $_REQUEST['sort']);
- } else {
- $this->template['infos']['comment_sort'] = $this->config['admin_comment_ordre'];
- }
- // Trie des commentaires : sens.
- if (isset($_REQUEST['sens']) && preg_match('`^ASC|DESC$`', $_REQUEST['sens']) && $_REQUEST['sens'] != $this->config['admin_comment_sens']) {
- $this->template['infos']['comment_sens'] = $_REQUEST['sens'];
- $this->update_option('admin_comment_sens', $_REQUEST['sens']);
- } else {
- $this->template['infos']['comment_sens'] = $this->config['admin_comment_sens'];
- }
- // Page ŕ afficher.
- if (isset($_REQUEST['startnum']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['startnum'])) {
- $startnum = $_REQUEST['startnum'];
- } else {
- $startnum = 0;
- }
- // Filtre.
- $filtre = $this->config['admin_comment_filtre'];
- if (isset($_REQUEST['filtre']) && preg_match('`^(tous|actif|inactif)$`', $_REQUEST['filtre']) && $filtre != $_REQUEST['filtre']) {
- $this->update_option('admin_comment_filtre', $_REQUEST['filtre']);
- $filtre = $_REQUEST['filtre'];
- $startnum = 0;
- }
- $this->template['infos']['comment_filtre'] = $filtre;
- switch ($filtre) {
- case 'actif' :
- $filtre = ' AND ' . MYSQL_PREF . 'commentaires.commentaire_visible = "1"';
- break;
- case 'inactif' :
- $filtre = ' AND ' . MYSQL_PREF . 'commentaires.commentaire_visible = "0"';
- break;
- default :
- $filtre = '';
- }
- // Nombre de commentaires par page.
- if (isset($_REQUEST['nb']) && preg_match('`^[1-9]\d{0,3}$`', $_REQUEST['nb']) && $_REQUEST['nb'] != $this->config['admin_comment_nb']) {
- $this->update_option('admin_comment_nb', $_REQUEST['nb']);
- $this->config['admin_comment_nb'] = $_REQUEST['nb'];
- $this->template['infos']['nb_comments'] = $_REQUEST['nb'];
- $startnum = 0;
- } else {
- $this->template['infos']['nb_comments'] = $this->config['admin_comment_nb'];
- }
- $this->template['infos']['startnum'] = $startnum;
- // Objet actuel.
- if (isset($_REQUEST['cat']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['cat'])) {
- $obj = $_REQUEST['cat'];
- $obj_type = 'cat';
- $obj_type_ext = 'categorie';
- } elseif (isset($_REQUEST['img']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['img'])) {
- $obj = $_REQUEST['img'];
- $obj_type = 'img';
- $obj_type_ext = 'image';
- } else {
- $obj = 1;
- $obj_type = 'cat';
- $obj_type_ext = 'categorie';
- }
- $this->template['infos']['section'] = 'section=commentaires&page=display&' . $obj_type . '=' . $obj;
- $this->template['infos']['obj'] = $obj;
- $this->template['infos']['obj_type'] = $obj_type;
- $mysql_requete = 'SELECT ' . $obj_type_ext . '_chemin,
- ' . $obj_type_ext . '_nom
- FROM ' . MYSQL_PREF . $obj_type_ext . 's
- WHERE ' . $obj_type_ext . '_id = "' . $obj . '"';
- $obj = $this->mysql->select($mysql_requete, 11);
- if (!is_array($obj)) {
- header('Location:index.php?section=commentaires&page=display');
- exit;
- }
- $obj_chemin = ($obj[$obj_type_ext . '_chemin'] == '.') ? '' : $obj[$obj_type_ext . '_chemin'];
- // Recherche.
- $this->template['infos']['recherche'] = '';
- $recherche = '';
- if (isset($_REQUEST['search'])) {
- if (isset($_REQUEST['s_accents'])) {
- $search_inputs['s_accents'] = '1';
- $this->template['infos']['recherche'] .= '&s_accents=on';
- }
- if (isset($_REQUEST['s_casse'])) {
- $search_inputs['s_casse'] = '1';
- $this->template['infos']['recherche'] .= '&s_casse=on';
- }
- if (isset($_REQUEST['s_tous'])) {
- $search_inputs['s_tous'] = '1';
- $this->template['infos']['recherche'] .= '&s_tous=on';
- }
- if (isset($_REQUEST['s_msg'])) {
- $search_inputs['s_msg'] = '1';
- $this->template['infos']['recherche'] .= '&s_msg=on';
- }
- if (isset($_REQUEST['s_auteur'])) {
- $search_inputs['s_auteur'] = '1';
- $this->template['infos']['recherche'] .= '&s_auteur=on';
- }
- if (isset($_REQUEST['s_ip'])) {
- $search_inputs['s_ip'] = '1';
- $this->template['infos']['recherche'] .= '&s_ip=on';
- }
- if (isset($_REQUEST['s_mail'])) {
- $search_inputs['s_mail'] = '1';
- $this->template['infos']['recherche'] .= '&s_mail=on';
- }
- if (isset($_REQUEST['s_web'])) {
- $search_inputs['s_web'] = '1';
- $this->template['infos']['recherche'] .= '&s_web=on';
- }
- // On affiche les messages des commentaires.
- $this->template['display']['comment_msg'] = 1;
-
- $search_inputs['search'] = outils::html_specialchars($_REQUEST['search']);
- $this->template['infos']['recherche'] .= '&search=' . urlencode($_REQUEST['search']);
- // Récupération de la requęte.
- $search = trim($_REQUEST['search']);
- $search = preg_replace('`-+`', '-', $search);
- $search = str_replace('- ', '', $search);
- $search = str_replace(' *', '', $search);
- $search = preg_replace('`\s+`', ' ', $search);
- // Méthodes Ť AND ť ou Ť OR ť.
- $method = (isset($_REQUEST['s_tous'])) ? 'AND' : 'OR';
- // Casse.
- $binary = (isset($_REQUEST['s_casse'])) ? 'BINARY ' : '';
- // Si ni la casse ni les accents comptent, on concertit tout en minuscule.
- if (!isset($_REQUEST['s_casse']) && !isset($_REQUEST['s_accents'])) {
- $search = strtolower($search);
- }
- // Paramčtres de recherche.
- $search = preg_split('`\s+(?!.*[^-\s]")`i', $search, -1, PREG_SPLIT_NO_EMPTY);
- $champs = array();
- $champs['message'] = '';
- $champs['auteur'] = '';
- $champs['ip'] = '';
- $champs['mail'] = '';
- $champs['web'] = '';
- for ($i = 0; $i < count($search); $i++) {
- // Suppression des guillemets.
- $terme = str_replace('"', '', $search[$i]);
- // Remplacement des espace par une suite de caractčres non-alpha-numérique.
- $terme = preg_replace('`[^-\w\*\?\'\s]+`', '?', $terme);
- // Doit-on ne pas faire de distinction pour les lettres accentuées ?
- $terme = (isset($_REQUEST['s_accents'])) ? $terme : outils::regexp_accents($terme);
- // Doit-on inclure ou exclure le terme ?
- $terme = ($search[$i]{0} == '-') ? substr($terme, 1) : $terme;
- $not = ($search[$i]{0} == '-') ? 'NOT ' : '';
- // Si le terme est vide, inutile d'aller plus loin.
- if (trim($terme) == '') {
- continue;
- }
- // Remplacement des espace par une suite de caractčres non-alpha-numérique.
- $terme = str_replace(' ', '[^[:alnum:]]', $terme);
- // Joker Ť * ť.
- $terme = str_replace('*', '[^[:space:]]*', $terme);
- // Joker Ť ? ť.
- $terme = str_replace('?', '.', $terme);
- // On ne recherche que des mots entiers.
- $terme = '([^[:alnum:]]|^)' . $terme . '([^[:alnum:]]|$)';
- // Champ message.
- if (isset($_REQUEST['s_msg'])) {
- $champs['message'] .= $method . ' ' . MYSQL_PREF . 'commentaires.commentaire_message ' . $not . 'REGEXP ' . $binary . '"' . outils::protege_mysql($terme, $this->mysql->lien) . '" ';
- }
- // Champ auteur.
- if (isset($_REQUEST['s_auteur'])) {
- $champs['auteur'] .= $method . ' ' . MYSQL_PREF . 'commentaires.commentaire_auteur ' . $not . 'REGEXP ' . $binary . '"' . outils::protege_mysql($terme, $this->mysql->lien) . '" ';
- }
- // Champ ip.
- if (isset($_REQUEST['s_ip'])) {
- $champs['ip'] .= $method . ' ' . MYSQL_PREF . 'commentaires.commentaire_ip ' . $not . 'REGEXP ' . $binary . '"' . outils::protege_mysql($terme, $this->mysql->lien) . '" ';
- }
- // Champ mail.
- if (isset($_REQUEST['s_mail'])) {
- $champs['mail'] .= $method . ' ' . MYSQL_PREF . 'commentaires.commentaire_mail ' . $not . 'REGEXP ' . $binary . '"' . outils::protege_mysql($terme, $this->mysql->lien) . '" ';
- }
- // Champ web.
- if (isset($_REQUEST['s_web'])) {
- $champs['web'] .= $method . ' ' . MYSQL_PREF . 'commentaires.commentaire_web ' . $not . 'REGEXP ' . $binary . '"' . outils::protege_mysql($terme, $this->mysql->lien) . '" ';
- }
- }
- // Champs de la table dans lesquels la recherche s'effectuera.
- $commentaires_champs = '';
- foreach ($champs as $v) {
- if ($v) {
- $commentaires_champs .= 'OR (' . preg_replace('`^(?:AND|OR) `', '', $v) . ') ';
- }
- }
- if ($commentaires_champs) {
- $commentaires_champs = '(' . preg_replace('`^OR `', '', $commentaires_champs) . ')';
- }
- // Date
- $commentaires_date = '';
- if (isset($_REQUEST['s_date']) && isset($_REQUEST['s_dnpc']) && isset($_REQUEST['s_dnpd'])
- && isset($_REQUEST['s_dnsc']) && isset($_REQUEST['s_dnsd'])) {
- $search_inputs['s_date'] = $_REQUEST['s_date'];
- $search_inputs['s_dnpc'] = $_REQUEST['s_dnpc'];
- $search_inputs['s_dnpd'] = $_REQUEST['s_dnpd'];
- $search_inputs['s_dnsc'] = $_REQUEST['s_dnsc'];
- $search_inputs['s_dnsd'] = $_REQUEST['s_dnsd'];
- $this->template['infos']['recherche'] .= '&s_date=on&s_dnpc=' . $_REQUEST['s_dnpc'];
- $this->template['infos']['recherche'] .= '&s_dnpd=' . $_REQUEST['s_dnpd'];
- $this->template['infos']['recherche'] .= '&s_dnsc=' . $_REQUEST['s_dnsc'];
- $this->template['infos']['recherche'] .= '&s_dnsd=' . $_REQUEST['s_dnsd'];
- $commentaires_date .= '' . MYSQL_PREF . 'commentaires.commentaire_date < ' . outils::time_date($_REQUEST['s_dnpc'], $_REQUEST['s_dnpd'])
- . ' AND ' . MYSQL_PREF . 'commentaires.commentaire_date > ' . outils::time_date($_REQUEST['s_dnsc'], $_REQUEST['s_dnsd']);
- }
- if ($commentaires_champs || $commentaires_date) {
- $and = ($commentaires_champs && $commentaires_date) ? ' AND ' : '';
- $recherche = ' AND (' . $commentaires_champs . $and . $commentaires_date . ')';
- }
- $this->template['comments']['search'] = $search_inputs;
- }
- // Sous-objets.
- $mysql_requete = 'SELECT categorie_id,categorie_nom,categorie_chemin FROM ' . MYSQL_PREF . 'categories
- WHERE categorie_chemin REGEXP "^' . $obj_chemin . '[^/]+/$"
- AND categorie_id > 1
- AND (categorie_commentaires > 0 OR categorie_commentaires_inactive > 0)';
- $sub_cat = $this->mysql->select($mysql_requete);
- if (is_array($sub_cat)) {
- for ($i = 0; $i < count($sub_cat); $i++) {
- $this->template['comments']['sub_item'][$i] = $sub_cat[$i];
- $this->template['display']['subcats'] = 1;
- $this->template['infos']['sub_objects'] = 'categorie';
-
- }
- } else {
- $mysql_requete = 'SELECT image_id,image_nom,image_chemin FROM ' . MYSQL_PREF . 'images
- WHERE image_chemin REGEXP "^' . $obj_chemin . '[^/]+$"
- AND image_commentaires > 0';
- $imgs = $this->mysql->select($mysql_requete);
- if (is_array($imgs)) {
- for ($i = 0; $i < count($imgs); $i++) {
- $this->template['comments']['sub_item'][$i] = $imgs[$i];
- $this->template['display']['subcats'] = 1;
- $this->template['infos']['sub_objects'] = 'image';
- }
- }
- }
- // Barre de position.
- $this->template['comments']['position'] = '';
- if ($obj_chemin) {
- $parent = dirname($obj_chemin);
- while ($parent != '.') {
- $mysql_requete = 'SELECT categorie_id,categorie_chemin,categorie_nom
- FROM ' . MYSQL_PREF . 'categories
- WHERE categorie_chemin = "' . $parent . '/"';
- $p_i = $this->mysql->select($mysql_requete, 11);
- $parent = dirname($p_i['categorie_chemin']);
- $this->template['comments']['position'] = '%sep<a href="index.php?section=commentaires&page=display&cat=' .
- $p_i['categorie_id'] . htmlentities($this->template['infos']['recherche']) . '">' .
- strip_tags($p_i['categorie_nom']) . '</a>' .
- $this->template['comments']['position'];
- }
- }
- $pos_actuel = ($this->template['infos']['obj'] > 1) ? '' : ' class="pos_actuel"' ;
- $this->template['comments']['position'] = '<a' . $pos_actuel . ' href="index.php?section=commentaires&page=display' .
- htmlentities($this->template['infos']['recherche']) . '">galerie</a>' . $this->template['comments']['position'];
- if ($this->template['infos']['obj'] > 1) {
- $this->template['comments']['position'] .= '%sep<a href="index.php?section=commentaires&page=display&' . $obj_type . '=' .
- $this->template['infos']['obj'] . htmlentities($this->template['infos']['recherche']) .
- '" class="pos_actuel">' .
- strip_tags($obj[$obj_type_ext . '_nom']) . '</a>';
- }
- // Récupération du nombre de commentaires de l'objet actuel.
- $mysql_requete = 'SELECT COUNT(*)
- FROM ' . MYSQL_PREF . 'commentaires INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)
- WHERE ' . MYSQL_PREF . 'images.image_chemin LIKE "' . $obj_chemin . '%"'
- . $recherche . $filtre;
- if ($nc = $this->mysql->select($mysql_requete, 5)) {
- $this->template['infos']['nb_objets'] = $nc;
- } else {
- $this->template['infos']['nb_objets'] = 0;
- }
- // On détermine le nombre de pages et la page actuelle.
- $this->template['infos']['nb_pages'] = ceil(($this->template['infos']['nb_objets']) / $this->config['admin_comment_nb']);
- for ($n = 0; $n < $this->template['infos']['nb_pages']; $n++) {
- $num = $n * $this->config['admin_comment_nb'];
- $this->template['nav']['pages'][$n + 1]['page'] = $num;
- if ($num == $startnum) {
- $this->template['infos']['page_actuelle'] = $n + 1;
- }
- }
- // On détermine les pages suivantes, précédentes, de début et de fin.
- $this->template['nav']['suivante'][1] = $startnum + $this->config['admin_comment_nb'];
- $this->template['nav']['precedente'][1] = $startnum - $this->config['admin_comment_nb'];
- $this->template['nav']['premiere'][1] = 0;
- $this->template['nav']['derniere'][1] = ($this->template['infos']['nb_pages'] * $this->config['admin_comment_nb']) - $this->config['admin_comment_nb'];
- // On détermine la position de l'objet actuel.
- if ($startnum == 0) {
- $this->template['nav']['premiere'][0] = 1;
- }
- if ($this->template['nav']['precedente'][1] < 0) {
- $this->template['nav']['precedente'][0] = 1;
- }
- if ($this->template['nav']['suivante'][1] >= ($this->template['infos']['nb_pages'] * $this->config['admin_comment_nb']) ||
- $this->template['nav']['suivante'][1] >= $this->template['infos']['nb_objets']) {
- $this->template['nav']['suivante'][0] = 1;
- }
- if ($startnum >= $this->template['nav']['derniere'][1]) {
- $this->template['nav']['derniere'][0] = 1;
- }
- // Récupération des informations des commentaires.
- $mysql_requete = 'SELECT ' . MYSQL_PREF . 'commentaires.*,
- ' . MYSQL_PREF . 'categories.categorie_id,
- ' . MYSQL_PREF . 'categories.categorie_nom,
- ' . MYSQL_PREF . 'images.image_id,
- ' . MYSQL_PREF . 'images.image_chemin,
- ' . MYSQL_PREF . 'images.image_nom,
- ' . MYSQL_PREF . 'images.image_hauteur,
- ' . MYSQL_PREF . 'images.image_largeur,
- ' . MYSQL_PREF . 'users.user_id,
- ' . MYSQL_PREF . 'users.user_login,
- ' . MYSQL_PREF . 'users.user_web,
- ' . MYSQL_PREF . 'users.user_mail
- FROM ' . MYSQL_PREF . 'categories,
- ' . MYSQL_PREF . 'images,
- ' . MYSQL_PREF . 'commentaires
- LEFT JOIN ' . MYSQL_PREF . 'users
- ON ' . MYSQL_PREF . 'commentaires.user_id = ' . MYSQL_PREF . 'users.user_id
- WHERE ' . MYSQL_PREF . 'images.image_chemin LIKE "' . $obj_chemin . '%"
- AND ' . MYSQL_PREF . 'commentaires.image_id = ' . MYSQL_PREF . 'images.image_id
- AND ' . MYSQL_PREF . 'categories.categorie_id = ' . MYSQL_PREF . 'images.categorie_parent_id ' .
- $recherche . $filtre . '
- ORDER BY ' . $this->template['infos']['comment_sort'] . ' ' . $this->template['infos']['comment_sens'] . '
- LIMIT ' . $startnum . ',' . $this->config['admin_comment_nb'] . '';
- $comments = $this->mysql->select($mysql_requete);
- if (!is_array($comments)) {
- $this->template['display']['co_vide'] = 1;
- $this->template['comments']['no_comments'] = 1;
- if ($this->template['infos']['startnum']) {
- header('Location:index.php?' . $this->template['infos']['section'] . $this->template['infos']['recherche']);
- exit;
- }
- } else {
- settype($this->template['comments'], 'array');
- $this->template['comments'] = array_merge($this->template['comments'], $comments);
- for ($i = 0; $i < count($comments); $i++) {
- if (isset($this->config['admin_comment_ban']['auteurs'][$comments[$i]['commentaire_auteur']])) {
- $this->template['comments'][$i]['ban_auteur'] = 1;
- }
- if (isset($this->config['admin_comment_ban']['IP'][$comments[$i]['commentaire_ip']])) {
- $this->template['comments'][$i]['ban_ip'] = 1;
- }
- }
- }
- $this->template['config']['admin_comment_ban'] = $this->config['admin_comment_ban'];
- // Affichage des message.
- if (isset($_REQUEST['o_msg_display'])) {
- if ($_REQUEST['o_msg_display'] == 'montrer' && !$this->config['admin_comment_msg_display']) {
- $this->update_option('admin_comment_msg_display', 1);
- $this->template['display']['comment_msg'] = 1;
- } elseif ($_REQUEST['o_msg_display'] == 'cacher' && $this->config['admin_comment_msg_display']) {
- $this->update_option('admin_comment_msg_display', 0);
- }
- $this->template['config'] = $this->config;
- }
- if ($this->config['admin_comment_msg_display']) {
- $this->template['display']['comment_msg'] = 1;
- }
- }
- /*
- * Options commentaires.
- */
- function comments_options() {
- $this->template['infos']['title'] = 'options des commentaires';
- if (isset($_REQUEST['u'])) {
- $maj = 0;
-
- // Elements obligatoires pour poster un commentaire.
- if (isset($_REQUEST['oc_fac_mail']) && empty($this->config['comment_courriel'])) {
- $this->update_option('comment_courriel', 1);
- $maj = 1;
-
- } elseif (empty($_REQUEST['oc_fac_mail']) && $this->config['comment_courriel']) {
- $this->update_option('comment_courriel', 0);
- $maj = 1;
- }
- if (isset($_REQUEST['oc_fac_web']) && empty($this->config['comment_siteweb'])) {
- $this->update_option('comment_siteweb', 1);
- $maj = 1;
-
- } elseif (empty($_REQUEST['oc_fac_web']) && $this->config['comment_siteweb']) {
- $this->update_option('comment_siteweb', 0);
- $maj = 1;
- }
- // Contrôles.
- if (isset($_POST['oc_pro_flood']) && preg_match('`^(0|[1-9]\d{0,3})$`', $_POST['oc_pro_flood'])
- && $_POST['oc_pro_flood'] != $this->config['comment_antiflood']) {
- $this->update_option('comment_antiflood', $_POST['oc_pro_flood']);
- $maj = 1;
- }
- if (isset($_REQUEST['oc_samemsg']) && empty($this->config['comment_samemsg'])) {
- $this->update_option('comment_samemsg', 1);
- $maj = 1;
-
- } elseif (empty($_REQUEST['oc_samemsg']) && $this->config['comment_samemsg']) {
- $this->update_option('comment_samemsg', 0);
- $maj = 1;
- }
- if (isset($_REQUEST['oc_maxmsg']) && empty($this->config['comment_maxmsg'])) {
- $this->update_option('comment_maxmsg', 1);
- $maj = 1;
-
- } elseif (empty($_REQUEST['oc_maxmsg']) && $this->config['comment_maxmsg']) {
- $this->update_option('comment_maxmsg', 0);
- $maj = 1;
- }
- if (isset($_POST['oc_maxmsg_nb']) && preg_match('`^(0|[1-9]\d{0,3})$`', $_POST['oc_maxmsg_nb'])
- && $_POST['oc_maxmsg_nb'] != $this->config['comment_maxmsg_nb']) {
- $this->update_option('comment_maxmsg_nb', $_POST['oc_maxmsg_nb']);
- $maj = 1;
- }
- if (isset($_REQUEST['oc_nourl']) && empty($this->config['comment_nourl'])) {
- $this->update_option('comment_nourl', 1);
- $maj = 1;
-
- } elseif (empty($_REQUEST['oc_nourl']) && $this->config['comment_nourl']) {
- $this->update_option('comment_nourl', 0);
- $maj = 1;
- }
- if (isset($_POST['oc_nourl_nb']) && preg_match('`^(0|[1-9]\d{0,3})$`', $_POST['oc_nourl_nb'])
- && $_POST['oc_nourl_nb'] != $this->config['comment_maxurl']) {
- $this->update_option('comment_maxurl', $_POST['oc_nourl_nb']);
- $maj = 1;
- }
- // Modération des commentaires.
- if (isset($_REQUEST['oc_mod']) && empty($this->config['admin_comment_moderer'])) {
- $this->update_option('admin_comment_moderer', 1);
- $maj = 1;
-
- } elseif (empty($_REQUEST['oc_mod']) && $this->config['admin_comment_moderer']) {
- $this->update_option('admin_comment_moderer', 0);
- $maj = 1;
- }
- // Alerte par courriel.
- if (!empty($_REQUEST['oc_objet']) && $_REQUEST['oc_objet'] != $this->config['admin_comment_objet']) {
- $this->update_option('admin_comment_objet', $_REQUEST['oc_objet']);
- $maj = 1;
- }
- if (isset($_REQUEST['oc_alert']) && empty($this->config['admin_comment_alert'])) {
- $this->update_option('admin_comment_alert', 1);
- $maj = 1;
-
- } elseif (empty($_REQUEST['oc_alert']) && $this->config['admin_comment_alert']) {
- $this->update_option('admin_comment_alert', 0);
- $maj = 1;
- }
- // Page des commentaires.
- if ($this->template['enabled']['co_page_comments']) {
- if (isset($_REQUEST['oc_comments']) && empty($this->config['galerie_page_comments'])) {
- $this->update_option('galerie_page_comments', 1);
- $maj = 1;
-
- } elseif (empty($_REQUEST['oc_comments']) && $this->config['galerie_page_comments']) {
- $this->up…
Large files files are truncated, but you can click here to view the full file