PageRenderTime 63ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 2ms

/iGal/admin/index.php

https://github.com/shlag/FSG2010
PHP | 9779 lines | 7691 code | 1197 blank | 891 comment | 2156 complexity | fd1afe512abb4dae58fa5536711cd26c MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /********************************************************************
  3. iGalerie - script de galerie d'images
  4. Copyright (C) 2006-2007 - http://www.igalerie.org/
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. ********************************************************************/
  17. error_reporting(E_ALL);
  18. if (@extension_loaded('zlib')
  19. && !@ini_get('zlib.output_compression')) {
  20. @ob_start('ob_gzhandler');
  21. }
  22. ignore_user_abort(TRUE);
  23. if (function_exists('set_time_limit')) {
  24. @set_time_limit(30);
  25. }
  26. // On mémorise l'heure exacte du début du script.
  27. global $TIME_START;
  28. $TIME_START = explode(' ', microtime());
  29. // Debug : requętes SQL.
  30. global $_MYSQL;
  31. $_MYSQL = array();
  32. $_MYSQL['debug'] = 0;
  33. $_MYSQL['mysql_requetes'] = 0;
  34. $_MYSQL['nb_requetes'] = 0;
  35. // Paramčtres de langue.
  36. setlocale(LC_ALL, 'fr');
  37. setlocale(LC_ALL, 'fr_FR');
  38. setlocale(LC_ALL, 'french');
  39. setlocale(LC_ALL, 'fr_FR.ISO8859-1');
  40. setlocale(LC_NUMERIC, 'en');
  41. setlocale(LC_NUMERIC, 'en_US');
  42. setlocale(LC_NUMERIC, 'english');
  43. setlocale(LC_NUMERIC, 'en_US.ISO8859-1');
  44. // On annule la fonction magic_quotes_gpc.
  45. function strip_magic_quotes(&$valeur) {
  46. if (is_array($valeur)) {
  47. array_walk($valeur, 'strip_magic_quotes');
  48. } else {
  49. $valeur = stripslashes($valeur);
  50. }
  51. }
  52. if (get_magic_quotes_gpc()) {
  53. array_walk($_GET, 'strip_magic_quotes');
  54. array_walk($_POST, 'strip_magic_quotes');
  55. array_walk($_COOKIE, 'strip_magic_quotes');
  56. array_walk($_REQUEST, 'strip_magic_quotes');
  57. }
  58. // On désactive la fonction magic_quotes_runtime
  59. if (get_magic_quotes_runtime() &&
  60. function_exists('set_magic_quotes_runtime')) {
  61. set_magic_quotes_runtime(0);
  62. }
  63. // Chargement de la config.
  64. if (file_exists(dirname(__FILE__) . '/../config/conf.php')) {
  65. require_once(dirname(__FILE__) . '/../config/conf.php');
  66. } else {
  67. define('GALERIE_INSTALL', 0);
  68. }
  69. // La galerie est-elle installée ?
  70. if (!defined('GALERIE_INSTALL') || !GALERIE_INSTALL) {
  71. header('Location:../install/');
  72. exit;
  73. }
  74. require_once(dirname(__FILE__) . '/../includes/classes/class.mysql.php');
  75. require_once(dirname(__FILE__) . '/../includes/classes/class.cookie.php');
  76. require_once(dirname(__FILE__) . '/../includes/classes/class.outils.php');
  77. require_once(dirname(__FILE__) . '/../includes/classes/class.files.php');
  78. // Filtrage des paramčtres GET et REQUEST.
  79. $gets = array('img', 'alb', 'cat', 'startnum', 'obj', 'sub_obj',
  80. 'str');
  81. for ($i = 0; $i < count($gets); $i++) {
  82. verif_gets($gets[$i], '`^\d{1,12}$`');
  83. }
  84. function verif_gets($p, $re) {
  85. if (isset($_GET[$p]) && !preg_match($re, $_GET[$p])) {
  86. unset($_GET[$p]);
  87. }
  88. if (isset($_REQUEST[$p]) && !preg_match($re, $_REQUEST[$p])) {
  89. unset($_REQUEST[$p]);
  90. }
  91. }
  92. // Si une section parmis celle existantes est demandée, on la traite...
  93. if (isset($_REQUEST['section'])) {
  94. // Création de l'objet "admin", avec initialisation de paramčtres communs.
  95. $admin = new admin();
  96. switch ($_REQUEST['section']) {
  97. case 'ftp' :
  98. require_once(dirname(__FILE__) . '/../includes/classes/class.upload.php');
  99. if (isset($_REQUEST['action'])) {
  100. switch ($_REQUEST['action']) {
  101. case 'enregistrement' :
  102. $admin->ftp();
  103. break;
  104. }
  105. }
  106. break;
  107. case 'galerie' :
  108. if (!empty($_FILES)) {
  109. require_once(dirname(__FILE__) . '/../includes/classes/class.upload.php');
  110. }
  111. if (isset($_REQUEST['page'])) {
  112. switch ($_REQUEST['page']) {
  113. case 'gestion' :
  114. $admin->galerie_action();
  115. $admin->galerie();
  116. break;
  117. default :
  118. header('Location: index.php?section=galerie&page=gestion');
  119. exit;
  120. }
  121. } else {
  122. header('Location: index.php?section=galerie&page=gestion');
  123. exit;
  124. }
  125. break;
  126. case 'representant' :
  127. if (isset($_REQUEST['cat']) && isset($_REQUEST['str'])) {
  128. $admin->galerie_representant();
  129. } else {
  130. header('Location: index.php?section=galerie&page=gestion');
  131. exit;
  132. }
  133. break;
  134. case 'votes' :
  135. $admin->display_votes();
  136. break;
  137. case 'tags' :
  138. $admin->display_tags();
  139. break;
  140. case 'utilisateurs' :
  141. if (isset($_REQUEST['page'])) {
  142. switch ($_REQUEST['page']) {
  143. case 'general' :
  144. $admin->users_general();
  145. break;
  146. case 'membres' :
  147. $admin->users_membres_action();
  148. $admin->users_membres();
  149. break;
  150. case 'groupes' :
  151. $admin->users_groupes();
  152. break;
  153. case 'modif_groupe' :
  154. $admin->users_modif_groupe();
  155. break;
  156. case 'modif_user' :
  157. $admin->users_modif_user();
  158. break;
  159. case 'images' :
  160. $admin->users_images_action();
  161. $admin->users_images();
  162. break;
  163. default :
  164. header('Location: index.php?section=utilisateurs&page=general');
  165. exit;
  166. }
  167. } else {
  168. header('Location: index.php?section=utilisateurs&page=general');
  169. exit;
  170. }
  171. break;
  172. case 'commentaires' :
  173. if (isset($_REQUEST['page'])) {
  174. switch ($_REQUEST['page']) {
  175. case 'display' :
  176. $admin->comments_action();
  177. $admin->comments();
  178. break;
  179. case 'options' :
  180. $admin->comments_options();
  181. break;
  182. case 'bans' :
  183. $admin->comments_bans();
  184. break;
  185. default :
  186. header('Location: index.php?section=commentaires&page=display');
  187. exit;
  188. }
  189. } else {
  190. header('Location: index.php?section=commentaires&page=display');
  191. exit;
  192. }
  193. break;
  194. case 'options' :
  195. if (isset($_REQUEST['page'])) {
  196. switch ($_REQUEST['page']) {
  197. case 'general' :
  198. $admin->options_general();
  199. break;
  200. case 'images' :
  201. $admin->options_images();
  202. break;
  203. case 'itext_params' :
  204. $admin->options_itext();
  205. break;
  206. case 'infos_exif' :
  207. $admin->options_exif();
  208. break;
  209. case 'infos_iptc' :
  210. $admin->options_iptc();
  211. break;
  212. case 'vignettes' :
  213. $admin->options_vignettes();
  214. break;
  215. case 'textes' :
  216. $admin->options_textes();
  217. break;
  218. case 'fonctions' :
  219. $admin->options_fonctions();
  220. break;
  221. case 'perso' :
  222. $admin->options_perso();
  223. break;
  224. default :
  225. header('Location: index.php?section=options&page=general');
  226. exit;
  227. }
  228. } else {
  229. header('Location: index.php?section=options&page=general');
  230. exit;
  231. }
  232. break;
  233. case 'infos' :
  234. $admin->infos();
  235. break;
  236. case 'outils' :
  237. if (isset($_REQUEST['page'])) {
  238. switch ($_REQUEST['page']) {
  239. case 'images' :
  240. $admin->outils_images();
  241. break;
  242. default :
  243. header('Location: index.php?section=outils&page=images');
  244. exit;
  245. }
  246. } else {
  247. header('Location: index.php?section=outils&page=images');
  248. exit;
  249. }
  250. break;
  251. break;
  252. case 'config' :
  253. if (isset($_REQUEST['page'])) {
  254. switch ($_REQUEST['page']) {
  255. case 'conf' :
  256. $admin->config_conf();
  257. break;
  258. case 'infos_sys' :
  259. $admin->config_infosys();
  260. break;
  261. default :
  262. header('Location: index.php?section=config&page=conf');
  263. exit;
  264. }
  265. } else {
  266. header('Location: index.php?section=config&page=conf');
  267. exit;
  268. }
  269. break;
  270. default :
  271. header('Location: index.php?section=galerie&page=gestion');
  272. exit;
  273. }
  274. // Fermeture de la connexion.
  275. $admin->mysql->fermer();
  276. // On démmarre la classe de template.
  277. $tpl = new template($admin->template);
  278. // On appelle le template.
  279. require('template/' . $admin->config['admin_template'] . '/index.php');
  280. // ...sinon on redirige vers la section 'albums'.
  281. } else {
  282. header('Location: index.php?section=galerie&page=gestion');
  283. }
  284. /*
  285. * ========== class.admin
  286. */
  287. class admin {
  288. var $config; // Configuration générale de la galerie.
  289. var $template; // Informations brutes ŕ destination des fonctions de template.
  290. var $mysql; // Connexion MySQL.
  291. var $galerie_dir; // Chemin relatif du répertoire des albums;
  292. /*
  293. * Constructeur.
  294. */
  295. function admin() {
  296. // Connexion ŕ la base de données.
  297. $this->mysql = new connexion(MYSQL_SERV, MYSQL_USER, MYSQL_PASS, MYSQL_BASE);
  298. // Récupération des paramčtres de configuration.
  299. $mysql_requete = 'SELECT parametre,valeur FROM ' . MYSQL_PREF . 'config';
  300. $this->config = $this->mysql->select($mysql_requete, 3);
  301. if (empty($this->config)) {
  302. die ('La base de données est vide.<br />' . mysql_error());
  303. }
  304. // Si l'identifiant de session du cookie est incorrect, on renvoie vers la console de connexion.
  305. $session = new cookie(0, 'galerie_sessionid', GALERIE_PATH . '/' . basename(dirname(__FILE__)));
  306. $session_id = $session->lire('session_id');
  307. $this->config['session_id'] = $session_id;
  308. if (empty($session_id)) {
  309. header('Location: connexion.php?t=cookie');
  310. exit;
  311. }
  312. if ($session_id != $this->config['admin_session_id']) {
  313. header('Location: connexion.php?t=session');
  314. exit;
  315. }
  316. // Si l'identifiant de session a expiré, on renvoie vers la console de connexion.
  317. if (time() > $this->config['admin_session_expire']) {
  318. header('Location: connexion.php?t=expire');
  319. exit;
  320. }
  321. // On génčre un nouveau VID.
  322. $this->template['new_vid'] = outils::gen_key(32);
  323. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'config
  324. SET valeur = "' . $this->template['new_vid'] . '"
  325. WHERE parametre = "admin_vid"';
  326. if (!$this->mysql->requete($mysql_requete)) {
  327. die('Impossible de générer le VID.');
  328. exit;
  329. }
  330. // Vérification du VID dans les formulaires.
  331. if (!empty($_POST)) {
  332. if (empty($this->config['admin_vid']) || empty($_POST['igalvid'])
  333. || $_POST['igalvid'] != $this->config['admin_vid']) {
  334. $params = '';
  335. $params .= (isset($_REQUEST['section'])) ? '?section=' . $_REQUEST['section'] : '';
  336. $params .= (isset($_REQUEST['page'])) ? '&page=' . $_REQUEST['page'] : '';
  337. $params .= (isset($_REQUEST['cat'])) ? '&cat=' . $_REQUEST['cat'] : '';
  338. $params .= (isset($_REQUEST['groupe'])) ? '&groupe=' . $_REQUEST['groupe'] : '';
  339. $params .= (isset($_REQUEST['user'])) ? '&user=' . $_REQUEST['user'] : '';
  340. header('Location: index.php' . $params);
  341. exit;
  342. }
  343. }
  344. // Deconnexion.
  345. if (isset($_GET['igal_admin_deconnect'])) {
  346. $this->verifVID();
  347. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'config SET valeur = ""
  348. WHERE parametre = "admin_session_id"';
  349. $this->mysql->requete($mysql_requete);
  350. header('Location: connexion.php');
  351. exit;
  352. }
  353. // Activation/désactivation de la galerie.
  354. if (!empty($_REQUEST['gal_desactive'])) {
  355. $this->verifVID();
  356. $this->update_option('active_galerie', 0);
  357. header('Location:index.php?' . preg_replace('`&gal_desactive=\d`', '', $_SERVER['QUERY_STRING']));
  358. }
  359. if (!empty($_REQUEST['gal_active'])) {
  360. $this->verifVID();
  361. $this->update_option('active_galerie', 1);
  362. header('Location:index.php?' . preg_replace('`&gal_active=\d`', '', $_SERVER['QUERY_STRING']));
  363. }
  364. $this->config['admin_template'] = 'defaut';
  365. switch ($_REQUEST['section']) {
  366. case 'ftp' :
  367. $this->template['infos']['title'] = 'upload FTP';
  368. break;
  369. }
  370. $this->galerie_dir = dirname(dirname(__FILE__)) . '/' . GALERIE_ALBUMS . '/';
  371. // Configuration.
  372. $this->template['config'] = $this->config;
  373. $this->template['config']['galerie_url'] = GALERIE_URL;
  374. $this->config['admin_comment_ban'] = unserialize($this->config['admin_comment_ban']);
  375. $this->config['img_resize_gd'] = IMG_RESIZE_GD;
  376. $this->config['galerie_template'] = GALERIE_THEME;
  377. $this->config['galerie_style'] = GALERIE_STYLE;
  378. $this->config['galerie_url_type'] = GALERIE_URL_TYPE;
  379. $this->config['galerie_url'] = GALERIE_URL;
  380. $this->config['galerie_path'] = GALERIE_PATH;
  381. $this->config['galerie_integrated'] = GALERIE_INTEGRATED;
  382. include(dirname(__FILE__) . '/../template/' . GALERIE_THEME . '/_fonctions.php');
  383. $this->template['enabled'] = $f;
  384. }
  385. /*
  386. * Vérification de l'identifiant de session pour chaque action sur la galerie.
  387. */
  388. function verifVID() {
  389. if (empty($this->config['admin_vid']) || empty($_GET['igalvid'])
  390. || $_GET['igalvid'] != $this->config['admin_vid']) {
  391. $params = '';
  392. $params .= (isset($_REQUEST['section'])) ? '?section=' . $_REQUEST['section'] : '';
  393. $params .= (isset($_REQUEST['page'])) ? '&page=' . $_REQUEST['page'] : '';
  394. $params .= (isset($_REQUEST['cat'])) ? '&cat=' . $_REQUEST['cat'] : '';
  395. $params .= (isset($_REQUEST['groupe'])) ? '&groupe=' . $_REQUEST['groupe'] : '';
  396. $params .= (isset($_REQUEST['user'])) ? '&user=' . $_REQUEST['user'] : '';
  397. header('Location: index.php' . $params);
  398. exit;
  399. }
  400. }
  401. /*
  402. * UPDATE des options.
  403. */
  404. function update_option($option, $valeur, $r = 1) {
  405. $valeur_mysql = outils::protege_mysql($valeur, $this->mysql->lien);
  406. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'config SET valeur = "' . $valeur_mysql . '"
  407. WHERE parametre = "' . $option . '"';
  408. if ($this->mysql->requete($mysql_requete)) {
  409. if ($r) {
  410. $this->config[$option] = $valeur;
  411. }
  412. return true;
  413. }
  414. return false;
  415. }
  416. /*
  417. * Fonction d'upload FTP.
  418. */
  419. function ftp() {
  420. // Recherche et ajout ŕ la base de données de nouvelles images et albums.
  421. $upload = new upload($this->mysql, $this->config);
  422. $upload->recup_albums();
  423. // Contrôle du temps d'exécution.
  424. if ($upload->arret) {
  425. $this->template['infos']['info']['ftp_trop'] = 'Il y a trop d\'images : cliquez ŕ nouveau sur le bouton pour scanner les répertoires restants...';
  426. }
  427. // Rapport.
  428. $rapport_resume = '';
  429. $rapport_details = '';
  430. // Erreurs.
  431. if ($upload->rapport['erreurs']) {
  432. if (count($upload->rapport['erreurs']) > 1) {
  433. $upload_verbes = ' se sont';
  434. $s = 's';
  435. } else {
  436. $upload_verbes = ' s\'est';
  437. $s = '';
  438. }
  439. $rapport_resume .= '<div class="rapport_msg rapport_erreur"><div><span>' . count($upload->rapport['erreurs']) . ' erreur' . $s . $upload_verbes . ' produite' . $s . '.</span></div></div>' . "\n";
  440. }
  441. // Ajouts.
  442. if ((count($upload->rapport['alb_ajouts']) + $upload->rapport['img_ajouts']) > 0) {
  443. $e = ($upload->rapport['alb_ajouts']) ? '' : 'e';
  444. $ajout_verbes = ((count($upload->rapport['alb_ajouts']) + $upload->rapport['img_ajouts']) > 1) ? ' ont été ajouté' . $e . 's' : ' a été ajouté' . $e;
  445. $et = ($upload->rapport['alb_ajouts']) ? ' et ' : '';
  446. $as = (count($upload->rapport['alb_ajouts']) > 1) ? 's' : '';
  447. $is = ($upload->rapport['img_ajouts'] > 1) ? 's' : '';
  448. $albs = ($upload->rapport['alb_ajouts']) ? count($upload->rapport['alb_ajouts']) . ' album' . $as : '';
  449. $imgs = ($upload->rapport['img_ajouts']) ? $et . $upload->rapport['img_ajouts'] . ' image' . $is : '';
  450. $rapport_resume .= '<div class="rapport_msg rapport_succes"><div><span>' . $albs . $imgs . $ajout_verbes . ' ŕ la base de données.</span></div></div>' . "\n";
  451. } else {
  452. $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";
  453. }
  454. // Mises ŕ jour.
  455. if ($upload->rapport['alb_maj']) {
  456. if (count($upload->rapport['alb_maj']) > 1) {
  457. $upload_verbes = ' ont';
  458. $s = 's';
  459. } else {
  460. $upload_verbes = ' a';
  461. $s = '';
  462. }
  463. $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";
  464. } else {
  465. $rapport_resume .= '<div class="rapport_msg rapport_infos"><div><span>Aucun album n\'a été mis ŕ jour.</span></div></div>' . "\n";
  466. }
  467. // Update Exif.
  468. if ($upload->images_update_exif) {
  469. $s = ($upload->images_update_exif > 1) ? 's' : '';
  470. $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";
  471. }
  472. // Rejets.
  473. if ((count($upload->rapport['cat_rejets']) + count($upload->rapport['img_rejets'])) > 0) {
  474. $e = ($upload->rapport['cat_rejets']) ? '' : 'e';
  475. $ajout_verbes = ((count($upload->rapport['cat_rejets']) + count($upload->rapport['img_rejets'])) > 1) ? ' ont été rejeté' . $e . 's' : ' a été rejeté' . $e;
  476. $et = ($upload->rapport['cat_rejets']) ? ' et ' : '';
  477. $as = ($upload->rapport['cat_rejets'] > 1) ? 's' : '';
  478. $is = (count($upload->rapport['img_rejets']) > 1) ? 's' : '';
  479. $albs = ($upload->rapport['cat_rejets']) ? count($upload->rapport['cat_rejets']) . ' catégorie' . $as . ' ou album' . $as : '';
  480. $imgs = ($upload->rapport['img_rejets']) ? $et . count($upload->rapport['img_rejets']) . ' image' . $is : '';
  481. $rapport_resume .= '<div class="rapport_msg rapport_avert"><div><span>' . $albs . $imgs . $ajout_verbes . '.</span></div></div>' . "\n";
  482. }
  483. // Détails du rapport.
  484. if ($upload->rapport['erreurs']) {
  485. $rapport_details .= '<table id="ftp_details_erreur" class="ftp_details">' . "\n" . '<tr><th>Objet</th><th>Erreur</th></tr>' . "\n";
  486. foreach ($upload->rapport['erreurs'] as $v) {
  487. $rapport_details .= '<tr><td>' . wordwrap($v[0], 50, '<br />', 1) . '</td><td>' . $v[1] . '</td></tr>';
  488. }
  489. $rapport_details .= '</table><br />' . "\n";
  490. }
  491. if ($upload->rapport['alb_ajouts']) {
  492. $rapport_details .= '<table class="ftp_details">' . "\n" . '<tr><th>Album ajouté</th><th>Nb. d\'images</th><th>Poids</th></tr>' . "\n";
  493. foreach ($upload->rapport['alb_ajouts'] as $v) {
  494. $rapport_details .= '<tr><td>' . wordwrap($v[0], 50, '<br />', 1) . '</td><td>' . $v[1] . '</td><td>' . $v[2] . '</td></tr>';
  495. }
  496. $rapport_details .= '</table><br />' . "\n";
  497. }
  498. if ($upload->rapport['alb_maj']) {
  499. $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";
  500. foreach ($upload->rapport['alb_maj'] as $v) {
  501. $rapport_details .= '<tr><td>' . wordwrap($v[0], 50, '<br />', 1) . '</td><td>' . $v[1] . '</td><td>' . $v[2] . '</td></tr>';
  502. }
  503. $rapport_details .= '</table><br />' . "\n";
  504. }
  505. if ($upload->rapport['cat_rejets']) {
  506. $rapport_details .= '<table class="ftp_details">' . "\n" . '<tr><th>Catégorie rejetée</th><th>Cause</th></tr>' . "\n";
  507. foreach ($upload->rapport['cat_rejets'] as $v) {
  508. $rapport_details .= '<tr><td>' . wordwrap($v[0], 50, '<br />', 1) . '</td><td>' . $v[1] . '</td></tr>';
  509. }
  510. $rapport_details .= '</table><br />' . "\n";
  511. }
  512. if ($upload->rapport['img_rejets']) {
  513. $rapport_details .= '<table class="ftp_details">' . "\n" . '<tr><th>Image rejetée</th><th>Album</th><th>Cause</th></tr>' . "\n";
  514. foreach ($upload->rapport['img_rejets'] as $v) {
  515. $rapport_details .= '<tr><td>' . wordwrap($v[0], 50, '<br />', 1) . '</td><td>' . wordwrap($v[1], 50, '<br />', 1) . '</td><td>' . $v[2] . '</td></tr>';
  516. }
  517. $rapport_details .= '</table><br />' . "\n";
  518. }
  519. // On ajoute le rapport finalisé au tableau destiné au template.
  520. $this->template['rapport'] = '<div id="ftp_rapport_resume"><span class="ftp_rapport_titre">Rapport résumé</span><br /><br />' . $rapport_resume . '</div>' . "\n";
  521. if (!empty($rapport_details)) {
  522. $this->template['rapport'] .= '<p id="ftp_rapport_details"><span class="ftp_rapport_titre">Rapport détaillé</span></p>' . "\n";
  523. $this->template['rapport'] .= $rapport_details;
  524. }
  525. // Template.
  526. $this->template['config'] = $this->config;
  527. }
  528. /*
  529. * Désactivation d'un commentaire.
  530. */
  531. function comment_action_desactive() {
  532. $mysql_requete = 'SELECT commentaire_visible FROM ' . MYSQL_PREF . 'commentaires
  533. WHERE commentaire_id = "' . $_REQUEST['desactive'] . '"';
  534. $visible = $this->mysql->select($mysql_requete, 5);
  535. if (!empty($visible)) {
  536. $this->comments_update_nb('desactive', 0, '-');
  537. $this->template['action_maj'] = 1;
  538. }
  539. }
  540. /*
  541. * Désactivation d'un commentaire.
  542. */
  543. function comment_action_active() {
  544. $mysql_requete = 'SELECT commentaire_visible FROM ' . MYSQL_PREF . 'commentaires
  545. WHERE commentaire_id = "' . $_REQUEST['active'] . '"';
  546. $visible = $this->mysql->select($mysql_requete, 5);
  547. if (empty($visible)) {
  548. $this->comments_update_nb('active', 1, '+');
  549. $this->template['action_maj'] = 1;
  550. }
  551. }
  552. /*
  553. * Suppression d'un commentaire.
  554. */
  555. function comment_action_delete($mass = 0) {
  556. static $ids_nb = 0;
  557. static $ids;
  558. $ids = $ids . ', ' . $_REQUEST['supprime'];
  559. $ids_nb++;
  560. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'images.image_chemin,
  561. ' . MYSQL_PREF . 'commentaires.commentaire_visible
  562. FROM ' . MYSQL_PREF . 'commentaires INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)
  563. WHERE ' . MYSQL_PREF . 'commentaires.commentaire_id = "' . $_REQUEST['supprime'] . '"';
  564. $i_co = $this->mysql->select($mysql_requete, 11);
  565. $path = $i_co['image_chemin'];
  566. // On vérifie si le commentaire existe.
  567. if ($i_co == 'vide') {
  568. return;
  569. }
  570. // On supprime le commentaire.
  571. $mysql_requete = 'DELETE FROM ' . MYSQL_PREF . 'commentaires
  572. WHERE commentaire_id = "' . $_REQUEST['supprime'] . '"';
  573. if ($this->mysql->requete($mysql_requete)) {
  574. // On UPDATE le nombre de commentaires de l'image et des catégories parentes,
  575. // mais seulement si le commentaire n'est pas désactivé !
  576. if ($i_co['commentaire_visible']) {
  577. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images SET
  578. image_commentaires = image_commentaires - 1
  579. WHERE image_chemin = "' . $path . '"';
  580. $this->mysql->requete($mysql_requete);
  581. while ($path != '.') {
  582. $path = dirname($path);
  583. $path = ($path == '.') ? $path : $path . '/' ;
  584. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET
  585. categorie_commentaires = categorie_commentaires - 1
  586. WHERE categorie_chemin = "' . $path . '"';
  587. $this->mysql->requete($mysql_requete);
  588. }
  589. }
  590. $comment_ids = substr($ids, 2);
  591. if (strstr($comment_ids, ',')) {
  592. $this->template['infos']['action']['co_supprime'] = 'Les commentaires ' . preg_replace('`, (\d+)$`', ' et $1', $comment_ids) . ' ont été supprimés.';
  593. } else {
  594. $this->template['infos']['action']['co_supprime'] = 'Le commentaire ' . $_REQUEST['supprime'] . ' a été supprimé.';
  595. }
  596. $_REQUEST['startnum'] = 0;
  597. }
  598. }
  599. /*
  600. * Bannissement d'un auteur.
  601. */
  602. function comments_action_ban_auteur() {
  603. $mysql_requete = 'SELECT commentaire_auteur FROM ' . MYSQL_PREF . 'commentaires
  604. WHERE commentaire_id = "' . $_REQUEST['ban_auteur'] . '"';
  605. $auteur = $this->mysql->select($mysql_requete, 5);
  606. $this->config['admin_comment_ban']['auteurs'][$auteur] = 1;
  607. $this->template['action_maj'] = 1;
  608. $bans = $this->config['admin_comment_ban'];
  609. $this->update_option('admin_comment_ban', serialize($bans), 0);
  610. }
  611. /*
  612. * Unban d'un auteur.
  613. */
  614. function comments_action_unban_auteur() {
  615. $mysql_requete = 'SELECT commentaire_auteur FROM ' . MYSQL_PREF . 'commentaires
  616. WHERE commentaire_id = "' . $_REQUEST['unban_auteur'] . '"';
  617. $auteur = $this->mysql->select($mysql_requete, 5);
  618. if (isset($this->config['admin_comment_ban']['auteurs'][$auteur])) {
  619. unset($this->config['admin_comment_ban']['auteurs'][$auteur]);
  620. }
  621. $this->template['action_maj'] = 1;
  622. $bans = $this->config['admin_comment_ban'];
  623. $this->update_option('admin_comment_ban', serialize($bans), 0);
  624. }
  625. /*
  626. * Bannissement d'une IP.
  627. */
  628. function comments_action_ban_ip() {
  629. $mysql_requete = 'SELECT commentaire_ip FROM ' . MYSQL_PREF . 'commentaires
  630. WHERE commentaire_id = "' . $_REQUEST['ban_ip'] . '"';
  631. $IP = $this->mysql->select($mysql_requete, 5);
  632. $this->config['admin_comment_ban']['IP'][$IP] = 1;
  633. //$this->template['infos']['action']['co_rb_ip'] = 'L\'IP ' . $IP . ' a été bannie.';
  634. $this->template['action_maj'] = 1;
  635. $bans = $this->config['admin_comment_ban'];
  636. $this->update_option('admin_comment_ban', serialize($bans), 0);
  637. }
  638. /*
  639. * Unban d'une IP.
  640. */
  641. function comments_action_unban_ip() {
  642. $mysql_requete = 'SELECT commentaire_ip FROM ' . MYSQL_PREF . 'commentaires
  643. WHERE commentaire_id = "' . $_REQUEST['unban_ip'] . '"';
  644. $IP = $this->mysql->select($mysql_requete, 5);
  645. if (isset($this->config['admin_comment_ban']['IP'][$IP])) {
  646. unset($this->config['admin_comment_ban']['IP'][$IP]);
  647. }
  648. //$this->template['infos']['action']['co_ru_ip'] = 'Les commentaires en provenance de l\'IP ' . $IP . ' sont de nouveau autorisés.';
  649. $this->template['action_maj'] = 1;
  650. $bans = $this->config['admin_comment_ban'];
  651. $this->update_option('admin_comment_ban', serialize($bans), 0);
  652. }
  653. /*
  654. * Action sur les commentaires, les auteurs et les IP.
  655. */
  656. function comments_action() {
  657. // Traitement par lot.
  658. if (isset($_GET['mass']) && isset($_POST['co_mass_action']) && isset($_POST['comment_id'])) {
  659. foreach ($_POST['comment_id'] as $id => $e) {
  660. switch ($_POST['co_mass_action']) {
  661. case 'desactiver' :
  662. $_REQUEST['desactive'] = $id;
  663. $this->comment_action_desactive();
  664. break;
  665. case 'activer' :
  666. $_REQUEST['active'] = $id;
  667. $this->comment_action_active();
  668. break;
  669. case 'supprimer' :
  670. $_REQUEST['supprime'] = $id;
  671. $this->comment_action_delete();
  672. break;
  673. case 'ban_auteurs' :
  674. $_REQUEST['ban_auteur'] = $id;
  675. $this->comments_action_ban_auteur();
  676. break;
  677. case 'aut_auteurs' :
  678. $_REQUEST['unban_auteur'] = $id;
  679. $this->comments_action_unban_auteur();
  680. break;
  681. case 'ban_ip' :
  682. $_REQUEST['ban_ip'] = $id;
  683. $this->comments_action_ban_ip();
  684. break;
  685. case 'aut_ip' :
  686. $_REQUEST['unban_ip'] = $id;
  687. $this->comments_action_unban_ip();
  688. break;
  689. }
  690. }
  691. unset($_REQUEST['desactive']);
  692. unset($_REQUEST['active']);
  693. unset($_REQUEST['supprime']);
  694. unset($_REQUEST['ban_auteur']);
  695. unset($_REQUEST['unban_auteur']);
  696. unset($_REQUEST['ban_ip']);
  697. unset($_REQUEST['unban_ip']);
  698. }
  699. // Désactivation du commentaire.
  700. if (isset($_REQUEST['desactive']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['desactive'])) {
  701. $this->verifVID();
  702. $this->comment_action_desactive();
  703. // Activation du commentaire.
  704. } elseif (isset($_REQUEST['active']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['active'])) {
  705. $this->verifVID();
  706. $this->comment_action_active();
  707. // Suppression du commentaire.
  708. } elseif (isset($_REQUEST['supprime']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['supprime'])) {
  709. $this->verifVID();
  710. $this->comment_action_delete();
  711. // Bannissement d'un auteur.
  712. } elseif (isset($_REQUEST['ban_auteur']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['ban_auteur'])) {
  713. $this->verifVID();
  714. $this->comments_action_ban_auteur();
  715. // Unban d'un auteur.
  716. } elseif (isset($_REQUEST['unban_auteur']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['unban_auteur'])) {
  717. $this->verifVID();
  718. $this->comments_action_unban_auteur();
  719. // Bannissement d'une IP.
  720. } elseif (isset($_REQUEST['ban_ip']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['ban_ip'])) {
  721. $this->verifVID();
  722. $this->comments_action_ban_ip();
  723. // Unban d'une IP.
  724. } elseif (isset($_REQUEST['unban_ip']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['unban_ip'])) {
  725. $this->verifVID();
  726. $this->comments_action_unban_ip();
  727. }
  728. }
  729. /*
  730. * UPDATE des informations sur l'activation/désactivation d'un commentaire.
  731. */
  732. function comments_update_nb($e, $n, $i) {
  733. // On UPDATE l'état 'visible' du commentaire.
  734. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'commentaires SET
  735. commentaire_visible = "' . $n . '"
  736. WHERE commentaire_id = "' . $_REQUEST[$e] . '"';
  737. if ($this->mysql->requete($mysql_requete)) {
  738. // On UPDATE le nombre de commentaires de l'image et des catégories parentes.
  739. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'images.image_chemin
  740. FROM ' . MYSQL_PREF . 'commentaires INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)
  741. WHERE ' . MYSQL_PREF . 'commentaires.commentaire_id = "' . $_REQUEST[$e] . '"';
  742. $path = $this->mysql->select($mysql_requete, 5);
  743. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images SET
  744. image_commentaires = image_commentaires ' . $i . ' 1
  745. WHERE image_chemin = "' . $path . '"';
  746. $this->mysql->requete($mysql_requete);
  747. while ($path != '.') {
  748. $path = dirname($path);
  749. $path = ($path == '.') ? $path : $path . '/' ;
  750. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET
  751. categorie_commentaires = categorie_commentaires ' . $i . ' 1
  752. WHERE categorie_chemin = "' . $path . '"';
  753. $this->mysql->requete($mysql_requete);
  754. }
  755. }
  756. }
  757. /*
  758. * Affichage des commentaires.
  759. */
  760. function comments() {
  761. $this->template['infos']['title'] = 'gestion des commentaires';
  762. // Trie des commentaires : ordre.
  763. if (isset($_REQUEST['sort']) && preg_match('`^commentaire_(auteur|date|mail|ip|web)|image_chemin$`', $_REQUEST['sort']) && $_REQUEST['sort'] != $this->config['admin_comment_ordre']) {
  764. $this->template['infos']['comment_sort'] = $_REQUEST['sort'];
  765. $this->update_option('admin_comment_ordre', $_REQUEST['sort']);
  766. } else {
  767. $this->template['infos']['comment_sort'] = $this->config['admin_comment_ordre'];
  768. }
  769. // Trie des commentaires : sens.
  770. if (isset($_REQUEST['sens']) && preg_match('`^ASC|DESC$`', $_REQUEST['sens']) && $_REQUEST['sens'] != $this->config['admin_comment_sens']) {
  771. $this->template['infos']['comment_sens'] = $_REQUEST['sens'];
  772. $this->update_option('admin_comment_sens', $_REQUEST['sens']);
  773. } else {
  774. $this->template['infos']['comment_sens'] = $this->config['admin_comment_sens'];
  775. }
  776. // Page ŕ afficher.
  777. if (isset($_REQUEST['startnum']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['startnum'])) {
  778. $startnum = $_REQUEST['startnum'];
  779. } else {
  780. $startnum = 0;
  781. }
  782. // Filtre.
  783. $filtre = $this->config['admin_comment_filtre'];
  784. if (isset($_REQUEST['filtre']) && preg_match('`^(tous|actif|inactif)$`', $_REQUEST['filtre']) && $filtre != $_REQUEST['filtre']) {
  785. $this->update_option('admin_comment_filtre', $_REQUEST['filtre']);
  786. $filtre = $_REQUEST['filtre'];
  787. $startnum = 0;
  788. }
  789. $this->template['infos']['comment_filtre'] = $filtre;
  790. switch ($filtre) {
  791. case 'actif' :
  792. $filtre = ' AND ' . MYSQL_PREF . 'commentaires.commentaire_visible = "1"';
  793. break;
  794. case 'inactif' :
  795. $filtre = ' AND ' . MYSQL_PREF . 'commentaires.commentaire_visible = "0"';
  796. break;
  797. default :
  798. $filtre = '';
  799. }
  800. // Nombre de commentaires par page.
  801. if (isset($_REQUEST['nb']) && preg_match('`^[1-9]\d{0,3}$`', $_REQUEST['nb']) && $_REQUEST['nb'] != $this->config['admin_comment_nb']) {
  802. $this->update_option('admin_comment_nb', $_REQUEST['nb']);
  803. $this->config['admin_comment_nb'] = $_REQUEST['nb'];
  804. $this->template['infos']['nb_comments'] = $_REQUEST['nb'];
  805. $startnum = 0;
  806. } else {
  807. $this->template['infos']['nb_comments'] = $this->config['admin_comment_nb'];
  808. }
  809. $this->template['infos']['startnum'] = $startnum;
  810. // Objet actuel.
  811. if (isset($_REQUEST['cat']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['cat'])) {
  812. $obj = $_REQUEST['cat'];
  813. $obj_type = 'cat';
  814. $obj_type_ext = 'categorie';
  815. } elseif (isset($_REQUEST['img']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['img'])) {
  816. $obj = $_REQUEST['img'];
  817. $obj_type = 'img';
  818. $obj_type_ext = 'image';
  819. } else {
  820. $obj = 1;
  821. $obj_type = 'cat';
  822. $obj_type_ext = 'categorie';
  823. }
  824. $this->template['infos']['section'] = 'section=commentaires&page=display&' . $obj_type . '=' . $obj;
  825. $this->template['infos']['obj'] = $obj;
  826. $this->template['infos']['obj_type'] = $obj_type;
  827. $mysql_requete = 'SELECT ' . $obj_type_ext . '_chemin,
  828. ' . $obj_type_ext . '_nom
  829. FROM ' . MYSQL_PREF . $obj_type_ext . 's
  830. WHERE ' . $obj_type_ext . '_id = "' . $obj . '"';
  831. $obj = $this->mysql->select($mysql_requete, 11);
  832. if (!is_array($obj)) {
  833. header('Location:index.php?section=commentaires&page=display');
  834. exit;
  835. }
  836. $obj_chemin = ($obj[$obj_type_ext . '_chemin'] == '.') ? '' : $obj[$obj_type_ext . '_chemin'];
  837. // Recherche.
  838. $this->template['infos']['recherche'] = '';
  839. $recherche = '';
  840. if (isset($_REQUEST['search'])) {
  841. if (isset($_REQUEST['s_accents'])) {
  842. $search_inputs['s_accents'] = '1';
  843. $this->template['infos']['recherche'] .= '&s_accents=on';
  844. }
  845. if (isset($_REQUEST['s_casse'])) {
  846. $search_inputs['s_casse'] = '1';
  847. $this->template['infos']['recherche'] .= '&s_casse=on';
  848. }
  849. if (isset($_REQUEST['s_tous'])) {
  850. $search_inputs['s_tous'] = '1';
  851. $this->template['infos']['recherche'] .= '&s_tous=on';
  852. }
  853. if (isset($_REQUEST['s_msg'])) {
  854. $search_inputs['s_msg'] = '1';
  855. $this->template['infos']['recherche'] .= '&s_msg=on';
  856. }
  857. if (isset($_REQUEST['s_auteur'])) {
  858. $search_inputs['s_auteur'] = '1';
  859. $this->template['infos']['recherche'] .= '&s_auteur=on';
  860. }
  861. if (isset($_REQUEST['s_ip'])) {
  862. $search_inputs['s_ip'] = '1';
  863. $this->template['infos']['recherche'] .= '&s_ip=on';
  864. }
  865. if (isset($_REQUEST['s_mail'])) {
  866. $search_inputs['s_mail'] = '1';
  867. $this->template['infos']['recherche'] .= '&s_mail=on';
  868. }
  869. if (isset($_REQUEST['s_web'])) {
  870. $search_inputs['s_web'] = '1';
  871. $this->template['infos']['recherche'] .= '&s_web=on';
  872. }
  873. // On affiche les messages des commentaires.
  874. $this->template['display']['comment_msg'] = 1;
  875. $search_inputs['search'] = outils::html_specialchars($_REQUEST['search']);
  876. $this->template['infos']['recherche'] .= '&search=' . urlencode($_REQUEST['search']);
  877. // Récupération de la requęte.
  878. $search = trim($_REQUEST['search']);
  879. $search = preg_replace('`-+`', '-', $search);
  880. $search = str_replace('- ', '', $search);
  881. $search = str_replace(' *', '', $search);
  882. $search = preg_replace('`\s+`', ' ', $search);
  883. // Méthodes Ť AND ť ou Ť OR ť.
  884. $method = (isset($_REQUEST['s_tous'])) ? 'AND' : 'OR';
  885. // Casse.
  886. $binary = (isset($_REQUEST['s_casse'])) ? 'BINARY ' : '';
  887. // Si ni la casse ni les accents comptent, on concertit tout en minuscule.
  888. if (!isset($_REQUEST['s_casse']) && !isset($_REQUEST['s_accents'])) {
  889. $search = strtolower($search);
  890. }
  891. // Paramčtres de recherche.
  892. $search = preg_split('`\s+(?!.*[^-\s]")`i', $search, -1, PREG_SPLIT_NO_EMPTY);
  893. $champs = array();
  894. $champs['message'] = '';
  895. $champs['auteur'] = '';
  896. $champs['ip'] = '';
  897. $champs['mail'] = '';
  898. $champs['web'] = '';
  899. for ($i = 0; $i < count($search); $i++) {
  900. // Suppression des guillemets.
  901. $terme = str_replace('"', '', $search[$i]);
  902. // Remplacement des espace par une suite de caractčres non-alpha-numérique.
  903. $terme = preg_replace('`[^-\w\*\?\'\s]+`', '?', $terme);
  904. // Doit-on ne pas faire de distinction pour les lettres accentuées ?
  905. $terme = (isset($_REQUEST['s_accents'])) ? $terme : outils::regexp_accents($terme);
  906. // Doit-on inclure ou exclure le terme ?
  907. $terme = ($search[$i]{0} == '-') ? substr($terme, 1) : $terme;
  908. $not = ($search[$i]{0} == '-') ? 'NOT ' : '';
  909. // Si le terme est vide, inutile d'aller plus loin.
  910. if (trim($terme) == '') {
  911. continue;
  912. }
  913. // Remplacement des espace par une suite de caractčres non-alpha-numérique.
  914. $terme = str_replace(' ', '[^[:alnum:]]', $terme);
  915. // Joker Ť * ť.
  916. $terme = str_replace('*', '[^[:space:]]*', $terme);
  917. // Joker Ť ? ť.
  918. $terme = str_replace('?', '.', $terme);
  919. // On ne recherche que des mots entiers.
  920. $terme = '([^[:alnum:]]|^)' . $terme . '([^[:alnum:]]|$)';
  921. // Champ message.
  922. if (isset($_REQUEST['s_msg'])) {
  923. $champs['message'] .= $method . ' ' . MYSQL_PREF . 'commentaires.commentaire_message ' . $not . 'REGEXP ' . $binary . '"' . outils::protege_mysql($terme, $this->mysql->lien) . '" ';
  924. }
  925. // Champ auteur.
  926. if (isset($_REQUEST['s_auteur'])) {
  927. $champs['auteur'] .= $method . ' ' . MYSQL_PREF . 'commentaires.commentaire_auteur ' . $not . 'REGEXP ' . $binary . '"' . outils::protege_mysql($terme, $this->mysql->lien) . '" ';
  928. }
  929. // Champ ip.
  930. if (isset($_REQUEST['s_ip'])) {
  931. $champs['ip'] .= $method . ' ' . MYSQL_PREF . 'commentaires.commentaire_ip ' . $not . 'REGEXP ' . $binary . '"' . outils::protege_mysql($terme, $this->mysql->lien) . '" ';
  932. }
  933. // Champ mail.
  934. if (isset($_REQUEST['s_mail'])) {
  935. $champs['mail'] .= $method . ' ' . MYSQL_PREF . 'commentaires.commentaire_mail ' . $not . 'REGEXP ' . $binary . '"' . outils::protege_mysql($terme, $this->mysql->lien) . '" ';
  936. }
  937. // Champ web.
  938. if (isset($_REQUEST['s_web'])) {
  939. $champs['web'] .= $method . ' ' . MYSQL_PREF . 'commentaires.commentaire_web ' . $not . 'REGEXP ' . $binary . '"' . outils::protege_mysql($terme, $this->mysql->lien) . '" ';
  940. }
  941. }
  942. // Champs de la table dans lesquels la recherche s'effectuera.
  943. $commentaires_champs = '';
  944. foreach ($champs as $v) {
  945. if ($v) {
  946. $commentaires_champs .= 'OR (' . preg_replace('`^(?:AND|OR) `', '', $v) . ') ';
  947. }
  948. }
  949. if ($commentaires_champs) {
  950. $commentaires_champs = '(' . preg_replace('`^OR `', '', $commentaires_champs) . ')';
  951. }
  952. // Date
  953. $commentaires_date = '';
  954. if (isset($_REQUEST['s_date']) && isset($_REQUEST['s_dnpc']) && isset($_REQUEST['s_dnpd'])
  955. && isset($_REQUEST['s_dnsc']) && isset($_REQUEST['s_dnsd'])) {
  956. $search_inputs['s_date'] = $_REQUEST['s_date'];
  957. $search_inputs['s_dnpc'] = $_REQUEST['s_dnpc'];
  958. $search_inputs['s_dnpd'] = $_REQUEST['s_dnpd'];
  959. $search_inputs['s_dnsc'] = $_REQUEST['s_dnsc'];
  960. $search_inputs['s_dnsd'] = $_REQUEST['s_dnsd'];
  961. $this->template['infos']['recherche'] .= '&s_date=on&s_dnpc=' . $_REQUEST['s_dnpc'];
  962. $this->template['infos']['recherche'] .= '&s_dnpd=' . $_REQUEST['s_dnpd'];
  963. $this->template['infos']['recherche'] .= '&s_dnsc=' . $_REQUEST['s_dnsc'];
  964. $this->template['infos']['recherche'] .= '&s_dnsd=' . $_REQUEST['s_dnsd'];
  965. $commentaires_date .= '' . MYSQL_PREF . 'commentaires.commentaire_date < ' . outils::time_date($_REQUEST['s_dnpc'], $_REQUEST['s_dnpd'])
  966. . ' AND ' . MYSQL_PREF . 'commentaires.commentaire_date > ' . outils::time_date($_REQUEST['s_dnsc'], $_REQUEST['s_dnsd']);
  967. }
  968. if ($commentaires_champs || $commentaires_date) {
  969. $and = ($commentaires_champs && $commentaires_date) ? ' AND ' : '';
  970. $recherche = ' AND (' . $commentaires_champs . $and . $commentaires_date . ')';
  971. }
  972. $this->template['comments']['search'] = $search_inputs;
  973. }
  974. // Sous-objets.
  975. $mysql_requete = 'SELECT categorie_id,categorie_nom,categorie_chemin FROM ' . MYSQL_PREF . 'categories
  976. WHERE categorie_chemin REGEXP "^' . $obj_chemin . '[^/]+/$"
  977. AND categorie_id > 1
  978. AND (categorie_commentaires > 0 OR categorie_commentaires_inactive > 0)';
  979. $sub_cat = $this->mysql->select($mysql_requete);
  980. if (is_array($sub_cat)) {
  981. for ($i = 0; $i < count($sub_cat); $i++) {
  982. $this->template['comments']['sub_item'][$i] = $sub_cat[$i];
  983. $this->template['display']['subcats'] = 1;
  984. $this->template['infos']['sub_objects'] = 'categorie';
  985. }
  986. } else {
  987. $mysql_requete = 'SELECT image_id,image_nom,image_chemin FROM ' . MYSQL_PREF . 'images
  988. WHERE image_chemin REGEXP "^' . $obj_chemin . '[^/]+$"
  989. AND image_commentaires > 0';
  990. $imgs = $this->mysql->select($mysql_requete);
  991. if (is_array($imgs)) {
  992. for ($i = 0; $i < count($imgs); $i++) {
  993. $this->template['comments']['sub_item'][$i] = $imgs[$i];
  994. $this->template['display']['subcats'] = 1;
  995. $this->template['infos']['sub_objects'] = 'image';
  996. }
  997. }
  998. }
  999. // Barre de position.
  1000. $this->template['comments']['position'] = '';
  1001. if ($obj_chemin) {
  1002. $parent = dirname($obj_chemin);
  1003. while ($parent != '.') {
  1004. $mysql_requete = 'SELECT categorie_id,categorie_chemin,categorie_nom
  1005. FROM ' . MYSQL_PREF . 'categories
  1006. WHERE categorie_chemin = "' . $parent . '/"';
  1007. $p_i = $this->mysql->select($mysql_requete, 11);
  1008. $parent = dirname($p_i['categorie_chemin']);
  1009. $this->template['comments']['position'] = '%sep<a href="index.php?section=commentaires&amp;page=display&amp;cat=' .
  1010. $p_i['categorie_id'] . htmlentities($this->template['infos']['recherche']) . '">' .
  1011. strip_tags($p_i['categorie_nom']) . '</a>' .
  1012. $this->template['comments']['position'];
  1013. }
  1014. }
  1015. $pos_actuel = ($this->template['infos']['obj'] > 1) ? '' : ' class="pos_actuel"' ;
  1016. $this->template['comments']['position'] = '<a' . $pos_actuel . ' href="index.php?section=commentaires&amp;page=display' .
  1017. htmlentities($this->template['infos']['recherche']) . '">galerie</a>' . $this->template['comments']['position'];
  1018. if ($this->template['infos']['obj'] > 1) {
  1019. $this->template['comments']['position'] .= '%sep<a href="index.php?section=commentaires&amp;page=display&amp;' . $obj_type . '=' .
  1020. $this->template['infos']['obj'] . htmlentities($this->template['infos']['recherche']) .
  1021. '" class="pos_actuel">' .
  1022. strip_tags($obj[$obj_type_ext . '_nom']) . '</a>';
  1023. }
  1024. // Récupération du nombre de commentaires de l'objet actuel.
  1025. $mysql_requete = 'SELECT COUNT(*)
  1026. FROM ' . MYSQL_PREF . 'commentaires INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)
  1027. WHERE ' . MYSQL_PREF . 'images.image_chemin LIKE "' . $obj_chemin . '%"'
  1028. . $recherche . $filtre;
  1029. if ($nc = $this->mysql->select($mysql_requete, 5)) {
  1030. $this->template['infos']['nb_objets'] = $nc;
  1031. } else {
  1032. $this->template['infos']['nb_objets'] = 0;
  1033. }
  1034. // On détermine le nombre de pages et la page actuelle.
  1035. $this->template['infos']['nb_pages'] = ceil(($this->template['infos']['nb_objets']) / $this->config['admin_comment_nb']);
  1036. for ($n = 0; $n < $this->template['infos']['nb_pages']; $n++) {
  1037. $num = $n * $this->config['admin_comment_nb'];
  1038. $this->template['nav']['pages'][$n + 1]['page'] = $num;
  1039. if ($num == $startnum) {
  1040. $this->template['infos']['page_actuelle'] = $n + 1;
  1041. }
  1042. }
  1043. // On détermine les pages suivantes, précédentes, de début et de fin.
  1044. $this->template['nav']['suivante'][1] = $startnum + $this->config['admin_comment_nb'];
  1045. $this->template['nav']['precedente'][1] = $startnum - $this->config['admin_comment_nb'];
  1046. $this->template['nav']['premiere'][1] = 0;
  1047. $this->template['nav']['derniere'][1] = ($this->template['infos']['nb_pages'] * $this->config['admin_comment_nb']) - $this->config['admin_comment_nb'];
  1048. // On détermine la position de l'objet actuel.
  1049. if ($startnum == 0) {
  1050. $this->template['nav']['premiere'][0] = 1;
  1051. }
  1052. if ($this->template['nav']['precedente'][1] < 0) {
  1053. $this->template['nav']['precedente'][0] = 1;
  1054. }
  1055. if ($this->template['nav']['suivante'][1] >= ($this->template['infos']['nb_pages'] * $this->config['admin_comment_nb']) ||
  1056. $this->template['nav']['suivante'][1] >= $this->template['infos']['nb_objets']) {
  1057. $this->template['nav']['suivante'][0] = 1;
  1058. }
  1059. if ($startnum >= $this->template['nav']['derniere'][1]) {
  1060. $this->template['nav']['derniere'][0] = 1;
  1061. }
  1062. // Récupération des informations des commentaires.
  1063. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'commentaires.*,
  1064. ' . MYSQL_PREF . 'categories.categorie_id,
  1065. ' . MYSQL_PREF . 'categories.categorie_nom,
  1066. ' . MYSQL_PREF . 'images.image_id,
  1067. ' . MYSQL_PREF . 'images.image_chemin,
  1068. ' . MYSQL_PREF . 'images.image_nom,
  1069. ' . MYSQL_PREF . 'images.image_hauteur,
  1070. ' . MYSQL_PREF . 'images.image_largeur,
  1071. ' . MYSQL_PREF . 'users.user_id,
  1072. ' . MYSQL_PREF . 'users.user_login,
  1073. ' . MYSQL_PREF . 'users.user_web,
  1074. ' . MYSQL_PREF . 'users.user_mail
  1075. FROM ' . MYSQL_PREF . 'categories,
  1076. ' . MYSQL_PREF . 'images,
  1077. ' . MYSQL_PREF . 'commentaires
  1078. LEFT JOIN ' . MYSQL_PREF . 'users
  1079. ON ' . MYSQL_PREF . 'commentaires.user_id = ' . MYSQL_PREF . 'users.user_id
  1080. WHERE ' . MYSQL_PREF . 'images.image_chemin LIKE "' . $obj_chemin . '%"
  1081. AND ' . MYSQL_PREF . 'commentaires.image_id = ' . MYSQL_PREF . 'images.image_id
  1082. AND ' . MYSQL_PREF . 'categories.categorie_id = ' . MYSQL_PREF . 'images.categorie_parent_id ' .
  1083. $recherche . $filtre . '
  1084. ORDER BY ' . $this->template['infos']['comment_sort'] . ' ' . $this->template['infos']['comment_sens'] . '
  1085. LIMIT ' . $startnum . ',' . $this->config['admin_comment_nb'] . '';
  1086. $comments = $this->mysql->select($mysql_requete);
  1087. if (!is_array($comments)) {
  1088. $this->template['display']['co_vide'] = 1;
  1089. $this->template['comments']['no_comments'] = 1;
  1090. if ($this->template['infos']['startnum']) {
  1091. header('Location:index.php?' . $this->template['infos']['section'] . $this->template['infos']['recherche']);
  1092. exit;
  1093. }
  1094. } else {
  1095. settype($this->template['comments'], 'array');
  1096. $this->template['comments'] = array_merge($this->template['comments'], $comments);
  1097. for ($i = 0; $i < count($comments); $i++) {
  1098. if (isset($this->config['admin_comment_ban']['auteurs'][$comments[$i]['commentaire_auteur']])) {
  1099. $this->template['comments'][$i]['ban_auteur'] = 1;
  1100. }
  1101. if (isset($this->config['admin_comment_ban']['IP'][$comments[$i]['commentaire_ip']])) {
  1102. $this->template['comments'][$i]['ban_ip'] = 1;
  1103. }
  1104. }
  1105. }
  1106. $this->template['config']['admin_comment_ban'] = $this->config['admin_comment_ban'];
  1107. // Affichage des message.
  1108. if (isset($_REQUEST['o_msg_display'])) {
  1109. if ($_REQUEST['o_msg_display'] == 'montrer' && !$this->config['admin_comment_msg_display']) {
  1110. $this->update_option('admin_comment_msg_display', 1);
  1111. $this->template['display']['comment_msg'] = 1;
  1112. } elseif ($_REQUEST['o_msg_display'] == 'cacher' && $this->config['admin_comment_msg_display']) {
  1113. $this->update_option('admin_comment_msg_display', 0);
  1114. }
  1115. $this->template['config'] = $this->config;
  1116. }
  1117. if ($this->config['admin_comment_msg_display']) {
  1118. $this->template['display']['comment_msg'] = 1;
  1119. }
  1120. }
  1121. /*
  1122. * Options commentaires.
  1123. */
  1124. function comments_options() {
  1125. $this->template['infos']['title'] = 'options des commentaires';
  1126. if (isset($_REQUEST['u'])) {
  1127. $maj = 0;
  1128. // Elements obligatoires pour poster un commentaire.
  1129. if (isset($_REQUEST['oc_fac_mail']) && empty($this->config['comment_courriel'])) {
  1130. $this->update_option('comment_courriel', 1);
  1131. $maj = 1;
  1132. } elseif (empty($_REQUEST['oc_fac_mail']) && $this->config['comment_courriel']) {
  1133. $this->update_option('comment_courriel', 0);
  1134. $maj = 1;
  1135. }
  1136. if (isset($_REQUEST['oc_fac_web']) && empty($this->config['comment_siteweb'])) {
  1137. $this->update_option('comment_siteweb', 1);
  1138. $maj = 1;
  1139. } elseif (empty($_REQUEST['oc_fac_web']) && $this->config['comment_siteweb']) {
  1140. $this->update_option('comment_siteweb', 0);
  1141. $maj = 1;
  1142. }
  1143. // Contrôles.
  1144. if (isset($_POST['oc_pro_flood']) && preg_match('`^(0|[1-9]\d{0,3})$`', $_POST['oc_pro_flood'])
  1145. && $_POST['oc_pro_flood'] != $this->config['comment_antiflood']) {
  1146. $this->update_option('comment_antiflood', $_POST['oc_pro_flood']);
  1147. $maj = 1;
  1148. }
  1149. if (isset($_REQUEST['oc_samemsg']) && empty($this->config['comment_samemsg'])) {
  1150. $this->update_option('comment_samemsg', 1);
  1151. $maj = 1;
  1152. } elseif (empty($_REQUEST['oc_samemsg']) && $this->config['comment_samemsg']) {
  1153. $this->update_option('comment_samemsg', 0);
  1154. $maj = 1;
  1155. }
  1156. if (isset($_REQUEST['oc_maxmsg']) && empty($this->config['comment_maxmsg'])) {
  1157. $this->update_option('comment_maxmsg', 1);
  1158. $maj = 1;
  1159. } elseif (empty($_REQUEST['oc_maxmsg']) && $this->config['comment_maxmsg']) {
  1160. $this->update_option('comment_maxmsg', 0);
  1161. $maj = 1;
  1162. }
  1163. if (isset($_POST['oc_maxmsg_nb']) && preg_match('`^(0|[1-9]\d{0,3})$`', $_POST['oc_maxmsg_nb'])
  1164. && $_POST['oc_maxmsg_nb'] != $this->config['comment_maxmsg_nb']) {
  1165. $this->update_option('comment_maxmsg_nb', $_POST['oc_maxmsg_nb']);
  1166. $maj = 1;
  1167. }
  1168. if (isset($_REQUEST['oc_nourl']) && empty($this->config['comment_nourl'])) {
  1169. $this->update_option('comment_nourl', 1);
  1170. $maj = 1;
  1171. } elseif (empty($_REQUEST['oc_nourl']) && $this->config['comment_nourl']) {
  1172. $this->update_option('comment_nourl', 0);
  1173. $maj = 1;
  1174. }
  1175. if (isset($_POST['oc_nourl_nb']) && preg_match('`^(0|[1-9]\d{0,3})$`', $_POST['oc_nourl_nb'])
  1176. && $_POST['oc_nourl_nb'] != $this->config['comment_maxurl']) {
  1177. $this->update_option('comment_maxurl', $_POST['oc_nourl_nb']);
  1178. $maj = 1;
  1179. }
  1180. // Modération des commentaires.
  1181. if (isset($_REQUEST['oc_mod']) && empty($this->config['admin_comment_moderer'])) {
  1182. $this->update_option('admin_comment_moderer', 1);
  1183. $maj = 1;
  1184. } elseif (empty($_REQUEST['oc_mod']) && $this->config['admin_comment_moderer']) {
  1185. $this->update_option('admin_comment_moderer', 0);
  1186. $maj = 1;
  1187. }
  1188. // Alerte par courriel.
  1189. if (!empty($_REQUEST['oc_objet']) && $_REQUEST['oc_objet'] != $this->config['admin_comment_objet']) {
  1190. $this->update_option('admin_comment_objet', $_REQUEST['oc_objet']);
  1191. $maj = 1;
  1192. }
  1193. if (isset($_REQUEST['oc_alert']) && empty($this->config['admin_comment_alert'])) {
  1194. $this->update_option('admin_comment_alert', 1);
  1195. $maj = 1;
  1196. } elseif (empty($_REQUEST['oc_alert']) && $this->config['admin_comment_alert']) {
  1197. $this->update_option('admin_comment_alert', 0);
  1198. $maj = 1;
  1199. }
  1200. // Page des commentaires.
  1201. if ($this->template['enabled']['co_page_comments']) {
  1202. if (isset($_REQUEST['oc_comments']) && empty($this->config['galerie_page_comments'])) {
  1203. $this->update_option('galerie_page_comments', 1);
  1204. $maj = 1;
  1205. } elseif (empty($_REQUEST['oc_comments']) && $this->config['galerie_page_comments']) {
  1206. $this->update_option('galerie_page_comments', 0);
  1207. $maj = 1;
  1208. }
  1209. if (isset($_REQUEST['oc_comments_nb']) && preg_match('`^[1-9]\d{0,3}$`', $_REQUEST['oc_comments_nb'])
  1210. && $_REQUEST['oc_comments_nb'] != $this->config['galerie_page_comments_nb']) {
  1211. $this->update_option('galerie_page_comments_nb', $_REQUEST['oc_comments_nb']);
  1212. $this->config['galerie_page_comments_nb'] = $_REQUEST['oc_comments_nb'];
  1213. $maj = 1;
  1214. }
  1215. }
  1216. $this->template['action_maj'] = $maj;
  1217. }
  1218. // Config.
  1219. $this->template['config'] = $this->config;
  1220. }
  1221. /*
  1222. * Commentaires : bannissements.
  1223. */
  1224. function comments_bans() {
  1225. $this->template['infos']['title'] = 'rčgles de bannissement des commentaires';
  1226. // Bannissements.
  1227. $ban_update = 0;
  1228. if (!empty($_POST['bans_mots_ajout'])) {
  1229. $mots = trim($_POST['bans_mots_ajout']);
  1230. if ($mots != '') {
  1231. $mots = preg_split('`[\r\n]+`', $mots, -1, PREG_SPLIT_NO_EMPTY);
  1232. for ($i = 0; $i < count($mots); $i++) {
  1233. $mots[$i] = strtolower($mots[$i]);
  1234. if (!isset($this->config['admin_comment_ban']['mots-cles'][$mots[$i]])) {
  1235. $this->config['admin_comment_ban']['mots-cles'][$mots[$i]] = 1;
  1236. $ban_update = 1;
  1237. }
  1238. }
  1239. }
  1240. }
  1241. if (!empty($_POST['bans_auteur_ajout'])) {
  1242. $auteurs = trim($_POST['bans_auteur_ajout']);
  1243. if ($auteurs != '') {
  1244. $auteurs = preg_split('`[\r\n]+`', $auteurs, -1, PREG_SPLIT_NO_EMPTY);
  1245. for ($i = 0; $i < count($auteurs); $i++) {
  1246. $auteurs[$i] = strtolower($auteurs[$i]);
  1247. if (!isset($this->config['admin_comment_ban']['auteurs'][$auteurs[$i]])) {
  1248. $this->config['admin_comment_ban']['auteurs'][$auteurs[$i]] = 1;
  1249. $ban_update = 1;
  1250. }
  1251. }
  1252. }
  1253. }
  1254. if (!empty($_POST['bans_ip_ajout'])) {
  1255. $ip = trim($_POST['bans_ip_ajout']);
  1256. if ($ip != '') {
  1257. $ip = preg_split('`[\r\n]+`', $ip, -1, PREG_SPLIT_NO_EMPTY);
  1258. for ($i = 0; $i < count($ip); $i++) {
  1259. $ip[$i] = strtolower($ip[$i]);
  1260. if (!isset($this->config['admin_comment_ban']['IP'][$ip[$i]])) {
  1261. $this->config['admin_comment_ban']['IP'][$ip[$i]] = 1;
  1262. $ban_update = 1;
  1263. }
  1264. }
  1265. }
  1266. }
  1267. // Ré-autorisations.
  1268. $unban_update = 0;
  1269. if (isset($_POST['bans_allow_select'])) {
  1270. if (isset($_POST['bans_mots']) && is_array($_POST['bans_mots'])) {
  1271. $mots = $_POST['bans_mots'];
  1272. for ($i = 0; $i < count($mots); $i++) {
  1273. if (isset($this->config['admin_comment_ban']['mots-cles'][$mots[$i]])) {
  1274. unset($this->config['admin_comment_ban']['mots-cles'][$mots[$i]]);
  1275. $unban_update = 1;
  1276. }
  1277. }
  1278. }
  1279. if (isset($_POST['bans_auteurs']) && is_array($_POST['bans_auteurs'])) {
  1280. $auteurs = $_POST['bans_auteurs'];
  1281. for ($i = 0; $i < count($auteurs); $i++) {
  1282. if (isset($this->config['admin_comment_ban']['auteurs'][$auteurs[$i]])) {
  1283. unset($this->config['admin_comment_ban']['auteurs'][$auteurs[$i]]);
  1284. $unban_update = 1;
  1285. }
  1286. }
  1287. }
  1288. if (isset($_POST['bans_ip']) && is_array($_POST['bans_ip'])) {
  1289. $ip = $_POST['bans_ip'];
  1290. for ($i = 0; $i < count($ip); $i++) {
  1291. if (isset($this->config['admin_comment_ban']['IP'][$ip[$i]])) {
  1292. unset($this->config['admin_comment_ban']['IP'][$ip[$i]]);
  1293. $unban_update = 1;
  1294. }
  1295. }
  1296. }
  1297. }
  1298. // Enregistrement des changements..
  1299. if ($ban_update || $unban_update) {
  1300. $this->update_option('admin_comment_ban', serialize($this->config['admin_comment_ban']), 0);
  1301. $this->template['action_maj'] = 1;
  1302. }
  1303. // Config.
  1304. $this->template['config'] = $this->config;
  1305. }
  1306. /*
  1307. * Vérifie si une option de type "mot" ou "nombre" doit ętre updatée, puis l'UPDATE.
  1308. */
  1309. function verif_option_word($param, $option, $type, $plus = '', $r = 0) {
  1310. switch ($type) {
  1311. case 'libre' :
  1312. $pattern = '`^[^\x5C' . $plus . ']{0,65535}$`si';
  1313. break;
  1314. case 'mot' :
  1315. $pattern = '`^[-a-z0-9_' . $plus . ']{1,99}$`i';
  1316. break;
  1317. case 'nombre' :
  1318. $pattern = '`^\d{1,9}$`';
  1319. break;
  1320. }
  1321. if (isset($_REQUEST[$param]) && preg_match($pattern, $_REQUEST[$param]) && $this->config[$option] != $_REQUEST[$param]) {
  1322. if ($this->update_option($option, $_REQUEST[$param])) {
  1323. if ($r) {
  1324. $this->template['action_maj'] = $r;
  1325. }
  1326. return true;
  1327. }
  1328. }
  1329. return false;
  1330. }
  1331. /*
  1332. * Vérifie si une option de type "binaire" doit ętre updatée, puis l'UPDATE.
  1333. */
  1334. function verif_option_bin($get, $option, $r = 0) {
  1335. if (isset($_REQUEST[$get]) && empty($this->config[$option])) {
  1336. if ($this->update_option($option, 1)) {
  1337. if ($r) {
  1338. $this->template['action_maj'] = $r;
  1339. }
  1340. return true;
  1341. }
  1342. } elseif (empty($_REQUEST[$get]) && $this->config[$option]) {
  1343. if ($this->update_option($option, 0)) {
  1344. if ($r) {
  1345. $this->template['action_maj'] = $r;
  1346. }
  1347. return true;
  1348. }
  1349. }
  1350. return false;
  1351. }
  1352. /*
  1353. * Vidage du cache.
  1354. */
  1355. function vidage_cache() {
  1356. $cache_dir = '../cache/';
  1357. $ok = FALSE;
  1358. if (is_dir($cache_dir)) {
  1359. if ($dir = @opendir($cache_dir)) {
  1360. $ok = TRUE;
  1361. while ($ent = readdir($dir)) {
  1362. $file = $cache_dir . $ent;
  1363. if (is_file($file) && $ent != '.htaccess') {
  1364. if (!files::suppFile($file)) {
  1365. $ok = FALSE;
  1366. }
  1367. }
  1368. }
  1369. closedir($dir);
  1370. }
  1371. }
  1372. return $ok;
  1373. }
  1374. /*
  1375. * Options : général.
  1376. */
  1377. function options_general() {
  1378. $this->template['infos']['title'] = 'paramétrage de la galerie';
  1379. if (isset($_POST['u'])) {
  1380. $conf = $this->recup_conf();
  1381. $change = 0;
  1382. // Liens.
  1383. if ($this->template['enabled']['liens']) {
  1384. $this->verif_option_bin('g_liens_active', 'active_liens', 1);
  1385. if (isset($_POST['g_liens'])) {
  1386. $liens = preg_split('`[\r\n]+`', $_POST['g_liens'], -1, PREG_SPLIT_NO_EMPTY);
  1387. $_REQUEST['g_liens'] = serialize($liens);
  1388. if ($_REQUEST['g_liens'] != $this->config['galerie_liens']) {
  1389. $this->verif_option_word('g_liens', 'galerie_liens', 'libre', '', 1);
  1390. }
  1391. }
  1392. }
  1393. // Format de la date.
  1394. $formats[1] = '%d-%m-%y';
  1395. $formats[2] = '%d/%m/%y';
  1396. $formats[3] = '%d-%m-%Y';
  1397. $formats[4] = '%d/%m/%Y';
  1398. $formats[5] = '%d %b %Y';
  1399. $formats[6] = '%d %B %Y';
  1400. $formats[7] = '%a %d %b %Y';
  1401. $formats[8] = '%a %d %B %Y';
  1402. $formats[9] = '%A %d %b %Y';
  1403. $formats[10] = '%A %d %B %Y';
  1404. if ($this->template['enabled']['date_format_thumbs']) {
  1405. $_REQUEST['g_ftbdate'] = $formats[$_REQUEST['g_ftbdate']];
  1406. $this->verif_option_word('g_ftbdate', 'galerie_tb_date_format', 'libre', '', 1);
  1407. }
  1408. if ($this->template['enabled']['date_format_images']) {
  1409. $_REQUEST['g_fimdate'] = $formats[$_REQUEST['g_fimdate']];
  1410. $this->verif_option_word('g_fimdate', 'galerie_im_date_format', 'libre', '', 1);
  1411. }
  1412. // Template.
  1413. if (!empty($_POST['g_theme']) && GALERIE_THEME != $_POST['g_theme']
  1414. && preg_match('`^[a-z0-9_-]{1,99}$`i', $_POST['g_theme'])
  1415. && is_dir('../template/' . $_POST['g_theme'])) {
  1416. $change = 1;
  1417. $conf['galerie_theme'] = $_POST['g_theme'];
  1418. $this->config['galerie_template'] = $_POST['g_theme'];
  1419. include(dirname(__FILE__) . '/../template/' . $_POST['g_theme'] . '/_fonctions.php');
  1420. $this->template['enabled'] = $f;
  1421. }
  1422. // Style.
  1423. if (!empty($_POST['g_style']) && GALERIE_STYLE != $_POST['g_style']
  1424. && preg_match('`^[a-z0-9_-]{1,99}$`i', $_POST['g_style'])
  1425. && is_dir('../template/' . $this->config['galerie_template'] . '/style/' . $_POST['g_style'])) {
  1426. $change = 1;
  1427. $conf['galerie_style'] = $_POST['g_style'];
  1428. $this->config['galerie_style'] = $_POST['g_style'];
  1429. }
  1430. // Style addtionnel.
  1431. if (trim($_POST['g_add_style']) != $this->config['galerie_add_style']) {
  1432. $this->verif_option_word('g_add_style', 'galerie_add_style', 'libre', '', 1);
  1433. }
  1434. // URL de la galerie.
  1435. if (!empty($_POST['g_url_galerie']) && $_POST['g_url_galerie'] != GALERIE_URL) {
  1436. $change = 1;
  1437. $_POST['g_url_galerie'] = preg_replace('`^http://[^/]+/`', '/', $_POST['g_url_galerie']);
  1438. $_POST['g_url_galerie'] = str_replace(' ', '%20', $_POST['g_url_galerie']);
  1439. $conf['galerie_url'] = $_POST['g_url_galerie'];
  1440. $this->config['galerie_url'] = $_POST['g_url_galerie'];
  1441. $galerie_path = dirname($_POST['g_url_galerie']);
  1442. $galerie_path = (preg_match('`^[./]*$`', $galerie_path)) ? '' : $galerie_path;
  1443. $galerie_path = preg_replace('`/+$`', '', $galerie_path);
  1444. $galerie_path = preg_replace('[\x5c]', '', $galerie_path);
  1445. $conf['galerie_path'] = $galerie_path;
  1446. $this->config['galerie_path'] = $galerie_path;
  1447. }
  1448. // Type d'URL.
  1449. if (!empty($_POST['g_url_type']) && GALERIE_URL_TYPE != $_POST['g_url_type']
  1450. && preg_match('`^(normal|query_string|path_info|url_rewrite)$`i', $_POST['g_url_type'])) {
  1451. $change = 1;
  1452. $conf['galerie_url_type'] = $_POST['g_url_type'];
  1453. $this->config['galerie_url_type'] = $_POST['g_url_type'];
  1454. }
  1455. // Intégration ?
  1456. if (!empty($_POST['g_integrated']) && !GALERIE_INTEGRATED) {
  1457. $change = 1;
  1458. $conf['galerie_integrated'] = 1;
  1459. $this->config['galerie_integrated'] = 1;
  1460. }
  1461. if (empty($_POST['g_integrated']) && GALERIE_INTEGRATED) {
  1462. $change = 1;
  1463. $conf['galerie_integrated'] = 0;
  1464. $this->config['galerie_integrated'] = 0;
  1465. }
  1466. // Non prises en compte des visites admin.
  1467. $anh_active = false;
  1468. $anh_cookie = false;
  1469. if ($this->verif_option_bin('g_admin_hits', 'admin_no_hits', 1)) {
  1470. if ($this->config['admin_no_hits']) {
  1471. $anh_active = true;
  1472. }
  1473. }
  1474. if ($this->verif_option_word('g_admin_hits_mode', 'admin_no_hits_mode', 'mot', '', 1)) {
  1475. if ($this->config['admin_no_hits_mode'] == 'cookie') {
  1476. $anh_cookie = true;
  1477. }
  1478. }
  1479. if ($_POST['g_admin_hits_ip_addr'] != $this->config['admin_no_hits_ip']) {
  1480. if (preg_match('`^(?:' . outils::http_url('IP') . ',?)+$`', trim($_POST['g_admin_hits_ip_addr']))) {
  1481. $this->verif_option_word('g_admin_hits_ip_addr', 'admin_no_hits_ip', 'libre', '', 1);
  1482. }
  1483. }
  1484. if ((($anh_active && $this->config['admin_no_hits_mode'] == 'cookie') || $anh_cookie)
  1485. && $this->config['admin_no_hits']) {
  1486. $prefs = new cookie(31536000, 'galerie_perso', $conf['galerie_path']);
  1487. $prefs->ajouter('anh', md5($this->config['galerie_key']));
  1488. $prefs->ecrire();
  1489. }
  1490. // Mise ŕ jour du fichier de configuration.
  1491. if ($change) {
  1492. if ($this->update_conf($conf, 0)) {
  1493. $this->template['action_maj'] = 1;
  1494. }
  1495. }
  1496. }
  1497. // Récupération des thčmes.
  1498. $i = 0;
  1499. $template = dirname(__FILE__) . '/../template/';
  1500. if ($rep = @opendir($template)) {
  1501. while ($ent = readdir($rep)) {
  1502. if (is_dir($template . $ent) && !preg_match('`^\.{1,2}$`', $ent)) {
  1503. if (preg_match('`^[a-z0-9-_]+$`i', $ent)) {
  1504. $this->template['themes'][$i] = $ent;
  1505. $this->template['js_themes_styles'][$ent] = array();
  1506. $i++;
  1507. }
  1508. }
  1509. }
  1510. closedir($rep);
  1511. }
  1512. // Récupération des styles.
  1513. foreach ($this->template['js_themes_styles'] as $themes => $styles) {
  1514. $i = 0;
  1515. $style_rep = dirname(__FILE__) . '/../template/' . $themes . '/style/';
  1516. if ($rep = @opendir($style_rep)) {
  1517. while ($ent = readdir($rep)) {
  1518. if (is_dir($style_rep . $ent) && !preg_match('`^\.{1,2}$`', $ent)) {
  1519. if (preg_match('`^[a-z0-9-_]+$`i', $ent)) {
  1520. $this->template['js_themes_styles'][$themes][$i] = $ent;
  1521. if ($themes == $this->config['galerie_template']) {
  1522. $this->template['styles'][$i] = $ent;
  1523. }
  1524. $i++;
  1525. }
  1526. }
  1527. }
  1528. closedir($rep);
  1529. }
  1530. }
  1531. // Config.
  1532. $this->template['config'] = $this->config;
  1533. }
  1534. /*
  1535. * Options : vignettes.
  1536. */
  1537. function options_vignettes() {
  1538. $this->template['infos']['title'] = 'paramčtres des vignettes';
  1539. $this->config['galerie_tb_alb_size'] = THUMB_ALB_SIZE;
  1540. $this->config['galerie_tb_img_size'] = THUMB_IMG_SIZE;
  1541. $this->config['galerie_tb_alb_crop_width'] = THUMB_ALB_CROP_WIDTH;
  1542. $this->config['galerie_tb_alb_crop_height'] = THUMB_ALB_CROP_HEIGHT;
  1543. $this->config['galerie_tb_img_crop_width'] = THUMB_IMG_CROP_WIDTH;
  1544. $this->config['galerie_tb_img_crop_height'] = THUMB_IMG_CROP_HEIGHT;
  1545. $this->config['galerie_tb_alb_mode'] = THUMB_ALB_MODE;
  1546. $this->config['galerie_tb_img_mode'] = THUMB_IMG_MODE;
  1547. if (isset($_POST['u'])) {
  1548. $conf = $this->recup_conf();
  1549. // Nombre de vignettes.
  1550. $this->verif_option_word('g_tb_img_vn', 'vignettes_col', 'nombre', '', 1);
  1551. $this->verif_option_word('g_tb_img_vl', 'vignettes_line', 'nombre', '', 1);
  1552. $this->verif_option_word('g_tb_cat_vn', 'vignettes_cat_col', 'nombre', '', 1);
  1553. $this->verif_option_word('g_tb_cat_vl', 'vignettes_cat_line', 'nombre', '', 1);
  1554. // Ordre et sens d'affichage des vignettes des images.
  1555. $this->verif_option_word('g_ordre', 'vignettes_ordre', 'mot', '*', 1);
  1556. $this->verif_option_word('g_sens', 'vignettes_sens', 'mot', '', 1);
  1557. // Ordre et sens d'affichage des vignettes des albums.
  1558. if (isset($_POST['g_cat_ordre']) && preg_match('`^[a-z]{2,15}$`i', $_POST['g_cat_ordre']) &&
  1559. isset($_POST['g_cat_sens']) && preg_match('`^[a-z]{3,4}$`i', $_POST['g_cat_sens'])) {
  1560. $cat_trie = 'categorie_' . $_POST['g_cat_ordre'] . ' ' . $_POST['g_cat_sens'];
  1561. if ($_POST['g_cat_ordre'] == 'nom') {
  1562. $cat_trie = $cat_trie . ',categorie_date DESC';
  1563. } else {
  1564. $cat_trie = $cat_trie . ',categorie_nom ASC';
  1565. }
  1566. $_REQUEST['g_cat_ordre'] = $cat_trie;
  1567. $this->verif_option_word('g_cat_ordre', 'vignettes_cat_ordre', 'libre', '', 1);
  1568. }
  1569. if (isset($_POST['g_tb_cat_type']) && preg_match('`^(alb|cat|sans)$`', $_POST['g_tb_cat_type'])) {
  1570. if ($_POST['g_tb_cat_type'] == 'alb') {
  1571. $cat_type = 'type DESC,';
  1572. } elseif ($_POST['g_tb_cat_type'] == 'cat') {
  1573. $cat_type = 'type ASC,';
  1574. } else {
  1575. $cat_type = '';
  1576. }
  1577. $_REQUEST['g_tb_cat_type'] = $cat_type;
  1578. $this->verif_option_word('g_tb_cat_type', 'vignettes_cat_type', 'libre', '', 1);
  1579. }
  1580. // Mode d'affichage des vignettes des catégories.
  1581. if ($this->template['enabled']['thumbs_display_mode']) {
  1582. $this->verif_option_word('g_tb_cat_mode', 'vignettes_cat_mode', 'mot', '', 1);
  1583. }
  1584. // Informations sous les vignettes.
  1585. if ($this->template['enabled']['thumbs_infos']) {
  1586. $this->verif_option_bin('g_info_c_nom', 'display_cat_nom', 1);
  1587. $this->verif_option_bin('g_info_c_imgs', 'display_cat_nb_images', 1);
  1588. $this->verif_option_bin('g_info_c_poids', 'display_cat_poids', 1);
  1589. $this->verif_option_bin('g_info_c_hits', 'display_cat_hits', 1);
  1590. $this->verif_option_bin('g_info_c_comments', 'display_cat_comments', 1);
  1591. $this->verif_option_bin('g_info_c_votes', 'display_cat_votes', 1);
  1592. $this->verif_option_bin('g_info_i_nom', 'display_img_nom', 1);
  1593. $this->verif_option_bin('g_info_i_date', 'display_img_date', 1);
  1594. $this->verif_option_bin('g_info_i_taille', 'display_img_taille', 1);
  1595. $this->verif_option_bin('g_info_i_poids', 'display_img_poids', 1);
  1596. $this->verif_option_bin('g_info_i_hits', 'display_img_hits', 1);
  1597. $this->verif_option_bin('g_info_i_comments', 'display_img_comments', 1);
  1598. $this->verif_option_bin('g_info_i_votes', 'display_img_votes', 1);
  1599. }
  1600. // Dimensions des vignettes des albums.
  1601. $del_thumbs = 0;
  1602. $change = 0;
  1603. $new_conf = $this->post_config($conf, THUMB_ALB_MODE, 'g_tb_alb_mode', 'galerie_tb_alb_mode', 'thumb_alb_mode', '`^(?:size|crop)$`');
  1604. $new_conf = $this->post_config($new_conf, THUMB_ALB_SIZE, 'g_tb_alb_size', 'galerie_tb_alb_size', 'thumb_alb_size', '`^([5-9]\d|[1-2]\d\d|300)$`');
  1605. $new_conf = $this->post_config($new_conf, THUMB_ALB_CROP_WIDTH, 'g_tb_alb_crop_width', 'galerie_tb_alb_crop_width', 'thumb_alb_crop_width', '`^([5-9]\d|[1-2]\d\d|300)$`');
  1606. $new_conf = $this->post_config($new_conf, THUMB_ALB_CROP_HEIGHT, 'g_tb_alb_crop_height', 'galerie_tb_alb_crop_height', 'thumb_alb_crop_height', '`^([5-9]\d|[1-2]\d\d|300)$`');
  1607. if ($new_conf != $conf) {
  1608. $conf = $new_conf;
  1609. $change = 1;
  1610. $this->del_thumbs(THUMB_TDIR, 0, 2);
  1611. }
  1612. // Dimensions des vignettes des images.
  1613. $new_conf = $this->post_config($conf, THUMB_IMG_MODE, 'g_tb_img_mode', 'galerie_tb_img_mode', 'thumb_img_mode', '`^(?:size|crop)$`');
  1614. $new_conf = $this->post_config($new_conf, THUMB_IMG_SIZE, 'g_tb_img_size', 'galerie_tb_img_size', 'thumb_img_size', '`^([5-9]\d|[1-2]\d\d|300)$`');
  1615. $new_conf = $this->post_config($new_conf, THUMB_IMG_CROP_WIDTH, 'g_tb_img_crop_width', 'galerie_tb_img_crop_width', 'thumb_img_crop_width', '`^([5-9]\d|[1-2]\d\d|300)$`');
  1616. $new_conf = $this->post_config($new_conf, THUMB_IMG_CROP_HEIGHT, 'g_tb_img_crop_height', 'galerie_tb_img_crop_height', 'thumb_img_crop_height', '`^([5-9]\d|[1-2]\d\d|300)$`');
  1617. if ($new_conf != $conf) {
  1618. $conf = $new_conf;
  1619. $change = 1;
  1620. $this->del_thumbs(THUMB_TDIR, 0, 1);
  1621. }
  1622. // Mise ŕ jour du fichier de configuration.
  1623. if ($change) {
  1624. $this->update_conf($conf, 0);
  1625. }
  1626. }
  1627. // Config.
  1628. $this->template['config'] = $this->config;
  1629. }
  1630. /*
  1631. * Traitement des options du fichier de configuration.
  1632. */
  1633. function post_config($conf_file, $constante, $post, $config, $conf_file_data, $regexp) {
  1634. if (isset($_POST[$post]) && preg_match($regexp, $_POST[$post])
  1635. && $constante != $_POST[$post]) {
  1636. $conf_file[$conf_file_data] = $_POST[$post];
  1637. $this->config[$config] = $_POST[$post];
  1638. $this->template['action_maj'] = 1;
  1639. }
  1640. return $conf_file;
  1641. }
  1642. /*
  1643. * Options : images.
  1644. */
  1645. function options_images() {
  1646. $this->template['infos']['title'] = 'paramčtres des images';
  1647. // Récupération des paramčtres de la fonction d'ajout de texte sur les images.
  1648. $this->config['itext'] = IMG_TEXTE;
  1649. $itext_params = preg_split('` `', IMG_TEXTE_PARAMS, -1, PREG_SPLIT_NO_EMPTY);
  1650. if (isset($_POST['u'])) {
  1651. $conf = $this->recup_conf();
  1652. $change = 0;
  1653. // Mode d'affichage des images.
  1654. $this->verif_option_word('g_img', 'galerie_images_window', 'nombre', '', 1);
  1655. // Redimensionnement des images : mode.
  1656. $this->verif_option_word('g_img_resize', 'galerie_images_resize', 'nombre', '', 1);
  1657. // Redimensionnement des images : taille max. HTML.
  1658. if (!empty($_POST['g_resize_max_html_largeur']) && !empty($_POST['g_resize_max_html_hauteur'])
  1659. && preg_match('`^\d{2,4}$`', $_POST['g_resize_max_html_largeur']) && preg_match('`^\d{2,4}$`', $_POST['g_resize_max_html_hauteur'])
  1660. && $_POST['g_resize_max_html_largeur'] . 'x' . $_POST['g_resize_max_html_hauteur'] != $this->config['galerie_images_resize_max_html']) {
  1661. $_REQUEST['galerie_images_resize_max_html'] = $_POST['g_resize_max_html_largeur'] . 'x' . $_POST['g_resize_max_html_hauteur'];
  1662. $this->verif_option_word('galerie_images_resize_max_html', 'galerie_images_resize_max_html', 'libre', '', 1);
  1663. }
  1664. // Redimensionnement des images : taille max. GD.
  1665. if (!empty($_POST['g_resize_max_gd_largeur']) && !empty($_POST['g_resize_max_gd_hauteur'])
  1666. && preg_match('`^\d{2,4}$`', $_POST['g_resize_max_gd_largeur']) && preg_match('`^\d{2,4}$`', $_POST['g_resize_max_gd_hauteur'])
  1667. && $_POST['g_resize_max_gd_largeur'] . 'x' . $_POST['g_resize_max_gd_hauteur'] != $this->config['img_resize_gd']) {
  1668. $conf['img_resize_gd'] = $_POST['g_resize_max_gd_largeur'] . 'x' . $_POST['g_resize_max_gd_hauteur'];
  1669. $this->config['img_resize_gd'] = $conf['img_resize_gd'];
  1670. $change = 1;
  1671. $this->template['action_maj'] = 1;
  1672. $this->vidage_cache();
  1673. }
  1674. // Meta-données EXIF.
  1675. if ($this->template['enabled']['exif']) {
  1676. $this->verif_option_bin('g_exif_active', 'active_exif', 1);
  1677. $this->verif_option_bin('g_exif_ajouts', 'active_exif_ajout', 1);
  1678. }
  1679. // Meta-données IPTC.
  1680. if ($this->template['enabled']['iptc']) {
  1681. $this->verif_option_bin('g_iptc_active', 'active_iptc', 1);
  1682. $this->verif_option_bin('g_iptc_ajouts', 'active_iptc_ajout', 1);
  1683. }
  1684. // Images récentes.
  1685. if ($this->template['enabled']['recentes']) {
  1686. $this->verif_option_bin('g_recentes', 'display_recentes', 1);
  1687. $this->verif_option_word('g_jours', 'galerie_recent', 'nombre', '', 1);
  1688. $this->verif_option_bin('g_recent_nb', 'galerie_recent_nb', 1);
  1689. }
  1690. // Texte sur chaque image : activation de la fonctionnalité.
  1691. $htaccess_file = '../' . GALERIE_ALBUMS . '/.htaccess';
  1692. if ((isset($_REQUEST['g_itext_active']) && !IMG_TEXTE)) {
  1693. $change = 1;
  1694. $conf['img_texte'] = 1;
  1695. $this->config['itext'] = 1;
  1696. // On supprime le fichier .htaccess interdisant l'accčs aux images de l'album.
  1697. if (file_exists($htaccess_file)) {
  1698. files::suppFile($htaccess_file);
  1699. }
  1700. // On crée un fichier .htaccess interdisant l'accčs aux images de l'album.
  1701. files::chmodDir(dirname($htaccess_file));
  1702. if ($htaccess = @fopen($htaccess_file, 'w')) {
  1703. $instruction = "Deny from all";
  1704. if (!@fwrite($htaccess, $instruction)) {
  1705. $this->template['infos']['erreur']['change_config'] = 'Impossible de créer le fichier .htaccess afin de protéger les images.';
  1706. }
  1707. @fclose($htaccess);
  1708. files::chmodFile($htaccess_file);
  1709. } else {
  1710. $this->template['infos']['erreur']['change_config'] = 'Impossible de créer le fichier .htaccess afin de protéger les images.';
  1711. }
  1712. } elseif ((empty($_REQUEST['g_itext_active']) && IMG_TEXTE)) {
  1713. $change = 1;
  1714. $conf['img_texte'] = 0;
  1715. $this->config['itext'] = 0;
  1716. // On supprime le fichier .htaccess interdisant l'accčs aux images de l'album.
  1717. if (file_exists($htaccess_file)) {
  1718. files::suppFile($htaccess_file);
  1719. }
  1720. }
  1721. // Texte sur chaque image : texte.
  1722. if (isset($_REQUEST['g_itext_texte'])) {
  1723. $_REQUEST['g_itext_texte'] = trim($_REQUEST['g_itext_texte']);
  1724. if ($_REQUEST['g_itext_texte'] === '') {
  1725. $_REQUEST['g_itext_texte'] = ' ';
  1726. }
  1727. if ($_REQUEST['g_itext_texte'] != str_replace('^', ' ', $itext_params[0])) {
  1728. $change = 1;
  1729. $itext_params[0] = preg_replace('`[\x5c]`', '', $_REQUEST['g_itext_texte']);
  1730. $itext_params[0] = str_replace(' ', '^', $itext_params[0]);
  1731. }
  1732. }
  1733. // Mise ŕ jour du fichier de configuration.
  1734. if ($change) {
  1735. $conf['img_texte_params'] = implode(' ', $itext_params);
  1736. $this->config['itext_params'] = $conf['img_texte_params'];
  1737. $this->template['action_maj'] = 1;
  1738. $this->update_conf($conf, 0);
  1739. }
  1740. }
  1741. // Config.
  1742. $this->template['config'] = $this->config;
  1743. $this->template['config']['itext_params'] = $itext_params;
  1744. }
  1745. /*
  1746. * Options : paramčtre du texte sur chaque image.
  1747. */
  1748. function options_itext() {
  1749. $this->template['infos']['title'] = 'texte de copyright';
  1750. $itext_params = preg_split('` `', IMG_TEXTE_PARAMS, -1, PREG_SPLIT_NO_EMPTY);
  1751. if (isset($_POST['itext_params'])) {
  1752. $conf = $this->recup_conf();
  1753. $change = 0;
  1754. // Texte sur chaque image : taille du texte.
  1755. if ((isset($_REQUEST['g_itext_taille']) && preg_match('`^\d{1,2}$`', $_REQUEST['g_itext_taille']) && $_REQUEST['g_itext_taille'] != $itext_params[17])) {
  1756. $change = 1;
  1757. $itext_params[17] = $_REQUEST['g_itext_taille'];
  1758. }
  1759. // Texte sur chaque image : fonte.
  1760. if ((isset($_REQUEST['g_itext_fonte']) && preg_match('`^[a-z0-9_.-]+$`i', $_REQUEST['g_itext_fonte']) && $_REQUEST['g_itext_fonte'] != $itext_params[4])) {
  1761. $change = 1;
  1762. $itext_params[4] = $_REQUEST['g_itext_fonte'];
  1763. }
  1764. // Texte sur chaque image : couleur du texte.
  1765. $rgb_texte[0] = $itext_params[1];
  1766. $rgb_texte[1] = $itext_params[2];
  1767. $rgb_texte[2] = $itext_params[3];
  1768. if ((isset($_REQUEST['g_itext_texte_color']) && preg_match('`^#?[0-9a-f]{6}$`i', $_REQUEST['g_itext_texte_color']))) {
  1769. $request_texte = str_replace('#', '', $_REQUEST['g_itext_texte_color']);
  1770. if ($request_texte != outils::convert_rgb2html($rgb_texte)) {
  1771. $new_rgb_texte = outils::convert_html2rgb($request_texte);
  1772. $itext_params[1] = $new_rgb_texte[0];
  1773. $itext_params[2] = $new_rgb_texte[1];
  1774. $itext_params[3] = $new_rgb_texte[2];
  1775. $change = 1;
  1776. }
  1777. }
  1778. // Texte sur chaque image : position.
  1779. if ((isset($_REQUEST['g_itext_position']) && preg_match('`^(top_left|top_center|top_right|bottom_left|bottom_center|bottom_right)$`', $_REQUEST['g_itext_position']) && $_REQUEST['g_itext_position'] != $itext_params[5])) {
  1780. $change = 1;
  1781. $itext_params[5] = $_REQUEST['g_itext_position'];
  1782. }
  1783. // Texte sur chaque image : position - exterieur.
  1784. if ((isset($_REQUEST['g_itext_exterieur']) && preg_match('`^(0|1)$`', $_REQUEST['g_itext_exterieur']) && $_REQUEST['g_itext_exterieur'] != $itext_params[21])) {
  1785. $change = 1;
  1786. $itext_params[21] = $_REQUEST['g_itext_exterieur'];
  1787. }
  1788. // Texte sur chaque image : position - bord vertical.
  1789. if ((isset($_REQUEST['g_itext_bord_y']) && preg_match('`^-?\d{1,3}$`', $_REQUEST['g_itext_bord_y']) && $_REQUEST['g_itext_bord_y'] != $itext_params[19])) {
  1790. $change = 1;
  1791. $itext_params[19] = $_REQUEST['g_itext_bord_y'];
  1792. }
  1793. // Texte sur chaque image : position - bord horizontal.
  1794. if ((isset($_REQUEST['g_itext_bord_x']) && preg_match('`^-?\d{1,3}$`', $_REQUEST['g_itext_bord_x']) && $_REQUEST['g_itext_bord_x'] != $itext_params[18])) {
  1795. $change = 1;
  1796. $itext_params[18] = $_REQUEST['g_itext_bord_x'];
  1797. }
  1798. // Texte sur chaque image : position - décalage vertical.
  1799. if ((isset($_REQUEST['g_itext_decalage']) && preg_match('`^-?\d{1,3}$`', $_REQUEST['g_itext_decalage']) && $_REQUEST['g_itext_decalage'] != $itext_params[26])) {
  1800. $change = 1;
  1801. $itext_params[26] = $_REQUEST['g_itext_decalage'];
  1802. }
  1803. // Texte sur chaque image : fond.
  1804. if ((isset($_REQUEST['g_itext_fond']) && !$itext_params[6])) {
  1805. $change = 1;
  1806. $itext_params[6] = 1;
  1807. } elseif ((empty($_REQUEST['g_itext_fond']) && $itext_params[6])) {
  1808. $change = 1;
  1809. $itext_params[6] = 0;
  1810. }
  1811. // Texte sur chaque image : couleur de fond.
  1812. $rgb_fond[0] = $itext_params[7];
  1813. $rgb_fond[1] = $itext_params[8];
  1814. $rgb_fond[2] = $itext_params[9];
  1815. if ((isset($_REQUEST['g_itext_fond_color']) && preg_match('`^#?[0-9a-f]{6}$`i', $_REQUEST['g_itext_fond_color']))) {
  1816. $request_fond = str_replace('#', '', $_REQUEST['g_itext_fond_color']);
  1817. if ($request_fond != outils::convert_rgb2html($rgb_fond)) {
  1818. $new_rgb_fond = outils::convert_html2rgb($request_fond);
  1819. $itext_params[7] = $new_rgb_fond[0];
  1820. $itext_params[8] = $new_rgb_fond[1];
  1821. $itext_params[9] = $new_rgb_fond[2];
  1822. $change = 1;
  1823. }
  1824. }
  1825. // Texte sur chaque image : couleur de fond - transparence.
  1826. if ((isset($_REQUEST['g_itext_fond_a']) && preg_match('`^(\d{1,2}|1[0-1]\d|12[0-7])$`', $_REQUEST['g_itext_fond_a']) && $_REQUEST['g_itext_fond_a'] != $itext_params[10])) {
  1827. $change = 1;
  1828. $itext_params[10] = $_REQUEST['g_itext_fond_a'];
  1829. }
  1830. // Texte sur chaque image : fond - prendre toute la largeur.
  1831. if ((isset($_REQUEST['g_itext_fond_largeur']) && !$itext_params[11])) {
  1832. $change = 1;
  1833. $itext_params[11] = 1;
  1834. } elseif ((empty($_REQUEST['g_itext_fond_largeur']) && $itext_params[11])) {
  1835. $change = 1;
  1836. $itext_params[11] = 0;
  1837. }
  1838. // Texte sur chaque image : padding
  1839. if ((isset($_REQUEST['g_itext_padding']) && preg_match('`^\d{1,3}$`', $_REQUEST['g_itext_padding']) && $_REQUEST['g_itext_padding'] != $itext_params[20])) {
  1840. $change = 1;
  1841. $itext_params[20] = $_REQUEST['g_itext_padding'];
  1842. }
  1843. // Texte sur chaque image : bordure.
  1844. if ((isset($_REQUEST['g_itext_bordure']) && !$itext_params[22])) {
  1845. $change = 1;
  1846. $itext_params[22] = 1;
  1847. } elseif ((empty($_REQUEST['g_itext_bordure']) && $itext_params[22])) {
  1848. $change = 1;
  1849. $itext_params[22] = 0;
  1850. }
  1851. // Texte sur chaque image : couleur de bordure.
  1852. $rgb_bordure[0] = $itext_params[23];
  1853. $rgb_bordure[1] = $itext_params[24];
  1854. $rgb_bordure[2] = $itext_params[25];
  1855. if ((isset($_REQUEST['g_itext_bordure_color']) && preg_match('`^#?[0-9a-f]{6}$`i', $_REQUEST['g_itext_bordure_color']))) {
  1856. $request_bordure = str_replace('#', '', $_REQUEST['g_itext_bordure_color']);
  1857. if ($request_bordure != outils::convert_rgb2html($rgb_bordure)) {
  1858. $new_rgb_bordure = outils::convert_html2rgb($request_bordure);
  1859. $itext_params[23] = $new_rgb_bordure[0];
  1860. $itext_params[24] = $new_rgb_bordure[1];
  1861. $itext_params[25] = $new_rgb_bordure[2];
  1862. $change = 1;
  1863. }
  1864. }
  1865. // Texte sur chaque image : ombrage.
  1866. if ((isset($_REQUEST['g_itext_ombre']) && !$itext_params[12])) {
  1867. $change = 1;
  1868. $itext_params[12] = 1;
  1869. } elseif ((empty($_REQUEST['g_itext_ombre']) && $itext_params[12])) {
  1870. $change = 1;
  1871. $itext_params[12] = 0;
  1872. }
  1873. // Texte sur chaque image : couleur de l'ombrage.
  1874. $rgb_ombre[0] = $itext_params[14];
  1875. $rgb_ombre[1] = $itext_params[15];
  1876. $rgb_ombre[2] = $itext_params[16];
  1877. if ((isset($_REQUEST['g_itext_ombre_color']) && preg_match('`^#?[0-9a-f]{6}$`i', $_REQUEST['g_itext_ombre_color']))) {
  1878. $request_ombre = str_replace('#', '', $_REQUEST['g_itext_ombre_color']);
  1879. if ($request_ombre != outils::convert_rgb2html($rgb_ombre)) {
  1880. $new_rgb_ombre = outils::convert_html2rgb($request_ombre);
  1881. $itext_params[14] = $new_rgb_ombre[0];
  1882. $itext_params[15] = $new_rgb_ombre[1];
  1883. $itext_params[16] = $new_rgb_ombre[2];
  1884. $change = 1;
  1885. }
  1886. }
  1887. // Texte sur chaque image : épaisseur de l'ombrage.
  1888. if ((isset($_REQUEST['g_itext_ombre_width']) && preg_match('`^\d{1,2}$`', $_REQUEST['g_itext_ombre_width']) && $_REQUEST['g_itext_ombre_width'] != $itext_params[13])) {
  1889. $change = 1;
  1890. $itext_params[13] = $_REQUEST['g_itext_ombre_width'];
  1891. }
  1892. // Texte sur chaque image : qualité de l'image.
  1893. if ((isset($_REQUEST['g_itext_qualite']) && preg_match('`^(\d{1,2}|100)$`', $_REQUEST['g_itext_qualite']) && $_REQUEST['g_itext_qualite'] != $itext_params[27])) {
  1894. $change = 1;
  1895. $itext_params[27] = $_REQUEST['g_itext_qualite'];
  1896. }
  1897. // Mise ŕ jour du fichier de configuration.
  1898. if ($change) {
  1899. $conf['img_texte_params'] = implode(' ', $itext_params);
  1900. $this->config['itext_params'] = $conf['img_texte_params'];
  1901. $this->template['action_maj'] = 1;
  1902. $this->update_conf($conf, 0);
  1903. // On mesure la taille de la correction de hauteur des images.
  1904. $mysql_requete = 'SELECT image_chemin,image_hauteur FROM ' . MYSQL_PREF . 'images
  1905. WHERE image_chemin REGEXP "\.jpe?g$"
  1906. ORDER BY image_largeur*image_hauteur ASC
  1907. LIMIT 1';
  1908. if ($image_infos = $this->mysql->select($mysql_requete)) {
  1909. $image_file = $this->galerie_dir . $image_infos[0]['image_chemin'];
  1910. $image_temp = dirname(dirname(__FILE__)) . '/cache/temp_' . basename($image_infos[0]['image_chemin']);
  1911. $img_correction = 1;
  1912. $it_params = $itext_params;
  1913. include(dirname(__FILE__) . '/../getitext.php');
  1914. imagejpeg($image_texte, $image_temp, $it_params[27]);
  1915. imagedestroy($image_texte);
  1916. if (file_exists($image_temp)) {
  1917. files::chmodFile($image_temp);
  1918. @list($width, $height) = getimagesize($image_temp);
  1919. files::suppFile($image_temp);
  1920. if (!empty($height)) {
  1921. $diff = $height - $image_infos[0]['image_hauteur'];
  1922. if ($diff != $this->config['galerie_images_text_correction']) {
  1923. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'config
  1924. SET valeur = "' . $diff . '"
  1925. WHERE parametre = "galerie_images_text_correction"';
  1926. $this->mysql->requete($mysql_requete);
  1927. }
  1928. }
  1929. }
  1930. }
  1931. }
  1932. }
  1933. // Récupération des fontes.
  1934. if (isset($_GET['page']) && $_GET['page'] == 'itext_params') {
  1935. $i = 0;
  1936. $fonte_dir = '../fontes/';
  1937. if ($rep = opendir($fonte_dir)) {
  1938. while ($ent = readdir($rep)) {
  1939. if (is_file($fonte_dir . $ent)) {
  1940. if (preg_match('`^[a-z0-9_.-]+\.ttf$`i', $ent)) {
  1941. $this->template['fontes'][$i] = $ent;
  1942. $i++;
  1943. }
  1944. }
  1945. }
  1946. closedir($rep);
  1947. }
  1948. }
  1949. // Récupération des informations d'affichage de texte sur les images.
  1950. $this->template['config']['itext_params'] = $itext_params;
  1951. }
  1952. /*
  1953. * Options : IPTC.
  1954. */
  1955. function options_iptc() {
  1956. $this->template['infos']['title'] = 'informations IPTC';
  1957. // Réinitilaisation des paramčtres.
  1958. if (isset($_GET['reinit_params'])) {
  1959. $this->update_option('galerie_iptc_params', $this->config['galerie_iptc_params_default']);
  1960. $this->config['galerie_iptc_params'] = $this->config['galerie_iptc_params_default'];
  1961. $this->template['infos']['action']['reinit_params'] = 'Les paramčtres ont été réinitialisés.';
  1962. }
  1963. $iptc_champs = unserialize($this->config['galerie_iptc_params']);
  1964. if (isset($_POST['iptc_param_description'])) {
  1965. $change = false;
  1966. foreach ($_POST['iptc_param_description'] as $champ => $nom) {
  1967. $iptc_champ = '2#' . $champ;
  1968. if (!isset($iptc_champs[$iptc_champ])) {
  1969. continue;
  1970. }
  1971. $nom = trim($nom);
  1972. // Etat.
  1973. if (empty($_POST['iptc_param'][$champ]) && $iptc_champs[$iptc_champ]['active']) {
  1974. $iptc_champs[$iptc_champ]['active'] = 0;
  1975. $change = true;
  1976. }
  1977. if (!empty($_POST['iptc_param'][$champ]) && !$iptc_champs[$iptc_champ]['active']) {
  1978. $iptc_champs[$iptc_champ]['active'] = 1;
  1979. $change = true;
  1980. }
  1981. // Description.
  1982. if ($nom != $iptc_champs[$iptc_champ]['nom']) {
  1983. $iptc_champs[$iptc_champ]['nom'] = $nom;
  1984. $change = true;
  1985. }
  1986. }
  1987. if ($change) {
  1988. $new_iptc_champs = preg_replace('`[\x5c]`', '', serialize($iptc_champs));
  1989. $this->update_option('galerie_iptc_params', $new_iptc_champs);
  1990. $this->template['action_maj'] = 1;
  1991. }
  1992. }
  1993. $this->template['config']['infos_iptc'] = $iptc_champs;
  1994. }
  1995. /*
  1996. * Options : Exif.
  1997. */
  1998. function options_exif_sort($exif_params, $section, $reinit = 0) {
  1999. static $i = 0;
  2000. static $exif_sections = array();
  2001. if ($reinit) {
  2002. $i = 0;
  2003. $exif_sections = array();
  2004. }
  2005. if (isset($exif_params[$section])) {
  2006. ksort($exif_params[$section]);
  2007. foreach ($exif_params[$section] as $tag => $params) {
  2008. $exif_sections[$i] = $params;
  2009. $exif_sections[$i]['tag'] = $tag;
  2010. $exif_sections[$i]['section'] = $section;
  2011. $i++;
  2012. }
  2013. }
  2014. return $exif_sections;
  2015. }
  2016. function options_exif() {
  2017. // Réinitilaisation des paramčtres.
  2018. if (isset($_GET['reinit_params'])) {
  2019. $this->verifVID();
  2020. $this->update_option('galerie_exif_params', $this->config['galerie_exif_params_default']);
  2021. $this->config['galerie_exif_params'] = $this->config['galerie_exif_params_default'];
  2022. $this->template['infos']['action']['reinit_params'] = 'Les paramčtres ont été réinitialisés.';
  2023. }
  2024. $this->template['infos']['title'] = 'informations EXIF';
  2025. $exif_params = unserialize($this->config['galerie_exif_params']);
  2026. $masque_libre_court = '`^[éčëęŕäâáĺăďîěíöôňóőůűüú˙ýçńa-z\s\d&,;/%.:_#\(\)\'\"Ťť<>!?-]{1,60}$`i';
  2027. $masque_libre_court_zero = '`^[éčëęŕäâáĺăďîěíöôňóőůűüú˙ýçńa-z\s\d&,;/%.:_#\(\)\'\"Ťť<>!?-]{0,60}$`i';
  2028. $masque_libre_etendu = '`^[éčëęŕäâáĺăďîěíöôňóőůűüú˙ýçńa-z\s\d&,;/%.:_#\(\)\'\"Ťť<>!?-]{1,250}$`i';
  2029. // Nouveau paramčtre.
  2030. if (isset($_GET['new_param'])) {
  2031. $exif_params['IFD0']['0.NouveauTag']['new'] = 1;
  2032. $exif_params['IFD0']['0.NouveauTag']['active'] = 0;
  2033. $exif_params['IFD0']['0.NouveauTag']['desc'] = 'Nouvelle description';
  2034. $exif_params['IFD0']['0.NouveauTag']['method'] = 'simple';
  2035. }
  2036. // Suppression d'un paramčtre.
  2037. if (isset($_GET['delete']) && preg_match('`^(COMPUTED|IFD0|THUMBNAIL|EXIF|INTEROP)\.[a-z\d\.:_]{2,100}$`i', $_GET['delete'])) {
  2038. $this->verifVID();
  2039. $delete = split('\.', $_GET['delete'], 2);
  2040. list($section, $tag) = $delete;
  2041. if (isset($exif_params[$section][$tag])) {
  2042. unset($exif_params[$section][$tag]);
  2043. $this->update_option('galerie_exif_params', serialize($exif_params));
  2044. $this->template['infos']['action']['vidage_cache'] = 'Le tag Ť ' . $tag . ' ť de la section Ť ' . $section . ' ť a été supprimé.';
  2045. }
  2046. }
  2047. // Trie des sections.
  2048. $this->options_exif_sort($exif_params, 'COMPUTED');
  2049. $this->options_exif_sort($exif_params, 'IFD0');
  2050. $this->options_exif_sort($exif_params, 'THUMBNAIL');
  2051. $this->options_exif_sort($exif_params, 'EXIF');
  2052. $this->options_exif_sort($exif_params, 'INTEROP');
  2053. $this->template['config']['infos_exif'] = $this->options_exif_sort($exif_params, 'MAKERNOTE');
  2054. if (isset($_POST['exif_param_section'])) {
  2055. $modif = 0;
  2056. $change = 0;
  2057. $nouveau = 0;
  2058. foreach ($_POST['exif_param_section'] as $id => $section) {
  2059. if (!isset($_POST['exif_param_format'][$id])
  2060. || empty($_POST['exif_param_methode'][$id])
  2061. || empty($_POST['exif_param_description'][$id])
  2062. || !preg_match('`^(simple|date|nombre|liste|version)$`', $_POST['exif_param_methode'][$id])
  2063. || !preg_match($masque_libre_etendu, $_POST['exif_param_description'][$id])) {
  2064. continue;
  2065. }
  2066. // Est-ce que le tag existe dans la section spécifiée ?
  2067. if (isset($exif_params[$section]) && isset($exif_params[$section][$_POST['exif_param_tag'][$id]])) {
  2068. // Etat.
  2069. if (isset($_POST['exif_param'][$id]) && !$exif_params[$section][$_POST['exif_param_tag'][$id]]['active']) {
  2070. $exif_params[$section][$_POST['exif_param_tag'][$id]]['active'] = 1;
  2071. $change = 1;
  2072. } elseif (empty($_POST['exif_param'][$id]) && $exif_params[$section][$_POST['exif_param_tag'][$id]]['active']) {
  2073. $exif_params[$section][$_POST['exif_param_tag'][$id]]['active'] = 0;
  2074. $change = 1;
  2075. }
  2076. // Description.
  2077. if ($_POST['exif_param_description'][$id] != $exif_params[$section][$_POST['exif_param_tag'][$id]]['desc']) {
  2078. $exif_params[$section][$_POST['exif_param_tag'][$id]]['desc'] = $_POST['exif_param_description'][$id];
  2079. $change = 1;
  2080. }
  2081. // Méthode.
  2082. if ($_POST['exif_param_methode'][$id] != $exif_params[$section][$_POST['exif_param_tag'][$id]]['method']) {
  2083. $exif_params[$section][$_POST['exif_param_tag'][$id]]['method'] = $_POST['exif_param_methode'][$id];
  2084. $change = 1;
  2085. }
  2086. // Format : liste.
  2087. if ($_POST['exif_param_methode'][$id] == 'liste' && isset($_POST['exif_param_liste'][$id])
  2088. && isset($_POST['exif_param_liste'][$id]['tag']) && isset($_POST['exif_param_liste'][$id]['display'])) {
  2089. $liste = array();
  2090. foreach ($_POST['exif_param_liste'][$id]['tag'] as $id_list => $value) {
  2091. if (preg_match($masque_libre_court, $value) && preg_match($masque_libre_etendu, $id_list)) {
  2092. $liste[$value] = $_POST['exif_param_liste'][$id]['display'][$id_list];
  2093. }
  2094. }
  2095. if ($liste != @$exif_params[$section][$_POST['exif_param_tag'][$id]]['format']) {
  2096. $exif_params[$section][$_POST['exif_param_tag'][$id]]['format'] = $liste;
  2097. $change = 1;
  2098. }
  2099. }
  2100. // Format : normal.
  2101. if (($_POST['exif_param_methode'][$id] == 'date'
  2102. || $_POST['exif_param_methode'][$id] == 'simple'
  2103. || $_POST['exif_param_methode'][$id] == 'nombre')
  2104. && isset($_POST['exif_param_format'][$id])
  2105. && preg_match($masque_libre_court_zero, $_POST['exif_param_format'][$id])
  2106. && $_POST['exif_param_format'][$id] != @$exif_params[$section][$_POST['exif_param_tag'][$id]]['format']) {
  2107. if (empty($_POST['exif_param_format'][$id])) {
  2108. unset($exif_params[$section][$_POST['exif_param_tag'][$id]]['format']);
  2109. } else {
  2110. $exif_params[$section][$_POST['exif_param_tag'][$id]]['format'] = $_POST['exif_param_format'][$id];
  2111. }
  2112. $change = 1;
  2113. }
  2114. // Format : version.
  2115. if ($_POST['exif_param_methode'][$id] == 'version' && isset($exif_params[$section][$_POST['exif_param_tag'][$id]]['format'])) {
  2116. unset($exif_params[$section][$_POST['exif_param_tag'][$id]]['format']);
  2117. $change = 1;
  2118. }
  2119. // Nouveau tag.
  2120. } elseif (!empty($section) && preg_match('`^(COMPUTED|IFD0|THUMBNAIL|EXIF|INTEROP)$`', $section) && !empty($_POST['exif_param_tag'][$id])) {
  2121. $etat = (isset($_POST['exif_param'][$id])) ? 1 : 0;
  2122. $exif_params[$section][$_POST['exif_param_tag'][$id]]['active'] = $etat;
  2123. $exif_params[$section][$_POST['exif_param_tag'][$id]]['desc'] = $_POST['exif_param_description'][$id];
  2124. $exif_params[$section][$_POST['exif_param_tag'][$id]]['method'] = $_POST['exif_param_methode'][$id];
  2125. switch ($_POST['exif_param_methode'][$id]) {
  2126. case 'simple' :
  2127. case 'nombre' :
  2128. case 'date' :
  2129. if (!empty($_POST['exif_param_format'][$id]) && preg_match($masque_libre_etendu, $_POST['exif_param_format'][$id])) {
  2130. $exif_params[$section][$_POST['exif_param_tag'][$id]]['format'] = $_POST['exif_param_format'][$id];
  2131. }
  2132. break;
  2133. case 'liste' :
  2134. if (isset($_POST['exif_param_liste'][$id]['tag']) && isset($_POST['exif_param_liste'][$id]['display'])) {
  2135. $liste = array();
  2136. foreach ($_POST['exif_param_liste'][$id]['tag'] as $id_list => $value) {
  2137. if (preg_match($masque_libre_court, $value) && preg_match($masque_libre_etendu, $id_list)) {
  2138. $liste[$value] = $_POST['exif_param_liste'][$id]['display'][$id_list];
  2139. }
  2140. }
  2141. $exif_params[$section][$_POST['exif_param_tag'][$id]]['format'] = $liste;
  2142. }
  2143. break;
  2144. }
  2145. $change = 1;
  2146. $nouveau = 1;
  2147. }
  2148. if ($change) {
  2149. $modif = 1;
  2150. $change = 0;
  2151. }
  2152. }
  2153. // On supprime un ancien tag.
  2154. if ($nouveau) {
  2155. if (isset($_POST['exif_param_section']) && isset($_POST['exif_param_tag'])) {
  2156. $params_post = array();
  2157. for ($i = 0; $i < count($_POST['exif_param_section']); $i++) {
  2158. $params_post[$_POST['exif_param_section'][$i]][$_POST['exif_param_tag'][$i]] = 1;
  2159. }
  2160. foreach ($exif_params as $section => $tags) {
  2161. foreach ($tags as $tag => $params) {
  2162. if (empty($params_post[$section][$tag])) {
  2163. unset($exif_params[$section][$tag]);
  2164. }
  2165. }
  2166. }
  2167. }
  2168. }
  2169. // On met ŕ jour les paramčtres EXIF dans la base de données et dans le tableau de template.
  2170. if ($modif) {
  2171. $new_exif_params = preg_replace('`[\x5c]`', '', serialize($exif_params));
  2172. $this->update_option('galerie_exif_params', $new_exif_params);
  2173. $this->template['action_maj'] = 1;
  2174. $this->options_exif_sort($exif_params, 'COMPUTED', 1);
  2175. $this->options_exif_sort($exif_params, 'IFD0');
  2176. $this->options_exif_sort($exif_params, 'THUMBNAIL');
  2177. $this->options_exif_sort($exif_params, 'EXIF');
  2178. $this->options_exif_sort($exif_params, 'INTEROP');
  2179. unset($this->template['config']['infos_exif']);
  2180. $this->template['config']['infos_exif'] = $this->options_exif_sort($exif_params, 'MAKERNOTE');
  2181. }
  2182. }
  2183. }
  2184. /*
  2185. * Options : textes.
  2186. */
  2187. function options_textes() {
  2188. $this->template['infos']['title'] = 'textes de la galerie';
  2189. if (isset($_POST['u'])) {
  2190. // Titre.
  2191. $this->verif_option_word('g_galtitre', 'galerie_titre', 'libre', '', 1);
  2192. $this->verif_option_word('g_galtitre_court', 'galerie_titre_court', 'libre', '', 1);
  2193. // Message d'accueil.
  2194. if ($this->template['enabled']['message_accueil']) {
  2195. $this->verif_option_word('g_accueil', 'galerie_message_accueil', 'libre', '', 1);
  2196. }
  2197. // Footer.
  2198. if ($this->template['enabled']['message_accueil']) {
  2199. $this->verif_option_word('g_msg_footer_txt', 'galerie_message_footer', 'libre', '', 1);
  2200. $footer = '';
  2201. if (isset($_REQUEST['g_msg_footer'])) {
  2202. $footer .= '1';
  2203. }
  2204. if (isset($_REQUEST['g_cnt_footer'])) {
  2205. $footer .= '2';
  2206. }
  2207. if (empty($footer)) {
  2208. $footer = '0';
  2209. }
  2210. $_REQUEST['g_msg_footer'] = $footer;
  2211. $this->verif_option_word('g_msg_footer', 'galerie_footer', 'nombre', '', 1);
  2212. }
  2213. // Page contact.
  2214. if ($this->template['enabled']['contact']) {
  2215. $this->verif_option_word('g_contact_text', 'galerie_contact_text', 'libre', '', 1);
  2216. $this->verif_option_bin('g_contact', 'galerie_contact', 1);
  2217. }
  2218. // Message de fermeture de la galerie.
  2219. $this->verif_option_word('g_close_text', 'galerie_message_fermeture', 'libre', '', 1);
  2220. }
  2221. // Config.
  2222. $this->template['config'] = $this->config;
  2223. }
  2224. /*
  2225. * Options : fonctionnalités.
  2226. */
  2227. function options_fonctions() {
  2228. $this->template['infos']['title'] = 'fonctionnalités';
  2229. if (isset($_POST['u'])) {
  2230. if ($this->template['enabled']['commentaires']) {
  2231. $this->verif_option_bin('f_comment', 'active_commentaires', 1);
  2232. }
  2233. if ($this->template['enabled']['votes']) {
  2234. $this->verif_option_bin('f_votes', 'active_votes', 1);
  2235. }
  2236. if ($this->template['enabled']['image_hasard']) {
  2237. $this->verif_option_bin('f_imgh', 'galerie_image_hasard', 1);
  2238. }
  2239. if ($this->template['enabled']['perso']) {
  2240. $this->verif_option_bin('f_perso', 'user_perso', 1);
  2241. }
  2242. if ($this->template['enabled']['adv_search']) {
  2243. $this->verif_option_bin('f_adv_search', 'active_advsearch', 1);
  2244. }
  2245. if ($this->template['enabled']['historique']) {
  2246. $this->verif_option_bin('f_historique', 'active_historique', 1);
  2247. }
  2248. if ($this->template['enabled']['diaporama']) {
  2249. $this->verif_option_bin('f_diaporama', 'active_diaporama', 1);
  2250. $this->verif_option_bin('f_diaporama_gd_resize', 'galerie_diaporama_resize', 1);
  2251. }
  2252. if ($this->template['enabled']['rss']) {
  2253. $this->verif_option_bin('f_rss', 'active_rss', 1);
  2254. $this->verif_option_word('f_rss_nb', 'galerie_nb_rss', 'nombre', '', 1);
  2255. }
  2256. if ($this->template['enabled']['tags']) {
  2257. $this->verif_option_bin('f_tags', 'active_tags', 1);
  2258. $this->verif_option_word('f_tags_nb', 'galerie_nb_tags', 'nombre', '', 1);
  2259. }
  2260. // Config.
  2261. $this->template['config'] = $this->config;
  2262. }
  2263. }
  2264. /*
  2265. * Options : personnalisation.
  2266. */
  2267. function options_perso() {
  2268. $this->template['infos']['title'] = 'personnalisation';
  2269. if (isset($_POST['u'])) {
  2270. // Divers.
  2271. if ($this->template['enabled']['perso_style']) {
  2272. $this->verif_option_bin('g_perso_style', 'user_style', 1);
  2273. }
  2274. if ($this->template['enabled']['perso_recentes']) {
  2275. $this->verif_option_bin('g_perso_recents', 'user_recentes', 1);
  2276. }
  2277. if ($this->template['enabled']['perso_image_size']) {
  2278. $this->verif_option_bin('g_perso_ajust', 'user_image_ajust', 1);
  2279. }
  2280. if ($this->template['enabled']['perso_nb_thumbs']) {
  2281. $this->verif_option_bin('g_perso_thumbs', 'user_vignettes', 1);
  2282. }
  2283. if ($this->template['enabled']['perso_sort_thumbs']) {
  2284. $this->verif_option_bin('g_perso_ordre', 'user_ordre', 1);
  2285. }
  2286. // Informations sous les vignettes.
  2287. if ($this->template['enabled']['perso_cat_nom']) {
  2288. $this->verif_option_bin('g_perso_c_nom', 'user_nom_categories', 1);
  2289. }
  2290. if ($this->template['enabled']['perso_nb_images']) {
  2291. $this->verif_option_bin('g_perso_c_imgs', 'user_nb_images', 1);
  2292. }
  2293. if ($this->template['enabled']['perso_img_nom']) {
  2294. $this->verif_option_bin('g_perso_i_nom', 'user_nom_images', 1);
  2295. }
  2296. if ($this->template['enabled']['perso_date']) {
  2297. $this->verif_option_bin('g_perso_i_date', 'user_date', 1);
  2298. }
  2299. if ($this->template['enabled']['perso_taille']) {
  2300. $this->verif_option_bin('g_perso_i_taille', 'user_taille', 1);
  2301. }
  2302. if ($this->template['enabled']['perso_poids']) {
  2303. $this->verif_option_bin('g_perso_i_poids', 'user_poids', 1);
  2304. }
  2305. if ($this->template['enabled']['perso_hits']) {
  2306. $this->verif_option_bin('g_perso_i_hits', 'user_hits', 1);
  2307. }
  2308. if ($this->template['enabled']['perso_commentaires']) {
  2309. $this->verif_option_bin('g_perso_i_comments', 'user_comments', 1);
  2310. }
  2311. if ($this->template['enabled']['perso_votes']) {
  2312. $this->verif_option_bin('g_perso_i_votes', 'user_votes', 1);
  2313. }
  2314. // Config.
  2315. $this->template['config'] = $this->config;
  2316. }
  2317. }
  2318. /*
  2319. * Outils : images.
  2320. */
  2321. function outils_images() {
  2322. $this->template['infos']['title'] = 'outils';
  2323. if (isset($_GET['action'])) {
  2324. $this->verifVID();
  2325. // Suppression des vignettes.
  2326. if ($_GET['action'] == 'supp_thumb') {
  2327. if ($this->del_thumbs(THUMB_TDIR, 0)) {
  2328. $this->template['infos']['action']['delete_thumbs'] = 'Toutes les vignettes ont été supprimées.';
  2329. } else {
  2330. $this->template['infos']['erreur']['sup_vignettes'] = 'Toutes les vignettes n\'ont pas pu ętre supprimées.';
  2331. }
  2332. // Vidage du répertoire cache.
  2333. } elseif ($_GET['action'] == 'vide_cache') {
  2334. if ($this->vidage_cache()) {
  2335. $this->template['infos']['action']['vidage_cache'] = 'Le cache a été vidé.';
  2336. } else {
  2337. $this->template['infos']['erreur']['vidage_cache'] = 'Le cache n\'a pas pu ętre vidé.';
  2338. }
  2339. // Modification de la date de derničre modification de chaque répertoire.
  2340. } elseif ($_GET['action'] == 'change_date') {
  2341. $mysql_requete = 'SELECT categorie_chemin FROM ' . MYSQL_PREF . 'categories
  2342. ORDER BY categorie_chemin';
  2343. $categories = $this->mysql->select($mysql_requete);
  2344. for ($i = 0; $i < count($categories); $i++) {
  2345. @touch($this->galerie_dir . $categories[$i]['categorie_chemin'] . '~#~');
  2346. files::suppFile($this->galerie_dir . $categories[$i]['categorie_chemin'] . '~#~');
  2347. }
  2348. $this->template['rapport'] = '<div class="rapport_msg rapport_succes"><div><span>La date de derničre modification de tous les répertoires a été changée.</span></div></div><br />';
  2349. // Vérification des informations des albums.
  2350. } elseif ($_GET['action'] == 'verif_infos') {
  2351. $ok = TRUE;
  2352. $bad_infos = array();
  2353. // On récupčre toutes les informations de toutes les catégories.
  2354. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . 'categories
  2355. ORDER BY categorie_chemin';
  2356. $categories = $this->mysql->select($mysql_requete);
  2357. // On vérifie toutes les informations pour chaque catégorie.
  2358. for ($i = 0; $i < count($categories); $i++) {
  2359. $bad_infos[$i] = '';
  2360. $select_path = ($categories[$i]['categorie_chemin'] == '.') ? '' : $categories[$i]['categorie_chemin'];
  2361. // On sélectionne toutes les informations des images activées.
  2362. $mysql_requete = 'SELECT COUNT(*),
  2363. SUM(image_poids),
  2364. SUM(image_hits),
  2365. SUM(image_commentaires),
  2366. SUM(image_votes),
  2367. SUM(image_note*image_votes)/SUM(image_votes)
  2368. FROM ' . MYSQL_PREF . 'images
  2369. WHERE image_chemin LIKE "' . $select_path . '%"
  2370. AND image_visible = "1"';
  2371. $infos_actives = $this->mysql->select($mysql_requete, 2);
  2372. // On sélectionne toutes les informations des images désactivées.
  2373. $mysql_requete = 'SELECT COUNT(*),
  2374. SUM(image_poids),
  2375. SUM(image_hits),
  2376. SUM(image_commentaires),
  2377. SUM(image_votes),
  2378. SUM(image_note*image_votes)/SUM(image_votes)
  2379. FROM ' . MYSQL_PREF . 'images
  2380. WHERE image_chemin LIKE "' . $select_path . '%"
  2381. AND image_visible = "0"';
  2382. $infos_inactives = $this->mysql->select($mysql_requete, 2);
  2383. // Nombre d'images.
  2384. $nb_images_actives = ($infos_actives[0][0]) ? $infos_actives[0][0] : 0;
  2385. if ($nb_images_actives != $categories[$i]['categorie_images']) {
  2386. $ok = FALSE;
  2387. $bad_infos[$i] .= '<div class="verifinfos_err">Le nombre d\'images activées est erroné [<span class="rapport_erreur">' . $categories[$i]['categorie_images'] . '</span>/<span class="rapport_succes">' . $nb_images_actives . '</span>]</div>';
  2388. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  2389. SET categorie_images = "' . $nb_images_actives . '"
  2390. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  2391. if ($this->mysql->requete($mysql_requete)) {
  2392. $bad_infos[$i] .= '<span class="rapport_succes">=> Information corrigée.</span>';
  2393. } else {
  2394. $bad_infos[$i] .= '<span class="rapport_erreur">=> La mise ŕ jour a échouée.</span>';
  2395. }
  2396. }
  2397. // Nombre d'images désactivées.
  2398. $nb_images_inactives = ($infos_inactives[0][0]) ? $infos_inactives[0][0] : 0;
  2399. if ($nb_images_inactives != $categories[$i]['categorie_images_inactive']) {
  2400. $ok = FALSE;
  2401. $bad_infos[$i] .= '<div class="verifinfos_err">Le nombre d\'images désactivées est erroné [<span class="rapport_erreur">' . $categories[$i]['categorie_images_inactive'] . '</span>/<span class="rapport_succes">' . $nb_images_inactives . '</span>]</div>';
  2402. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  2403. SET categorie_images_inactive = "' . $nb_images_inactives . '"
  2404. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  2405. if ($this->mysql->requete($mysql_requete)) {
  2406. $bad_infos[$i] .= '<span class="rapport_succes">=> Information corrigée.</span>';
  2407. } else {
  2408. $bad_infos[$i] .= '<span class="rapport_erreur">=> La mise ŕ jour a échouée.</span>';
  2409. }
  2410. }
  2411. // Poids des images activées.
  2412. $poids_images_actives = ($infos_actives[0][1]) ? $infos_actives[0][1] : '0.0';
  2413. if ($poids_images_actives != $categories[$i]['categorie_poids']) {
  2414. $ok = FALSE;
  2415. $bad_infos[$i] .= '<div class="verifinfos_err">Le poids des images activées est erroné [<span class="rapport_erreur">' . outils::poids($categories[$i]['categorie_poids']) . '</span>/<span class="rapport_succes">' . outils::poids($poids_images_actives) . '</span>]</div>';
  2416. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  2417. SET categorie_poids = "' . $poids_images_actives . '"
  2418. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  2419. if ($this->mysql->requete($mysql_requete)) {
  2420. $bad_infos[$i] .= '<span class="rapport_succes">=> Information corrigée.</span>';
  2421. } else {
  2422. $bad_infos[$i] .= '<span class="rapport_erreur">=> La mise ŕ jour a échouée.</span>';
  2423. }
  2424. }
  2425. // Poids des images désactivées.
  2426. $poids_images_inactives = ($infos_inactives[0][1]) ? $infos_inactives[0][1] : '0.0';
  2427. if ($poids_images_inactives != $categories[$i]['categorie_poids_inactive']) {
  2428. $ok = FALSE;
  2429. $bad_infos[$i] .= '<div class="verifinfos_err">Le poids des images désactivées est erroné [<span class="rapport_erreur">' . outils::poids($categories[$i]['categorie_poids_inactive']) . '</span>/<span class="rapport_succes">' . outils::poids($poids_images_inactives) . '</span>]</div>';
  2430. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  2431. SET categorie_poids_inactive = "' . $poids_images_inactives . '"
  2432. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  2433. if ($this->mysql->requete($mysql_requete)) {
  2434. $bad_infos[$i] .= '<span class="rapport_succes">=> Information corrigée.</span>';
  2435. } else {
  2436. $bad_infos[$i] .= '<span class="rapport_erreur">=> La mise ŕ jour a échouée.</span>';
  2437. }
  2438. }
  2439. // Nombre de visites des images activées.
  2440. $nb_hits_actives = ($infos_actives[0][2]) ? $infos_actives[0][2] : '0';
  2441. if ($nb_hits_actives != $categories[$i]['categorie_hits']) {
  2442. $ok = FALSE;
  2443. $bad_infos[$i] .= '<div class="verifinfos_err">Le nombre de visites des images activées est erroné [<span class="rapport_erreur">' . $categories[$i]['categorie_hits'] . '</span>/<span class="rapport_succes">' . $nb_hits_actives . '</span>]</div>';
  2444. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  2445. SET categorie_hits = "' . $nb_hits_actives . '"
  2446. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  2447. if ($this->mysql->requete($mysql_requete)) {
  2448. $bad_infos[$i] .= '<span class="rapport_succes">=> Information corrigée.</span>';
  2449. } else {
  2450. $bad_infos[$i] .= '<span class="rapport_erreur">=> La mise ŕ jour a échouée.</span>';
  2451. }
  2452. }
  2453. // Nombre de visites des images désactivées.
  2454. $nb_hits_inactives = ($infos_inactives[0][2]) ? $infos_inactives[0][2] : '0';
  2455. if ($nb_hits_inactives != $categories[$i]['categorie_hits_inactive']) {
  2456. $ok = FALSE;
  2457. $bad_infos[$i] .= '<div class="verifinfos_err">Le nombre de visites des images désactivées est erroné [<span class="rapport_erreur">' . $categories[$i]['categorie_hits_inactive'] . '</span>/<span class="rapport_succes">' . $nb_hits_inactives . '</span>]</div>';
  2458. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  2459. SET categorie_hits_inactive = "' . $nb_hits_inactives . '"
  2460. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  2461. if ($this->mysql->requete($mysql_requete)) {
  2462. $bad_infos[$i] .= '<span class="rapport_succes">=> Information corrigée.</span>';
  2463. } else {
  2464. $bad_infos[$i] .= '<span class="rapport_erreur">=> La mise ŕ jour a échouée.</span>';
  2465. }
  2466. }
  2467. // Nombre de commentaires des images activées.
  2468. $nb_comments_actives = ($infos_actives[0][3]) ? $infos_actives[0][3] : '0';
  2469. if ($nb_comments_actives != $categories[$i]['categorie_commentaires']) {
  2470. $ok = FALSE;
  2471. $bad_infos[$i] .= '<div class="verifinfos_err">Le nombre de commentaires des images activées est erroné [<span class="rapport_erreur">' . $categories[$i]['categorie_commentaires'] . '</span>/<span class="rapport_succes">' . $nb_comments_actives . '</span>]</div>';
  2472. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  2473. SET categorie_commentaires = "' . $nb_comments_actives . '"
  2474. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  2475. if ($this->mysql->requete($mysql_requete)) {
  2476. $bad_infos[$i] .= '<span class="rapport_succes">=> Information corrigée.</span>';
  2477. } else {
  2478. $bad_infos[$i] .= '<span class="rapport_erreur">=> La mise ŕ jour a échouée.</span>';
  2479. }
  2480. }
  2481. // Nombre de commentaires des images désactivées.
  2482. $nb_comments_inactives = ($infos_inactives[0][3]) ? $infos_inactives[0][3] : '0';
  2483. if ($nb_comments_inactives != $categories[$i]['categorie_commentaires_inactive']) {
  2484. $ok = FALSE;
  2485. $bad_infos[$i] .= '<div class="verifinfos_err">Le nombre de commentaires des images désactivées est erroné [<span class="rapport_erreur">' . $categories[$i]['categorie_commentaires_inactive'] . '</span>/<span class="rapport_succes">' . $nb_comments_inactives . '</span>]</div>';
  2486. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  2487. SET categorie_commentaires_inactive = "' . $nb_comments_inactives . '"
  2488. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  2489. if ($this->mysql->requete($mysql_requete)) {
  2490. $bad_infos[$i] .= '<span class="rapport_succes">=> Information corrigée.</span>';
  2491. } else {
  2492. $bad_infos[$i] .= '<span class="rapport_erreur">=> La mise ŕ jour a échouée.</span>';
  2493. }
  2494. }
  2495. // Nombre de votes et note des images activées.
  2496. $nb_votes_actives = ($infos_actives[0][4]) ? $infos_actives[0][4] : '0';
  2497. $note_actives = ($infos_actives[0][5]) ? $infos_actives[0][5] : '0';
  2498. if ($nb_votes_actives != $categories[$i]['categorie_votes']) {
  2499. $ok = FALSE;
  2500. $bad_infos[$i] .= '<div class="verifinfos_err">Le nombre de votes des images activées est erroné [<span class="rapport_erreur">' . $categories[$i]['categorie_votes'] . '</span>/<span class="rapport_succes">' . $nb_votes_actives . '</span>]</div>';
  2501. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  2502. SET categorie_votes = "' . $nb_votes_actives . '",
  2503. categorie_note = "' . $note_actives . '"
  2504. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  2505. if ($this->mysql->requete($mysql_requete)) {
  2506. $bad_infos[$i] .= '<span class="rapport_succes">=> Information corrigée.</span>';
  2507. } else {
  2508. $bad_infos[$i] .= '<span class="rapport_erreur">=> La mise ŕ jour a échouée.</span>';
  2509. }
  2510. }
  2511. // Nombre de votes et note des images désactivées.
  2512. $nb_votes_inactives = ($infos_inactives[0][4]) ? $infos_inactives[0][4] : '0';
  2513. $note_inactives = ($infos_inactives[0][5]) ? $infos_inactives[0][5] : '0';
  2514. if ($nb_votes_inactives != $categories[$i]['categorie_votes_inactive']) {
  2515. $ok = FALSE;
  2516. $bad_infos[$i] .= '<div class="verifinfos_err">Le nombre de votes des images désactivées est erroné [<span class="rapport_erreur">' . $categories[$i]['categorie_votes_inactive'] . '</span>/<span class="rapport_succes">' . $nb_votes_inactives . '</span>]</div>';
  2517. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  2518. SET categorie_votes_inactive = "' . $nb_votes_inactives . '",
  2519. categorie_note_inactive = "' . $note_inactives . '"
  2520. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  2521. if ($this->mysql->requete($mysql_requete)) {
  2522. $bad_infos[$i] .= '<span class="rapport_succes">=> Information corrigée.</span>';
  2523. } else {
  2524. $bad_infos[$i] .= '<span class="rapport_erreur">=> La mise ŕ jour a échouée.</span>';
  2525. }
  2526. }
  2527. }
  2528. if ($ok) {
  2529. $this->template['rapport'] = '<div class="rapport_msg rapport_succes" id="verifinfos_ok"><div><span>Toutes les informations enregistrées semblent correctes.</span></div></div><br />';
  2530. } else {
  2531. $this->template['rapport'] = '<table id="verifinfos_errors">';
  2532. $this->template['rapport'] .= "\r\t\t\t\t" . '<tr><th>album ou catégorie</th><th>problčme</th></tr>';
  2533. foreach ($bad_infos as $k => $v) {
  2534. if ($v) {
  2535. $cat_nom = ($categories[$k]['categorie_nom'] == '') ? '<strong>galerie</strong>' : $categories[$k]['categorie_nom'];
  2536. $cat_chemin = ($categories[$k]['categorie_nom'] == '') ? '' : ' title="' . $categories[$k]['categorie_chemin'] . '"';
  2537. $this->template['rapport'] .= "\r\t\t\t\t" . '<tr><td class="verifinfos_cat"><a href="index.php?section=galerie&amp;page=gestion&amp;cat=' . $categories[$k]['categorie_id'] . '"' . $cat_chemin . '>' . $cat_nom . '</a></td><td class="verifinfos_prb">' . $v . '</td></tr>';
  2538. }
  2539. }
  2540. $this->template['rapport'] .= "\r\t\t\t" . '</table>';
  2541. }
  2542. // Vérification de l'intégrité de la table des images.
  2543. } elseif ($_GET['action'] == 'repare_images') {
  2544. // Vérification et réparation du champ categorie_parent_id.
  2545. $mysql_requete = 'SELECT categorie_parent_id FROM ' . MYSQL_PREF . 'images WHERE categorie_parent_id = "0" LIMIT 1';
  2546. if ($this->mysql->select($mysql_requete) != 'vide') {
  2547. $mysql_requete = 'SELECT categorie_id,categorie_chemin FROM ' . MYSQL_PREF . 'categories
  2548. WHERE categorie_derniere_modif != "0"';
  2549. $albums = $this->mysql->select($mysql_requete);
  2550. $ok = TRUE;
  2551. for ($i = 0; $i < count($albums); $i++) {
  2552. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images
  2553. SET categorie_parent_id = "' . $albums[$i]['categorie_id'] . '"
  2554. WHERE image_chemin LIKE "' . $albums[$i]['categorie_chemin'] . '%"
  2555. AND categorie_parent_id = "0"';
  2556. if (!$this->mysql->requete($mysql_requete)) {
  2557. $ok = FALSE;
  2558. }
  2559. }
  2560. if ($ok) {
  2561. $this->template['rapport'] = '<div class="rapport_msg rapport_succes" id="verifinfos_ok"><div><span>La table des images a été réparée.</span></div></div><br />';
  2562. } else {
  2563. $this->template['rapport'] = '<div class="rapport_msg rapport_erreur" id="verifinfos_ok"><div><span>La réparation de la table des images ŕ échouée.</span></div></div><br />';
  2564. }
  2565. } else {
  2566. $this->template['rapport'] = '<div class="rapport_msg rapport_succes" id="verifinfos_ok"><div><span>La table des images semble intacte.</span></div></div><br />';
  2567. }
  2568. // Optimisation des tables.
  2569. } elseif ($_GET['action'] == 'optimize_tables') {
  2570. $ok = true;
  2571. $mysql_requete = 'OPTIMIZE TABLE ' . MYSQL_PREF . 'config';
  2572. if (!$this->mysql->requete($mysql_requete)) {
  2573. $ok = FALSE;
  2574. }
  2575. $mysql_requete = 'OPTIMIZE TABLE ' . MYSQL_PREF . 'images';
  2576. if (!$this->mysql->requete($mysql_requete)) {
  2577. $ok = FALSE;
  2578. }
  2579. $mysql_requete = 'OPTIMIZE TABLE ' . MYSQL_PREF . 'categories';
  2580. if (!$this->mysql->requete($mysql_requete)) {
  2581. $ok = FALSE;
  2582. }
  2583. $mysql_requete = 'OPTIMIZE TABLE ' . MYSQL_PREF . 'commentaires';
  2584. if (!$this->mysql->requete($mysql_requete)) {
  2585. $ok = FALSE;
  2586. }
  2587. $mysql_requete = 'OPTIMIZE TABLE ' . MYSQL_PREF . 'votes';
  2588. if (!$this->mysql->requete($mysql_requete)) {
  2589. $ok = FALSE;
  2590. }
  2591. $mysql_requete = 'OPTIMIZE TABLE ' . MYSQL_PREF . 'tags';
  2592. if (!$this->mysql->requete($mysql_requete)) {
  2593. $ok = FALSE;
  2594. }
  2595. $mysql_requete = 'OPTIMIZE TABLE ' . MYSQL_PREF . 'membres';
  2596. if (!$this->mysql->requete($mysql_requete)) {
  2597. $ok = FALSE;
  2598. }
  2599. $mysql_requete = 'OPTIMIZE TABLE ' . MYSQL_PREF . 'groupes';
  2600. if (!$this->mysql->requete($mysql_requete)) {
  2601. $ok = FALSE;
  2602. }
  2603. $mysql_requete = 'OPTIMIZE TABLE ' . MYSQL_PREF . 'images_attente';
  2604. if (!$this->mysql->requete($mysql_requete)) {
  2605. $ok = FALSE;
  2606. }
  2607. $mysql_requete = 'OPTIMIZE TABLE ' . MYSQL_PREF . 'favoris';
  2608. if (!$this->mysql->requete($mysql_requete)) {
  2609. $ok = FALSE;
  2610. }
  2611. if ($ok) {
  2612. $this->template['rapport'] = '<div class="rapport_msg rapport_succes" id="verifinfos_ok"><div><span>Toutes les tables ont été optimisées.</span></div></div><br />';
  2613. } else {
  2614. $this->template['rapport'] = '<div class="rapport_msg rapport_erreur" id="verifinfos_ok"><div><span>L\'optimisation des tables a échouée.</span></div></div><br />';
  2615. }
  2616. }
  2617. }
  2618. }
  2619. /*
  2620. * Informations de galerie.
  2621. */
  2622. function infos() {
  2623. $this->template['infos']['title'] = 'infos galerie';
  2624. // Nombre d'images, de commentaires, de hits, de votes et poids.
  2625. $mysql_requete = 'SELECT categorie_poids,
  2626. categorie_images,
  2627. categorie_hits,
  2628. categorie_commentaires,
  2629. categorie_votes FROM ' . MYSQL_PREF . 'categories
  2630. WHERE categorie_id = "1"';
  2631. $nb_infos = $this->mysql->select($mysql_requete, 11);
  2632. // Nombre d'images, de commentaires, de hits, de votes et poids des images désactivées.
  2633. $mysql_requete = 'SELECT categorie_poids_inactive,
  2634. categorie_images_inactive,
  2635. categorie_hits_inactive,
  2636. categorie_commentaires_inactive,
  2637. categorie_votes_inactive FROM ' . MYSQL_PREF . 'categories
  2638. WHERE categorie_id = "1"';
  2639. $nb_infos_inactive = $this->mysql->select($mysql_requete, 11);
  2640. // Nombre d'albums activés.
  2641. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'categories
  2642. WHERE categorie_derniere_modif > 0
  2643. AND categorie_visible = "1"';
  2644. $nb_albums = $this->mysql->select($mysql_requete, 5);
  2645. // Nombre d'albums désactivés.
  2646. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'categories
  2647. WHERE categorie_derniere_modif > 0
  2648. AND categorie_visible != "1"';
  2649. $nb_albums_inactive = $this->mysql->select($mysql_requete, 5);
  2650. // Nombre d'albums protégés par un mot de passe activés.
  2651. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'categories
  2652. WHERE categorie_derniere_modif > 0
  2653. AND categorie_pass REGEXP "^.+$"
  2654. AND categorie_visible = "1"';
  2655. $nb_albums_pass = $this->mysql->select($mysql_requete, 5);
  2656. // Nombre d'albums protégés par un mot de passe désactivés.
  2657. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'categories
  2658. WHERE categorie_derniere_modif > 0
  2659. AND categorie_pass REGEXP "^.+$"
  2660. AND categorie_visible != "1"';
  2661. $nb_albums_pass_inactive = $this->mysql->select($mysql_requete, 5);
  2662. // Nombre de catégories activées.
  2663. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'categories
  2664. WHERE categorie_derniere_modif = "0"
  2665. AND categorie_id NOT IN (1)
  2666. AND categorie_visible = "1"';
  2667. $nb_categories = $this->mysql->select($mysql_requete, 5);
  2668. // Nombre de catégories désactivées.
  2669. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'categories
  2670. WHERE categorie_derniere_modif = "0"
  2671. AND categorie_id NOT IN (1)
  2672. AND categorie_visible != "1"';
  2673. $nb_categories_inactive = $this->mysql->select($mysql_requete, 5);
  2674. // Nombre de catégories protégées par un mot de passe activées.
  2675. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'categories
  2676. WHERE categorie_derniere_modif = "0"
  2677. AND categorie_id NOT IN (1)
  2678. AND categorie_pass REGEXP "^.+$"
  2679. AND categorie_visible = "1"';
  2680. $nb_categories_pass = $this->mysql->select($mysql_requete, 5);
  2681. // Nombre de catégories protégées par un mot de passe désactivées.
  2682. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'categories
  2683. WHERE categorie_derniere_modif = "0"
  2684. AND categorie_id NOT IN (1)
  2685. AND categorie_visible != "1"
  2686. AND categorie_pass REGEXP "^.+$"';
  2687. $nb_categories_pass_inactive = $this->mysql->select($mysql_requete, 5);
  2688. // Nombre d'images visitées.
  2689. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'images
  2690. WHERE image_hits > 0
  2691. AND image_visible = "1"';
  2692. $zero_hits = $this->mysql->select($mysql_requete, 5);
  2693. // Nombre d'images visitées désactivées.
  2694. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'images
  2695. WHERE image_hits > 0
  2696. AND image_visible = "0"';
  2697. $zero_hits_inactive = $this->mysql->select($mysql_requete, 5);
  2698. // Nombre d'images commentées activées.
  2699. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'images
  2700. WHERE image_commentaires > 0
  2701. AND image_visible = "1"';
  2702. $imgs_comments = $this->mysql->select($mysql_requete, 5);
  2703. // Nombre d'images commentées désactivées.
  2704. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'images
  2705. WHERE image_commentaires > 0
  2706. AND image_visible = "0"';
  2707. $imgs_comments_inactive = $this->mysql->select($mysql_requete, 5);
  2708. // Nombre d'images votées activées.
  2709. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'images
  2710. WHERE image_votes > 0
  2711. AND image_visible = "1"';
  2712. $imgs_vote = $this->mysql->select($mysql_requete, 5);
  2713. // Nombre d'images votées désactivées.
  2714. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'images
  2715. WHERE image_votes > 0
  2716. AND image_visible = "0"';
  2717. $imgs_vote_inactive = $this->mysql->select($mysql_requete, 5);
  2718. // Nombre d'images protégées par un mot de passe activées.
  2719. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'images
  2720. WHERE image_pass REGEXP "^.+$"
  2721. AND image_visible = "1"';
  2722. $imgs_pass = $this->mysql->select($mysql_requete, 5);
  2723. // Nombre d'images protégées par un mot de passe désactivées.
  2724. $mysql_requete = 'SELECT count(*) FROM ' . MYSQL_PREF . 'images
  2725. WHERE image_pass REGEXP "^.+$"
  2726. AND image_visible = "0"';
  2727. $imgs_pass_inactive = $this->mysql->select($mysql_requete, 5);
  2728. // Tags activés.
  2729. $mysql_requete = 'SELECT count(DISTINCT ' . MYSQL_PREF . 'tags.tag_id)
  2730. FROM ' . MYSQL_PREF . 'tags INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)
  2731. WHERE ' . MYSQL_PREF . 'images.image_visible = "1"';
  2732. $tags = $this->mysql->select($mysql_requete, 5);
  2733. // Tags désactivés.
  2734. $mysql_requete = 'SELECT count(DISTINCT ' . MYSQL_PREF . 'tags.tag_id)
  2735. FROM ' . MYSQL_PREF . 'tags INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)
  2736. WHERE ' . MYSQL_PREF . 'images.image_visible = "0"';
  2737. $tags_inactive = $this->mysql->select($mysql_requete, 5);
  2738. // Total de tags.
  2739. $mysql_requete = 'SELECT count(DISTINCT ' . MYSQL_PREF . 'tags.tag_id)
  2740. FROM ' . MYSQL_PREF . 'tags INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)';
  2741. $tags_total = $this->mysql->select($mysql_requete, 5);
  2742. // Nombre d'images taggées activées.
  2743. $mysql_requete = 'SELECT count(DISTINCT ' . MYSQL_PREF . 'images.image_id)
  2744. FROM ' . MYSQL_PREF . 'tags INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)
  2745. WHERE ' . MYSQL_PREF . 'images.image_visible = "1"
  2746. AND ' . MYSQL_PREF . 'images.image_tags != ""';
  2747. $imgs_tags = $this->mysql->select($mysql_requete, 5);
  2748. // Nombre d'images taggées déactivées.
  2749. $mysql_requete = 'SELECT count(DISTINCT ' . MYSQL_PREF . 'images.image_id)
  2750. FROM ' . MYSQL_PREF . 'tags INNER JOIN ' . MYSQL_PREF . 'images USING(image_id)
  2751. WHERE ' . MYSQL_PREF . 'images.image_visible = "0"
  2752. AND ' . MYSQL_PREF . 'images.image_tags != ""';
  2753. $imgs_tags_inactive = $this->mysql->select($mysql_requete, 5);
  2754. // Tableau de tous ces nombres.
  2755. $g_stats = '<table class="g_infos" id="g_infos_stats">';
  2756. $g_stats .= '<tr><th class="g_tpr"></th><th>activés</th><th>désactivés</th><th>total</th></tr>';
  2757. $g_stats .= '<tr><td class="g_tpr">Nombre d\'images</td><td>' . $nb_infos['categorie_images'] . '</td><td>' . $nb_infos_inactive['categorie_images_inactive'] . '</td><td>' . ($nb_infos['categorie_images'] + $nb_infos_inactive['categorie_images_inactive']) . '</td></tr>';
  2758. $g_stats .= '<tr><td class="g_tpr">Poids total des images</td><td>' . outils::poids($nb_infos['categorie_poids']) . '</td><td>' . outils::poids($nb_infos_inactive['categorie_poids_inactive']) . '</td><td>' . outils::poids(($nb_infos['categorie_poids'] + $nb_infos_inactive['categorie_poids_inactive'])) . '</td></tr>';
  2759. $g_stats .= '<tr><td class="g_tpr">Nombre d\'albums</td><td>' . $nb_albums . '</td><td>' . $nb_albums_inactive . '</td><td>' . ($nb_albums + $nb_albums_inactive) . '</td></tr>';
  2760. $g_stats .= '<tr><td class="g_tpr">Nombre d\'albums protégés</td><td>' . $nb_albums_pass . '</td><td>' . $nb_albums_pass_inactive . '</td><td>' . ($nb_albums_pass + $nb_albums_pass_inactive) . '</td></tr>';
  2761. $g_stats .= '<tr><td class="g_tpr">Nombre de catégories</td><td>' . $nb_categories . '</td><td>' . $nb_categories_inactive . '</td><td>' . ($nb_categories + $nb_categories_inactive) . '</td></tr>';
  2762. $g_stats .= '<tr><td class="g_tpr">Nombre de catégories protégées</td><td>' . $nb_categories_pass . '</td><td>' . $nb_categories_pass_inactive . '</td><td>' . ($nb_categories_pass + $nb_categories_pass_inactive) . '</td></tr>';
  2763. $g_stats .= '<tr><td class="g_tpr">Nombre de visites</td><td>' . $nb_infos['categorie_hits'] . '</td><td>' . $nb_infos_inactive['categorie_hits_inactive'] . '</td><td>' . ($nb_infos['categorie_hits'] + $nb_infos_inactive['categorie_hits_inactive']) . '</td></tr>';
  2764. $g_stats .= '<tr><td class="g_tpr">Nombre d\'images visitées</td><td>' . $zero_hits . '</td><td>' . $zero_hits_inactive . '</td><td>' . ($zero_hits + $zero_hits_inactive) . '</td></tr>';
  2765. $g_stats .= '<tr><td class="g_tpr">Nombre de commentaires</td><td>' . $nb_infos['categorie_commentaires'] . '</td><td>' . $nb_infos_inactive['categorie_commentaires_inactive'] . '</td><td>' . ($nb_infos['categorie_commentaires'] + $nb_infos_inactive['categorie_commentaires_inactive']) . '</td></tr>';
  2766. $g_stats .= '<tr><td class="g_tpr">Nombre d\'images commentées</td><td>' . $imgs_comments . '</td><td>' . $imgs_comments_inactive . '</td><td>' . ($imgs_comments + $imgs_comments_inactive) . '</td></tr>';
  2767. $g_stats .= '<tr><td class="g_tpr">Nombre de votes</td><td>' . $nb_infos['categorie_votes'] . '</td><td>' . $nb_infos_inactive['categorie_votes_inactive'] . '</td><td>' . ($nb_infos['categorie_votes'] + $nb_infos_inactive['categorie_votes_inactive']) . '</td></tr>';
  2768. $g_stats .= '<tr><td class="g_tpr">Nombre d\'images notées</td><td>' . $imgs_vote . '</td><td>' . $imgs_vote_inactive . '</td><td>' . ($imgs_vote + $imgs_vote_inactive) . '</td></tr>';
  2769. $g_stats .= '<tr><td class="g_tpr">Nombre d\'images protégées</td><td>' . $imgs_pass . '</td><td>' . $imgs_pass_inactive . '</td><td>' . ($imgs_pass + $imgs_pass_inactive) . '</td></tr>';
  2770. $g_stats .= '<tr><td class="g_tpr">Nombre de tags distincts</td><td>' . $tags . '</td><td>' . $tags_inactive . '</td><td>' . $tags_total . '</td></tr>';
  2771. $g_stats .= '<tr><td class="g_tpr">Nombre d\'images taggées</td><td>' . $imgs_tags . '</td><td>' . $imgs_tags_inactive . '</td><td>' . ($imgs_tags + $imgs_tags_inactive) . '</td></tr>';
  2772. $g_stats .= '</table>';
  2773. $this->template['infos']['g_stats'] = $g_stats;
  2774. }
  2775. /*
  2776. * Activation d'un objet de la galerie.
  2777. */
  2778. function galerie_action_active($infos) {
  2779. // On ne peut pas activer une catégorie vide.
  2780. if ($_REQUEST['type'] == 'categorie' && ($infos['categorie_images'] + $infos['categorie_images_inactive']) == 0) {
  2781. return;
  2782. }
  2783. // On active l'objet que s'il est désactivé.
  2784. if (empty($infos[$_REQUEST['type'] . '_visible'])) {
  2785. if ($this->objet_update_nb('active', $infos)) {
  2786. $this->template['action_maj'] = 1;
  2787. } else {
  2788. $this->template['infos']['erreur']['desactive'] = '[' . __LINE__ . '] Des erreurs se sont produites lors de cette opération.';
  2789. }
  2790. }
  2791. // On vérifie le représentant de chaque catégorie parente.
  2792. $this->verif_representant($infos[$_REQUEST['type'] . '_chemin']);
  2793. }
  2794. /*
  2795. * Désactivation d'un objet de la galerie.
  2796. */
  2797. function galerie_action_desactive($infos) {
  2798. // On désactive l'objet que s'il est activé.
  2799. if (!empty($infos[$_REQUEST['type'] . '_visible'])) {
  2800. if ($this->objet_update_nb('desactive', $infos)) {
  2801. $this->template['action_maj'] = 1;
  2802. } else {
  2803. $this->template['infos']['erreur']['desactive'] = '[' . __LINE__ . '] Des erreurs se sont produites lors de cette opération.';
  2804. }
  2805. }
  2806. // On vérifie le représentant de chaque catégorie parente.
  2807. $this->verif_representant($infos[$_REQUEST['type'] . '_chemin']);
  2808. }
  2809. /*
  2810. * Suppression d'un objet de la galerie.
  2811. */
  2812. function galerie_action_delete($infos, $objet = '', $fm = '') {
  2813. static $deletes = array();
  2814. // On UPDATE les informations des catégores parentes.
  2815. $this->objet_update_nb('supprime', $infos, $objet);
  2816. // On supprime les tags liés.
  2817. if (isset($infos['categorie_nom'])) {
  2818. $mysql_requete = 'DELETE FROM ' . MYSQL_PREF . 'tags
  2819. USING ' . MYSQL_PREF . 'tags,
  2820. ' . MYSQL_PREF . 'images
  2821. WHERE ' . MYSQL_PREF . 'images.image_chemin LIKE "' . $infos['categorie_chemin'] . '%"
  2822. AND ' . MYSQL_PREF . 'tags.image_id = ' . MYSQL_PREF . 'images.image_id';
  2823. $this->mysql->requete($mysql_requete);
  2824. } elseif (!empty($infos['image_tags'])) {
  2825. $mysql_requete = 'DELETE FROM ' . MYSQL_PREF . 'tags
  2826. WHERE image_id = "' . $infos['image_id'] . '%"';
  2827. $this->mysql->requete($mysql_requete);
  2828. }
  2829. // On supprime la référence de l'objet de la base de données,
  2830. // ainsi que celles de tous ses éventuels objets enfants s'il s'agit d'une catégorie.
  2831. if ($_REQUEST['type'] == 'image') {
  2832. $mysql_requete = 'DELETE FROM '. MYSQL_PREF . 'images
  2833. WHERE image_id = "' . $infos['image_id'] . '"';
  2834. $this->mysql->requete($mysql_requete);
  2835. } else {
  2836. $mysql_requete = 'DELETE FROM '. MYSQL_PREF . 'categories
  2837. WHERE categorie_chemin LIKE "' . $infos['categorie_chemin'] . '%"';
  2838. $this->mysql->requete($mysql_requete);
  2839. $mysql_requete = 'DELETE FROM '. MYSQL_PREF . 'images
  2840. WHERE image_chemin LIKE "' . $infos['categorie_chemin'] . '%"';
  2841. $this->mysql->requete($mysql_requete);
  2842. }
  2843. // On supprime tous les commentaires de l'objet.
  2844. $mysql_requete = 'DELETE ' . MYSQL_PREF . 'commentaires
  2845. FROM ' . MYSQL_PREF . 'commentaires,
  2846. ' . MYSQL_PREF . 'images
  2847. WHERE ' . MYSQL_PREF . 'commentaires.image_id = ' . MYSQL_PREF . 'images.image_id
  2848. AND ' . MYSQL_PREF . 'images.image_chemin LIKE "' . $infos[$_REQUEST['type'] . '_chemin'] . '%"';
  2849. $this->mysql->requete($mysql_requete);
  2850. // On supprime tous les votes de l'objet.
  2851. $mysql_requete = 'DELETE ' . MYSQL_PREF . 'votes
  2852. FROM ' . MYSQL_PREF . 'votes,
  2853. ' . MYSQL_PREF . 'images
  2854. WHERE ' . MYSQL_PREF . 'votes.image_id = ' . MYSQL_PREF . 'images.image_id
  2855. AND ' . MYSQL_PREF . 'images.image_chemin LIKE "' . $infos[$_REQUEST['type'] . '_chemin'] . '%"';
  2856. $this->mysql->requete($mysql_requete);
  2857. // On vérifie le représentant de chaque catégorie parente.
  2858. $this->verif_representant($infos[$_REQUEST['type'] . '_chemin']);
  2859. // On supprime l'objet sur le disque.
  2860. $file = $this->galerie_dir . $infos[$_REQUEST['type'] . '_chemin'];
  2861. if ($_REQUEST['type'] == 'image') {
  2862. // On supprime l'image.
  2863. if (files::suppFile($file)) {
  2864. if ($objet) {
  2865. $this->template['infos']['action']['delete'] = $objet . ' Ť ' . strip_tags($infos[$_REQUEST['type'] . '_nom']) . ' ť a été supprimée.';
  2866. } else {
  2867. $deletes[1] = 1;
  2868. }
  2869. } else {
  2870. if ($objet) {
  2871. $this->template['infos']['info']['delete'] = $objet . ' Ť ' . strip_tags($infos[$_REQUEST['type'] . '_nom']) . ' ť n\'a pas pu ętre supprimée du disque.<br />Vous devrez la supprimer manuellement par FTP.';
  2872. } else {
  2873. $deletes[0] = 1;
  2874. }
  2875. }
  2876. // On supprime la vignette de l'image, si elle existe.
  2877. $thumb = $this->galerie_dir .
  2878. dirname($infos[$_REQUEST['type'] . '_chemin']) . '/' .
  2879. THUMB_TDIR . '/' . THUMB_PREF . basename($infos[$_REQUEST['type'] . '_chemin']);
  2880. if (file_exists($thumb)) {
  2881. files::suppFile($thumb);
  2882. }
  2883. } else {
  2884. // On supprime le répertoire et tout ce qu'il contient correspondant ŕ la catégorie.
  2885. if ($this->delete_dir($file)) {
  2886. if ($objet) {
  2887. $this->template['infos']['action']['delete'] = $objet . ' Ť ' . strip_tags($infos[$_REQUEST['type'] . '_nom']) . ' ť a été supprimé' . $fm . '.';
  2888. } else {
  2889. $deletes[1] = 1;
  2890. }
  2891. } else {
  2892. if ($objet) {
  2893. $this->template['infos']['info']['delete'] = $objet . ' Ť ' . strip_tags($infos[$_REQUEST['type'] . '_nom']) . ' ť n\'a pas pu ętre supprimé du disque.<br />Vous devrez le supprimer manuellement par FTP.';
  2894. } else {
  2895. $deletes[0] = 1;
  2896. }
  2897. }
  2898. }
  2899. // On renvoie vers la premičre page.
  2900. $_REQUEST['startnum'] = 0;
  2901. // On renvoie le tableau des objets supprimés pour le traitement par lot.
  2902. if (!$objet) {
  2903. return $deletes;
  2904. }
  2905. }
  2906. /*
  2907. * Actions sur la galerie.
  2908. */
  2909. function galerie_action() {
  2910. // Vérification de l'ID de session dans les formulaires.
  2911. if (isset($_GET['supprime']) || isset($_GET['active']) || isset($_GET['desactive'])) {
  2912. $this->verifVID();
  2913. }
  2914. // Traitement par lot : bouton valider.
  2915. if (isset($_POST['mass_change'])
  2916. && isset($_POST['nom']) && is_array($_POST['nom'])
  2917. && isset($_POST['description']) && is_array($_POST['description'])
  2918. && isset($_POST['f_type']) && is_array($_POST['f_type'])
  2919. && (empty($_POST['reinit_hits'])
  2920. || (isset($_POST['reinit_hits']) && is_array($_POST['reinit_hits'])))
  2921. && ((isset($_POST['file_name']) && is_array($_POST['file_name']) &&
  2922. isset($_POST['tags']) && is_array($_POST['tags']) &&
  2923. isset($_POST['date_creation_jour']) && is_array($_POST['date_creation_jour']) &&
  2924. isset($_POST['date_creation_mois']) && is_array($_POST['date_creation_mois']) &&
  2925. isset($_POST['date_creation_annee']) && is_array($_POST['date_creation_annee']))
  2926. || (isset($_POST['password']) && is_array($_POST['password'])))) {
  2927. // S'agit-il d'images ou de catégories ?
  2928. $table = (current($_POST['f_type']) == 'img') ? 'images' : 'categories';
  2929. $champ = (current($_POST['f_type']) == 'img') ? 'image' : 'categorie';
  2930. // On récupčre l'identifiant de chaque objet.
  2931. $ids = '';
  2932. foreach ($_POST['nom'] as $id => $nom) {
  2933. if (!is_int($id)) {
  2934. return;
  2935. }
  2936. $ids .= $champ . '_id = "' . $id . '" OR ';
  2937. }
  2938. $ids = preg_replace('`OR $`', '', $ids);
  2939. if (!$ids) {
  2940. return;
  2941. }
  2942. // On récupčre les informations de chaque objet.
  2943. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . $table . ' WHERE ' . $ids;
  2944. $objets = $this->mysql->select($mysql_requete);
  2945. if (!is_array($objets)) {
  2946. return;
  2947. }
  2948. if (current($_POST['f_type']) == 'img') {
  2949. $type = 'L\'image';
  2950. $type2 = 'une image';
  2951. $type3 = 'image';
  2952. $fm = 'e';
  2953. }
  2954. // Initialisation des variables de remise ŕ zéro du nombre de hits des catégories parentes.
  2955. $update_hits = 0;
  2956. $update_nb_hits = 0;
  2957. $update_nb_hits_inactive = 0;
  2958. // Les années 2000...
  2959. for ($y2ks = '', $y = 2000; $y <= date('Y'); $y++) $y2ks .= '|' . $y;
  2960. $insert_tags = '';
  2961. $delete_tags = '';
  2962. // On traite chaque objet.
  2963. for ($i = 0; $i < count($objets); $i++) {
  2964. $objet_id = $objets[$i][$champ . '_id'];
  2965. // On initialise la variable qui contiendra les informations ŕ updater
  2966. // sous forme de bouts de requętes MySQL.
  2967. $sets = '';
  2968. if (current($_POST['f_type']) != 'img') {
  2969. $type = ($objets[$i]['categorie_derniere_modif']) ? 'L\'album' : 'La catégorie';
  2970. $type2 = ($objets[$i]['categorie_derniere_modif']) ? 'un album' : 'une catégorie';
  2971. $type3 = ($objets[$i]['categorie_derniere_modif']) ? 'album' : 'catégorie';
  2972. $fm = ($objets[$i]['categorie_derniere_modif']) ? '' : 'e';
  2973. }
  2974. // Changement du nom.
  2975. if (isset($_POST['nom'][$objet_id]) && $_POST['nom'][$objet_id] != $objets[$i][$champ . '_nom']) {
  2976. if (strlen($_POST['nom'][$objet_id]) < 1
  2977. || strlen($_POST['nom'][$objet_id]) > 255) {
  2978. $this->template['infos']['attention']['nom_' . $objet_id] = '[' . $type3 . ' ' . $objet_id . '] : Le nom doit faire entre 1 et 255 caractčres.';
  2979. } else {
  2980. // On renomme l'objet que s'il n'y a pas un objet portant déjŕ le męme nom.
  2981. $path = dirname($objets[$i][$champ . '_chemin']) . '/';
  2982. $path = ($path == './') ? '' : $path;
  2983. $mysql_requete = 'SELECT ' . $champ . '_nom FROM ' . MYSQL_PREF . $table . '
  2984. WHERE ' . $champ . '_id NOT IN ("' . $objet_id . '") AND ' .
  2985. $champ . '_nom = "' . outils::protege_mysql($_POST['nom'][$objet_id], $this->mysql->lien) . '" AND ' .
  2986. $champ . '_chemin LIKE "' . $path . '%"';
  2987. if ($this->mysql->select($mysql_requete, 11) != 'vide') {
  2988. $this->template['infos']['attention']['rename_' . $objet_id] = '[' . $type3 . ' ' . $objet_id . '] : Il y a déjŕ ' . $type2 . ' portant le męme nom.';
  2989. } else {
  2990. $sets .= $champ . '_nom = "' . outils::protege_mysql($_POST['nom'][$objet_id], $this->mysql->lien) . '", ';
  2991. }
  2992. }
  2993. }
  2994. // Changement de nom de fichier.
  2995. if (isset($_POST['file_name'])&& $_POST['file_name'][$objet_id] != basename($objets[$i]['image_chemin'])) {
  2996. if (preg_match('`^([-_a-z0-9.]){1,80}\.(?:jpe?g|gif|png)$`i', $_POST['file_name'][$objet_id]) ) {
  2997. $f_ancien = $this->galerie_dir . $objets[$i]['image_chemin'];
  2998. $f_nouveau = $this->galerie_dir . dirname($objets[$i]['image_chemin']) . '/' . $_POST['file_name'][$objet_id];
  2999. if (file_exists($f_nouveau) && strtolower($f_ancien) != strtolower($f_nouveau)) {
  3000. $this->template['infos']['attention']['file_rename_' . $objet_id] = '[image ' . $objet_id . '] : Il y a déjŕ un fichier portant le męme nom.';
  3001. } else {
  3002. files::chmodFile($f_ancien);
  3003. if (files::rename($f_ancien, $f_nouveau)) {
  3004. $f_tb_ancien = $this->galerie_dir . dirname($objets[$i]['image_chemin']) . '/' . THUMB_TDIR . '/' . THUMB_PREF . basename($objets[$i]['image_chemin']);
  3005. $f_tb_nouveau = $this->galerie_dir . dirname($objets[$i]['image_chemin']) . '/' . THUMB_TDIR . '/' . THUMB_PREF . $_POST['file_name'][$objet_id];
  3006. files::rename($f_tb_ancien, $f_tb_nouveau);
  3007. $sets .= $champ . '_chemin = "' . dirname($objets[$i]['image_chemin']) . '/' . $_POST['file_name'][$objet_id] . '", ';
  3008. } else {
  3009. $this->template['infos']['erreur']['file_rename_' . $objet_id] = '[image ' . $objet_id . '] : Impossible de renommer le fichier.';
  3010. }
  3011. }
  3012. } else {
  3013. $this->template['infos']['attention']['rename_' . $objet_id] = '[' . $type3 . ' ' . $objet_id . '] : Le nom de fichier doit ętre constitué de 1 ŕ 80 caractčres alphanumériques, tirets (-) ou soulignés (_).';
  3014. }
  3015. }
  3016. // Changement de la description.
  3017. if (isset($_POST['description'][$objet_id]) && $_POST['description'][$objet_id] != $objets[$i][$champ . '_description']) {
  3018. if (strlen($_POST['description'][$objet_id]) > 65535) {
  3019. $this->template['infos']['attention']['description_' . $objet_id] = '[' . $type3 . ' ' . $objet_id . '] : La description ne doit pas dépasser 65535 caractčres.';
  3020. } else {
  3021. $sets .= $champ . '_description = "' . outils::protege_mysql($_POST['description'][$objet_id], $this->mysql->lien) . '", ';
  3022. }
  3023. }
  3024. // Changement des tags.
  3025. if (isset($_POST['tags'])) {
  3026. if (strlen($_POST['tags'][$objet_id]) < 10000) {
  3027. // Tags existants.
  3028. $tags_actuels = array();
  3029. if ($objets[$i]['image_tags']) {
  3030. $tags_actuels = $objets[$i]['image_tags'];
  3031. $tags_actuels = $tags_actuels;
  3032. $tags_actuels = explode(',', $tags_actuels);
  3033. sort($tags_actuels);
  3034. }
  3035. // Tags envoyés.
  3036. $new_tags = $_POST['tags'][$objet_id];
  3037. $new_tags = preg_replace('`[\r\n\x5c#]+`', '', $new_tags);
  3038. $new_tags = preg_replace('`\s*,\s*`', ',', $new_tags);
  3039. $new_tags = trim($new_tags);
  3040. $new_tags = htmlentities($new_tags);
  3041. $new_tags = preg_split('`,`', $new_tags, -1 , PREG_SPLIT_NO_EMPTY);
  3042. sort($new_tags);
  3043. // On détermine les nouveaux tags et les tags ŕ supprimer.
  3044. if ($new_tags != $tags_actuels) {
  3045. for ($it = 0; $it < count($new_tags); $it++) {
  3046. if ($new_tags[$it] && !in_array($new_tags[$it], $tags_actuels)) {
  3047. $insert_tags .= ',("' . outils::protege_mysql($new_tags[$it], $this->mysql->lien) . '","' . $objet_id . '")';
  3048. }
  3049. }
  3050. for ($it = 0; $it < count($tags_actuels); $it++) {
  3051. if (!empty($tags_actuels[$it]) && !in_array($tags_actuels[$it], $new_tags)) {
  3052. $delete_tags .= 'OR (tag_id = "' . outils::protege_mysql($tags_actuels[$it], $this->mysql->lien) . '" AND image_id = "' . $objet_id . '")';
  3053. }
  3054. }
  3055. $new_tags = outils::protege_mysql(implode(',', $new_tags), $this->mysql->lien);
  3056. $new_tags = ($new_tags == '') ? '' : ',' . $new_tags . ',';
  3057. $sets .= 'image_tags = "' . $new_tags . '", ';
  3058. }
  3059. }
  3060. }
  3061. // Mot de passe.
  3062. if (isset($_POST['password'])) {
  3063. $_POST['password'][$objet_id] = trim($_POST['password'][$objet_id]);
  3064. $objets[$i]['categorie_pass'] = preg_replace('`^\d+:(.+)$`', '$1', $objets[$i]['categorie_pass']);
  3065. if (isset($_POST['password'][$objet_id]) &&
  3066. ((empty($_POST['password'][$objet_id]) && !empty($objets[$i]['categorie_pass'])) ||
  3067. ($_POST['password'][$objet_id] != $objets[$i]['categorie_pass']))) {
  3068. // Le mot de passe ne doit contenir que des caractčres alphanumériques
  3069. // ou soulignés et doit faire entre 4 et 50 caractčres.
  3070. $new_pass = (empty($_POST['password'][$objet_id])) ? '_pass = NULL' : '_pass = "' . $objet_id . ':' . $_POST['password'][$objet_id] . '"';
  3071. if (preg_match('`^(?:[0-9a-z_]{4,50})?$`i', $_POST['password'][$objet_id])) {
  3072. $ok = true;
  3073. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET categorie' . $new_pass . '
  3074. WHERE categorie_chemin LIKE "' . $objets[$i]['categorie_chemin'] . '%"';
  3075. if (!$this->mysql->requete($mysql_requete)) {
  3076. $ok = false;
  3077. }
  3078. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images SET image' . $new_pass . '
  3079. WHERE image_chemin LIKE "' . $objets[$i]['categorie_chemin'] . '%"';
  3080. if (!$this->mysql->requete($mysql_requete)) {
  3081. $ok = false;
  3082. }
  3083. if ($ok) {
  3084. $this->template['action_maj'] = 1;
  3085. } else {
  3086. $this->template['infos']['erreur']['new_pass_' . $objet_id] = '[' . $type3 . ' ' . $objet_id . '] : Un erreur s\'est produite lors de l\'affectation du mot de passe aux images.';
  3087. }
  3088. } else {
  3089. $this->template['infos']['attention']['new_pass_' . $objet_id] = '[' . $type3 . ' ' . $objet_id . '] : Le mot de passe doit contenir entre 4 et 50 caractčres alphanumériques.';
  3090. }
  3091. }
  3092. }
  3093. // Date de création.
  3094. if (isset($_POST['date_creation_jour'][$objet_id]) &&
  3095. isset($_POST['date_creation_mois'][$objet_id]) &&
  3096. isset($_POST['date_creation_annee'][$objet_id]) &&
  3097. preg_match('`^(?:[1-9]|[1-2]\d|3[01])?$`', $_POST['date_creation_jour'][$objet_id]) &&
  3098. preg_match('`^(?:[1-9]|1[0-2])?$`', $_POST['date_creation_mois'][$objet_id]) &&
  3099. preg_match('`^(?:(?:19[7-9]\d)' . $y2ks . ')?$`', $_POST['date_creation_annee'][$objet_id])
  3100. ) {
  3101. if ($_POST['date_creation_jour'][$objet_id] == '' ||
  3102. $_POST['date_creation_mois'][$objet_id] == '' ||
  3103. $_POST['date_creation_annee'][$objet_id] == '') {
  3104. $post_timestamp = 0;
  3105. } else {
  3106. $dc_seconde = 0;
  3107. $dc_minute = 0;
  3108. $dc_heure = 0;
  3109. $dc_jour = $_POST['date_creation_jour'][$objet_id];
  3110. $dc_mois = $_POST['date_creation_mois'][$objet_id];
  3111. $dc_annee = $_POST['date_creation_annee'][$objet_id];
  3112. }
  3113. if (!isset($post_timestamp) && $objets[$i]['image_exif_datetimeoriginal']) {
  3114. $dc_exif = @getdate($objets[$i]['image_exif_datetimeoriginal']);
  3115. if ($dc_exif['mday'] == $dc_jour &&
  3116. $dc_exif['mon'] == $dc_mois &&
  3117. $dc_exif['year'] == $dc_annee) {
  3118. $post_timestamp = $objets[$i]['image_exif_datetimeoriginal'];
  3119. }
  3120. }
  3121. if (!isset($post_timestamp)) {
  3122. $post_timestamp = @mktime($dc_heure, $dc_minute, $dc_seconde, $dc_mois, $dc_jour, $dc_annee);
  3123. }
  3124. $bd_timestamp = ($objets[$i]['image_date_creation']) ? $objets[$i]['image_date_creation'] : 0;
  3125. if (preg_match('`^(?:\d{5,10}|0)$`', $post_timestamp) &&
  3126. $bd_timestamp != $post_timestamp) {
  3127. $sets .= 'image_date_creation = "' . $post_timestamp . '", ';
  3128. }
  3129. unset($post_timestamp);
  3130. }
  3131. // Remise ŕ zéro du compteur de visites.
  3132. if (!empty($_POST['reinit_hits'][$objet_id])) {
  3133. $update_hits = 1;
  3134. // On UPDATE le nombre de hits pour l'objet et, s'il s'agit d'une catégorie,
  3135. //de toutes ses sous-catégories éventuelles.
  3136. $mysql_requete = 'UPDATE ' . MYSQL_PREF . $table . ' SET ' . $champ . '_hits = "0"
  3137. WHERE ' . $champ . '_chemin LIKE "' . $objets[$i][$champ . '_chemin'] . '%"';
  3138. if ($this->mysql->requete($mysql_requete)) {
  3139. $this->template['action_maj'] = 1;
  3140. // Si l'objet est une image et qu'elle est désactivée, alors on updatera
  3141. // le nombre de hits des objets inactifs des catégories parentes.
  3142. if ($_POST['f_type'][$objet_id] == 'img' && !$objets[$i][$champ . '_visible']) {
  3143. $update_nb_hits_inactive += $objets[$i][$champ . '_hits'];
  3144. } else {
  3145. $update_nb_hits += $objets[$i][$champ . '_hits'];
  3146. }
  3147. // Si l'objet est une catégorie, on UPDATE le nombre de hits
  3148. // pour toutes les images qu'il contient et le nombre de hits
  3149. // des catégories inactives pour toutes ses sous-catégories.
  3150. if ($_POST['f_type'][$objet_id] == 'cat') {
  3151. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET categorie_hits_inactive = "0"
  3152. WHERE categorie_chemin LIKE "' . $objets[$i]['categorie_chemin'] . '%"';
  3153. $this->mysql->requete($mysql_requete);
  3154. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images SET image_hits = "0"
  3155. WHERE image_chemin LIKE "' . $objets[$i]['categorie_chemin'] . '%"';
  3156. $this->mysql->requete($mysql_requete);
  3157. $update_nb_hits_inactive += $objets[$i][$champ . '_hits_inactive'];
  3158. }
  3159. }
  3160. }
  3161. // Si changement(s), mise ŕ jour des informations de l'objet.
  3162. if ($sets) {
  3163. $sets = preg_replace('`, $`', '', $sets);
  3164. $mysql_requete = 'UPDATE ' . MYSQL_PREF . $table .
  3165. ' SET ' . $sets . ' WHERE ' . $champ . '_id = ' . $objet_id;
  3166. if ($this->mysql->requete($mysql_requete)) {
  3167. $this->template['action_maj'] = 1;
  3168. } else {
  3169. $this->template['infos']['erreur']['update_' . $objet_id] = '[' . $type3 . ' ' . $objet_id . '] : Impossible de mettre les informations ŕ jour';
  3170. }
  3171. }
  3172. }
  3173. // Modification de la table des tags.
  3174. if ($insert_tags) {
  3175. $mysql_requete = 'INSERT INTO ' . MYSQL_PREF . 'tags(tag_id,image_id) VALUES' . substr($insert_tags, 1);
  3176. $this->mysql->requete($mysql_requete);
  3177. }
  3178. if ($delete_tags) {
  3179. $mysql_requete = 'DELETE FROM ' . MYSQL_PREF . 'tags WHERE ' . substr($delete_tags, 2);
  3180. $this->mysql->requete($mysql_requete);
  3181. }
  3182. // On UPDATE le nombre de hits des catégories parentes.
  3183. if ($update_hits) {
  3184. $path = $objets[0][$champ . '_chemin'];
  3185. while ($path != '.') {
  3186. $path = dirname($path);
  3187. $path = ($path == '.') ? $path : $path . '/';
  3188. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET
  3189. categorie_id = categorie_id,
  3190. categorie_hits = categorie_hits - "' . $update_nb_hits . '",
  3191. categorie_hits_inactive = categorie_hits_inactive - "' . $update_nb_hits_inactive . '"
  3192. WHERE categorie_chemin = "' . $path . '"';
  3193. $this->mysql->requete($mysql_requete);
  3194. }
  3195. }
  3196. unset($_REQUEST['f_type']);
  3197. }
  3198. // Traitement par lot : opérations de la liste déroulante : activer, désactiver, supprimer.
  3199. if (isset($_POST['gal_mass_action']) && isset($_POST['action'])
  3200. && isset($_POST['objet_id']) && is_array($_POST['objet_id'])) {
  3201. // On récupčre l'identifiant de chaque objet.
  3202. $ids = '';
  3203. $champ = (current($_POST['objet_type']) != 'image') ? 'categorie' : 'image';
  3204. $table = (current($_POST['objet_type']) == 'image') ? 'images' : 'categories';
  3205. $_REQUEST['type'] = $champ;
  3206. foreach ($_POST['objet_id'] as $id => $nom) {
  3207. if (!is_int($id)) {
  3208. return;
  3209. }
  3210. $ids .= $champ . '_id = "' . $id . '" OR ';
  3211. }
  3212. $ids = preg_replace('`OR $`', '', $ids);
  3213. if (!$ids) {
  3214. return;
  3215. }
  3216. // On récupčre les informations de chaque objet.
  3217. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . $table . ' WHERE ' . $ids;
  3218. $objets = $this->mysql->select($mysql_requete);
  3219. if (!is_array($objets)) {
  3220. return;
  3221. }
  3222. for ($i = 0; $i < count($objets); $i++) {
  3223. $infos = array();
  3224. $infos[$champ . '_id'] = $objets[$i][$champ . '_id'];
  3225. $infos[$champ . '_nom'] = $objets[$i][$champ . '_nom'];
  3226. $infos[$champ . '_visible'] = $objets[$i][$champ . '_visible'];
  3227. $infos[$champ . '_chemin'] = $objets[$i][$champ . '_chemin'];
  3228. $infos[$champ . '_commentaires'] = $objets[$i][$champ . '_commentaires'];
  3229. $infos[$champ . '_votes'] = $objets[$i][$champ . '_votes'];
  3230. $infos[$champ . '_hits'] = $objets[$i][$champ . '_hits'];
  3231. $infos[$champ . '_poids'] = $objets[$i][$champ . '_poids'];
  3232. if ($champ == 'categorie') {
  3233. $infos['categorie_images'] = $objets[$i]['categorie_images'];
  3234. $infos['categorie_images_inactive'] = $objets[$i]['categorie_images_inactive'];
  3235. $infos['categorie_commentaires_inactive'] = $objets[$i]['categorie_commentaires_inactive'];
  3236. $infos['categorie_votes_inactive'] = $objets[$i]['categorie_votes_inactive'];
  3237. $infos['categorie_hits_inactive'] = $objets[$i]['categorie_hits_inactive'];
  3238. $infos['categorie_poids_inactive'] = $objets[$i]['categorie_poids_inactive'];
  3239. }
  3240. switch ($_POST['action']) {
  3241. case 'desactiver' :
  3242. $_REQUEST['desactive'] = $objets[$i][$champ . '_id'];
  3243. $this->galerie_action_desactive($infos);
  3244. break;
  3245. case 'activer' :
  3246. $_REQUEST['active'] = $objets[$i][$champ . '_id'];
  3247. $this->galerie_action_active($infos);
  3248. break;
  3249. case 'supprimer' :
  3250. $_REQUEST['supprime'] = $objets[$i][$champ . '_id'];
  3251. $deletes = $this->galerie_action_delete($infos);
  3252. break;
  3253. }
  3254. }
  3255. if (isset($deletes)) {
  3256. if (isset($deletes[0])) {
  3257. $objet_type = (current($_POST['objet_type']) == 'image') ? 'images' : 'catégories';
  3258. $this->template['infos']['info']['delete'] = 'Certaines ' . $objet_type . 'n\'ont pas pu ętre supprimées.<br />Vous devrez les supprimer manuellement par FTP.';
  3259. } else {
  3260. $objet_type = (current($_POST['objet_type']) == 'image') ? 'Toutes les images sélectionnées ont été supprimées.' : 'Tous les albums ou catégories sélectionnés ont été supprimés.';
  3261. $this->template['infos']['action']['delete'] = $objet_type;
  3262. }
  3263. }
  3264. unset($_REQUEST['desactive']);
  3265. unset($_REQUEST['active']);
  3266. unset($_REQUEST['supprime']);
  3267. }
  3268. // Traitement par lot : opérations de la liste déroulante : déplacer.
  3269. if (isset($_POST['gal_deplacer_imgs']) && isset($_POST['vers']) && preg_match('`^\d{1,9}$`', $_POST['vers'])
  3270. && isset($_POST['objet_id']) && is_array($_POST['objet_id'])) {
  3271. // On récupčre l'identifiant de chaque objet.
  3272. $ids = '';
  3273. foreach ($_POST['objet_id'] as $id => $nom) {
  3274. if (!is_int($id)) {
  3275. return;
  3276. }
  3277. $ids .= 'image_id = "' . $id . '" OR ';
  3278. }
  3279. $ids = preg_replace('`OR $`', '', $ids);
  3280. if (!$ids) {
  3281. return;
  3282. }
  3283. // On récupčre les informations de chaque objet.
  3284. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . 'images WHERE ' . $ids;
  3285. $images = $this->mysql->select($mysql_requete);
  3286. if (!is_array($images)) {
  3287. return;
  3288. }
  3289. // Récupération des informations de la catégorie de destination.
  3290. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . 'categories
  3291. WHERE categorie_id = "' . $_POST['vers'] . '"';
  3292. $destination = $this->mysql->select($mysql_requete, 11);
  3293. // On s'assure que la catégorie cible existe.
  3294. if (is_array($destination)) {
  3295. $_REQUEST['f_type'] = 'img';
  3296. for ($i = 0; $i < count($images); $i++) {
  3297. // On vérifie si un objet du męme nom ou du męme nom de fichier existe déjŕ dans la catégorie cible.
  3298. $path = $destination['categorie_chemin'] . basename($images[$i]['image_chemin']);
  3299. $test1 = 'SELECT image_id FROM ' . MYSQL_PREF . 'images
  3300. WHERE image_chemin = "' . $path . '"';
  3301. $test2 = 'SELECT image_id FROM ' . MYSQL_PREF . 'images
  3302. WHERE image_chemin REGEXP "^' . dirname($path) . '/[^/]+' . '$" AND image_nom = "' . outils::protege_mysql($images[$i]['image_nom'], $this->mysql->lien) . '"';
  3303. if ($this->mysql->select($test2, 5) != 'vide') {
  3304. $this->template['infos']['attention']['deja_' . $images[$i]['image_id']] = '[image ' . $images[$i]['image_id'] . '] : Le répertoire cible contient déjŕ une image de męme nom.';
  3305. continue;
  3306. }
  3307. if ($this->mysql->select($test1, 5) != 'vide') {
  3308. $this->template['infos']['attention']['deja_' . $images[$i]['image_id']] = '[image ' . $images[$i]['image_id'] . '] : Le répertoire cible contient déjŕ une image de męme nom de fichier.';
  3309. continue;
  3310. }
  3311. $img['image_visible'] = $images[$i]['image_visible'];
  3312. $img['image_commentaires'] = $images[$i]['image_commentaires'];
  3313. $img['image_votes'] = $images[$i]['image_votes'];
  3314. $img['image_hits'] = $images[$i]['image_hits'];
  3315. $img['image_poids'] = $images[$i]['image_poids'];
  3316. $img['image_visible'] = $images[$i]['image_visible'];
  3317. // On UPDATE les informations de la catégorie de l'objet source,
  3318. // ainsi que de ses catégories parentes.
  3319. $this->update_deplace(dirname($images[$i]['image_chemin']) . '/', '-', 'image', $img, '');
  3320. // On déplace l'image sur le disque et on UPDATE le chemin de l'image.
  3321. $images_deplace_ok = $this->deplace($images[$i]['image_chemin'], $destination['categorie_chemin'], $destination['categorie_pass']);
  3322. // On UPDATE les informations de la catégorie cible,
  3323. // ainsi que ses catégories parentes.
  3324. $this->update_deplace($destination['categorie_chemin'], '+', 'image', $img);
  3325. }
  3326. // On attribue ŕ la date de dernier ajout de la catégorie source et de la catégorie cible
  3327. // la date d'ajout de l'image la plus récente qu'elles contiennent.
  3328. $this->date_img_recente($destination['categorie_chemin']);
  3329. $this->date_img_recente(dirname($images[0]['image_chemin']) . '/');
  3330. // On vérifie le représentant de la catégories source et de la catégorie cible,
  3331. // ainsi que leurs catégories parentes.
  3332. $this->verif_representant($destination['categorie_chemin']);
  3333. $this->verif_representant(dirname($images[0]['image_chemin']) . '/');
  3334. // Si toutes les images ont bien été déplacées...
  3335. if (isset($images_deplace_ok)) {
  3336. if ($images_deplace_ok) {
  3337. // Message de confirmation.
  3338. if ($destination['categorie_nom']) {
  3339. $dest_type = ($destination['categorie_derniere_modif']) ? 'l\'album' : 'la catégorie';
  3340. $dest = 'vers ' . $dest_type . ' Ť ' . strip_tags($destination['categorie_nom']) . ' ť.';
  3341. } else {
  3342. $dest = 'ŕ la racine de la galerie.';
  3343. }
  3344. $img_deplace_msg = (count($images) == 1) ? 'L\'image sélectionnée a été déplacée ' : 'Les images sélectionnées ont été déplacées ';
  3345. $this->template['infos']['action']['deplace'] = $img_deplace_msg . $dest;
  3346. } else {
  3347. $this->template['infos']['erreur']['deplace'] = 'Certaines images n\'ont pas pu ętre déplacées.';
  3348. }
  3349. }
  3350. unset($_REQUEST['f_type']);
  3351. // On renvoie vers la premičre page.
  3352. $_REQUEST['startnum'] = 0;
  3353. }
  3354. }
  3355. // Traitement individuel : déplacement d'une catégorie.
  3356. if (isset($_POST['deplacer_cat']) && is_array($_POST['deplacer_cat']) && preg_match('`^\d{1,9}$`', key($_POST['deplacer_cat']))
  3357. && isset($_POST['vers'][key($_POST['deplacer_cat'])]) && preg_match('`^\d{1,9}$`', $_POST['vers'][key($_POST['deplacer_cat'])])) {
  3358. // On récupčre les informations de la catégorie.
  3359. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . 'categories
  3360. WHERE categorie_id = ' . key($_POST['deplacer_cat']);
  3361. $objet = $this->mysql->select($mysql_requete, 11);
  3362. // On s'assure que la catégorie existe.
  3363. if (is_array($objet)) {
  3364. $type = ($objet['categorie_derniere_modif']) ? 'L\'album' : 'La catégorie';
  3365. $type2 = ($objet['categorie_derniere_modif']) ? 'un album' : 'une catégorie';
  3366. $fm = ($objet['categorie_derniere_modif']) ? '' : 'e';
  3367. $_REQUEST['f_type'] = 'cat';
  3368. // Mot de passe.
  3369. $objet_pass = $objet['categorie_pass'];
  3370. $objet['categorie_pass'] = preg_replace('`^\d+:(.+)$`', '$1', $objet['categorie_pass']);
  3371. // Les catégories ŕ déplacer ne doivent pas faire plus de 60 Mo et contenir plus de 200 images.
  3372. if ($objet['categorie_poids'] > 60000 || $objet['categorie_images'] > 200) {
  3373. $this->template['infos']['attention']['mc_supp'] = 'Vous ne pouvez pas déplacer ' . $type2 . ' de plus de 60 Mo et contenant plus de 200 images.';
  3374. return;
  3375. }
  3376. // Récupération des informations de la catégorie de destination.
  3377. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . 'categories
  3378. WHERE categorie_id = "' . $_POST['vers'][key($_POST['deplacer_cat'])] . '"';
  3379. $destination = $this->mysql->select($mysql_requete, 11);
  3380. // On s'assure que la catégorie cible existe.
  3381. if (is_array($destination)) {
  3382. // On vérifie si un objet du męme nom ou du męme nom de fichier existe déjŕ dans la catégorie cible.
  3383. $path = $destination['categorie_chemin'] . basename($objet['categorie_chemin']) . '/';
  3384. $test1 = 'SELECT categorie_id FROM ' . MYSQL_PREF . 'categories
  3385. WHERE categorie_chemin = "' . $path . '"';
  3386. $test2 = 'SELECT categorie_id FROM ' . MYSQL_PREF . 'categories
  3387. WHERE categorie_chemin REGEXP "^' . dirname($path) . '/[^/]+/$" AND categorie_nom = "' . outils::protege_mysql($objet['categorie_nom'], $this->mysql->lien) . '"';
  3388. if ($this->mysql->select($test2, 5) != 'vide') {
  3389. $this->template['infos']['attention']['deja'] = 'Le répertoire cible contient déjŕ ' . $type2 . ' de męme nom.';
  3390. return;
  3391. }
  3392. if ($this->mysql->select($test1, 5) != 'vide') {
  3393. $this->template['infos']['attention']['deja'] = 'Le répertoire cible contient déjŕ ' . $type2 . ' de męme nom de fichier.';
  3394. return;
  3395. }
  3396. // On UPDATE les informations de la catégorie de l'objet source,
  3397. // ainsi que de ses catégories parentes.
  3398. $this->update_deplace(dirname($objet['categorie_chemin']) . '/', '-', 'categorie', $objet, '');
  3399. // On détermine le mot de passe qu'aura la catégorie déplacée.
  3400. $pass = ($objet_pass) ? $objet_pass : $destination['categorie_pass'];
  3401. // On déplace la catégorie sur le disque et
  3402. // on UPDATE le chemin de la catégorie et de tous ses sous-objets.
  3403. $this->deplace($objet['categorie_chemin'], $destination['categorie_chemin'], $pass);
  3404. // On UPDATE les informations de la catégorie cible,
  3405. // ainsi que ses catégories parentes.
  3406. $this->update_deplace($destination['categorie_chemin'], '+', 'categorie', $objet);
  3407. // On vérifie le représentant de la catégories source et de la catégorie cible,
  3408. // ainsi que leurs catégories parentes.
  3409. $this->verif_representant($destination['categorie_chemin']);
  3410. $this->verif_representant(dirname($objet['categorie_chemin']) . '/');
  3411. // On attribue ŕ la date de dernier ajout de la catégorie source et de la catégorie cible
  3412. // la date d'ajout de l'image la plus récente qu'elles contiennent.
  3413. $this->date_img_recente($destination['categorie_chemin']);
  3414. $this->date_img_recente(dirname($objet['categorie_chemin']) . '/');
  3415. // Message de confirmation.
  3416. if ($destination['categorie_nom']) {
  3417. $dest_type = ($destination['categorie_derniere_modif']) ? 'l\'album' : 'la catégorie';
  3418. $dest = 'vers ' . $dest_type . ' Ť ' . strip_tags($destination['categorie_nom']) . ' ť.';
  3419. } else {
  3420. $dest = 'ŕ la racine de la galerie.';
  3421. }
  3422. $this->template['infos']['action']['deplace'] = $type . ' Ť ' . strip_tags($objet['categorie_nom']) . ' ť a été déplacé' . $fm . ' ' . $dest;
  3423. // On renvoie vers la premičre page.
  3424. $_REQUEST['startnum'] = 0;
  3425. }
  3426. }
  3427. }
  3428. // Traitement individuel : activation / désactivation / suppression d'un objet.
  3429. if (isset($_REQUEST['type']) && preg_match('`^(album|categorie|image)$`', $_REQUEST['type'])) {
  3430. switch ($_REQUEST['type']) {
  3431. case 'image' : $objet = 'L\'image'; $fm = 'e'; break;
  3432. case 'album' : $objet = 'L\'album'; $_REQUEST['type'] = 'categorie'; $fm = ''; break;
  3433. case 'categorie' : $objet = 'La catégorie'; $fm = 'e'; break;
  3434. }
  3435. // Désactivation d'un objet.
  3436. if (isset($_REQUEST['desactive']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['desactive'])) {
  3437. // On récupčre des informations de l'objet.
  3438. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . $_REQUEST['type'] . 's
  3439. WHERE ' . $_REQUEST['type'] . '_id = "' . $_REQUEST['desactive'] . '"';
  3440. $infos = $this->mysql->select($mysql_requete, 11);
  3441. $this->galerie_action_desactive($infos);
  3442. }
  3443. // Activation d'un objet.
  3444. if (isset($_REQUEST['active']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['active'])) {
  3445. // On récupčre les informations de l'objet.
  3446. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . $_REQUEST['type'] . 's
  3447. WHERE ' . $_REQUEST['type'] . '_id = "' . $_REQUEST['active'] . '"';
  3448. $infos = $this->mysql->select($mysql_requete, 11);
  3449. $this->galerie_action_active($infos);
  3450. }
  3451. // Suppression d'un objet.
  3452. if (isset($_REQUEST['supprime']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['supprime'])) {
  3453. // Récupération des informations sur l'objet.
  3454. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . $_REQUEST['type'] . 's
  3455. WHERE ' . $_REQUEST['type'] . '_id = "' . $_REQUEST['supprime'] . '"';
  3456. $infos = $this->mysql->select($mysql_requete, 11);
  3457. // S'il existe une référence de l'objet dans la base de données...
  3458. if ($infos != 'vide') {
  3459. $this->galerie_action_delete($infos, $objet, $fm);
  3460. }
  3461. }
  3462. }
  3463. // Création d'un album ou d'une catégorie.
  3464. if (isset($_REQUEST['gal_new_obj'])
  3465. && preg_match('`^alb|cat$`', $_REQUEST['gal_new_obj'])
  3466. && preg_match('`\w`', $_REQUEST['gal_new_name'])) {
  3467. $_REQUEST['gal_new_name'] = trim($_REQUEST['gal_new_name']);
  3468. if (isset($_REQUEST['cat']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['cat'])) {
  3469. $cat = $_REQUEST['cat'];
  3470. } else {
  3471. $cat = 1;
  3472. }
  3473. $type = ($_REQUEST['gal_new_obj'] == 'alb') ? 'cet album' : 'cette catégorie';
  3474. $type2 = ($_REQUEST['gal_new_obj'] == 'alb') ? 'L\'album' : 'La catégorie';
  3475. $fm = ($_REQUEST['gal_new_obj'] == 'alb') ? '' : 'e';
  3476. // On vérifie si on peut créer l'objet ŕ cet endroit.
  3477. $mysql_requete = 'SELECT categorie_derniere_modif,categorie_chemin FROM ' . MYSQL_PREF . 'categories
  3478. WHERE categorie_id = "' .$cat . '"';
  3479. $infos_cat = $this->mysql->select($mysql_requete, 11);
  3480. if (!$infos_cat['categorie_derniere_modif']) {
  3481. $new_name = outils::protege_mysql($_REQUEST['gal_new_name'], $this->mysql->lien);
  3482. // On vérifie s'il n'y a pas déjŕ un objet du męme nom.
  3483. $path = $infos_cat['categorie_chemin'];
  3484. $path = ($path == '.') ? '': $path;
  3485. $test1 = 'SELECT categorie_nom FROM ' . MYSQL_PREF . 'categories WHERE
  3486. categorie_id NOT IN ("' . $cat . '") AND
  3487. categorie_nom = "' . $new_name . '" AND
  3488. categorie_chemin REGEXP "^' . $path . '[^/]+/$"';
  3489. $test = $this->mysql->select($test1);
  3490. if (is_array($test)) {
  3491. $this->template['infos']['attention']['deja'] = 'Cette catégorie contient déjŕ une catégorie ou un album de męme nom.';
  3492. return;
  3493. }
  3494. // On remplace les caractčres spéciaux pour le nom du répertoire.
  3495. $dir_cat = ($infos_cat['categorie_chemin'] == '.') ? '': $infos_cat['categorie_chemin'];
  3496. $post_name = strtr($_REQUEST['gal_new_name'],
  3497. 'éčëęŕäâáĺăďîěíöôňóőůűüú˙ýçń',
  3498. 'eeeeaaaaaaiiiiooooouuuuyycn');
  3499. $post_name = preg_replace('`[^-a-z0-9]`i', '_', $post_name);
  3500. $dir = $this->galerie_dir . $dir_cat . $post_name;
  3501. // Si un répertoire au męme nom existe, on modifie le nom du répertoire.
  3502. $n = 1;
  3503. $testdir = $dir;
  3504. while (is_dir($testdir)) {
  3505. $testdir = $dir . $n;
  3506. $n++;
  3507. if ($n > 999) {
  3508. $this->template['infos']['erreur']['impossible'] = '[' . __LINE__ . '] Impossible de créer ' . $type . '.';
  3509. return;
  3510. }
  3511. }
  3512. $dir = $testdir . '/';
  3513. // On crée le répertoire sur le disque.
  3514. if (!files::createDir($dir)) {
  3515. $this->template['infos']['erreur']['impossible'] = '[' . __LINE__ . '] Impossible de créer ' . $type . '.';
  3516. return;
  3517. }
  3518. // Si c'est un album ŕ créer, on crée également le répertoire de vignettes.
  3519. if ($_REQUEST['gal_new_obj'] == 'alb') {
  3520. files::createDir($dir . THUMB_TDIR);
  3521. }
  3522. $dir = preg_replace('`^.+/' . GALERIE_ALBUMS . '/`', '', $dir);
  3523. // On récupčre le mot de passe de la catégorie parente.
  3524. $mysql_requete = 'SELECT categorie_pass FROM ' . MYSQL_PREF . 'categories
  3525. WHERE categorie_chemin = "' . dirname($dir) . '/"';
  3526. $pass = $this->mysql->select($mysql_requete);
  3527. $pass_champ = (!is_array($pass) || empty($pass[0]['categorie_pass'])) ? '' : ', categorie_pass';
  3528. $pass_valeur = (!is_array($pass) || empty($pass[0]['categorie_pass'])) ? '' : ', "' . $pass[0]['categorie_pass'] . '"';
  3529. // On insére la nouvelle catégorie dans la base de données.
  3530. $derniere_modif = ($_REQUEST['gal_new_obj'] == 'cat') ? '0' : time();
  3531. $mysql_requete = 'INSERT INTO ' . MYSQL_PREF . 'categories (
  3532. categorie_chemin,
  3533. categorie_nom,
  3534. categorie_visible,
  3535. image_representant_id,
  3536. categorie_derniere_modif,
  3537. categorie_date'
  3538. . $pass_champ . ') VALUES ("'
  3539. . $dir . '","'
  3540. . $new_name . '","'
  3541. . '0' . '","'
  3542. . '0' . '","'
  3543. . $derniere_modif . '","'
  3544. . time() . '"'
  3545. . $pass_valeur . ')';
  3546. if ($this->mysql->requete($mysql_requete)) {
  3547. $this->template['infos']['action']['new'] = $type2 . ' Ť ' . $_REQUEST['gal_new_name'] . ' ť a été créé' . $fm . '.';
  3548. }
  3549. }
  3550. }
  3551. // Changement du représentant d'une catégorie.
  3552. if (isset($_REQUEST['obj']) && preg_match('`^\d{1,12}$`', $_REQUEST['obj'])
  3553. && isset($_REQUEST['new_thumb']) && preg_match('`^\d{1,12}$`', $_REQUEST['new_thumb'])) {
  3554. $this->verifVID();
  3555. $mysql_requete = 'SELECT image_id,image_visible FROM ' . MYSQL_PREF . 'images
  3556. WHERE image_id = "' . $_REQUEST['new_thumb'] . '"';
  3557. $infos_tb = $this->mysql->select($mysql_requete, 11);
  3558. if (is_array($infos_tb)) {
  3559. $mysql_requete = 'SELECT categorie_visible FROM ' . MYSQL_PREF . 'categories
  3560. WHERE categorie_id = "' . $_REQUEST['obj'] . '"';
  3561. $infos_cat = $this->mysql->select($mysql_requete, 11);
  3562. // On vérifie si la visibilité de l'image est en adéquation avec celle de la catégorie.
  3563. if ($infos_cat['categorie_visible'] && !$infos_tb['image_visible']) {
  3564. return;
  3565. }
  3566. // On UPDATE la catégorie.
  3567. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET
  3568. image_representant_id = "' . $infos_tb['image_id'] . '"
  3569. WHERE categorie_id = "' . $_REQUEST['obj'] . '"';
  3570. if ($this->mysql->requete($mysql_requete)) {
  3571. $this->template['infos']['action']['representant'] = 'Le représentant a été changé.';
  3572. } else {
  3573. $this->template['infos']['erreur']['representant'] = 'Impossible de changer le représentant.';
  3574. }
  3575. }
  3576. }
  3577. // Upload HTTP d'images.
  3578. if (!empty($_FILES) && isset($_REQUEST['cat']) && preg_match('`^\d{1,9}$`', $_REQUEST['cat'])) {
  3579. $n = 0;
  3580. // Si GD n'est pas activé, on arręte tout.
  3581. if (!function_exists('imagetypes')) {
  3582. $this->template['infos']['erreur']['upload_' . $n] = 'GD n\'est pas activé.';
  3583. return;
  3584. }
  3585. $mysql_requete = 'SELECT categorie_chemin,categorie_derniere_modif FROM ' . MYSQL_PREF . 'categories
  3586. WHERE categorie_id = ' . $_REQUEST['cat'];
  3587. $cat_infos = $this->mysql->select($mysql_requete, 11);
  3588. // Si l'objet n'est pas un album, on arręte tout.
  3589. if (empty($cat_infos['categorie_derniere_modif'])) {
  3590. return;
  3591. }
  3592. $dir = $this->galerie_dir . $cat_infos['categorie_chemin'];
  3593. $images_http = array();
  3594. foreach ($_FILES as $f_file => $infos) {
  3595. $n++;
  3596. // Y a-t-il une erreur ?
  3597. if ($infos['error']) {
  3598. switch ($infos['error']) {
  3599. case 4 :
  3600. break;
  3601. case 2 :
  3602. case 1 :
  3603. $this->template['infos']['attention']['upload_' . $n] = 'Le fichier Ť <em>' . $infos['name'] . '</em> ť est trop lourd.';
  3604. break;
  3605. default :
  3606. $this->template['infos']['erreur']['upload_' . $n] = 'Impossible de récupérer le fichier Ť <em>' . $infos['name'] . ' </em> ť.';
  3607. }
  3608. continue;
  3609. }
  3610. // Est-ce une image ?
  3611. if (preg_match('`\.(jpe?g|gif|png)$`i', $infos['name'])
  3612. && preg_match('`^image/(gif|p?jpeg|(x-)?png)$`i', trim($infos['type']))) {
  3613. // On vérifie si un fichier du męme nom existe déjŕ.
  3614. if (file_exists($dir . $infos['name'])) {
  3615. $this->template['infos']['attention']['upload_' . $n] = 'L\'image Ť <em>' . $infos['name'] . '</em> ť ne peut ętre ajoutée ŕ l\'album car un fichier du męme nom existe déjŕ dans cet album.';
  3616. continue;
  3617. }
  3618. // On déplace le fichier envoyé vers le répertoire de l'album.
  3619. files::chmodDir($dir);
  3620. if (!move_uploaded_file($infos['tmp_name'], $dir . $infos['name'])) {
  3621. $this->template['infos']['erreur']['upload_' . $n] = 'Impossible de récupérer le fichier Ť <em>' . $infos['name'] . ' </em> ť.';
  3622. continue;
  3623. }
  3624. files::chmodFile($dir . $infos['name']);
  3625. $images_http[] = $infos['name'];
  3626. // Est-ce une archive Zip ?
  3627. } elseif (preg_match('`\.zip$`i', $infos['name']) && preg_match('`^application/(zip|x-zip-compressed)$`i', trim($infos['type']))) {
  3628. if (function_exists('zip_open')) {
  3629. if ($zip = zip_open($infos['tmp_name'])) {
  3630. while ($zip_entry = zip_read($zip)) {
  3631. if (zip_entry_open($zip, $zip_entry, 'r')) {
  3632. $zip_file = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
  3633. $image_name = zip_entry_name($zip_entry);
  3634. if (!preg_match('`\.(jpe?g|gif|png)$`i', $image_name)) {
  3635. continue;
  3636. }
  3637. $image_path = $dir . $image_name;
  3638. if (file_exists($image_path)) {
  3639. continue;
  3640. }
  3641. $image_file = fopen($image_path, 'w');
  3642. fwrite($image_file, $zip_file);
  3643. fclose($image_file);
  3644. zip_entry_close($zip_entry);
  3645. list($width, $height, $type) = getimagesize($image_path);
  3646. if ($type != 1 && $type != 2 && $type != 3) {
  3647. files::suppFile($image_path);
  3648. continue;
  3649. }
  3650. $images_http[] = $image_name;
  3651. }
  3652. }
  3653. }
  3654. }
  3655. // Fichier non valide.
  3656. } else {
  3657. $this->template['infos']['attention']['upload_' . $n] = 'Le fichier Ť <em>' . $infos['name'] . '</em> ť n\'est pas une image ou une archive Zip valide (type : ' . $infos['type'] . ').';
  3658. }
  3659. // On limite le nombre d'images envoyées en męme temps.
  3660. if ($n > 11) {
  3661. break;
  3662. }
  3663. }
  3664. // Enregistrement des images dans la base de données.
  3665. $upload = new upload($this->mysql, $this->config);
  3666. $upload->http['album'] = $cat_infos['categorie_chemin'];
  3667. $upload->http['images'] = $images_http;
  3668. $upload->recup_albums();
  3669. // Rapport.
  3670. if ($upload->rapport['erreurs']) {
  3671. foreach ($upload->rapport['erreurs'] as $v) {
  3672. $this->template['infos']['erreur']['upload_' . $v[0]] = 'Une erreur s\'est produite avec l\'objet Ť <em>' . $v[0] . '</em> ť : ' . $v[1];
  3673. }
  3674. }
  3675. for ($i = 0; $i < count($images_http); $i++) {
  3676. $ok = 1;
  3677. for ($n = 0; $n < count($upload->rapport['img_rejets']); $n++) {
  3678. if ($upload->rapport['img_rejets'][$n][0] == $images_http[$i]) {
  3679. $this->template['infos']['attention']['upload_' . $i] = 'L\'image Ť <em>' . $images_http[$i] . '</em> ť a été rejetée pour la raison suivante : ' . $upload->rapport['img_rejets'][$n][2];
  3680. files::suppFile($dir . $images_http[$i]);
  3681. files::suppFile($dir . '~#~');
  3682. $ok = 0;
  3683. break;
  3684. }
  3685. }
  3686. if ($ok && empty($this->template['infos']['erreur'])) {
  3687. $this->template['infos']['action']['upload_' . $i] = 'L\'image Ť <em>' . $images_http[$i] . ' </em> ť a été ajoutée ŕ l\'album.';
  3688. }
  3689. }
  3690. }
  3691. }
  3692. /*
  3693. * Déplace une image ou une catégorie vers une autre catégorie.
  3694. */
  3695. function deplace($source, $cible, $pass) {
  3696. static $ok = TRUE;
  3697. $source = preg_replace('`/$`', '', $source);
  3698. $cible = preg_replace('`/$`', '', $cible);
  3699. $gal_dir = $this->galerie_dir;
  3700. if (is_dir($gal_dir . $source)) {
  3701. if ($dir = @opendir($gal_dir . $source)) {
  3702. $cible_dir = ($cible == '.') ? basename($source) : $cible . '/' . basename($source);
  3703. if (!is_dir($gal_dir . $cible_dir)) {
  3704. if (!files::createDir($gal_dir . $cible_dir)) {
  3705. $ok = FALSE;
  3706. }
  3707. }
  3708. if (basename($source) != THUMB_TDIR) {
  3709. $categorie_pass = (!empty($pass)) ? ', categorie_pass = "' . $pass . '"' : '';
  3710. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  3711. SET categorie_chemin = "' . $cible_dir . '/"'
  3712. . $categorie_pass . '
  3713. WHERE categorie_chemin = "' . $source . '/"';
  3714. $this->mysql->requete($mysql_requete);
  3715. }
  3716. while ($ent = readdir($dir)) {
  3717. $source_obj = $source . '/' . $ent;
  3718. if (is_dir($gal_dir . $source_obj) && $ent != '.' && $ent != '..') {
  3719. if ($ent != THUMB_TDIR) {
  3720. $this->deplace($source_obj, $cible_dir, $pass);
  3721. }
  3722. } elseif (is_file($gal_dir . $source_obj)) {
  3723. $thumb_source = $gal_dir . dirname($source_obj) . '/' .
  3724. THUMB_TDIR . '/' .
  3725. THUMB_PREF . basename($source_obj);
  3726. $thumbnails_dir = $gal_dir . $cible_dir . '/' . THUMB_TDIR;
  3727. if (!is_dir($thumbnails_dir)) {
  3728. if (!files::createDir($thumbnails_dir)) {
  3729. $ok = FALSE;
  3730. }
  3731. }
  3732. $thumb_cible = $thumbnails_dir . '/' . THUMB_PREF . basename($source_obj);
  3733. if (!files::deplace($gal_dir . $source_obj, $gal_dir . $cible_dir . '/' . $ent)) {
  3734. $ok = FALSE;
  3735. }
  3736. if (file_exists($thumb_source)) {
  3737. if (!files::deplace($thumb_source, $thumb_cible)) {
  3738. $ok = FALSE;
  3739. }
  3740. }
  3741. if (basename(dirname($source_obj)) != THUMB_TDIR) {
  3742. $image_pass = (!empty($pass)) ? ', ' . MYSQL_PREF . 'images.image_pass = "' . $pass . '"' : '';
  3743. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images,' . MYSQL_PREF . 'categories
  3744. SET ' . MYSQL_PREF . 'images.categorie_parent_id = ' . MYSQL_PREF . 'categories.categorie_id,
  3745. ' . MYSQL_PREF . 'images.image_chemin = "' . $cible_dir . '/' . $ent . '"
  3746. ' . $image_pass . '
  3747. WHERE ' . MYSQL_PREF . 'images.image_chemin = "' . $source_obj . '"
  3748. AND ' . MYSQL_PREF . 'categories.categorie_chemin = "' . $cible_dir . '/"';
  3749. if (!$this->mysql->requete($mysql_requete)) {
  3750. $ok = FALSE;
  3751. }
  3752. }
  3753. }
  3754. }
  3755. closedir($dir);
  3756. if (!$this->delete_dir($gal_dir . $source)) {
  3757. $ok = FALSE;
  3758. }
  3759. } else {
  3760. $ok = FALSE;
  3761. }
  3762. } elseif (is_file($gal_dir . $source)) {
  3763. $thumb_source = $gal_dir . dirname($source) . '/' .
  3764. THUMB_TDIR . '/' .
  3765. THUMB_PREF . basename($source);
  3766. $thumbnails_dir = $gal_dir . $cible . '/' . THUMB_TDIR;
  3767. if (!is_dir($thumbnails_dir)) {
  3768. if (!files::createDir($thumbnails_dir)) {
  3769. $ok = FALSE;
  3770. }
  3771. }
  3772. $thumb_cible = $thumbnails_dir . '/' . THUMB_PREF . basename($source);
  3773. if (!files::deplace($gal_dir . $source, $gal_dir . $cible . '/' . basename($source))) {
  3774. $ok = FALSE;
  3775. }
  3776. if (file_exists($thumb_source)) {
  3777. if (!files::deplace($thumb_source, $thumb_cible)) {
  3778. $ok = FALSE;
  3779. }
  3780. }
  3781. $image_pass = (!empty($pass)) ? ', ' . MYSQL_PREF . 'images.image_pass = "' . $pass . '"' : '';
  3782. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images,' . MYSQL_PREF . 'categories
  3783. SET ' . MYSQL_PREF . 'images.categorie_parent_id = ' . MYSQL_PREF . 'categories.categorie_id,
  3784. ' . MYSQL_PREF . 'images.image_chemin = "' . $cible . '/' . basename($source) . '"
  3785. ' . $image_pass . '
  3786. WHERE ' . MYSQL_PREF . 'images.image_chemin = "' . $source . '"
  3787. AND ' . MYSQL_PREF . 'categories.categorie_chemin = "' . $cible . '/"';
  3788. if (!$this->mysql->requete($mysql_requete)) {
  3789. $ok = FALSE;
  3790. }
  3791. } else {
  3792. $ok = FALSE;
  3793. }
  3794. return $ok;
  3795. }
  3796. /*
  3797. * UPDATE les informations des catégories parentes lors
  3798. * du déplacement d'objets.
  3799. */
  3800. function update_deplace($path, $pm, $champ, $objet, $active = 'categorie_visible = "1",') {
  3801. $images = ($_REQUEST['f_type'] == 'img') ? 1 : $objet['categorie_images'];
  3802. $updates = '';
  3803. if (($_REQUEST['f_type'] == 'img' && $objet['image_visible']) || $_REQUEST['f_type'] == 'cat') {
  3804. $updates .= 'categorie_commentaires = categorie_commentaires ' . $pm . '"' . $objet[$champ . '_commentaires'] . '",';
  3805. $updates .= 'categorie_votes = categorie_votes ' . $pm . '"' . $objet[$champ . '_votes'] . '",';
  3806. $updates .= 'categorie_hits = categorie_hits ' . $pm . '"' . $objet[$champ . '_hits'] . '",';
  3807. $updates .= 'categorie_poids = categorie_poids ' . $pm . '"' . $objet[$champ . '_poids'] . '",';
  3808. $updates .= 'categorie_images = categorie_images ' . $pm . '"' . $images . '",';
  3809. }
  3810. if (($_REQUEST['f_type'] == 'img' && !$objet['image_visible']) || $_REQUEST['f_type'] == 'cat') {
  3811. $inactive = '';
  3812. if ($_REQUEST['f_type'] == 'cat') {
  3813. $inactive = '_inactive';
  3814. $images = $objet['categorie_images_inactive'];
  3815. }
  3816. $updates .= 'categorie_commentaires_inactive = categorie_commentaires_inactive ' . $pm . '"' . $objet[$champ . '_commentaires' . $inactive] . '",';
  3817. $updates .= 'categorie_votes_inactive = categorie_votes_inactive ' . $pm . '"' . $objet[$champ . '_votes' . $inactive] . '",';
  3818. $updates .= 'categorie_hits_inactive = categorie_hits_inactive ' . $pm . '"' . $objet[$champ . '_hits' . $inactive] . '",';
  3819. $updates .= 'categorie_poids_inactive = categorie_poids_inactive ' . $pm . '"' . $objet[$champ . '_poids' . $inactive] . '",';
  3820. $updates .= 'categorie_images_inactive = categorie_images_inactive ' . $pm . '"' . $images . '",';
  3821. }
  3822. if ($path == '.') {
  3823. $path = './';
  3824. }
  3825. while ($path != './') {
  3826. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET ' .
  3827. $updates . $active . ' categorie_id = categorie_id
  3828. WHERE categorie_chemin = "' . $path . '"';
  3829. $this->mysql->requete($mysql_requete);
  3830. $path = dirname($path) . '/';
  3831. }
  3832. }
  3833. /*
  3834. * Vérifie si un objet désactivé ou supprimé supprimera ou
  3835. * désactivera le représentant de ses catégories parentes,
  3836. * et choisi un nouveau représentant selon les cas.
  3837. */
  3838. function verif_representant($dir) {
  3839. while ($dir != './') {
  3840. // Si le chemin est une image, on repassera.
  3841. if (preg_match('`/$`', $dir)) {
  3842. // On récupčre les informations utiles de la catégorie.
  3843. $mysql_requete = 'SELECT categorie_id,
  3844. image_representant_id,
  3845. categorie_images,
  3846. categorie_images_inactive
  3847. FROM ' . MYSQL_PREF . 'categories
  3848. WHERE categorie_chemin = "' . $dir . '"';
  3849. $infos = $this->mysql->select($mysql_requete, 11);
  3850. // Si la catégorie ne contient aucune image, on remplace le
  3851. // représentant par une image indiquant que la catégorie est vide,
  3852. // et on désactive la catégorie.
  3853. if (($infos['categorie_images'] + $infos['categorie_images_inactive']) == 0) {
  3854. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET
  3855. categorie_visible = "0",
  3856. image_representant_id = "0"
  3857. WHERE categorie_id = "' . $infos['categorie_id'] . '"';
  3858. $this->mysql->requete($mysql_requete);
  3859. $dir = dirname($dir) . '/';
  3860. continue;
  3861. }
  3862. // Si la catégorie ne contient aucune image visible,
  3863. // on la désactive.
  3864. if ($infos['categorie_images'] == 0) {
  3865. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  3866. SET categorie_visible = "0"
  3867. WHERE categorie_id = "' . $infos['categorie_id'] . '"';
  3868. $this->mysql->requete($mysql_requete);
  3869. }
  3870. // Si le représentant est désactivé ou inexistant, on en choisi un nouveau.
  3871. $mysql_requete = 'SELECT image_visible FROM ' . MYSQL_PREF . 'images
  3872. WHERE image_id = "' . $infos['image_representant_id'] . '"
  3873. AND image_chemin LIKE "' . $dir . '%"';
  3874. $is_active = $this->mysql->select($mysql_requete, 5);
  3875. $visible = 'AND image_visible = "1" ';
  3876. if ($is_active == 'vide') {
  3877. $is_active = 0;
  3878. if ($infos['categorie_images'] == 0) {
  3879. $visible = '';
  3880. }
  3881. }
  3882. if (!$is_active) {
  3883. $mysql_requete = 'SELECT image_id FROM ' . MYSQL_PREF . 'images
  3884. WHERE image_chemin LIKE "' . $dir . '%" ' . $visible . '
  3885. ORDER BY RAND()
  3886. LIMIT 1';
  3887. $nouveau_representant = $this->mysql->select($mysql_requete, 5);
  3888. if ($nouveau_representant != 'vide') {
  3889. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  3890. SET image_representant_id = "' . $nouveau_representant . '"
  3891. WHERE categorie_id = "' . $infos['categorie_id'] . '"';
  3892. $this->mysql->requete($mysql_requete);
  3893. }
  3894. }
  3895. }
  3896. $dir = dirname($dir) . '/';
  3897. }
  3898. }
  3899. /*
  3900. * On attribue ŕ la date de dernier ajout de la catégorie cible
  3901. * la date d'ajout de l'image la plus récente qu'elle contient,
  3902. * et de męme pour les catégorie parentes.
  3903. */
  3904. function date_img_recente($path) {
  3905. while ($path != './' && $path != '.') {
  3906. $mysql_requete = 'SELECT image_date
  3907. FROM ' . MYSQL_PREF . 'images
  3908. WHERE image_chemin LIKE "' . $path . '%"
  3909. ORDER BY image_date DESC
  3910. LIMIT 1';
  3911. $date = $this->mysql->select($mysql_requete);
  3912. if (is_array($date)) {
  3913. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  3914. SET categorie_dernier_ajout = "' . $date[0]['image_date'] . '"
  3915. WHERE categorie_chemin = "' . $path . '"';
  3916. $this->mysql->requete($mysql_requete);
  3917. }
  3918. $path = dirname($path) . '/';
  3919. }
  3920. }
  3921. /*
  3922. * Supprime le contenu d'un répertoire non-vide et éventuellement le répertoire lui-męme.
  3923. */
  3924. function delete_dir($dir, $supp_dir = 1) {
  3925. if ($dir_link = @opendir($dir)) {
  3926. while ($ent = readdir($dir_link)) {
  3927. $sub_obj = $dir . '/' . $ent;
  3928. if (is_dir($sub_obj) && $ent != '.' && $ent != '..') {
  3929. $this->delete_dir($sub_obj, 1);
  3930. } elseif (is_file($sub_obj)) {
  3931. files::suppFile($sub_obj);
  3932. }
  3933. }
  3934. closedir($dir_link);
  3935. }
  3936. if ($supp_dir) {
  3937. if (files::suppFile($dir)) {
  3938. return TRUE;
  3939. }
  3940. } else {
  3941. return TRUE;
  3942. }
  3943. }
  3944. /*
  3945. * UPDATE des informations lors d'une
  3946. * activation/désativation/suppression sur un objet.
  3947. */
  3948. function objet_update_nb($e, $infos, $objet = '') {
  3949. $ok = TRUE;
  3950. $etat = ($e == 'active') ? 1 : 0;
  3951. // On UPDATE l'état 'visible' de l'objet
  3952. $mysql_requete = 'UPDATE ' . MYSQL_PREF . $_REQUEST['type'] . 's SET
  3953. ' . $_REQUEST['type'] . '_visible = "' . $etat . '"
  3954. WHERE ' . $_REQUEST['type'] . '_id = "' . $_REQUEST[$e] . '"';
  3955. if ($this->mysql->requete($mysql_requete)) {
  3956. // Si l'objet est une catégorie ou un album,
  3957. // on UPDATE l'état 'visible' de tous les objets qu'il contient.
  3958. if ($_REQUEST['type'] == 'categorie') {
  3959. // Images.
  3960. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images SET
  3961. image_visible = "' . $etat . '"
  3962. WHERE image_chemin LIKE "' . $infos[$_REQUEST['type'] . '_chemin'] . '%"';
  3963. if (!$this->mysql->requete($mysql_requete)) {
  3964. $ok = FALSE;
  3965. }
  3966. // Catégories.
  3967. if ($e == 'active') {
  3968. $upac = ', categorie_commentaires = categorie_commentaires + categorie_commentaires_inactive,
  3969. categorie_commentaires_inactive = "0",
  3970. categorie_votes = categorie_votes + categorie_votes_inactive,
  3971. categorie_votes_inactive = "0",
  3972. categorie_hits = categorie_hits + categorie_hits_inactive,
  3973. categorie_hits_inactive = "0",
  3974. categorie_poids = categorie_poids + categorie_poids_inactive,
  3975. categorie_poids_inactive = "0",
  3976. categorie_images = categorie_images + categorie_images_inactive,
  3977. categorie_images_inactive = "0"';
  3978. } else {
  3979. $upac = '';
  3980. }
  3981. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET
  3982. categorie_visible = "' . $etat . '"' . $upac . '
  3983. WHERE categorie_chemin LIKE "' . $infos[$_REQUEST['type'] . '_chemin'] . '%"';
  3984. if (!$this->mysql->requete($mysql_requete)) {
  3985. $ok = FALSE;
  3986. }
  3987. }
  3988. // Rčgles d'UPDATE des informations des catégories parentes.
  3989. $images = ($_REQUEST['type'] == 'image') ? 1 : $infos[$_REQUEST['type'] . '_images'];
  3990. $mp_p = ($e == 'active') ? '+' : '-';
  3991. $mp_dc = ($e == 'desactive') ? '+' : '-';
  3992. $P_Ob_P = 'categorie_commentaires = categorie_commentaires ' . $mp_p . ' ' . $infos[$_REQUEST['type'] . '_commentaires'] . ',
  3993. categorie_votes = categorie_votes ' . $mp_p. ' ' . $infos[$_REQUEST['type'] . '_votes'] . ',
  3994. categorie_hits = categorie_hits ' . $mp_p . ' ' . $infos[$_REQUEST['type'] . '_hits'] . ',
  3995. categorie_poids = categorie_poids ' . $mp_p. ' ' . $infos[$_REQUEST['type'] . '_poids'] . ',
  3996. categorie_images = categorie_images ' . $mp_p . ' ' . $images;
  3997. $DC_Ob_P = 'categorie_commentaires_inactive = categorie_commentaires_inactive ' . $mp_dc . ' ' . $infos[$_REQUEST['type'] . '_commentaires'] . ',
  3998. categorie_votes_inactive = categorie_votes_inactive ' . $mp_dc. ' ' . $infos[$_REQUEST['type'] . '_votes'] . ',
  3999. categorie_hits_inactive = categorie_hits_inactive ' . $mp_dc . ' ' . $infos[$_REQUEST['type'] . '_hits'] . ',
  4000. categorie_poids_inactive = categorie_poids_inactive ' . $mp_dc. ' ' . $infos[$_REQUEST['type'] . '_poids'] . ',
  4001. categorie_images_inactive = categorie_images_inactive ' . $mp_dc . ' ' . $images;
  4002. if ($_REQUEST['type'] == 'categorie') {
  4003. $P_Ob_DC = 'categorie_commentaires = categorie_commentaires + ' . $infos['categorie_commentaires_inactive'] . ',
  4004. categorie_votes = categorie_votes + ' . $infos['categorie_votes_inactive'] . ',
  4005. categorie_hits = categorie_hits + ' . $infos['categorie_hits_inactive'] . ',
  4006. categorie_poids = categorie_poids + ' . $infos['categorie_poids_inactive'] . ',
  4007. categorie_images = categorie_images + ' . $infos['categorie_images_inactive'];
  4008. $DC_Ob_DC = 'categorie_commentaires_inactive = categorie_commentaires_inactive - ' . $infos['categorie_commentaires_inactive'] . ',
  4009. categorie_votes_inactive = categorie_votes_inactive - ' . $infos['categorie_votes_inactive'] . ',
  4010. categorie_hits_inactive = categorie_hits_inactive - ' . $infos['categorie_hits_inactive'] . ',
  4011. categorie_poids_inactive = categorie_poids_inactive - ' . $infos['categorie_poids_inactive'] . ',
  4012. categorie_images_inactive = categorie_images_inactive - ' . $infos['categorie_images_inactive'];
  4013. }
  4014. if ($e == 'supprime') {
  4015. if ($_REQUEST['type'] == 'image') {
  4016. $updates = ($infos['image_visible']) ? $P_Ob_P : $DC_Ob_P;
  4017. } else {
  4018. $updates = $P_Ob_P . ', ' . $DC_Ob_DC;
  4019. }
  4020. } else {
  4021. if ($e == 'active' && $_REQUEST['type'] == 'categorie') {
  4022. $updates = $P_Ob_DC . ', ' . $DC_Ob_DC;
  4023. } else {
  4024. $updates = $P_Ob_P . ', ' . $DC_Ob_P;
  4025. }
  4026. }
  4027. // On s'assure que toutes les catégories parentes d'un
  4028. // objet ŕ activer soient également activées.
  4029. if ($e == 'active') {
  4030. $updates .= ', categorie_visible = "1"';
  4031. }
  4032. // On UPDATE les informations des catégories parentes.
  4033. $path = $infos[$_REQUEST['type'] . '_chemin'];
  4034. $where = 'categorie_chemin = "."';
  4035. while ($path != '.') {
  4036. $path = dirname($path);
  4037. if ($path != '.') {
  4038. $where .= ' OR categorie_chemin = "' . $path . '/"';
  4039. }
  4040. //On update la note moyenne de la catégorie pour les images activées et désactivée.
  4041. $path_img = ($path == '.') ? '' : $path . '/';
  4042. $path_cat = ($path == '.') ? '.' : $path . '/';
  4043. $mysql_requete = 'SELECT SUM(image_note*image_votes)/SUM(image_votes) FROM ' . MYSQL_PREF . 'images
  4044. WHERE image_chemin LIKE "' . $path_img . '%"
  4045. AND image_note > 0
  4046. AND image_visible = "1"';
  4047. $note_active = $this->mysql->select($mysql_requete, 5);
  4048. $note_active = ($note_active == '') ? 0 : $note_active;
  4049. $mysql_requete = 'SELECT SUM(image_note*image_votes)/SUM(image_votes) FROM ' . MYSQL_PREF . 'images
  4050. WHERE image_chemin LIKE "' . $path_img . '%"
  4051. AND image_note > 0
  4052. AND image_visible = "0"';
  4053. $note_inactive = $this->mysql->select($mysql_requete, 5);
  4054. $note_inactive = ($note_inactive == '') ? 0 : $note_inactive;
  4055. if (($note_active && $note_active > 0) || ($note_inactive && $note_inactive > 0)) {
  4056. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  4057. SET categorie_note = "' . $note_active . '",
  4058. categorie_note_inactive = "' . $note_inactive . '"
  4059. WHERE categorie_chemin = "' . $path_cat . '"';
  4060. if (!$this->mysql->requete($mysql_requete)) {
  4061. $ok = FALSE;
  4062. }
  4063. }
  4064. }
  4065. // On update les autres informations de toutes les catégories parentes.
  4066. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET ' . $updates . ' WHERE ' . $where;
  4067. if (!$this->mysql->requete($mysql_requete)) {
  4068. $ok = FALSE;
  4069. }
  4070. // Si c'est une catégorie ŕ désactiver, on UPDATE les informations
  4071. // de cette catégorie et de ses sous-catégories.
  4072. if ($e == 'desactive' && $_REQUEST['type'] == 'categorie') {
  4073. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories SET
  4074. categorie_commentaires_inactive = categorie_commentaires_inactive + categorie_commentaires,
  4075. categorie_commentaires = "0",
  4076. categorie_votes_inactive = categorie_votes_inactive + categorie_votes,
  4077. categorie_votes = "0",
  4078. categorie_hits_inactive = categorie_hits_inactive + categorie_hits,
  4079. categorie_hits = "0",
  4080. categorie_poids_inactive = categorie_poids_inactive + categorie_poids,
  4081. categorie_poids = "0",
  4082. categorie_images_inactive = categorie_images_inactive + categorie_images,
  4083. categorie_images = "0"
  4084. WHERE categorie_chemin LIKE "' . $infos['categorie_chemin'] . '%"';
  4085. if (!$this->mysql->requete($mysql_requete)) {
  4086. $ok = FALSE;
  4087. }
  4088. }
  4089. } else {
  4090. $ok = FALSE;
  4091. }
  4092. return $ok;
  4093. }
  4094. /*
  4095. * Affichage de la galerie.
  4096. */
  4097. function galerie() {
  4098. $this->template['infos']['title'] = 'gestion des albums';
  4099. // Page ŕ afficher.
  4100. if (isset($_REQUEST['startnum']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['startnum'])) {
  4101. $startnum = $_REQUEST['startnum'];
  4102. } else {
  4103. $startnum = 0;
  4104. }
  4105. // Catégorie actuelle.
  4106. if (isset($_REQUEST['cat']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['cat'])) {
  4107. $cat = $_REQUEST['cat'];
  4108. } else {
  4109. $cat = 1;
  4110. }
  4111. $this->template['infos']['cat'] = $cat;
  4112. $this->template['infos']['section'] = 'section=galerie&page=gestion&cat=' . $cat;
  4113. // Personnalisation: nombre d'objets maximal ŕ afficher par page.
  4114. if (isset($_REQUEST['nb']) && preg_match('`^[1-9]\d{0,3}$`', $_REQUEST['nb']) && $_REQUEST['nb'] != $this->config['admin_galerie_nb']) {
  4115. $this->update_option('admin_galerie_nb', $_REQUEST['nb']);
  4116. $this->config['admin_galerie_nb'] = $_REQUEST['nb'];
  4117. $this->template['infos']['nb_limit'] = $_REQUEST['nb'];
  4118. $startnum = 0;
  4119. } else {
  4120. $this->template['infos']['nb_limit'] = $this->config['admin_galerie_nb'];
  4121. }
  4122. $limit = $this->config['admin_galerie_nb'];
  4123. $this->template['infos']['startnum'] = $startnum;
  4124. // Personnalisation: trie des objets.
  4125. if (isset($_REQUEST['ordre']) && preg_match('`^\w{2,20}$`', $_REQUEST['ordre']) && $_REQUEST['ordre'] != $this->config['admin_galerie_ordre']) {
  4126. $this->update_option('admin_galerie_ordre', $_REQUEST['ordre']);
  4127. $this->config['admin_galerie_ordre'] = $_REQUEST['ordre'];
  4128. $this->template['infos']['objets_ordre'] = $_REQUEST['ordre'];
  4129. } else {
  4130. $this->template['infos']['objets_ordre'] = $this->config['admin_galerie_ordre'];
  4131. }
  4132. $ordre = $this->template['infos']['objets_ordre'];
  4133. // Personnalisation: sens du trie des objets.
  4134. if (isset($_REQUEST['sens']) && preg_match('`^(ASC|DESC)$`', $_REQUEST['sens']) && $_REQUEST['sens'] != $this->config['admin_galerie_sens']) {
  4135. $this->update_option('admin_galerie_sens', $_REQUEST['sens']);
  4136. $this->config['admin_galerie_sens'] = $_REQUEST['sens'];
  4137. $this->template['infos']['objets_sens'] = $_REQUEST['sens'];
  4138. } else {
  4139. $this->template['infos']['objets_sens'] = $this->config['admin_galerie_sens'];
  4140. }
  4141. $sens = $this->template['infos']['objets_sens'];
  4142. // Récupération des informations de la catégorie actuelle.
  4143. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . 'categories
  4144. WHERE categorie_id = "' . $cat . '"';
  4145. $cat_infos = $this->mysql->select($mysql_requete, 11);
  4146. // On vérifie si la catégorie existe.
  4147. if ($cat_infos == 'vide') {
  4148. header('Location: index.php?section=galerie&page=gestion');
  4149. }
  4150. // Catégorie ou album ?
  4151. $this->template['infos']['objet_type'] = ($cat_infos['categorie_derniere_modif']) ? 'alb' : 'cat';
  4152. // Personnalisation: filtre.
  4153. $filtre = $this->config['admin_galerie_filtre'];
  4154. if (isset($_REQUEST['filtre']) && preg_match('`^(tous|actif|inactif)$`', $_REQUEST['filtre']) && $filtre != $_REQUEST['filtre']) {
  4155. $this->update_option('admin_galerie_filtre', $_REQUEST['filtre']);
  4156. $filtre = $_REQUEST['filtre'];
  4157. $startnum = 0;
  4158. }
  4159. $this->template['infos']['galerie_filtre'] = $filtre;
  4160. $cat_img = ($cat_infos['categorie_derniere_modif']) ? MYSQL_PREF . 'images.image' : MYSQL_PREF . 'categories.categorie';
  4161. switch ($filtre) {
  4162. case 'actif' :
  4163. $filtre = ' AND ' . $cat_img . '_visible = "1"';
  4164. break;
  4165. case 'inactif' :
  4166. $filtre = ' AND ' . $cat_img . '_visible != "1"';
  4167. break;
  4168. case 'tous' :
  4169. $filtre = '';
  4170. break;
  4171. }
  4172. // Liste des trie possibles par type d'objet.
  4173. $this->template['infos']['liste_trie'] = array('nom' => 'Nom', 'date' => 'Date d\'ajout');
  4174. // Récupération des objets de la catégorie actuelle.
  4175. if ($this->template['infos']['objet_type'] == 'alb') {
  4176. $from_where = ' FROM ' . MYSQL_PREF . 'images LEFT JOIN ' . MYSQL_PREF . 'users USING(user_id)
  4177. WHERE ' . MYSQL_PREF . 'images.image_chemin LIKE "' . $cat_infos['categorie_chemin'] . '%"' . $filtre;
  4178. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'images.*,
  4179. ' . MYSQL_PREF . 'users.user_login
  4180. ' . $from_where . '
  4181. ORDER BY ' . MYSQL_PREF . 'images.image_' . $ordre . ' ' . $sens . ',
  4182. ' . MYSQL_PREF . 'images.image_id ' . $sens . '
  4183. LIMIT ' . $startnum . ',' . $limit;
  4184. } else {
  4185. $actuel = ($cat_infos['categorie_chemin'] == '.') ? '' : $cat_infos['categorie_chemin'];
  4186. $from_where = ' FROM ' . MYSQL_PREF . 'categories LEFT JOIN ' . MYSQL_PREF . 'users USING(user_id)
  4187. WHERE ' . MYSQL_PREF . 'categories.categorie_chemin REGEXP "^' . $actuel . '[^/]+/$"' . $filtre;
  4188. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'categories.*,
  4189. ' . MYSQL_PREF . 'users.user_login
  4190. ' . $from_where . '
  4191. ORDER BY ' . MYSQL_PREF . 'categories.categorie_' . $ordre . ' ' . $sens . '
  4192. LIMIT ' . $startnum . ',' . $limit;
  4193. }
  4194. $this->template['objets'] = $this->mysql->select($mysql_requete);
  4195. // On récupčre les dimensions des représentants de chaque objet.
  4196. $where_paths = '';
  4197. if (is_array($this->template['objets'])) {
  4198. if ($this->template['infos']['objet_type'] != 'alb') {
  4199. for ($i = 0; $i < count($this->template['objets']); $i++) {
  4200. if ($this->template['objets'][$i]['image_representant_id']) {
  4201. $where_paths .= 'image_id = "' . $this->template['objets'][$i]['image_representant_id'] . '" OR ';
  4202. }
  4203. }
  4204. $where_paths = preg_replace('`OR $`', '', $where_paths);
  4205. if ($where_paths) {
  4206. $mysql_requete = 'SELECT image_id,
  4207. image_chemin,
  4208. image_largeur,
  4209. image_hauteur
  4210. FROM ' . MYSQL_PREF . 'images
  4211. WHERE ' . $where_paths;
  4212. $this->template['representants'] = $this->mysql->select($mysql_requete, 4);
  4213. }
  4214. }
  4215. }
  4216. // Récupération du nombre d'objets de la catégorie actuelle.
  4217. $mysql_requete = 'SELECT COUNT(*) ' . $from_where;
  4218. if ($nc = $this->mysql->select($mysql_requete, 5)) {
  4219. $this->template['infos']['nb_objets'] = $nc;
  4220. } else {
  4221. $this->template['infos']['nb_objets'] = 0;
  4222. }
  4223. // On détermine le nombre de pages et la page actuelle.
  4224. $this->template['infos']['nb_pages'] = ceil(($this->template['infos']['nb_objets']) / $this->config['admin_galerie_nb']);
  4225. for ($n = 0; $n < $this->template['infos']['nb_pages']; $n++) {
  4226. $num = $n * $this->config['admin_galerie_nb'];
  4227. $this->template['nav']['pages'][$n + 1]['page'] = $num;
  4228. if ($num == $startnum) {
  4229. $this->template['infos']['page_actuelle'] = $n + 1;
  4230. }
  4231. }
  4232. // On détermine les pages suivantes, précédentes, de début et de fin.
  4233. $this->template['nav']['suivante'][1] = $startnum + $this->config['admin_galerie_nb'];
  4234. $this->template['nav']['precedente'][1] = $startnum - $this->config['admin_galerie_nb'];
  4235. $this->template['nav']['premiere'][1] = 0;
  4236. $this->template['nav']['derniere'][1] = ($this->template['infos']['nb_pages'] * $this->config['admin_galerie_nb']) - $this->config['admin_galerie_nb'];
  4237. // On détermine la position de l'objet actuel.
  4238. if ($startnum == 0) {
  4239. $this->template['nav']['premiere'][0] = 1;
  4240. }
  4241. if ($this->template['nav']['precedente'][1] < 0) {
  4242. $this->template['nav']['precedente'][0] = 1;
  4243. }
  4244. if ($this->template['nav']['suivante'][1] >= ($this->template['infos']['nb_pages'] * $this->config['admin_galerie_nb']) ||
  4245. $this->template['nav']['suivante'][1] >= $this->template['infos']['nb_objets']) {
  4246. $this->template['nav']['suivante'][0] = 1;
  4247. }
  4248. if ($startnum >= $this->template['nav']['derniere'][1]) {
  4249. $this->template['nav']['derniere'][0] = 1;
  4250. }
  4251. // Barre de position.
  4252. $obj_chemin = $cat_infos['categorie_chemin'];
  4253. $this->template['galerie']['position'] = '';
  4254. if ($obj_chemin) {
  4255. $parent_id = 0;
  4256. $parent = dirname($obj_chemin);
  4257. while ($parent != '.') {
  4258. $mysql_requete = 'SELECT categorie_id,categorie_chemin,categorie_nom FROM ' . MYSQL_PREF . 'categories
  4259. WHERE categorie_chemin = "' . $parent . '/"';
  4260. $p_i = $this->mysql->select($mysql_requete, 11);
  4261. if (empty($parent_id)) {
  4262. $parent_id = $p_i['categorie_id'];
  4263. }
  4264. $parent = dirname($p_i['categorie_chemin']);
  4265. $this->template['galerie']['position'] = '%sep<a href="index.php?section=galerie&amp;page=gestion&amp;cat=' .
  4266. $p_i['categorie_id'] . '">' .
  4267. strip_tags($p_i['categorie_nom']) . '</a>' .
  4268. $this->template['galerie']['position'];
  4269. }
  4270. }
  4271. $pos_actuel = ($this->template['infos']['cat'] > 1) ? '' : ' class="pos_actuel"';
  4272. $this->template['galerie']['position'] = '<a' . $pos_actuel . ' href="index.php?section=galerie&amp;page=gestion&amp;cat=1' .
  4273. '">galerie</a>' .
  4274. $this->template['galerie']['position'];
  4275. if ($this->template['infos']['cat'] > 1) {
  4276. $this->template['galerie']['position'] .= '%sep<a href="index.php?section=galerie&amp;page=gestion&amp;cat=' .
  4277. $this->template['infos']['cat'] .
  4278. '" class="pos_actuel">' .
  4279. strip_tags($cat_infos['categorie_nom']) . '</a>';
  4280. }
  4281. // Lien retour.
  4282. if ($cat > 1) {
  4283. $dir = dirname($cat_infos['categorie_chemin']);
  4284. $dir = ($dir == '.') ? '' : $dir . '/';
  4285. $mysql_requete = 'SELECT categorie_id FROM ' . MYSQL_PREF . 'categories
  4286. WHERE categorie_chemin REGEXP "^' . $dir . '[^/]+/$"
  4287. ORDER BY categorie_' . $ordre . ' ' . $sens;
  4288. $voisines = $this->mysql->select($mysql_requete, 2);
  4289. $ids = array_flip(array_keys($voisines));
  4290. $objet_num = $ids[$cat_infos['categorie_id']] + 1;
  4291. $parent_page = (ceil($objet_num / $limit) * $limit) - $limit;
  4292. $prvs = (empty($parent_page)) ? '' : '&amp;startnum=' . $parent_page ;
  4293. $parent_id = (empty($parent_id)) ? 1 : $parent_id;
  4294. $this->template['nav']['retour'] = './?section=galerie&amp;page=gestion&amp;cat=' . $parent_id . $prvs;
  4295. }
  4296. // On génčre une liste déroulante de la hiérarchie de la galerie,
  4297. // ainsi que qu'une liste pour le déplacement des objets.
  4298. $selected = ($cat == 1) ? ' selected="selected"' : '';
  4299. $this->template['nav']['hierarchie'] = '<select class="albums_list" name="cat" onchange="if (this.options[this.selectedIndex].value) window.location.href=\'?cat=\' + this.options[this.selectedIndex].value + \'&amp;section=galerie&amp;page=gestion\';" >';
  4300. $this->template['nav']['deplace_img'] = '<select class="albums_list" name="vers">';
  4301. if ($this->template['infos']['objet_type'] == 'cat' && $cat > 1) {
  4302. $this->template['nav']['deplace_img'] .= '<option class="gal_hier_cat" value="1">galerie</option>';
  4303. }
  4304. $this->template['nav']['hierarchie'] .= '<option' . $selected . ' class="gal_hier_cat" value="1">galerie</option>';
  4305. $this->template['nav']['deplace_cat'] = array();
  4306. $mysql_requete = 'SELECT categorie_id,
  4307. categorie_nom,
  4308. categorie_chemin,
  4309. categorie_images,
  4310. categorie_derniere_modif
  4311. FROM ' . MYSQL_PREF . 'categories
  4312. WHERE categorie_id != 1
  4313. ORDER BY categorie_' . $ordre . ' ' . $sens;
  4314. $categories = $this->mysql->select($mysql_requete);
  4315. $path = $cat_infos['categorie_chemin'];
  4316. if ($path == '.') {
  4317. $path = '';
  4318. }
  4319. $this->galerie_hierarchie($categories, $path);
  4320. if (isset($this->template['nav']['deplace_cat'][0])) {
  4321. $this->template['display']['cat_move'] = 1;
  4322. }
  4323. $this->template['nav']['hierarchie'] .= '</select>';
  4324. $this->template['nav']['deplace_img'] .= '</select>';
  4325. // Message a afficher si la catégorie ou l'album est vide.
  4326. if (!$this->template['infos']['nb_objets']) {
  4327. $this->template['display']['cat_vide'] = 1;
  4328. switch ($this->template['infos']['galerie_filtre']) {
  4329. case 'actif' :
  4330. $msg_img = ' active';
  4331. $msg_cat = ' actif';
  4332. break;
  4333. case 'inactif' :
  4334. $msg_img = ' inactive';
  4335. $msg_cat = ' inactif';
  4336. break;
  4337. case 'tous' :
  4338. $msg_img = '';
  4339. $msg_cat = '';
  4340. break;
  4341. }
  4342. if ($this->template['infos']['objet_type'] == 'alb') {
  4343. $this->template['infos']['info']['cat_vide'] = 'L\'album ne contient aucune image' . $msg_img . '.';
  4344. } else {
  4345. $this->template['infos']['info']['cat_vide'] = 'La catégorie ne contient aucun objet' . $msg_cat . '.';
  4346. }
  4347. }
  4348. }
  4349. /*
  4350. * Génčre une liste déroulante de la hierarchie de la galerie.
  4351. */
  4352. function galerie_hierarchie($categories, $apath, $path = '', $level = 1) {
  4353. if (!is_array($categories)) {
  4354. return;
  4355. }
  4356. foreach ($categories as $id => $cat) {
  4357. if (preg_match('`^' . $path . '[^/]+/$`', $categories[$id]['categorie_chemin'])) {
  4358. $actuel = $categories[$id];
  4359. unset($categories[$id]);
  4360. $selected = ($actuel['categorie_chemin'] == $apath) ? ' selected="selected"' : '';
  4361. // Catégorie.
  4362. if ($actuel['categorie_derniere_modif'] == 0) {
  4363. $this->template['nav']['hierarchie'] .= '<option' . $selected . ' class="gal_hier_cat" value="' . $actuel['categorie_id'] . '">';
  4364. $this->template['nav']['hierarchie'] .= str_repeat('&nbsp;', $level*4) . outils::html_specialchars(strip_tags($actuel['categorie_nom'])) . '</option>';
  4365. if ($this->template['infos']['objet_type'] == 'alb') {
  4366. if (!preg_match('`' . $apath . '.+`', $actuel['categorie_chemin'])) {
  4367. $this->template['nav']['deplace_img'] .= '<optgroup label="' . str_repeat('&nbsp;', $level*4) . outils::html_specialchars(strip_tags($actuel['categorie_nom'])) . '">';
  4368. }
  4369. } else {
  4370. array_push($this->template['nav']['deplace_cat'],
  4371. array(
  4372. 'id' => $actuel['categorie_id'],
  4373. 'nom' => $actuel['categorie_nom'],
  4374. 'chemin' => $actuel['categorie_chemin'],
  4375. 'space' => $level
  4376. )
  4377. );
  4378. }
  4379. $this->galerie_hierarchie($categories, $apath, $actuel['categorie_chemin'], $level+1);
  4380. // Album.
  4381. } else {
  4382. $this->template['nav']['hierarchie'] .= '<option' . $selected . ' value="' . $actuel['categorie_id'] . '">';
  4383. $this->template['nav']['hierarchie'] .= str_repeat('&nbsp;', $level*4) . '|--&nbsp;' . outils::html_specialchars(strip_tags($actuel['categorie_nom'])) . '</option>';
  4384. if ($actuel['categorie_chemin'] != $apath && $this->template['infos']['objet_type'] == 'alb') {
  4385. $this->template['nav']['deplace_img'] .= '<option value="' . $actuel['categorie_id'] . '">';
  4386. $this->template['nav']['deplace_img'] .= str_repeat('&nbsp;', $level*4) . '|--&nbsp;' . outils::html_specialchars(strip_tags($actuel['categorie_nom'])) . '</option>';
  4387. }
  4388. }
  4389. if ($actuel['categorie_derniere_modif'] == 0
  4390. && !preg_match('`' . $apath . '.+`', $actuel['categorie_chemin'])
  4391. && $this->template['infos']['objet_type'] == 'alb') {
  4392. $this->template['nav']['deplace_img'] .= '</optgroup>';
  4393. }
  4394. }
  4395. }
  4396. }
  4397. /*
  4398. * Changement du représentant d'une catégorie ou d'un album.
  4399. */
  4400. function galerie_representant() {
  4401. $this->template['infos']['title'] = 'représentants';
  4402. $nb_max = 48;
  4403. if (!preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['cat'])
  4404. || empty($_REQUEST['obj']) || !preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['obj'])
  4405. || empty($_REQUEST['sub_obj']) || !preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['sub_obj'])) {
  4406. header('Location: index.php?section=galerie&page=gestion');
  4407. }
  4408. // Informations de la catégorie.
  4409. $mysql_requete = 'SELECT categorie_nom,categorie_derniere_modif,categorie_chemin,categorie_visible FROM ' . MYSQL_PREF . 'categories
  4410. WHERE categorie_id = "' . $_REQUEST['sub_obj'] . '"';
  4411. $cat_infos = $this->mysql->select($mysql_requete, 11);
  4412. // Page ŕ afficher.
  4413. if (isset($_REQUEST['startnum']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['startnum'])) {
  4414. $startnum = $_REQUEST['startnum'];
  4415. } else {
  4416. $startnum = 0;
  4417. }
  4418. // Récupération des images de la catégorie.
  4419. $visible = ($cat_infos['categorie_visible']) ? ' AND image_visible = "1"': '';
  4420. $from_where = 'FROM ' . MYSQL_PREF . 'images
  4421. WHERE image_chemin LIKE "' . $cat_infos['categorie_chemin'] . '%" ' . $visible;
  4422. $mysql_requete = 'SELECT image_id,image_chemin,image_nom ' . $from_where . '
  4423. ORDER BY image_' . $this->config['admin_galerie_ordre'] . ' ' . $this->config['admin_galerie_sens'] . '
  4424. LIMIT ' . $startnum . ',' . $nb_max;
  4425. $this->template['vignettes'] = $this->mysql->select($mysql_requete);
  4426. // Récupération du nombre d'images de la catégorie.
  4427. $mysql_requete = 'SELECT COUNT(*) ' . $from_where;
  4428. if (!$img_nb = $this->mysql->select($mysql_requete, 5)) {
  4429. $img_nb = 0;
  4430. }
  4431. // On détermine le nombre de pages et la page actuelle.
  4432. $this->template['infos']['nb_pages'] = ceil(($img_nb) / $nb_max);
  4433. for ($n = 0; $n < $this->template['infos']['nb_pages']; $n++) {
  4434. $num = $n * $nb_max;
  4435. $this->template['nav']['pages'][$n + 1]['page'] = $num;
  4436. if ($num == $startnum) {
  4437. $this->template['infos']['page_actuelle'] = $n + 1;
  4438. }
  4439. }
  4440. // On détermine les pages suivantes, précédentes, de début et de fin.
  4441. $this->template['nav']['suivante'][1] = $startnum + $nb_max;
  4442. $this->template['nav']['precedente'][1] = $startnum - $nb_max;
  4443. $this->template['nav']['premiere'][1] = 0;
  4444. $this->template['nav']['derniere'][1] = ($this->template['infos']['nb_pages'] * $nb_max) - $nb_max;
  4445. // On détermine la position de l'objet actuel.
  4446. if ($startnum == 0) {
  4447. $this->template['nav']['premiere'][0] = 1;
  4448. }
  4449. if ($this->template['nav']['precedente'][1] < 0) {
  4450. $this->template['nav']['precedente'][0] = 1;
  4451. }
  4452. if ($this->template['nav']['suivante'][1] >= ($this->template['infos']['nb_pages'] * $nb_max) ||
  4453. $this->template['nav']['suivante'][1] >= $img_nb) {
  4454. $this->template['nav']['suivante'][0] = 1;
  4455. }
  4456. if ($startnum >= $this->template['nav']['derniere'][1]) {
  4457. $this->template['nav']['derniere'][0] = 1;
  4458. }
  4459. // Si c'est une catégorie, on génčre une liste déroulante pour n'afficher
  4460. // que les représentants de chaque sous-catégorie.
  4461. $mysql_requete = 'SELECT categorie_id,categorie_nom,categorie_chemin,categorie_derniere_modif FROM ' . MYSQL_PREF . 'categories
  4462. WHERE categorie_id = "' . $_REQUEST['obj'] . '"';
  4463. $obj = $this->mysql->select($mysql_requete, 11);
  4464. if (!$obj['categorie_derniere_modif']) {
  4465. $this->template['display']['rep_nav'] = 1;
  4466. $this->template['infos']['type_nom'] = 'la catégorie Ť ' . $obj['categorie_nom'] . ' ť';
  4467. $selected = (empty($_REQUEST['sub_obj']) || $_REQUEST['sub_obj'] == $_REQUEST['obj']) ? ' selected="selected"' : '';
  4468. $this->template['nav']['hierarchie'] = '<select name="sub_obj" onchange="if (this.options[this.selectedIndex].value) window.location.href=\'?sub_obj=\' + this.options[this.selectedIndex].value + \'&amp;section=representant&amp;str=' . $_REQUEST['str'] . '&amp;cat=' . $_REQUEST['cat'] . '&amp;obj=' . $_REQUEST['obj'] . '\';" >';
  4469. $this->template['nav']['hierarchie'] .= '<option' . $selected . ' class="gal_hier_cat" value="' . $obj['categorie_id'] . '">' . $obj['categorie_nom'] . '</option>';
  4470. $this->galerie_hierarchie_thumbs($obj['categorie_chemin']);
  4471. $this->template['nav']['hierarchie'] .= '</select>';
  4472. } else {
  4473. $this->template['infos']['type_nom'] = 'l\'album ' . $obj['categorie_nom'];
  4474. }
  4475. $this->template['infos']['section'] = 'section=representant&cat=' . $_REQUEST['cat'] . '&str=' . $_REQUEST['str'] . '&obj=' . $_REQUEST['obj'] . '&sub_obj=' . $_REQUEST['sub_obj'];
  4476. }
  4477. /*
  4478. * Liste déroulante pour la page représentant.
  4479. */
  4480. function galerie_hierarchie_thumbs($parent, $space = '&nbsp;&nbsp;&nbsp;&nbsp;') {
  4481. $mysql_requete = 'SELECT categorie_id,categorie_nom,categorie_chemin,categorie_visible,categorie_derniere_modif
  4482. FROM ' . MYSQL_PREF . 'categories
  4483. WHERE categorie_chemin REGEXP "^' . $parent . '[^/]+/$"
  4484. ORDER BY categorie_' . $this->config['admin_galerie_ordre'] . ' ' . $this->config['admin_galerie_sens'];
  4485. $cats = $this->mysql->select($mysql_requete);
  4486. if ($cats != 'vide') {
  4487. for ($i = 0; $i < count($cats); $i++) {
  4488. $obj = (isset($_REQUEST['sub_obj'])) ? $_REQUEST['sub_obj'] : $_REQUEST['obj'];
  4489. $selected = ($cats[$i]['categorie_id'] == $obj) ? ' selected="selected"' : '';
  4490. if ($cats[$i]['categorie_derniere_modif'] == 0) {
  4491. if ($cats[$i]['categorie_visible']) {
  4492. $this->template['nav']['hierarchie'] .= '<option' . $selected . ' class="gal_hier_cat" value="' . $cats[$i]['categorie_id'] . '">' . $space . htmlentities($cats[$i]['categorie_nom']) . '</option>';
  4493. }
  4494. $this->galerie_hierarchie_thumbs($cats[$i]['categorie_chemin'], $space . '&nbsp;&nbsp;&nbsp;&nbsp;');
  4495. } else {
  4496. if ($cats[$i]['categorie_visible']) {
  4497. $this->template['nav']['hierarchie'] .= '<option' . $selected . ' value="' . $cats[$i]['categorie_id'] . '">' . $space . '|--&nbsp;' . htmlentities($cats[$i]['categorie_nom']) . '</option>';
  4498. }
  4499. }
  4500. }
  4501. }
  4502. }
  4503. /*
  4504. * Affichage des votes.
  4505. */
  4506. function display_votes() {
  4507. if (isset($_POST['vote_action']) || isset($_GET['delete'])) {
  4508. $this->gestion_votes();
  4509. }
  4510. // Page ŕ afficher.
  4511. $startnum = 0;
  4512. if (isset($_GET['startnum']) && preg_match('`^[1-9]\d{0,9}$`', $_GET['startnum'])) {
  4513. $startnum = $_GET['startnum'];
  4514. }
  4515. // Nombre de votes par page.
  4516. if (isset($_REQUEST['nb']) && preg_match('`^[1-9]\d{0,3}$`', $_REQUEST['nb']) && $_REQUEST['nb'] != $this->config['admin_vote_nb']) {
  4517. $this->update_option('admin_vote_nb', $_REQUEST['nb']);
  4518. $this->config['admin_vote_nb'] = $_REQUEST['nb'];
  4519. $this->template['infos']['nb_votes'] = $_REQUEST['nb'];
  4520. $startnum = 0;
  4521. } else {
  4522. $this->template['infos']['nb_votes'] = $this->config['admin_vote_nb'];
  4523. }
  4524. $this->template['infos']['nb_votes'] = $this->config['admin_vote_nb'];
  4525. // Trie des votes : ordre.
  4526. if (isset($_REQUEST['sort']) && preg_match('`^vote_(date|ip|note)|image_nom|categorie_nom$`', $_REQUEST['sort']) && $_REQUEST['sort'] != $this->config['admin_vote_ordre']) {
  4527. $this->template['infos']['vote_sort'] = $_REQUEST['sort'];
  4528. $this->update_option('admin_vote_ordre', $_REQUEST['sort']);
  4529. } else {
  4530. $this->template['infos']['vote_sort'] = $this->config['admin_vote_ordre'];
  4531. }
  4532. // Trie des votes : sens.
  4533. if (isset($_REQUEST['sens']) && preg_match('`^ASC|DESC$`', $_REQUEST['sens']) && $_REQUEST['sens'] != $this->config['admin_vote_sens']) {
  4534. $this->template['infos']['vote_sens'] = $_REQUEST['sens'];
  4535. $this->update_option('admin_vote_sens', $_REQUEST['sens']);
  4536. } else {
  4537. $this->template['infos']['vote_sens'] = $this->config['admin_vote_sens'];
  4538. }
  4539. $this->template['infos']['title'] = 'gestion des votes';
  4540. $this->template['infos']['startnum'] = $startnum;
  4541. $params = '';
  4542. // Objet actuel.
  4543. $categorie_dernier_modif = '';
  4544. if (isset($_GET['img']) && preg_match('`^[1-9]\d{0,9}$`', $_GET['img'])) {
  4545. $obj = $_GET['img'];
  4546. $obj_type = 'img';
  4547. $obj_type_ext = 'image';
  4548. $params .= '&img=' . $_GET['img'];
  4549. } elseif (isset($_GET['cat']) && preg_match('`^[1-9]\d{0,9}$`', $_GET['cat'])) {
  4550. $obj = $_GET['cat'];
  4551. $obj_type = 'cat';
  4552. $obj_type_ext = 'categorie';
  4553. $params .= '&cat=' . $_GET['cat'];
  4554. $categorie_dernier_modif = ', categorie_derniere_modif';
  4555. } else {
  4556. $obj = 1;
  4557. $obj_type = 'cat';
  4558. $obj_type_ext = 'categorie';
  4559. $categorie_dernier_modif = ', categorie_derniere_modif';
  4560. }
  4561. $this->template['infos']['obj'] = $obj;
  4562. $this->template['infos']['obj_type'] = $obj_type;
  4563. $mysql_requete = 'SELECT ' . $obj_type_ext . '_chemin,
  4564. ' . $obj_type_ext . '_nom
  4565. ' . $categorie_dernier_modif . '
  4566. FROM ' . MYSQL_PREF . $obj_type_ext . 's
  4567. WHERE ' . $obj_type_ext . '_id = "' . $obj . '"';
  4568. $obj = $this->mysql->select($mysql_requete, 11);
  4569. if (!is_array($obj)) {
  4570. header('Location:index.php?section=votes');
  4571. exit;
  4572. }
  4573. $obj_chemin = ($obj[$obj_type_ext . '_chemin'] == '.') ? '' : $obj[$obj_type_ext . '_chemin'];
  4574. // Date.
  4575. $date = '';
  4576. if (!empty($_GET['date']) && preg_match('`^\d{1,11}$`', $_GET['date'])) {
  4577. $ts = $_GET['date'];
  4578. $jour = date('d', $ts);
  4579. $mois = date('m', $ts);
  4580. $annee = date('Y', $ts);
  4581. $debut = mktime(0,0,0,$mois,$jour,$annee);
  4582. $fin = mktime(23,59,59,$mois,$jour,$annee);
  4583. $date = ' AND ' . MYSQL_PREF . 'votes.vote_date >= "' . $debut . '"';
  4584. $date .= ' AND ' . MYSQL_PREF . 'votes.vote_date <= "' . $fin . '"';
  4585. $params .= '&date=' . $_GET['date'];
  4586. }
  4587. // IP.
  4588. $IP = '';
  4589. if (!empty($_GET['ip'])) {
  4590. $IP = ' AND ' . MYSQL_PREF . 'votes.vote_ip = "' . outils::protege_mysql($_GET['ip'], $this->mysql->lien) . '"';
  4591. $params .= '&ip=' . $_GET['ip'];
  4592. }
  4593. // Image.
  4594. $img = '';
  4595. if (isset($_GET['img']) && preg_match('`^\d{1,12}$`', $_GET['img'])) {
  4596. $img = ' AND ' . MYSQL_PREF . 'votes.image_id = "' . $_GET['img'] . '"';
  4597. $params .= '&img=' . $_GET['img'];
  4598. }
  4599. // WHERE.
  4600. $from_where = 'FROM ' . MYSQL_PREF . 'votes,
  4601. ' . MYSQL_PREF . 'images,
  4602. ' . MYSQL_PREF . 'categories
  4603. WHERE ' . MYSQL_PREF . 'votes.image_id = ' . MYSQL_PREF . 'images.image_id
  4604. AND ' . MYSQL_PREF . 'images.categorie_parent_id = ' . MYSQL_PREF . 'categories.categorie_id
  4605. AND ' . MYSQL_PREF . 'images.image_chemin LIKE "' . $obj_chemin . '%"'
  4606. . $date
  4607. . $IP
  4608. . $img;
  4609. // On récupčre les votes.
  4610. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'votes.vote_id,
  4611. ' . MYSQL_PREF . 'votes.vote_date AS vote_date,
  4612. ' . MYSQL_PREF . 'votes.vote_note AS vote_note,
  4613. ' . MYSQL_PREF . 'votes.vote_ip AS vote_ip,
  4614. ' . MYSQL_PREF . 'images.image_id,
  4615. ' . MYSQL_PREF . 'images.image_chemin,
  4616. ' . MYSQL_PREF . 'images.image_nom AS image_nom,
  4617. ' . MYSQL_PREF . 'images.image_largeur,
  4618. ' . MYSQL_PREF . 'images.image_hauteur,
  4619. ' . MYSQL_PREF . 'categories.categorie_id,
  4620. ' . MYSQL_PREF . 'categories.categorie_nom AS categorie_nom
  4621. ' . $from_where . '
  4622. ORDER BY ' . $this->template['infos']['vote_sort'] . ' ' . $this->template['infos']['vote_sens'] . '
  4623. LIMIT ' . $startnum . ',' . $this->config['admin_vote_nb'];
  4624. $this->template['votes'] = $this->mysql->select($mysql_requete);
  4625. if (!is_array($this->template['votes'])) {
  4626. $delete = '';
  4627. if (isset($this->template['infos']['erreur'])) {
  4628. $delete = '&s=error';
  4629. } elseif (isset($this->template['infos']['action'])) {
  4630. $delete = '&s=ok';
  4631. }
  4632. if ($delete) {
  4633. header('Location: ?section=votes' . $delete);
  4634. exit;
  4635. }
  4636. }
  4637. if (isset($_GET['s'])) {
  4638. if ($_GET['s'] == 'ok') {
  4639. $this->template['infos']['action']['delete_votes'] = 'Tous les votes sélectionnés ont été supprimés.';
  4640. } elseif ($_GET['s'] == 'errror') {
  4641. $this->template['infos']['erreur']['delete_votes'] = '[' . __LINE__ . '] Des erreurs se sont produites lors de la suppression des votes.';
  4642. }
  4643. }
  4644. // Nombre total de votes.
  4645. $mysql_requete = 'SELECT COUNT(' . MYSQL_PREF . 'votes.image_id) ' . $from_where;
  4646. $this->template['infos']['nb_objets'] = $this->mysql->select($mysql_requete, 5);
  4647. // On détermine le nombre de pages et la page actuelle.
  4648. $this->template['infos']['nb_pages'] = ceil(($this->template['infos']['nb_objets']) / $this->config['admin_vote_nb']);
  4649. for ($n = 0; $n < $this->template['infos']['nb_pages']; $n++) {
  4650. $num = $n * $this->config['admin_vote_nb'];
  4651. $this->template['nav']['pages'][$n + 1]['page'] = $num;
  4652. if ($num == $startnum) {
  4653. $this->template['infos']['page_actuelle'] = $n + 1;
  4654. }
  4655. }
  4656. // On détermine les pages suivantes, précédentes, de début et de fin.
  4657. $this->template['nav']['suivante'][1] = $startnum + $this->config['admin_vote_nb'];
  4658. $this->template['nav']['precedente'][1] = $startnum - $this->config['admin_vote_nb'];
  4659. $this->template['nav']['premiere'][1] = 0;
  4660. $this->template['nav']['derniere'][1] = ($this->template['infos']['nb_pages'] * $this->config['admin_vote_nb']) - $this->config['admin_vote_nb'];
  4661. // On détermine la position de l'objet actuel.
  4662. if ($startnum == 0) {
  4663. $this->template['nav']['premiere'][0] = 1;
  4664. }
  4665. if ($this->template['nav']['precedente'][1] < 0) {
  4666. $this->template['nav']['precedente'][0] = 1;
  4667. }
  4668. if ($this->template['nav']['suivante'][1] >= ($this->template['infos']['nb_pages'] * $this->config['admin_vote_nb']) ||
  4669. $this->template['nav']['suivante'][1] >= $this->template['infos']['nb_objets']) {
  4670. $this->template['nav']['suivante'][0] = 1;
  4671. }
  4672. if ($startnum >= $this->template['nav']['derniere'][1]) {
  4673. $this->template['nav']['derniere'][0] = 1;
  4674. }
  4675. // Type.
  4676. $type = 'cat';
  4677. if (isset($obj['categorie_derniere_modif'])) {
  4678. if (!empty($obj['categorie_derniere_modif'])) {
  4679. $type = 'alb';
  4680. }
  4681. } else {
  4682. $type = 'img';
  4683. }
  4684. $this->template['infos']['obj_type'] = $type;
  4685. // Sous-objets.
  4686. $subcats = true;
  4687. if (isset($obj['categorie_derniere_modif']) && ($IP || $date)) {
  4688. $subcats = false;
  4689. }
  4690. if (is_array($this->template['votes']) && $subcats) {
  4691. $sub_cat = '';
  4692. if (empty($obj['categorie_derniere_modif'])) {
  4693. $mysql_requete = 'SELECT categorie_id,categorie_nom,categorie_chemin FROM ' . MYSQL_PREF . 'categories
  4694. WHERE categorie_chemin REGEXP "^' . $obj_chemin . '[^/]+/$"
  4695. AND categorie_id NOT IN (1)
  4696. AND (categorie_votes > 0 OR categorie_votes_inactive > 0)';
  4697. $sub_cat = $this->mysql->select($mysql_requete);
  4698. if (is_array($sub_cat)) {
  4699. for ($i = 0; $i < count($sub_cat); $i++) {
  4700. $this->template['votes']['sub_item'][$i] = $sub_cat[$i];
  4701. $this->template['display']['subcats'] = 1;
  4702. $this->template['infos']['sub_objects'] = 'categorie';
  4703. }
  4704. }
  4705. } else {
  4706. $mysql_requete = 'SELECT DISTINCT ' . MYSQL_PREF . 'images.image_id,
  4707. ' . MYSQL_PREF . 'images.image_nom,
  4708. ' . MYSQL_PREF . 'images.image_chemin
  4709. FROM ' . MYSQL_PREF . 'images INNER JOIN ' . MYSQL_PREF . 'votes USING (image_id)
  4710. WHERE ' . MYSQL_PREF . 'images.image_chemin REGEXP "^' . $obj_chemin . '[^/]+$"
  4711. AND ' . MYSQL_PREF . 'images.image_note > 0 '
  4712. . $date
  4713. . $IP
  4714. . $img;
  4715. $imgs = $this->mysql->select($mysql_requete);
  4716. if (is_array($imgs)) {
  4717. for ($i = 0; $i < count($imgs); $i++) {
  4718. $this->template['votes']['sub_item'][$i] = $imgs[$i];
  4719. $this->template['display']['subcats'] = 1;
  4720. $this->template['infos']['sub_objects'] = 'image';
  4721. }
  4722. }
  4723. }
  4724. }
  4725. // Barre de position.
  4726. $this->template['votes']['position'] = '';
  4727. if (is_array($this->template['votes'])) {
  4728. if ($obj_chemin) {
  4729. $parent = dirname($obj_chemin);
  4730. while ($parent != '.') {
  4731. $mysql_requete = 'SELECT categorie_id,
  4732. categorie_chemin,
  4733. categorie_nom
  4734. FROM ' . MYSQL_PREF . 'categories
  4735. WHERE categorie_chemin = "' . $parent . '/"';
  4736. $p_i = $this->mysql->select($mysql_requete, 11);
  4737. $parent = dirname($p_i['categorie_chemin']);
  4738. $this->template['votes']['position'] = '%sep<a href="index.php?section=votes&amp;cat=' .
  4739. $p_i['categorie_id'] . '">' .
  4740. strip_tags($p_i['categorie_nom']) . '</a>' .
  4741. $this->template['votes']['position'];
  4742. }
  4743. }
  4744. $pos_actuel = ($this->template['infos']['obj'] > 1) ? '' : ' class="pos_actuel"' ;
  4745. $this->template['votes']['position'] = '<a' . $pos_actuel . ' href="index.php?section=votes">galerie</a>'
  4746. . $this->template['votes']['position'];
  4747. if ($this->template['infos']['obj'] > 1) {
  4748. $this->template['votes']['position'] .= '%sep<a href="index.php?section=votes&amp;' . $obj_type . '=' .
  4749. $this->template['infos']['obj'] .
  4750. '" class="pos_actuel">' .
  4751. strip_tags($obj[$obj_type_ext . '_nom']) . '</a>';
  4752. }
  4753. }
  4754. $this->template['infos']['section'] = 'section=votes&' . $params;
  4755. }
  4756. /*
  4757. * Gestion des votes
  4758. */
  4759. function gestion_votes() {
  4760. if (isset($_GET['delete']) && $_GET['delete'] == 'all') {
  4761. $this->verifVID();
  4762. if (empty($_GET['date']) && empty($_GET['ip'])) {
  4763. $where = ' WHERE ';
  4764. $ok = true;
  4765. // Suppression de tous les votes d'une image.
  4766. if (isset($_GET['img']) && preg_match('`^\d{1,12}$`', $_GET['img'])) {
  4767. $where .= MYSQL_PREF . 'images.image_id = "' . $_GET['img'] . '" ';
  4768. // Suppression de tous les votes d'une catégorie.
  4769. } elseif ($cat_path = $this->get_categorie_vote_path()) {
  4770. $where .= MYSQL_PREF . 'images.image_chemin LIKE "' . $cat_path . '%"';
  4771. // Suppression de tous les votes de la galerie.
  4772. } elseif (empty($_GET['cat']) || $_GET['cat'] == 1) {
  4773. $where = '';
  4774. // On redirige.
  4775. } else {
  4776. header('Location: index.php?section=votes');
  4777. exit;
  4778. }
  4779. // On supprime les votes de la table des votes.
  4780. $where_join = ($where == '') ? '' : ' AND ' . MYSQL_PREF . 'votes.image_id = ' . MYSQL_PREF . 'images.image_id';
  4781. $mysql_requete = 'DELETE FROM ' . MYSQL_PREF . 'votes
  4782. USING ' . MYSQL_PREF . 'votes,
  4783. ' . MYSQL_PREF . 'images '
  4784. . $where
  4785. . $where_join;
  4786. if (!$this->mysql->requete($mysql_requete)) {
  4787. $ok = false;
  4788. }
  4789. // On UPDATE la table des images.
  4790. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images
  4791. SET image_votes = 0,
  4792. image_note = 0 ' . $where;
  4793. if (!$this->mysql->requete($mysql_requete)) {
  4794. $ok = false;
  4795. }
  4796. // On UPDATE la table des catégories.
  4797. if ($this->update_categories_vote() === false) {
  4798. $ok = false;
  4799. }
  4800. } elseif (isset($_GET['date']) || isset($_GET['ip'])) {
  4801. $ok = true;
  4802. // On récupčre les id de toutes les images correspondant aux critčres d'affichage.
  4803. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'votes.vote_id,
  4804. ' . MYSQL_PREF . 'votes.image_id,
  4805. ' . MYSQL_PREF . 'votes.vote_note,
  4806. ' . MYSQL_PREF . 'images.image_chemin
  4807. FROM ' . MYSQL_PREF . 'votes LEFT JOIN ' . MYSQL_PREF . 'images USING(image_id)
  4808. WHERE ' . $this->get_criteres_vote_mysql();
  4809. $images_id = $this->mysql->select($mysql_requete);
  4810. if (!$this->delete_votes_images_id($images_id)) {
  4811. $ok = false;
  4812. }
  4813. if ($this->update_categories_vote($images_id) === false) {
  4814. $ok = false;
  4815. }
  4816. }
  4817. } elseif (isset($_POST['vote_action'])
  4818. && isset($_POST['vote_selection']) && is_array($_POST['vote_selection'])) {
  4819. $ok = true;
  4820. $vote_ids = '';
  4821. foreach ($_POST['vote_selection'] as $id => $e) {
  4822. if (preg_match('`^\d{1,12}$`', $id)) {
  4823. $vote_ids .= ',"' . $id . '"';
  4824. }
  4825. }
  4826. // On récupčre les id de toutes les images sélectionnées.
  4827. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'votes.vote_id,
  4828. ' . MYSQL_PREF . 'votes.image_id,
  4829. ' . MYSQL_PREF . 'votes.vote_note,
  4830. ' . MYSQL_PREF . 'images.image_chemin
  4831. FROM ' . MYSQL_PREF . 'votes LEFT JOIN ' . MYSQL_PREF . 'images USING (image_id)
  4832. WHERE ' . MYSQL_PREF . 'votes.vote_id IN(' . substr($vote_ids,1) . ')';
  4833. $images_id = $this->mysql->select($mysql_requete);
  4834. if (!$this->delete_votes_images_id($images_id)) {
  4835. $ok = false;
  4836. }
  4837. if (!$this->update_categories_vote($images_id)) {
  4838. $ok = false;
  4839. }
  4840. }
  4841. if (isset($ok)) {
  4842. if ($ok) {
  4843. $this->template['infos']['action']['delete_votes'] = 'Tous les votes sélectionnés ont été supprimés.';
  4844. } else {
  4845. $this->template['infos']['erreur']['delete_votes'] = '[' . __LINE__ . '] Des erreurs se sont produites lors de la suppression des votes.';
  4846. }
  4847. }
  4848. }
  4849. function delete_votes_images_id($images_id) {
  4850. if (is_array($images_id)) {
  4851. $ok = true;
  4852. $vote_ids = '';
  4853. for ($i = 0; $i < count($images_id); $i++) {
  4854. $mysql_requete =
  4855. 'UPDATE ' . MYSQL_PREF . 'images
  4856. SET image_note = ((image_note * image_votes) - ' . $images_id[$i]['vote_note'] . ') / (image_votes - 1),
  4857. image_votes = image_votes - 1
  4858. WHERE image_id = "' . $images_id[$i]['image_id'] . '"';
  4859. if (!$this->mysql->requete($mysql_requete)) {
  4860. $ok = false;
  4861. }
  4862. $vote_ids .= ',"' . $images_id[$i]['vote_id'] . '"';
  4863. }
  4864. $mysql_requete =
  4865. 'DELETE FROM ' . MYSQL_PREF . 'votes
  4866. WHERE vote_id IN (' . substr($vote_ids,1) . ')';
  4867. if (!$this->mysql->requete($mysql_requete)) {
  4868. $ok = false;
  4869. }
  4870. return $ok;
  4871. } else {
  4872. return false;
  4873. }
  4874. }
  4875. function get_criteres_vote_mysql() {
  4876. // IP ou date.
  4877. $ipdate = '';
  4878. if (!empty($_GET['date']) && preg_match('`^\d{1,11}$`', $_GET['date'])) {
  4879. $ts = $_GET['date'];
  4880. $jour = date('d', $ts);
  4881. $mois = date('m', $ts);
  4882. $annee = date('Y', $ts);
  4883. $debut = mktime(0,0,0,$mois,$jour,$annee);
  4884. $fin = mktime(23,59,59,$mois,$jour,$annee);
  4885. $ipdate = ' AND ' . MYSQL_PREF . 'votes.vote_date >= "' . $debut . '"';
  4886. $ipdate .= ' AND ' . MYSQL_PREF . 'votes.vote_date <= "' . $fin . '"';
  4887. } elseif (!empty($_GET['ip'])) {
  4888. $ipdate = ' AND ' . MYSQL_PREF . 'votes.vote_ip = "' . outils::protege_mysql($_GET['ip'], $this->mysql->lien) . '"';
  4889. }
  4890. // Objet.
  4891. $obj = '';
  4892. if (isset($_GET['img']) && preg_match('`^\d{1,12}$`', $_GET['img'])) {
  4893. $obj = ' AND ' . MYSQL_PREF . 'votes.image_id = "' . $_GET['img'] . '"';
  4894. } elseif ($cat_path = $this->get_categorie_vote_path()) {
  4895. $obj = ' AND ' . MYSQL_PREF . 'images.image_chemin LIKE "' . $cat_path . '%"';
  4896. }
  4897. return ' 1=1 ' . $ipdate . $obj;
  4898. }
  4899. function get_categorie_vote_path() {
  4900. if (isset($_GET['cat']) && preg_match('`^\d{1,12}$`', $_GET['cat']) && $_GET['cat'] > 1) {
  4901. $mysql_requete = 'SELECT categorie_chemin
  4902. FROM ' . MYSQL_PREF . 'categories
  4903. WHERE categorie_id = "' . $_GET['cat'] . '"';
  4904. $path = $this->mysql->select($mysql_requete, 5);
  4905. if ($path && $path != 'vide') {
  4906. return $path;
  4907. }
  4908. }
  4909. }
  4910. function update_categories_vote($images_id = '') {
  4911. $paths = '';
  4912. if (is_array($images_id)) {
  4913. $paths = '"."';
  4914. for ($i = 0; $i < count($images_id); $i++) {
  4915. $p = dirname($images_id[$i]['image_chemin']) . '/';
  4916. while ($p != './') {
  4917. $paths .= ',"' . $p . '"';
  4918. $p = dirname($p) . '/';
  4919. }
  4920. }
  4921. $paths = ' WHERE categorie_chemin IN (' . $paths . ') ';
  4922. }
  4923. // On récupčre toutes les informations de toutes les catégories.
  4924. $mysql_requete = 'SELECT * FROM ' . MYSQL_PREF . 'categories
  4925. ' . $paths . '
  4926. ORDER BY categorie_chemin';
  4927. $categories = $this->mysql->select($mysql_requete);
  4928. if (!is_array($categories)) {
  4929. return false;
  4930. }
  4931. $ok = true;
  4932. for ($i = 0; $i < count($categories); $i++) {
  4933. $path = ($categories[$i]['categorie_chemin'] == '.') ? '' : $categories[$i]['categorie_chemin'];
  4934. // On sélectionne les informations de votes des images activées.
  4935. $mysql_requete = 'SELECT SUM(image_votes) as votes,
  4936. SUM(image_note*image_votes)/SUM(image_votes) as note
  4937. FROM ' . MYSQL_PREF . 'images
  4938. WHERE image_chemin LIKE "' . $path . '%"
  4939. AND image_visible = "1"';
  4940. $infos_actives = $this->mysql->select($mysql_requete, 11);
  4941. if (!is_array($infos_actives)) {
  4942. $ok = false;
  4943. }
  4944. // On sélectionne les informations de votes des images désactivées.
  4945. $mysql_requete = 'SELECT SUM(image_votes) as votes,
  4946. SUM(image_note*image_votes)/SUM(image_votes) as note
  4947. FROM ' . MYSQL_PREF . 'images
  4948. WHERE image_chemin LIKE "' . $path . '%"
  4949. AND image_visible = "0"';
  4950. $infos_inactives = $this->mysql->select($mysql_requete, 11);
  4951. if (!is_array($infos_inactives)) {
  4952. $ok = false;
  4953. }
  4954. // Nombre de votes et note des images activées.
  4955. $nb_votes_actives = ($infos_actives['votes']) ? $infos_actives['votes'] : '0';
  4956. if ($nb_votes_actives != $categories[$i]['categorie_votes']) {
  4957. $note_actives = ($infos_actives['note']) ? $infos_actives['note'] : '0';
  4958. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  4959. SET categorie_votes = "' . $nb_votes_actives . '",
  4960. categorie_note = "' . $note_actives . '"
  4961. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  4962. if (!$this->mysql->requete($mysql_requete)) {
  4963. $ok = false;
  4964. }
  4965. }
  4966. // Nombre de votes et note des images désactivées.
  4967. $nb_votes_inactives = ($infos_inactives['votes']) ? $infos_inactives['votes'] : '0';
  4968. if ($nb_votes_inactives != $categories[$i]['categorie_votes_inactive']) {
  4969. $note_inactives = ($infos_inactives['note']) ? $infos_inactives['note'] : '0';
  4970. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'categories
  4971. SET categorie_votes_inactive = "' . $nb_votes_inactives . '",
  4972. categorie_note_inactive = "' . $note_inactives . '"
  4973. WHERE categorie_chemin = "' . $categories[$i]['categorie_chemin'] . '"';
  4974. if (!$this->mysql->requete($mysql_requete)) {
  4975. $ok = false;
  4976. }
  4977. }
  4978. }
  4979. return $ok;
  4980. }
  4981. /*
  4982. * Affichage des tags.
  4983. */
  4984. function display_tags() {
  4985. $this->template['infos']['title'] = 'gestion des tags';
  4986. if (isset($_POST['tag_action'])) {
  4987. $this->gestion_tags();
  4988. }
  4989. // On récupčre tous les tags.
  4990. $mysql_requete = 'SELECT DISTINCT ' . MYSQL_PREF . 'tags.tag_id,
  4991. COUNT(tag_id) AS tag_nombre
  4992. FROM ' . MYSQL_PREF . 'tags
  4993. GROUP BY tag_id
  4994. ORDER BY tag_nombre DESC,tag_id ASC';
  4995. $tags = $this->mysql->select($mysql_requete, 4);
  4996. // On trie les tags.
  4997. if (is_array($tags)) {
  4998. $sort_tags = array();
  4999. foreach ($tags as $t => $i) {
  5000. $sort_tags[] = $t;
  5001. }
  5002. natcasesort($sort_tags);
  5003. foreach ($sort_tags as $t) {
  5004. $this->template['tags'][$t] = $tags[$t];
  5005. }
  5006. }
  5007. }
  5008. /*
  5009. * Gestion des tags.
  5010. */
  5011. function gestion_tags() {
  5012. // Rennomage.
  5013. if (isset($_POST['tag_name']) && is_array($_POST['tag_name'])) {
  5014. $ok = true;
  5015. $maj = false;
  5016. foreach ($_POST['tag_name'] as $name => $new_name) {
  5017. $new_name = preg_replace('`[\x5c#]`', '', $new_name);
  5018. $new_name = trim($new_name);
  5019. if ($name != $new_name && preg_match('`\w`i', $new_name)) {
  5020. $maj = true;
  5021. $mysql_requete = 'UPDATE IGNORE ' . MYSQL_PREF . 'tags
  5022. SET tag_id = "' . htmlentities($new_name) . '"
  5023. WHERE tag_id = "' . htmlentities($name) . '"';
  5024. if (!$this->mysql->requete($mysql_requete)) {
  5025. $ok = false;
  5026. }
  5027. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images
  5028. SET image_tags = REPLACE(image_tags, ",' . htmlentities($name) . ',", ",' . htmlentities($new_name) . ',")
  5029. WHERE image_tags LIKE "%,' . htmlentities($name) . ',%"';
  5030. if (!$this->mysql->requete($mysql_requete)) {
  5031. $ok = false;
  5032. }
  5033. }
  5034. }
  5035. if ($maj && $ok) {
  5036. $this->template['infos']['action']['change_name_tags'] = 'Changements effectués avec succčs.';
  5037. }
  5038. }
  5039. // Suppression.
  5040. if (isset($_POST['tag_supp']) && is_array($_POST['tag_supp'])) {
  5041. $ok = true;
  5042. $tags = $_POST['tag_supp'];
  5043. $tags = array_map('htmlentities', $tags);
  5044. $tags = implode('","', $tags);
  5045. $mysql_requete = 'DELETE FROM ' . MYSQL_PREF . 'tags
  5046. WHERE tag_id IN ("' . $tags . '")';
  5047. if (!$this->mysql->requete($mysql_requete)) {
  5048. $ok = false;
  5049. }
  5050. $tags = $_POST['tag_supp'];
  5051. foreach ($tags as $tag) {
  5052. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'images
  5053. SET image_tags = REPLACE(image_tags, "' . $tag . ',", "")
  5054. WHERE image_tags LIKE "%,' . $tag . ',%"';
  5055. if (!$this->mysql->requete($mysql_requete)) {
  5056. $ok = false;
  5057. }
  5058. }
  5059. if ($ok) {
  5060. $this->template['infos']['action']['change_name_tags'] = 'Les tags sélectionnés ont été supprimés.';
  5061. } else {
  5062. $this->template['infos']['erreur']['change_name_tags'] = 'Tous les tags sélectionnés n\'ont pas pu ętre supprimés.';
  5063. }
  5064. }
  5065. }
  5066. /*
  5067. * Utilisateurs - général.
  5068. */
  5069. function users_general() {
  5070. $this->template['infos']['title'] = 'utilisateurs';
  5071. $up_max = strtolower(ini_get('upload_max_filesize'));
  5072. if (substr($up_max, -1, 1) == 'g') {
  5073. $up_max = floatval(ini_get('upload_max_filesize')) * 1024 * 1024 . ' Ko';
  5074. } elseif (substr($up_max, -1, 1) == 'm') {
  5075. $up_max = floatval(ini_get('upload_max_filesize')) * 1024 . ' Ko';
  5076. } elseif (substr($up_max, -1, 1) == 'k') {
  5077. $up_max = floatval(ini_get('upload_max_filesize')) . ' Ko';
  5078. } else {
  5079. $up_max = floatval(ini_get('upload_max_filesize')) / 1024 . ' Ko';
  5080. }
  5081. $this->config['upload_max_filesize'] = $up_max;
  5082. if (isset($_POST['u'])) {
  5083. $this->verif_option_bin('u_general_membres_active', 'users_membres_active', 1);
  5084. $this->verif_option_bin('u_general_membres_alert', 'users_membres_alert', 1);
  5085. $this->verif_option_bin('u_general_membres_avatars', 'users_membres_avatars', 1);
  5086. $this->verif_option_bin('u_general_upload_alert', 'users_upload_alert', 1);
  5087. $_POST['u_general_upload_maxsize'] = floatval($_POST['u_general_upload_maxsize']);
  5088. if (!empty($_POST['u_general_upload_maxsize'])
  5089. && $_POST['u_general_upload_maxsize'] >= 1
  5090. && $_POST['u_general_upload_maxsize'] <= $up_max) {
  5091. $this->verif_option_word('u_general_upload_maxsize', 'users_upload_maxsize', 'nombre', '', 1);
  5092. } else {
  5093. $this->template['infos']['attention']['change_name_tags'] = 'Le poids maximum d\'une image doit ętre compris entre 1 Ko et ' . $up_max . '.';
  5094. }
  5095. $_POST['u_general_upload_maxwidth'] = floatval($_POST['u_general_upload_maxwidth']);
  5096. $_POST['u_general_upload_maxheight'] = floatval($_POST['u_general_upload_maxheight']);
  5097. if (!empty($_POST['u_general_upload_maxwidth'])
  5098. && !empty($_POST['u_general_upload_maxheight'])
  5099. && $_POST['u_general_upload_maxwidth'] >= 1
  5100. && $_POST['u_general_upload_maxwidth'] <= 20000
  5101. && $_POST['u_general_upload_maxheight'] >= 1
  5102. && $_POST['u_general_upload_maxheight'] <= 20000) {
  5103. $this->verif_option_word('u_general_upload_maxwidth', 'users_upload_maxwidth', 'nombre', '', 1);
  5104. $this->verif_option_word('u_general_upload_maxheight', 'users_upload_maxheight', 'nombre', '', 1);
  5105. } else {
  5106. $this->template['infos']['attention']['change_name_tags'] = 'Les dimensions maximum d\'une image doivent ętre comprises entre 1 pixels et 20000 pixels.';
  5107. }
  5108. }
  5109. // Config.
  5110. $this->template['config'] = $this->config;
  5111. }
  5112. /*
  5113. * Utilisateurs - membres.
  5114. */
  5115. function users_membres_action() {
  5116. if (empty($_POST['membres']) || !is_array($_POST['membres'])) {
  5117. return;
  5118. }
  5119. if (!empty($_POST['mass_delete'])) {
  5120. foreach ($_POST['membres'] as $id => $p) {
  5121. if (!empty($_POST['membres'][$id]['delete'])) {
  5122. $maj = (isset($maj)) ? $maj : 1;
  5123. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'users
  5124. SET groupe_id = "0",
  5125. user_pass = "",
  5126. user_mail = "",
  5127. user_web = "",
  5128. user_avatar = "0",
  5129. user_date_creation = "0",
  5130. user_date_derniere_visite = "0",
  5131. user_ip_creation = "",
  5132. user_ip_derniere_visite = "",
  5133. user_session_id = ""
  5134. WHERE user_id = "' . $id . '"';
  5135. if (!$this->mysql->requete($mysql_requete)) {
  5136. $maj = 0;
  5137. $this->template['infos']['erreur']['delete_' . $id] = '[' . __LINE__ . '] Impossible de supprimer le membre ' . $id;
  5138. }
  5139. }
  5140. }
  5141. if (!empty($maj)) {
  5142. $this->template['infos']['action']['delete'] = 'Les membres sélectionnés ont été supprimés.';
  5143. }
  5144. return;
  5145. }
  5146. if (isset($_POST['mass_groupes'])) {
  5147. foreach ($_POST['membres'] as $id => $p) {
  5148. if (!empty($_POST['membres'][$id]['groupe'])
  5149. && !empty($_POST['membres'][$id]['groupe_actuel'])
  5150. && $_POST['membres'][$id]['groupe'] != $_POST['membres'][$id]['groupe_actuel']) {
  5151. $maj = (isset($maj)) ? $maj : 1;
  5152. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'users
  5153. SET groupe_id = "' . $_POST['membres'][$id]['groupe'] . '"
  5154. WHERE user_id = "' . $id . '"';
  5155. if (!$this->mysql->requete($mysql_requete)) {
  5156. $maj = 0;
  5157. $this->template['infos']['erreur']['change_groupe_' . $id] = '[' . __LINE__ . '][' . $id . '] Impossible de modifier le groupe.';
  5158. }
  5159. }
  5160. }
  5161. if (!empty($maj)) {
  5162. $this->template['action_maj'] = 1;
  5163. }
  5164. }
  5165. }
  5166. /*
  5167. * Utilisateurs - membres.
  5168. */
  5169. function users_membres() {
  5170. $this->template['infos']['title'] = 'membres';
  5171. $this->template['infos']['section'] = 'section=utilisateurs&page=membres';
  5172. // Page ŕ afficher.
  5173. if (isset($_REQUEST['startnum']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['startnum'])) {
  5174. $startnum = $_REQUEST['startnum'];
  5175. } else {
  5176. $startnum = 0;
  5177. }
  5178. $this->template['infos']['startnum'] = $startnum;
  5179. // Trie des membres : ordre.
  5180. if (isset($_POST['sort']) && preg_match('`^login|date_creation|date_derniere_visite$`', $_POST['sort'])
  5181. && $_POST['sort'] != $this->config['admin_membres_ordre']) {
  5182. $this->update_option('admin_membres_ordre', $_POST['sort']);
  5183. }
  5184. // Trie des membres : sens.
  5185. if (isset($_POST['sens']) && preg_match('`^ASC|DESC$`', $_POST['sens'])
  5186. && $_POST['sens'] != $this->config['admin_membres_sens']) {
  5187. $this->update_option('admin_membres_sens', $_POST['sens']);
  5188. }
  5189. // Nombre de membres par page.
  5190. if (isset($_POST['nb']) && preg_match('`^[1-9]\d{0,3}$`', $_POST['nb'])
  5191. && $_POST['nb'] != $this->config['admin_membres_nb']) {
  5192. $this->update_option('admin_membres_nb', $_POST['nb']);
  5193. $startnum = 0;
  5194. }
  5195. $this->template['infos']['recherche'] = '';
  5196. // Groupe.
  5197. $groupe_id = 0;
  5198. if (isset($_GET['groupe']) && preg_match('`^\d{1,9}$`', $_GET['groupe'])) {
  5199. $groupe_id = $_GET['groupe'];
  5200. }
  5201. $this->template['infos']['groupe_id'] = $groupe_id;
  5202. if ($groupe_id) {
  5203. $this->template['infos']['recherche'] = '&groupe=' . $groupe_id;;
  5204. }
  5205. // Recherche.
  5206. $recherche = '';
  5207. if (isset($_REQUEST['search'])) {
  5208. $this->template['infos']['recherche'] .= '&search=' . htmlentities($_REQUEST['search']);
  5209. foreach ($_REQUEST as $k => $v) {
  5210. if (substr($k, 0, 2) == 's_') {
  5211. $this->template['infos']['recherche'] .= '&' . $k . '=' . $v;
  5212. }
  5213. }
  5214. // Requęte.
  5215. $search = trim($_REQUEST['search']);
  5216. if ($search == '') {
  5217. header('Location: index.php?section=utilisateurs&page=membres');
  5218. exit;
  5219. }
  5220. $search = preg_replace('`\s+`', ' ', $search);
  5221. $search = preg_replace('`[^\w\*\?\s]+`', '?', $search);
  5222. $search = str_replace(' ', '[^[:alnum:]]', $search);
  5223. $search = str_replace('*', '[^[:space:]]*', $search);
  5224. $search = str_replace('?', '.', $search);
  5225. $search = '([^[:alnum:]]|^)' . $search . '([^[:alnum:]]|$)';;
  5226. // Champs.
  5227. $champs = array();
  5228. if (isset($_REQUEST['s_nom'])) { $champs[] = 'login'; }
  5229. if (isset($_REQUEST['s_mail'])) { $champs[] = 'mail'; }
  5230. if (isset($_REQUEST['s_web'])) { $champs[] = 'web'; }
  5231. if (isset($_REQUEST['s_ip_creation'])) { $champs[] = 'ip_creation'; }
  5232. if (isset($_REQUEST['s_ip_derniere'])) { $champs[] = 'ip_derniere_visite'; }
  5233. $membres_champs = '';
  5234. for ($i = 0; $i < count($champs); $i++) {
  5235. $membres_champs .= ' OR ' . MYSQL_PREF . 'users.user_' . $champs[$i] . ' REGEXP "' . outils::protege_mysql($search, $this->mysql->lien) . '" ';
  5236. }
  5237. $membres_champs = '(' . substr($membres_champs, 4) . ')';
  5238. // Dates.
  5239. $membres_date = '';
  5240. if (isset($_REQUEST['s_date']) && isset($_REQUEST['s_dnpc']) && isset($_REQUEST['s_dnpd'])
  5241. && isset($_REQUEST['s_dnsc']) && isset($_REQUEST['s_dnsd']) && isset($_REQUEST['s_date_type'])) {
  5242. $date_type = ($_REQUEST['s_date_type'] == 'creation') ? 'creation' : 'derniere_visite';
  5243. $membres_date = MYSQL_PREF . 'users.user_date_' . $date_type . ' < ' . outils::time_date($_REQUEST['s_dnpc'], $_REQUEST['s_dnpd'])
  5244. . ' AND ' . MYSQL_PREF . 'users.user_date_' . $date_type . ' > ' . outils::time_date($_REQUEST['s_dnsc'], $_REQUEST['s_dnsd']);
  5245. }
  5246. if ($membres_champs || $membres_date) {
  5247. $and = ($membres_champs && $membres_date) ? ' AND ' : '';
  5248. $recherche = ' AND (' . $membres_champs . $and . $membres_date . ')';
  5249. }
  5250. }
  5251. // FROM et WHERE.
  5252. if ($groupe_id) {
  5253. $from_where = 'FROM ' . MYSQL_PREF . 'users LEFT JOIN ' . MYSQL_PREF . 'groupes USING (groupe_id)
  5254. WHERE ' . MYSQL_PREF . 'groupes.groupe_id != "0"
  5255. AND ' . MYSQL_PREF . 'groupes.groupe_id = "' . $groupe_id . '"'
  5256. . $recherche;
  5257. } else {
  5258. $from_where = 'FROM ' . MYSQL_PREF . 'users
  5259. WHERE groupe_id != "0"
  5260. AND groupe_id != "1"' . $recherche;
  5261. }
  5262. // Membres.
  5263. $mysql_requete = 'SELECT * ' . $from_where . '
  5264. ORDER BY ' . MYSQL_PREF . 'users.user_' . $this->config['admin_membres_ordre'] . ' ' . $this->config['admin_membres_sens'] . '
  5265. LIMIT ' . $startnum . ',' . $this->config['admin_membres_nb'];
  5266. $this->template['membres'] = $this->mysql->select($mysql_requete);
  5267. // Groupes.
  5268. $mysql_requete = 'SELECT groupe_id,groupe_nom
  5269. FROM ' . MYSQL_PREF . 'groupes
  5270. WHERE groupe_id != "1"
  5271. AND groupe_id != "2"
  5272. ORDER BY groupe_nom ASC';
  5273. $this->template['groupes'] = $this->mysql->select($mysql_requete, 3);
  5274. // Nombre total de membres.
  5275. $mysql_requete = 'SELECT COUNT(user_id) ' . $from_where;
  5276. $this->template['infos']['nb_objets'] = $this->mysql->select($mysql_requete, 5);
  5277. // On détermine le nombre de pages et la page actuelle.
  5278. $this->template['infos']['nb_pages'] = ceil(($this->template['infos']['nb_objets']) / $this->config['admin_membres_nb']);
  5279. for ($n = 0; $n < $this->template['infos']['nb_pages']; $n++) {
  5280. $num = $n * $this->config['admin_membres_nb'];
  5281. $this->template['nav']['pages'][$n + 1]['page'] = $num;
  5282. if ($num == $startnum) {
  5283. $this->template['infos']['page_actuelle'] = $n + 1;
  5284. }
  5285. }
  5286. // On détermine les pages suivantes, précédentes, de début et de fin.
  5287. $this->template['nav']['suivante'][1] = $startnum + $this->config['admin_membres_nb'];
  5288. $this->template['nav']['precedente'][1] = $startnum - $this->config['admin_membres_nb'];
  5289. $this->template['nav']['premiere'][1] = 0;
  5290. $this->template['nav']['derniere'][1] = ($this->template['infos']['nb_pages'] * $this->config['admin_membres_nb']) - $this->config['admin_membres_nb'];
  5291. // On détermine la position de l'objet actuel.
  5292. if ($startnum == 0) {
  5293. $this->template['nav']['premiere'][0] = 1;
  5294. }
  5295. if ($this->template['nav']['precedente'][1] < 0) {
  5296. $this->template['nav']['precedente'][0] = 1;
  5297. }
  5298. if ($this->template['nav']['suivante'][1] >= ($this->template['infos']['nb_pages'] * $this->config['admin_membres_nb']) ||
  5299. $this->template['nav']['suivante'][1] >= $this->template['infos']['nb_objets']) {
  5300. $this->template['nav']['suivante'][0] = 1;
  5301. }
  5302. if ($startnum >= $this->template['nav']['derniere'][1]) {
  5303. $this->template['nav']['derniere'][0] = 1;
  5304. }
  5305. $this->template['config'] = $this->config;
  5306. }
  5307. /*
  5308. * Utilisateurs - groupes.
  5309. */
  5310. function users_groupes() {
  5311. $this->template['infos']['title'] = 'groupes';
  5312. // Création d'un groupe.
  5313. if (!empty($_POST['new_group'])) {
  5314. // Quelques vérifications...
  5315. $_POST['new_group'] = trim($_POST['new_group']);
  5316. if ($_POST['new_group'] == '') {
  5317. $this->template['infos']['attention']['new_group'] = 'Le nom du groupe est vide.';
  5318. } elseif (strlen($_POST['new_group'] > 80)) {
  5319. $this->template['infos']['attention']['new_group'] = 'Le nom du groupe ne doit pas dépasser 80 caractčres.';
  5320. } elseif (!preg_match('`^[@éčëęŕäâáĺăďîěíöôňóőůűüú˙ýçńa-z\s\d&]{1,80}$`i', $_POST['new_group'])) {
  5321. $this->template['infos']['attention']['new_group'] = 'Le nom du groupe ne doit pas contenir de caractčres spéciaux.';
  5322. // On peut créer notre nouveau groupe !
  5323. } else {
  5324. $nom = outils::protege_mysql($_POST['new_group'], $this->mysql->lien);
  5325. $mysql_requete = 'INSERT INTO ' . MYSQL_PREF . 'groupes(
  5326. groupe_nom,
  5327. groupe_titre,
  5328. groupe_date_creation,
  5329. groupe_album_pass)
  5330. VALUES ("' . $nom . '",
  5331. "' . $nom . '",
  5332. "' . time() . '",
  5333. "")';
  5334. if ($this->mysql->requete($mysql_requete)) {
  5335. $this->template['infos']['action']['new_group'] = 'Le groupe Ť <em>' . $_POST['new_group'] . '</em> ť a été créé.';
  5336. } else {
  5337. $this->template['infos']['erreur']['new_group'] = 'Impossible de créer le nouveau groupe.';
  5338. }
  5339. }
  5340. }
  5341. // Suppression de groupe.
  5342. if (!empty($_GET['supprimer']) && preg_match('`^\d{1,9}$`', $_GET['supprimer']) && $_GET['supprimer'] > 3) {
  5343. $this->verifVID();
  5344. $mysql_requete = 'DELETE FROM ' . MYSQL_PREF . 'groupes
  5345. WHERE groupe_id = "' . $_GET['supprimer'] . '"';
  5346. if ($this->mysql->requete($mysql_requete)) {
  5347. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'users
  5348. SET groupe_id = "3"
  5349. WHERE groupe_id = "' . $_GET['supprimer'] . '"';
  5350. if ($this->mysql->requete($mysql_requete)) {
  5351. $this->template['infos']['action']['delete'] = 'Le groupe a été correctement supprimé.';
  5352. } else {
  5353. $this->template['infos']['erreur']['delete'] = 'Le groupe n\'a pas été correctement supprimé.';
  5354. }
  5355. } else {
  5356. $this->template['infos']['erreur']['delete'] = 'Impossible de supprimer le groupe.';
  5357. }
  5358. }
  5359. // Récupération des groupes.
  5360. $mysql_requete = 'SELECT groupe_id,
  5361. groupe_nom,
  5362. groupe_titre,
  5363. groupe_date_creation
  5364. FROM ' . MYSQL_PREF . 'groupes
  5365. ORDER BY groupe_id ASC';
  5366. $this->template['groupes'] = $this->mysql->select($mysql_requete);
  5367. for ($i = 0; $i < count($this->template['groupes']); $i++) {
  5368. $mysql_requete = 'SELECT COUNT(user_id)
  5369. FROM ' . MYSQL_PREF . 'users
  5370. WHERE groupe_id = "' . $this->template['groupes'][$i]['groupe_id'] . '"';
  5371. $this->template['groupes'][$i]['nb_users'] = $this->mysql->select($mysql_requete, 5);
  5372. }
  5373. }
  5374. /*
  5375. * Utilisateurs - modification du profil utilisateur.
  5376. */
  5377. function users_modif_user() {
  5378. $this->template['infos']['title'] = 'profil membre';
  5379. if (isset($_GET['user']) && preg_match('`^\d{1,9}$`', $_GET['user'])) {
  5380. // Récupération des informations du membre.
  5381. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'users.*,
  5382. ' . MYSQL_PREF . 'groupes.*
  5383. FROM ' . MYSQL_PREF . 'users LEFT JOIN ' . MYSQL_PREF . 'groupes USING(groupe_id)
  5384. WHERE ' . MYSQL_PREF . 'users.user_id = "' . $_GET['user'] . '"
  5385. AND ' . MYSQL_PREF . 'users.user_id != "1"';
  5386. $this->template['user'] = $this->mysql->select($mysql_requete);
  5387. if (is_array($this->template['user'])) {
  5388. // Nombre de commentaires.
  5389. $mysql_requete = 'SELECT COUNT(' . MYSQL_PREF . 'commentaires.commentaire_id)
  5390. FROM ' . MYSQL_PREF . 'commentaires
  5391. WHERE ' . MYSQL_PREF . 'commentaires.user_id = "' . $_GET['user'] . '"';
  5392. $this->template['user'][0]['nb_comments'] = $this->mysql->select($mysql_requete, 5);
  5393. // Nombre d'images envoyées
  5394. $mysql_requete = 'SELECT COUNT(' . MYSQL_PREF . 'images.image_id)
  5395. FROM ' . MYSQL_PREF . 'images
  5396. WHERE ' . MYSQL_PREF . 'images.user_id = "' . $_GET['user'] . '"';
  5397. $this->template['user'][0]['nb_images'] = $this->mysql->select($mysql_requete, 5);
  5398. // Nombre de favoris.
  5399. $mysql_requete = 'SELECT COUNT(' . MYSQL_PREF . 'favoris.image_id)
  5400. FROM ' . MYSQL_PREF . 'favoris
  5401. WHERE ' . MYSQL_PREF . 'favoris.user_id = "' . $_GET['user'] . '" ';
  5402. $this->template['user'][0]['nb_favoris'] = $this->mysql->select($mysql_requete, 5);
  5403. $img_avatar = './../membres/avatars/avatar_' . $this->template['user'][0]['user_login'] . '.jpg';
  5404. $img_avatar_thumb = './../membres/avatars/avatar_' . $this->template['user'][0]['user_login'] . '_thumb.jpg';
  5405. // Suppression de l'avatar.
  5406. if (isset($_POST['supp_avatar'])) {
  5407. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'users
  5408. SET user_avatar = "0"
  5409. WHERE user_id = "' . $_GET['user'] . '"';
  5410. if ($this->mysql->requete($mysql_requete)) {
  5411. if (file_exists($img_avatar)) {
  5412. files::suppFile($img_avatar);
  5413. }
  5414. if (file_exists($img_avatar_thumb)) {
  5415. files::suppFile($img_avatar_thumb);
  5416. }
  5417. $this->template['infos']['action']['avatar'] = 'L\'avatar a été supprimé.';
  5418. $this->template['user'][0]['user_avatar'] = 0;
  5419. } else {
  5420. $this->template['infos']['erreur']['avatar'] = 'Impossible de supprimer l\'avatar.';
  5421. }
  5422. }
  5423. // Changement de l'avatar.
  5424. if (!empty($_FILES['new_avatar'])) {
  5425. // Si GD n'est pas activé, on arręte tout.
  5426. if (!function_exists('imagetypes')) {
  5427. $this->template['infos']['attention']['avatar'] = 'GD n\'est pas présent.';
  5428. return;
  5429. }
  5430. $infos = $_FILES['new_avatar'];
  5431. // Y a-t-il une erreur ?
  5432. if ($infos['error']) {
  5433. switch ($infos['error']) {
  5434. case 4 :
  5435. break;
  5436. case 2 :
  5437. case 1 :
  5438. $this->template['infos']['attention']['avatar'] = 'Le fichier est trop lourd.';
  5439. return;
  5440. default :
  5441. $this->template['infos']['erreur']['avatar'] = 'Impossible de récupérer le fichier.<br />Code erreur : ' . __LINE__;
  5442. return;
  5443. }
  5444. }
  5445. // Le fichier est-il trop lourd ?
  5446. if (filesize($infos['tmp_name']) > 81920) {
  5447. $this->template['infos']['attention']['avatar'] = 'Le fichier est trop lourd.';
  5448. return;
  5449. }
  5450. // Est-ce une image au format JPEG ?
  5451. if (($file_infos = @getimagesize($infos['tmp_name'])) === false) {
  5452. $this->template['infos']['attention']['avatar'] = 'Le fichier n\'est pas au format JPEG.';
  5453. return;
  5454. }
  5455. if (!preg_match('`\.jpg$`i', $infos['name'])
  5456. || !preg_match('`^image/(p?jpeg)$`i', trim($file_infos['mime']))) {
  5457. $this->template['infos']['attention']['avatar'] = 'Le fichier n\'est pas au format JPEG.';
  5458. return;
  5459. }
  5460. // Dimensions minimales.
  5461. if ($file_infos[0] < 50 || $file_infos[1] < 50) {
  5462. $this->template['infos']['attention']['avatar'] = 'L\'image doit faire au moins 50 pixels de coté.';
  5463. return;
  5464. }
  5465. // Dimensions maximales.
  5466. if ($file_infos[0] > 1000 || $file_infos[1] > 1000) {
  5467. $this->template['infos']['attention']['avatar'] = 'L\'image est trop grande.';
  5468. return;
  5469. }
  5470. // On redimensionne l'image avec GD si nécessaire.
  5471. $file_temp = $infos['tmp_name'];
  5472. $width = 200;
  5473. $height = 200;
  5474. if ($file_infos[0] > $width || $file_infos[1] > $height) {
  5475. $image = FALSE;
  5476. if (imagetypes() & IMG_JPG) {
  5477. if (($image = imagecreatefromjpeg($file_temp)) === false) {
  5478. $this->template['infos']['attention']['avatar'] = 'Impossible de créer l\'avatar<br />Code erreur : ' . __LINE__;
  5479. return;
  5480. }
  5481. } else {
  5482. $this->template['infos']['attention']['avatar'] = 'Type de fichier non pris en charge (JPEG).';
  5483. return;
  5484. }
  5485. if ($file_infos[0] < $file_infos[1]) {
  5486. $width = ($height / $file_infos[1]) * $file_infos[0];
  5487. } else {
  5488. $height = ($width / $file_infos[0]) * $file_infos[1];
  5489. }
  5490. $image_p = imagecreatetruecolor($width, $height);
  5491. imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $file_infos[0], $file_infos[1]);
  5492. if (file_exists($img_avatar)) {
  5493. files::suppFile($img_avatar);
  5494. }
  5495. if (!imagejpeg($image_p, $img_avatar, 90)) {
  5496. if (file_exists($img_avatar)) { files::suppFile($img_avatar); }
  5497. $this->template['infos']['erreur']['avatar'] = 'Impossible de redimensionner l\'image.<br />Code erreur : ' . __LINE__;
  5498. return;
  5499. }
  5500. imagedestroy($image_p);
  5501. files::chmodFile($img_avatar);
  5502. if (!file_exists($img_avatar)) {
  5503. if (file_exists($img_avatar)) { files::suppFile($img_avatar); }
  5504. $this->template['infos']['erreur']['avatar'] = 'Impossible de redimensionner l\'image.<br />Code erreur : ' . __LINE__;
  5505. return;
  5506. }
  5507. // Sinon on copie directement l'image dans le répertoire das avatars.
  5508. } else {
  5509. if (file_exists($img_avatar)) {
  5510. files::suppFile($img_avatar);
  5511. }
  5512. if (!files::copie($file_temp, $img_avatar)) {
  5513. if (file_exists($img_avatar)) { files::suppFile($img_avatar); }
  5514. $this->template['infos']['erreur']['avatar'] = 'Impossible de récupérér l\'image.<br />Code erreur : ' . __LINE__;
  5515. return;
  5516. }
  5517. }
  5518. // On crée la vignette de l'avatar.
  5519. $width = 50;
  5520. $height = 50;
  5521. $width_i = 50;
  5522. $height_i = 50;
  5523. $image = FALSE;
  5524. $image = imagecreatefromjpeg($file_temp);
  5525. $dst_x = 0;
  5526. $dst_y = 0;
  5527. if ($file_infos[0] < $file_infos[1]) {
  5528. $width_i = ($height / $file_infos[1]) * $file_infos[0];
  5529. $dst_x = ($width - $width_i) / 2;
  5530. } else {
  5531. $height_i = ($width / $file_infos[0]) * $file_infos[1];
  5532. $dst_y = ($height - $height_i) / 2;
  5533. }
  5534. $image_p = imagecreatetruecolor($width, $height);
  5535. $bg = imagecolorallocate($image_p, 255, 255, 255);
  5536. imagefill($image_p, 0, 0, $bg);
  5537. imagecopyresampled($image_p, $image, $dst_x, $dst_y, 0, 0, $width_i, $height_i, $file_infos[0], $file_infos[1]);
  5538. if (file_exists($img_avatar_thumb)) {
  5539. files::suppFile($img_avatar_thumb);
  5540. }
  5541. if (!imagejpeg($image_p, $img_avatar_thumb, 90)) {
  5542. if (file_exists($img_avatar)) { files::suppFile($img_avatar); }
  5543. $this->template['infos']['erreur']['avatar'] = 'Impossible de créer la vignette de l\'avatar.';
  5544. return;
  5545. }
  5546. imagedestroy($image_p);
  5547. files::chmodFile($img_avatar_thumb);
  5548. if (!file_exists($img_avatar_thumb)) {
  5549. if (file_exists($img_avatar)) { files::suppFile($img_avatar); }
  5550. $this->template['infos']['erreur']['avatar'] = 'Impossible de créer la vignette de l\'avatar.';
  5551. return;
  5552. }
  5553. // On indique dans la base de données que l'on doit utiliser l'avatar.
  5554. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'users
  5555. SET user_avatar = "1"
  5556. WHERE user_id = "' . $_GET['user'] . '"';
  5557. if ($this->mysql->requete($mysql_requete)) {
  5558. $this->template['infos']['action']['avatar'] = 'L\'avatar a été changé.';
  5559. $this->template['user'][0]['user_avatar'] = 1;
  5560. } else {
  5561. $this->template['infos']['erreur']['avatar'] = 'Impossible de créer l\'avatar.';
  5562. return;
  5563. }
  5564. }
  5565. // Modification du profil.
  5566. if (isset($_POST['modif_profil'])) {
  5567. $update = '';
  5568. // Modification du courriel.
  5569. if (isset($_POST['new_mail'])
  5570. && $_POST['new_mail'] != $this->template['user'][0]['user_mail']) {
  5571. $_POST['new_mail'] = trim($_POST['new_mail']);
  5572. if ($_POST['new_mail'] == '' || preg_match('`^' . outils::email_address() . '$`i', $_POST['new_mail'])) {
  5573. // On vérifie si le courriel n'est pas déjŕ pris.
  5574. $test = '';
  5575. if ($_POST['new_mail'] != '') {
  5576. $mysql_requete = 'SELECT user_mail
  5577. FROM ' . MYSQL_PREF . 'users
  5578. WHERE user_mail LIKE "' . outils::protege_mysql($_POST['new_mail'], $this->mysql->lien) . '"';
  5579. $test = $this->mysql->select($mysql_requete);
  5580. }
  5581. if (is_array($test)) {
  5582. $this->template['infos']['attention']['mail'] = 'Cette adresse courriel existe déjŕ.';
  5583. } else {
  5584. $update .= ',user_mail = "' . $_POST['new_mail'] . '"';
  5585. $this->template['user'][0]['user_mail'] = $_POST['new_mail'];
  5586. }
  5587. } else {
  5588. $this->template['infos']['attention']['mail'] = 'L\'adresse du courriel est incorrecte.';
  5589. }
  5590. }
  5591. // Modification du site Web.
  5592. if (isset($_POST['new_web'])
  5593. && $_POST['new_web'] != $this->template['user'][0]['user_web']) {
  5594. if ($_POST['new_web'] == '' || preg_match('`^' . outils::http_url() . '$`i', $_POST['new_web'])) {
  5595. $update .= ',user_web = "' . $_POST['new_web'] . '"';
  5596. $this->template['user'][0]['user_web'] = $_POST['new_web'];
  5597. } else {
  5598. $this->template['infos']['attention']['web'] = 'L\'adresse du site Web est incorrecte.';
  5599. }
  5600. }
  5601. // Modification de la localisation.
  5602. if (isset($_POST['new_lieu'])
  5603. && $_POST['new_lieu'] != $this->template['user'][0]['user_lieu']) {
  5604. if (strlen($_POST['new_lieu']) < 61) {
  5605. if ($_POST['new_lieu'] == '' || preg_match('`^[@éčëęŕäâáĺăďîěíöôňóőůűüú˙ýçńa-z\s\d&,;/%.:_#\(\)Ťť<>!?-]{1,60}$`i', $_POST['new_lieu'])) {
  5606. $update .= ',user_lieu = "' . $_POST['new_lieu'] . '"';
  5607. $this->template['user'][0]['user_lieu'] = $_POST['new_lieu'];
  5608. } else {
  5609. $this->template['infos']['attention']['lieu'] = 'Le texte de la localisation ne doit pas contenir de caractčres exotiques.';
  5610. }
  5611. } else {
  5612. $this->template['infos']['attention']['lieu'] = 'Le texte de la localisation ne doit pas contenir plus de 60 caractčres.';
  5613. }
  5614. }
  5615. // Courriel public ?
  5616. if (!empty($_POST['new_mail_public']) && empty($this->template['user'][0]['user_mail_public'])) {
  5617. $update .= ',user_mail_public = "1"';
  5618. $this->template['user'][0]['user_mail_public'] = 1;
  5619. } elseif (empty($_POST['new_mail_public']) && !empty($this->template['user'][0]['user_mail_public'])) {
  5620. $update .= ',user_mail_public = "0"';
  5621. $this->template['user'][0]['user_mail_public'] = 0;
  5622. }
  5623. // Newsletter.
  5624. if ($this->template['user'][0]['groupe_newsletter']) {
  5625. if (!empty($_POST['new_newsletter']) && empty($this->template['user'][0]['user_newsletter'])) {
  5626. $update .= ',user_newsletter = "1"';
  5627. $this->template['user'][0]['user_newsletter'] = 1;
  5628. } elseif (empty($_POST['new_newsletter']) && !empty($this->template['user'][0]['user_newsletter'])) {
  5629. $update .= ',user_newsletter = "0"';
  5630. $this->template['user'][0]['user_newsletter'] = 0;
  5631. }
  5632. }
  5633. if ($update) {
  5634. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'users
  5635. SET ' . substr($update, 1) . '
  5636. WHERE user_id = "' . $_GET['user'] . '"';
  5637. if ($this->mysql->requete($mysql_requete)) {
  5638. $this->template['infos']['action']['update'] = 'Les informations du profil ont été changées.';
  5639. } else {
  5640. $this->template['infos']['erreur']['update'] = 'Impossible de modifier les informations du profil.';
  5641. }
  5642. }
  5643. }
  5644. } else {
  5645. header('Location: index.php?section=utilisateurs&page=membres');
  5646. exit;
  5647. }
  5648. } else {
  5649. header('Location: index.php?section=utilisateurs&page=membres');
  5650. exit;
  5651. }
  5652. }
  5653. /*
  5654. * Utilisateurs - modification de groupe.
  5655. */
  5656. function users_modif_groupe() {
  5657. $this->template['infos']['title'] = 'groupes';
  5658. // Récupération des informations du groupe.
  5659. if (empty($_REQUEST['groupe']) || !preg_match('`^\d{1,9}$`', $_REQUEST['groupe'])) {
  5660. $_REQUEST['groupe'] = 1;
  5661. }
  5662. $mysql_requete = 'SELECT *
  5663. FROM ' . MYSQL_PREF . 'groupes
  5664. WHERE groupe_id = "' . $_REQUEST['groupe'] . '"';
  5665. $this->template['groupe'] = $this->mysql->select($mysql_requete);
  5666. // Groupe autre que "invité".
  5667. if ($_REQUEST['groupe'] != 2) {
  5668. $this->template['display']['groupe_membres'] = true;
  5669. }
  5670. // Groupe autre que "admin".
  5671. if ($_REQUEST['groupe'] > 1) {
  5672. $this->template['display']['groupe_noadmin'] = true;
  5673. }
  5674. // Récupération des mots de passe des albums.
  5675. $mysql_requete = 'SELECT DISTINCT categorie_pass
  5676. FROM ' . MYSQL_PREF . 'categories
  5677. WHERE categorie_pass IS NOT NULL
  5678. ORDER BY categorie_pass';
  5679. $this->template['passwords'] = $this->mysql->select($mysql_requete);
  5680. // Modifications des paramčtres du groupe.
  5681. if (!empty($_POST)) {
  5682. $mysql_update = '';
  5683. // Textes.
  5684. $mysql_update .= $this->users_modif_groupe_texte('groupe_nom', 'nom', 'nom', 80);
  5685. $mysql_update .= $this->users_modif_groupe_texte('groupe_titre', 'titre', 'titre', 80);
  5686. if (!empty($this->template['display']['groupe_noadmin'])) {
  5687. // Checkboxes.
  5688. $mysql_update .= $this->users_modif_groupe_checkbox('groupe_aut_comments', 'commentaires');
  5689. $mysql_update .= $this->users_modif_groupe_checkbox('groupe_aut_votes', 'votes');
  5690. $mysql_update .= $this->users_modif_groupe_checkbox('groupe_aut_perso', 'perso');
  5691. $mysql_update .= $this->users_modif_groupe_checkbox('groupe_aut_search', 'recherche_avance');
  5692. if (isset($this->template['display']['groupe_membres'])) {
  5693. $mysql_update .= $this->users_modif_groupe_checkbox('groupe_aut_newsletter', 'newsletter');
  5694. $mysql_update .= $this->users_modif_groupe_checkbox('groupe_aut_upload', 'upload');
  5695. $mysql_update .= $this->users_modif_groupe_checkbox('groupe_aut_create', 'upload_create');
  5696. }
  5697. // Radios.
  5698. if (isset($this->template['display']['groupe_membres'])) {
  5699. $mysql_update .= $this->users_modif_groupe_radio('groupe_aut_upload_mode', 'upload_mode', 'direct|attente');
  5700. }
  5701. $mysql_update .= $this->users_modif_groupe_radio('groupe_protect', 'album_pass_mode', 'aucun|tous|select');
  5702. // Listes de mots de passe.
  5703. if (!empty($_POST['groupe_protect_mdp_dever'])
  5704. && isset($_POST['groupe_protect_mdp_ver'])
  5705. && is_array($_POST['groupe_protect_mdp_ver'])) {
  5706. if (serialize($_POST['groupe_protect_mdp_ver']) != $this->template['groupe'][0]['groupe_album_pass']) {
  5707. $album_pass = unserialize($this->template['groupe'][0]['groupe_album_pass']);
  5708. $album_pass = (is_array($album_pass)) ? $album_pass : array();
  5709. $album_pass = array_merge($album_pass, $_POST['groupe_protect_mdp_ver']);
  5710. $this->template['groupe'][0]['groupe_album_pass'] = serialize($album_pass);
  5711. $mysql_update .= ',groupe_album_pass = "' . outils::protege_mysql(serialize($album_pass), $this->mysql->lien) . '"';
  5712. }
  5713. }
  5714. if (!empty($_POST['groupe_protect_mdp_rever'])
  5715. && isset($_POST['groupe_protect_mdp_dev'])
  5716. && is_array($_POST['groupe_protect_mdp_dev'])) {
  5717. $album_pass = unserialize($this->template['groupe'][0]['groupe_album_pass']);
  5718. $album_pass = array_flip($album_pass);
  5719. for ($i = 0; $i < count($_POST['groupe_protect_mdp_dev']); $i++) {
  5720. unset($album_pass[$_POST['groupe_protect_mdp_dev'][$i]]);
  5721. }
  5722. $album_pass = array_flip($album_pass);
  5723. sort($album_pass);
  5724. if ($this->template['groupe'][0]['groupe_album_pass'] != serialize($album_pass)) {
  5725. $this->template['groupe'][0]['groupe_album_pass'] = serialize($album_pass);
  5726. $mysql_update .= ',groupe_album_pass = "' . outils::protege_mysql(serialize($album_pass), $this->mysql->lien) . '"';
  5727. }
  5728. }
  5729. }
  5730. // On met ŕ jour les paramčtres du groupe.
  5731. if ($mysql_update != '') {
  5732. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'groupes
  5733. SET ' . substr($mysql_update, 1) . '
  5734. WHERE groupe_id = "' . $_REQUEST['groupe'] . '"';
  5735. if ($this->mysql->requete($mysql_requete)) {
  5736. $this->template['infos']['action']['update'] = 'Paramčtres du groupe mis ŕ jour.';
  5737. } else {
  5738. $this->template['infos']['erreur']['update'] = 'Impossible de mettre ŕ jour les paramčtres du groupe.';
  5739. }
  5740. }
  5741. }
  5742. }
  5743. function users_modif_groupe_texte($post, $nom, $bdd, $limit = 80) {
  5744. if (!empty($_POST[$post])) {
  5745. $_POST[$post] = trim($_POST[$post]);
  5746. if ($_POST[$post] != $this->template['groupe'][0]['groupe_' . $bdd]) {
  5747. if ($_POST[$post] == '') {
  5748. $this->template['infos']['attention'][$nom] = 'Le ' . $nom . ' du groupe est vide.';
  5749. } elseif (strlen($_POST[$post] > $limit)) {
  5750. $this->template['infos']['attention'][$nom] = 'Le ' . $nom . ' du groupe ne doit pas dépasser ' . $limit . ' caractčres.';
  5751. } elseif (!preg_match('`^[@éčëęŕäâáĺăďîěíöôňóőůűüú˙ýçńa-z\s\d&]{1,80}$`i', $_POST[$post])) {
  5752. $this->template['infos']['attention'][$nom] = 'Le ' . $nom . ' du groupe ne doit pas contenir de caractčres spéciaux.';
  5753. } else {
  5754. $this->template['groupe'][0]['groupe_' . $bdd] = $_POST[$post];
  5755. return ',groupe_' . $bdd . ' = "' . outils::protege_mysql($_POST[$post], $this->mysql->lien) . '"';
  5756. }
  5757. }
  5758. }
  5759. return '';
  5760. }
  5761. function users_modif_groupe_checkbox($post, $bdd) {
  5762. if (isset($_POST[$post]) && empty($this->template['groupe'][0]['groupe_' . $bdd])) {
  5763. $this->template['groupe'][0]['groupe_' . $bdd] = 1;
  5764. return ',groupe_' . $bdd . ' = "1"';
  5765. }
  5766. if (empty($_POST[$post]) && $this->template['groupe'][0]['groupe_' . $bdd]) {
  5767. $this->template['groupe'][0]['groupe_' . $bdd] = 0;
  5768. return ',groupe_' . $bdd . ' = "0"';
  5769. }
  5770. return '';
  5771. }
  5772. function users_modif_groupe_radio($post, $bdd, $termes) {
  5773. if (isset($_POST[$post])
  5774. && preg_match('`^' . $termes . '$`', $_POST[$post])
  5775. && $_POST[$post] != $this->template['groupe'][0]['groupe_' . $bdd]) {
  5776. $this->template['groupe'][0]['groupe_' . $bdd] = $_POST[$post];
  5777. return ',groupe_' . $bdd . ' = "' . $_POST[$post] . '"';
  5778. }
  5779. return '';
  5780. }
  5781. /*
  5782. * Utilisateurs - images.
  5783. */
  5784. function users_images_action() {
  5785. if (empty($_POST['users_images_action'])
  5786. || empty($_POST['images'])
  5787. || !is_array($_POST['images'])) {
  5788. return;
  5789. }
  5790. // Suppression.
  5791. if ($_POST['users_images_action'] == 'supprimer') {
  5792. $delete_file = true;
  5793. $delete_bdd = true;
  5794. for ($i = 0; $i < count($_POST['images']); $i++) {
  5795. if (!preg_match('`^\d{1,9}$`', $_POST['images'][$i])) {
  5796. continue;
  5797. }
  5798. $mysql_requete = 'SELECT img_att_fichier
  5799. FROM ' . MYSQL_PREF . 'images_attente
  5800. WHERE img_att_id = "' . $_POST['images'][$i] . '"';
  5801. $image = $this->mysql->select($mysql_requete);
  5802. if (!is_array($image)) {
  5803. continue;
  5804. }
  5805. // Suppression de l'image et de la vignette.
  5806. $dir = './../membres/images/';
  5807. $image_file = $dir . $image[0]['img_att_fichier'];
  5808. $image_thumb = $dir . 'vignettes/thumb_' . basename($image[0]['img_att_fichier']);
  5809. if (file_exists($image_file)) {
  5810. if (!files::suppFile($image_file)) {
  5811. $delete_file = false;
  5812. }
  5813. }
  5814. if (file_exists($image_thumb)) {
  5815. if (!files::suppFile($image_thumb)) {
  5816. $delete_file = false;
  5817. }
  5818. }
  5819. // Suppression de la base de données.
  5820. $mysql_requete = 'DELETE FROM ' . MYSQL_PREF . 'images_attente
  5821. WHERE img_att_id = "' . $_POST['images'][$i] . '"';
  5822. if (!$this->mysql->requete($mysql_requete)) {
  5823. $delete_bdd = false;
  5824. }
  5825. // Messages.
  5826. if (!$delete_file) {
  5827. $this->template['infos']['erreur']['delete_file_' . $i] = 'Image Ť ' . $image[0]['img_att_fichier'] . ' ť : impossible de supprimer le fichier du répertoire d\'upload.';
  5828. }
  5829. if (!$delete_bdd) {
  5830. $this->template['infos']['erreur']['delete_bdd_' . $i] = 'Image Ť ' . $image[0]['img_att_fichier'] . ' ť : impossible de supprimer la référence du fichier de la base de données.';
  5831. }
  5832. }
  5833. // Messages.
  5834. if ($delete_file && $delete_bdd) {
  5835. $this->template['infos']['action']['delete'] = 'Les images sélectionnées ont été supprimées.';
  5836. }
  5837. }
  5838. // Validation.
  5839. if ($_POST['users_images_action'] == 'valider') {
  5840. // Informations utilisateur.
  5841. $ids = '';
  5842. for ($i = 0; $i < count($_POST['images']); $i++) {
  5843. if (!preg_match('`^\d{1,9}$`', $_POST['images'][$i])) {
  5844. continue;
  5845. }
  5846. $ids .= ' OR ' . MYSQL_PREF . 'images_attente.img_att_id = "' . $_POST['images'][$i] . '"';
  5847. }
  5848. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'images_attente.user_id,
  5849. ' . MYSQL_PREF . 'images_attente.img_att_id,
  5850. ' . MYSQL_PREF . 'images_attente.img_att_nom,
  5851. ' . MYSQL_PREF . 'images_attente.img_att_description,
  5852. ' . MYSQL_PREF . 'images_attente.img_att_fichier,
  5853. ' . MYSQL_PREF . 'categories.categorie_chemin
  5854. FROM ' . MYSQL_PREF . 'images_attente LEFT JOIN ' . MYSQL_PREF . 'categories USING (categorie_id)
  5855. WHERE ' . substr($ids, 4);
  5856. $infos = $this->mysql->select($mysql_requete);
  5857. if (!is_array($infos)) {
  5858. return;
  5859. }
  5860. $images_user = array();
  5861. $upload_dir = './../membres/images/';
  5862. $albums_dir = './../' . GALERIE_ALBUMS . '/';
  5863. for ($i = 0; $i < count($infos); $i++) {
  5864. $path = $infos[$i]['categorie_chemin'] . $infos[$i]['img_att_fichier'];
  5865. // On déplace l'image.
  5866. if (file_exists($albums_dir . $path)) {
  5867. $this->template['infos']['attention']['upload_' . $path] = 'Ť ' . $infos[$i]['img_att_fichier'] . ' ť : une image de męme nom existe déjŕ dans le répertoire cible.';
  5868. continue;
  5869. }
  5870. if (files::deplace($upload_dir . $infos[$i]['img_att_fichier'], $albums_dir . $path)) {
  5871. $images_user[$path]['user_id'] = $infos[$i]['user_id'];
  5872. $images_user[$path]['image_nom'] = $infos[$i]['img_att_nom'];
  5873. $images_user[$path]['image_desc'] = $infos[$i]['img_att_description'];
  5874. // On supprime l'image de la base de données.
  5875. $mysql_requete = 'DELETE FROM ' . MYSQL_PREF . 'images_attente
  5876. WHERE img_att_id = "' . $infos[$i]['img_att_id'] . '"';
  5877. $this->mysql->requete($mysql_requete);
  5878. }
  5879. // On supprime la vignette.
  5880. $image_thumb = $upload_dir . 'vignettes/thumb_' . $infos[$i]['img_att_fichier'];
  5881. if (file_exists($image_thumb)) {
  5882. files::suppFile($image_thumb);
  5883. }
  5884. }
  5885. // On ajoute les images ŕ la base de données.
  5886. require_once(dirname(__FILE__) . '/../includes/classes/class.upload.php');
  5887. $upload = new upload($this->mysql, $this->config);
  5888. $upload->users = $images_user;
  5889. $upload->recup_albums();
  5890. // Rapport.
  5891. if ($upload->rapport['erreurs']) {
  5892. foreach ($upload->rapport['erreurs'] as $v) {
  5893. $this->template['infos']['erreur']['upload_' . $v[0]] = 'Une erreur s\'est produite avec l\'objet Ť <em>' . $v[0] . '</em> ť : ' . $v[1];
  5894. }
  5895. }
  5896. for ($n = 0; $n < count($upload->rapport['img_rejets']); $n++) {
  5897. $this->template['infos']['erreur']['upload_' . $i] = 'L\'image Ť <em>' . $upload->rapport['img_rejets'][$n][0] . '</em> ť a été rejetée pour la raison suivante : ' . $upload->rapport['img_rejets'][$n][2];
  5898. }
  5899. if (empty($upload->rapport['img_rejets']) && empty($upload->rapport['erreur'])) {
  5900. $this->template['infos']['action']['upload_' . $i] = 'Les images sélectionnées ont été ajoutées ŕ la galerie.';
  5901. }
  5902. }
  5903. }
  5904. /*
  5905. * Utilisateurs - images.
  5906. */
  5907. function users_images() {
  5908. $this->template['infos']['title'] = 'images en attente';
  5909. $this->template['infos']['section'] = 'section=utilisateurs&page=images';
  5910. // Page ŕ afficher.
  5911. if (isset($_REQUEST['startnum']) && preg_match('`^[1-9]\d{0,9}$`', $_REQUEST['startnum'])) {
  5912. $startnum = $_REQUEST['startnum'];
  5913. } else {
  5914. $startnum = 0;
  5915. }
  5916. // Trie des membres : ordre.
  5917. if (isset($_POST['sort']) && preg_match('`^date_envoi|album|membre$`', $_POST['sort'])
  5918. && $_POST['sort'] != $this->config['admin_imgatt_ordre']) {
  5919. $this->update_option('admin_imgatt_ordre', $_POST['sort']);
  5920. }
  5921. switch ($this->config['admin_imgatt_ordre']) {
  5922. case 'album' :
  5923. $sort = MYSQL_PREF . 'categories.categorie_nom';
  5924. break;
  5925. case 'membre' :
  5926. $sort = MYSQL_PREF . 'users.user_login';
  5927. break;
  5928. default :
  5929. $sort = MYSQL_PREF . 'images_attente.img_att_date';
  5930. }
  5931. // Trie des membres : sens.
  5932. if (isset($_POST['sens']) && preg_match('`^ASC|DESC$`', $_POST['sens'])
  5933. && $_POST['sens'] != $this->config['admin_imgatt_sens']) {
  5934. $this->update_option('admin_imgatt_sens', $_POST['sens']);
  5935. }
  5936. // Nombre de membres par page.
  5937. if (isset($_POST['nb']) && preg_match('`^[1-9]\d{0,3}$`', $_POST['nb'])
  5938. && $_POST['nb'] != $this->config['admin_imgatt_nb']) {
  5939. $this->update_option('admin_imgatt_nb', $_POST['nb']);
  5940. $startnum = 0;
  5941. }
  5942. $nb_images = $this->config['admin_imgatt_nb'];
  5943. // On récupčre les images en attente.
  5944. $from_where = ' FROM ' . MYSQL_PREF . 'images_attente
  5945. LEFT JOIN ' . MYSQL_PREF . 'users
  5946. ON ' . MYSQL_PREF . 'images_attente.user_id = ' . MYSQL_PREF . 'users.user_id
  5947. LEFT JOIN ' . MYSQL_PREF . 'categories
  5948. ON ' . MYSQL_PREF . 'images_attente.categorie_id = ' . MYSQL_PREF . 'categories.categorie_id';
  5949. $mysql_requete = 'SELECT ' . MYSQL_PREF . 'images_attente.*,
  5950. ' . MYSQL_PREF . 'users.user_login,
  5951. ' . MYSQL_PREF . 'categories.categorie_id,
  5952. ' . MYSQL_PREF . 'categories.categorie_nom'
  5953. . $from_where . '
  5954. ORDER BY ' . $sort . ' ' . $this->config['admin_imgatt_sens'] . '
  5955. LIMIT ' . $startnum . ',' . $nb_images;
  5956. $this->template['images_attente'] = $this->mysql->select($mysql_requete);
  5957. // Nombre total d'images.
  5958. $mysql_requete = 'SELECT COUNT(img_att_id) ' . $from_where;
  5959. $this->template['infos']['nb_objets'] = $this->mysql->select($mysql_requete, 5);
  5960. // On détermine le nombre de pages et la page actuelle.
  5961. $this->template['infos']['nb_pages'] = ceil(($this->template['infos']['nb_objets']) / $nb_images);
  5962. for ($n = 0; $n < $this->template['infos']['nb_pages']; $n++) {
  5963. $num = $n * $nb_images;
  5964. $this->template['nav']['pages'][$n + 1]['page'] = $num;
  5965. if ($num == $startnum) {
  5966. $this->template['infos']['page_actuelle'] = $n + 1;
  5967. }
  5968. }
  5969. // On détermine les pages suivantes, précédentes, de début et de fin.
  5970. $this->template['nav']['suivante'][1] = $startnum + $nb_images;
  5971. $this->template['nav']['precedente'][1] = $startnum - $nb_images;
  5972. $this->template['nav']['premiere'][1] = 0;
  5973. $this->template['nav']['derniere'][1] = ($this->template['infos']['nb_pages'] * $nb_images) - $nb_images;
  5974. // On détermine la position de l'objet actuel.
  5975. if ($startnum == 0) {
  5976. $this->template['nav']['premiere'][0] = 1;
  5977. }
  5978. if ($this->template['nav']['precedente'][1] < 0) {
  5979. $this->template['nav']['precedente'][0] = 1;
  5980. }
  5981. if ($this->template['nav']['suivante'][1] >= ($this->template['infos']['nb_pages'] * $nb_images) ||
  5982. $this->template['nav']['suivante'][1] >= $this->template['infos']['nb_objets']) {
  5983. $this->template['nav']['suivante'][0] = 1;
  5984. }
  5985. if ($startnum >= $this->template['nav']['derniere'][1]) {
  5986. $this->template['nav']['derniere'][0] = 1;
  5987. }
  5988. $this->template['config'] = $this->config;
  5989. }
  5990. /*
  5991. * Mise ŕ jour du fichier de configuration.
  5992. */
  5993. function recup_conf() {
  5994. $conf = array();
  5995. $conf['admin_user'] = ADMIN_USER;
  5996. $conf['admin_pass'] = ADMIN_PASS;
  5997. $conf['mysql_serv'] = MYSQL_SERV;
  5998. $conf['mysql_user'] = MYSQL_USER;
  5999. $conf['mysql_pass'] = MYSQL_PASS;
  6000. $conf['mysql_base'] = MYSQL_BASE;
  6001. $conf['mysql_pref'] = MYSQL_PREF;
  6002. $conf['thumb_tdir'] = THUMB_TDIR;
  6003. $conf['thumb_pref'] = THUMB_PREF;
  6004. $conf['thumb_alb_mode'] = THUMB_ALB_MODE;
  6005. $conf['thumb_alb_size'] = THUMB_ALB_SIZE;
  6006. $conf['thumb_alb_crop_width'] = THUMB_ALB_CROP_WIDTH;
  6007. $conf['thumb_alb_crop_height'] = THUMB_ALB_CROP_HEIGHT;
  6008. $conf['thumb_img_mode'] = THUMB_IMG_MODE;
  6009. $conf['thumb_img_size'] = THUMB_IMG_SIZE;
  6010. $conf['thumb_img_crop_width'] = THUMB_IMG_CROP_WIDTH;
  6011. $conf['thumb_img_crop_height'] = THUMB_IMG_CROP_HEIGHT;
  6012. $conf['thumb_quality'] = THUMB_QUALITY;
  6013. $conf['img_resize_gd'] = IMG_RESIZE_GD;
  6014. $conf['img_texte'] = IMG_TEXTE;
  6015. $conf['img_texte_params'] = IMG_TEXTE_PARAMS;
  6016. $conf['galerie_url'] = GALERIE_URL;
  6017. $conf['galerie_path'] = GALERIE_PATH;
  6018. $conf['galerie_theme'] = GALERIE_THEME;
  6019. $conf['galerie_style'] = GALERIE_STYLE;
  6020. $conf['galerie_url_type'] = GALERIE_URL_TYPE;
  6021. $conf['galerie_albums'] = GALERIE_ALBUMS;
  6022. $conf['galerie_install'] = GALERIE_INSTALL;
  6023. $conf['galerie_version'] = GALERIE_VERSION;
  6024. $conf['galerie_integrated'] = GALERIE_INTEGRATED;
  6025. return $conf;
  6026. }
  6027. function update_conf($conf, $msg = 1) {
  6028. if ($conf == $this->recup_conf()) {
  6029. return TRUE;
  6030. }
  6031. $file = '../config/conf.php';
  6032. if (!file_exists($file)) {
  6033. $this->template['infos']['erreur']['change_config'] = 'Fichier de config inexistant.';
  6034. return FALSE;
  6035. }
  6036. files::chmodFile($file);
  6037. if ($id = @fopen($file, 'w')) {
  6038. $config = "<?php\n\n";
  6039. $config .= "define('ADMIN_USER', '" . $conf['admin_user'] . "');\n";
  6040. $config .= "define('ADMIN_PASS', '" . $conf['admin_pass'] . "');\n";
  6041. $config .= "define('MYSQL_SERV', '" . $conf['mysql_serv'] . "');\n";
  6042. $config .= "define('MYSQL_USER', '" . $conf['mysql_user'] . "');\n";
  6043. $config .= "define('MYSQL_PASS', '" . $conf['mysql_pass'] . "');\n";
  6044. $config .= "define('MYSQL_BASE', '" . $conf['mysql_base'] . "');\n";
  6045. $config .= "define('MYSQL_PREF', '" . $conf['mysql_pref'] . "');\n";
  6046. $config .= "define('THUMB_TDIR', '" . $conf['thumb_tdir'] . "');\n";
  6047. $config .= "define('THUMB_PREF', '" . $conf['thumb_pref'] . "');\n";
  6048. $config .= "define('THUMB_ALB_MODE', '" . $conf['thumb_alb_mode'] . "');\n";
  6049. $config .= "define('THUMB_ALB_SIZE', " . $conf['thumb_alb_size'] . ");\n";
  6050. $config .= "define('THUMB_ALB_CROP_WIDTH', " . $conf['thumb_alb_crop_width'] . ");\n";
  6051. $config .= "define('THUMB_ALB_CROP_HEIGHT', " . $conf['thumb_alb_crop_height'] . ");\n";
  6052. $config .= "define('THUMB_IMG_MODE', '" . $conf['thumb_img_mode'] . "');\n";
  6053. $config .= "define('THUMB_IMG_SIZE', " . $conf['thumb_img_size'] . ");\n";
  6054. $config .= "define('THUMB_IMG_CROP_WIDTH', " . $conf['thumb_img_crop_width'] . ");\n";
  6055. $config .= "define('THUMB_IMG_CROP_HEIGHT', " . $conf['thumb_img_crop_height'] . ");\n";
  6056. $config .= "define('THUMB_QUALITY', " . $conf['thumb_quality'] . ");\n";
  6057. $config .= "define('IMG_RESIZE_GD', '" . $conf['img_resize_gd'] . "');\n";
  6058. $config .= "define('IMG_TEXTE', '" . $conf['img_texte'] . "');\n";
  6059. $config .= "define('IMG_TEXTE_PARAMS', '" . str_replace("'", "\'", $conf['img_texte_params']) . "');\n";
  6060. $config .= "define('GALERIE_URL', '" . $conf['galerie_url'] . "');\n";
  6061. $config .= "define('GALERIE_PATH', '" . $conf['galerie_path'] . "');\n";
  6062. $config .= "define('GALERIE_THEME', '" . $conf['galerie_theme'] . "');\n";
  6063. $config .= "define('GALERIE_STYLE', '" . $conf['galerie_style'] . "');\n";
  6064. $config .= "define('GALERIE_URL_TYPE', '" . $conf['galerie_url_type'] . "');\n";
  6065. $config .= "define('GALERIE_ALBUMS', '" . $conf['galerie_albums'] . "');\n";
  6066. $config .= "define('GALERIE_INSTALL', " . $conf['galerie_install'] . ");\n";
  6067. $config .= "define('GALERIE_VERSION', '" . $conf['galerie_version'] . "');\n";
  6068. $config .= "define('GALERIE_INTEGRATED', " . $conf['galerie_integrated'] . ");\n";
  6069. $config .= "\n?>";
  6070. if (!@fwrite($id, $config)) {
  6071. return FALSE;
  6072. }
  6073. @fclose($id);
  6074. if ($msg) {
  6075. $this->template['infos']['action']['change_config'] = 'Fichier de configuration mis ŕ jour.';
  6076. }
  6077. } else {
  6078. $this->template['infos']['erreur']['change_config'] = 'Impossible de modifier le fichier de config.';
  6079. return FALSE;
  6080. }
  6081. return TRUE;
  6082. }
  6083. /*
  6084. * Configuration.
  6085. */
  6086. function config_conf() {
  6087. $this->template['infos']['title'] = 'configuration de la galerie';
  6088. $this->template['config']['galerie_albums_dir'] = GALERIE_ALBUMS;
  6089. $this->template['config']['galerie_repertoire_vignettes'] = THUMB_TDIR;
  6090. $this->template['config']['galerie_prefixe_vignettes'] = THUMB_PREF;
  6091. if (isset($_POST['u'])) {
  6092. // On vérifie que le mot de passe actuel a bien été entré.
  6093. if (empty($_POST['g_pass']) || $_POST['g_pass'] !== ADMIN_PASS) {
  6094. $this->template['infos']['attention']['config_admin_change_pass'] = 'Le mot de passe actuel que vous avez entré est incorrect.';
  6095. return;
  6096. }
  6097. $change = 0;
  6098. $conf = $this->recup_conf();
  6099. // Identifiant.
  6100. if (!empty($_POST['g_login'])) {
  6101. $_POST['g_login'] = trim($_POST['g_login']);
  6102. if (!preg_match('`^[a-z\d_]{3,30}$`i', $_POST['g_login'])) {
  6103. $this->template['infos']['attention']['config_admin_change_login'] = 'L\'identifiant doit comporter entre 3 et 30 caractčres alphanumériques (non accentués) ou souligné (_).';
  6104. } else {
  6105. $mysql_requete = 'SELECT user_id
  6106. FROM ' . MYSQL_PREF . 'users
  6107. WHERE user_login = "' . $_POST['g_login'] . '"';
  6108. if (is_array($this->mysql->select($mysql_requete))) {
  6109. $this->template['infos']['attention']['config_admin_change_login'] = 'L\'identifiant choisi est déjŕ pris.';
  6110. } else {
  6111. $conf['admin_user'] = $_POST['g_login'];
  6112. $change = 1;
  6113. $this->template['infos']['action']['config_admin_change'] = 'Les paramčtres admin ont été changés.';
  6114. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'users
  6115. SET user_login = "' . $_POST['g_login'] . '"
  6116. WHERE user_id = 1';
  6117. $this->mysql->requete($mysql_requete);
  6118. }
  6119. }
  6120. }
  6121. // Mot de passe.
  6122. if (!empty($_POST['g_pass']) && !empty($_POST['g_new_pass']) && !empty($_POST['g_new_pass_confirm'])) {
  6123. if (!preg_match('`^[a-z\d_]{6,50}$`i', $_POST['g_new_pass'])) {
  6124. $this->template['infos']['attention']['config_admin_change_pass'] = 'Le nouveau mot de passe doit comporter entre 6 et 50 caractčres alphanumériques (non accentués) ou souligné (_).';
  6125. } elseif ($_POST['g_new_pass'] != $_POST['g_new_pass_confirm']) {
  6126. $this->template['infos']['attention']['config_admin_change_pass'] = 'La confirmation du nouveau mot de passe ne correspond pas.';
  6127. } else {
  6128. $conf['admin_pass'] = $_POST['g_new_pass'];
  6129. $change = 1;
  6130. $this->template['infos']['action']['config_admin_change'] = 'Les paramčtres admin ont été changés.';
  6131. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'users
  6132. SET user_pass = "' . md5($_POST['g_new_pass']) . '"
  6133. WHERE user_id = 1';
  6134. $this->mysql->requete($mysql_requete);
  6135. }
  6136. }
  6137. // Courriel.
  6138. if (isset($_POST['g_mail'])) {
  6139. $_POST['g_mail'] = trim($_POST['g_mail']);
  6140. if ($_POST['g_mail'] != $this->config['admin_mail']) {
  6141. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'users
  6142. SET user_mail = "' . $_POST['g_mail'] . '"
  6143. WHERE user_id = 1';
  6144. $this->mysql->requete($mysql_requete);
  6145. $mysql_requete = 'UPDATE ' . MYSQL_PREF . 'config
  6146. SET valeur = "' . outils::protege_mysql($_POST['g_mail'], $this->mysql->lien) . '"
  6147. WHERE parametre = "admin_mail"';
  6148. $this->mysql->requete($mysql_requete);
  6149. $this->template['config']['admin_mail'] = $_POST['g_mail'];
  6150. $this->template['infos']['action']['config_admin_change'] = 'Les paramčtres admin ont été changés.';
  6151. }
  6152. }
  6153. // Répertoire des albums.
  6154. if (!empty($_POST['g_dir_alb']) && GALERIE_ALBUMS != $_POST['g_dir_alb']) {
  6155. if (is_dir('../' . $_POST['g_dir_alb'] . '/')) {
  6156. $conf['galerie_albums'] = $_POST['g_dir_alb'];
  6157. $this->template['config']['galerie_albums_dir'] = $_POST['g_dir_alb'];
  6158. $change = 1;
  6159. } else {
  6160. $this->template['infos']['attention']['config_albums_dir'] = 'Le répertoire d\'albums que vous avez spécifié n\'existe pas.';
  6161. }
  6162. }
  6163. $del_thumbs = 0;
  6164. $remakedir = 0;
  6165. $thumb_dir = THUMB_TDIR;
  6166. // Répertoire des vignettes.
  6167. if (!empty($_POST['g_dir_tb']) && THUMB_TDIR != $_POST['g_dir_tb']
  6168. && preg_match('`^[a-z0-9_-]{1,99}$`i', $_POST['g_dir_tb'])) {
  6169. $del_thumbs = 1;
  6170. $remakedir = 1;
  6171. $change = 1;
  6172. $conf['thumb_tdir'] = $_POST['g_dir_tb'];
  6173. $this->template['config']['galerie_repertoire_vignettes'] = $_POST['g_dir_tb'];
  6174. }
  6175. // Préfixe des vignettes.
  6176. if (isset($_POST['g_pref_tb']) && THUMB_PREF != $_POST['g_pref_tb']
  6177. && preg_match('`^[a-z0-9_-]{0,99}$`i', $_POST['g_pref_tb'])) {
  6178. $del_thumbs = 1;
  6179. $change = 1;
  6180. $conf['thumb_pref'] = $_POST['g_pref_tb'];
  6181. $this->template['config']['galerie_prefixe_vignettes'] = $_POST['g_pref_tb'];
  6182. }
  6183. if ($del_thumbs) {
  6184. if (!$this->del_thumbs($thumb_dir, $remakedir)) {
  6185. $this->template['infos']['erreur']['sup_vignettes'] = 'Toutes les vignettes n\'ont pas pu ętre supprimées.';
  6186. }
  6187. }
  6188. // Mise ŕ jour du fichier de configuration.
  6189. if ($change) {
  6190. $this->update_conf($conf);
  6191. }
  6192. }
  6193. }
  6194. /*
  6195. * Suppression des vignettes.
  6196. */
  6197. function del_thumbs($thumb_dir, $remakedir = 0, $what = 0) {
  6198. $ok = TRUE;
  6199. if ($what === 0 || $what === 1) {
  6200. if (!$this->del_thumbs_img($thumb_dir, $remakedir)) {
  6201. $ok = FALSE;
  6202. }
  6203. }
  6204. if ($what === 0 || $what === 2) {
  6205. if (!$this->delete_dir(dirname(dirname(__FILE__)) . '/cache/cat_thumb/', 0)) {
  6206. $ok = FALSE;
  6207. }
  6208. }
  6209. return $ok;
  6210. }
  6211. function del_thumbs_img($thumb_dir, $remakedir = 0, $rep = '') {
  6212. static $ok = TRUE;
  6213. $gal_dir = substr($this->galerie_dir, 0, strlen($this->galerie_dir)-1);
  6214. if (is_dir($gal_dir . $rep)) {
  6215. if ($dir = @opendir($gal_dir . $rep)) {
  6216. while ($ent = readdir($dir)) {
  6217. $file = $gal_dir . $rep . '/' . $ent;
  6218. if (is_dir($file) && $ent != '.' && $ent != '..') {
  6219. $this->del_thumbs_img($thumb_dir, $remakedir, $rep . '/' . $ent);
  6220. } elseif (is_file($file) && preg_match('`/' . $thumb_dir . '$`', $rep)) {
  6221. if (!files::suppFile($file)) {
  6222. $ok = FALSE;
  6223. }
  6224. }
  6225. }
  6226. closedir($dir);
  6227. if ($remakedir) {
  6228. if (preg_match('`/' . $thumb_dir . '$`', $rep)) {
  6229. if (file_exists(($gal_dir . $rep))) {
  6230. if (!files::suppFile($gal_dir . $rep)) {
  6231. $ok = FALSE;
  6232. }
  6233. }
  6234. $newdir = $gal_dir . preg_replace('`/' . $thumb_dir . '$`', '/' . $this->template['config']['galerie_repertoire_vignettes'] . '', $rep);
  6235. if (!files::createDir($newdir)) {
  6236. if (!file_exists(($newdir))) {
  6237. $ok = FALSE;
  6238. }
  6239. }
  6240. }
  6241. }
  6242. } else {
  6243. $ok = FALSE;
  6244. }
  6245. }
  6246. return $ok;
  6247. }
  6248. /*
  6249. * Infos systčme.
  6250. */
  6251. function config_infosys() {
  6252. $this->template['infos']['title'] = 'infos systčme';
  6253. // OS.
  6254. $this->template['infos']['php_os'] = '<span class="action_infos">' . PHP_OS . '</span>';
  6255. // Version de PHP.
  6256. $this->template['infos']['php_version'] = '<span class="action_infos">' . PHP_VERSION . '</span>';
  6257. // Version de MySQL.
  6258. $this->template['infos']['mysql_version'] = '<span class="action_infos">' . @mysql_get_server_info() . '</span>';
  6259. // Version GD.
  6260. if (function_exists('gd_info')) {
  6261. $gd_info = gd_info();
  6262. $gd_version = (empty($gd_info['GD Version'])) ? 'inconnue' : $gd_info['GD Version'];
  6263. } elseif (function_exists('imagetypes')) {
  6264. $gd_version = 'inconnue';
  6265. } else {
  6266. $gd_version = 'GD n\'est pas activé';
  6267. }
  6268. $this->template['infos']['gd_version'] = '<span class="action_infos">' . $gd_version . '</span>';
  6269. // Support JPG
  6270. $jpg = (imagetypes() & IMG_JPG) ? 'oui' : 'non';
  6271. $this->template['infos']['gd_jpg'] = '<span class="action_infos">' . $jpg . '</span>';
  6272. // Support GIF
  6273. $gif = (imagetypes() & IMG_GIF) ? 'oui' : 'non';
  6274. $this->template['infos']['gd_gif'] = '<span class="action_infos">' . $gif . '</span>';
  6275. // Support PNG
  6276. $png = (imagetypes() & IMG_PNG) ? 'oui' : 'non';
  6277. $this->template['infos']['gd_png'] = '<span class="action_infos">' . $png . '</span>';
  6278. // Mémoire disponible.
  6279. $this->template['infos']['memory_limit'] = (function_exists('ini_get')) ? ini_get('memory_limit') : 'inconnue';
  6280. // Extension Exif.
  6281. $this->template['infos']['exif'] = (function_exists('read_exif_data')) ? 'activée' : 'désactivée';
  6282. // Extension Zip.
  6283. $this->template['infos']['zip'] = (function_exists('zip_open')) ? 'activée' : 'désactivée';
  6284. // Date serveur.
  6285. $this->template['infos']['server_time'] = '<span class="action_infos">' . outils::ladate(0, '%A %d %B %Y - %H:%M:%S') . '</span>';
  6286. // Infos serveur.
  6287. if (isset($_SERVER['SERVER_SIGNATURE'])) {
  6288. $this->template['infos']['server_infos'] = '<span class="action_infos">' . strip_tags($_SERVER['SERVER_SIGNATURE']) . '</span>';
  6289. } else {
  6290. $this->template['infos']['server_infos'] = '<span class="action_infos">non disponible</span>';
  6291. }
  6292. // Safe Mode.
  6293. $this->template['infos']['safe_mode'] = (ini_get('safe_mode')) ? 'activé' : 'désactivé';
  6294. // magic_quotes_gpc et magic_quotes_runtime
  6295. if (get_magic_quotes_gpc()) {
  6296. $this->template['infos']['magic_quotes_gpc'] = '<span class="action_infos">activée</span>';
  6297. } else {
  6298. $this->template['infos']['magic_quotes_gpc'] = '<span class="action_infos">désactivée</span>';
  6299. }
  6300. if (get_magic_quotes_runtime()) {
  6301. $this->template['infos']['magic_quotes_runtime'] = '<span class="action_infos">activée</span>';
  6302. } else {
  6303. $this->template['infos']['magic_quotes_runtime'] = '<span class="action_infos">désactivée</span>';
  6304. }
  6305. // Droits d'accčs en écriture.
  6306. $f = './../config/conf.php';
  6307. if (files::chmodTest($f)) {
  6308. $this->template['infos']['acces_conf'] = '<span class="infosys_succes">Le fichier de configuration est accessible en écriture (' . substr(sprintf('%o', fileperms($f)), -4) . ').</span>';
  6309. } else {
  6310. $this->template['infos']['acces_conf'] = '<span class="infosys_erreur">Le fichier de configuration n\'est pas accessible en écriture (' . substr(sprintf('%o', fileperms($f)), -4) . ').</span>';
  6311. }
  6312. $f = './../' . GALERIE_ALBUMS . '/';
  6313. if (files::chmodTest($f)) {
  6314. $this->template['infos']['acces_albums'] = '<span class="infosys_succes">Le répertoire des albums est accessible en écriture (' . substr(sprintf('%o', fileperms($f)), -4) . ').</span>';
  6315. } else {
  6316. $this->template['infos']['acces_albums'] = '<span class="infosys_erreur">Le répertoire des albums n\'est pas accessible en écriture (' . substr(sprintf('%o', fileperms($f)), -4) . ').</span>';
  6317. }
  6318. $f = './../cache/';
  6319. if (files::chmodTest($f)) {
  6320. $this->template['infos']['acces_cache'] = '<span class="infosys_succes">Le répertoire cache/ est accessible en écriture (' . substr(sprintf('%o', fileperms($f)), -4) . ').</span>';
  6321. } else {
  6322. $this->template['infos']['acces_cache'] = '<span class="infosys_erreur">Le répertoire cache/ n\'est pas accessible en écriture (' . substr(sprintf('%o', fileperms($f)), -4) . ').</span>';
  6323. }
  6324. $f = './../cache/cat_thumb/';
  6325. if (files::chmodTest($f)) {
  6326. $this->template['infos']['acces_cat_thumb'] = '<span class="infosys_succes">Le répertoire cache/cat_thumb/ est accessible en écriture (' . substr(sprintf('%o', fileperms($f)), -4) . ').</span>';
  6327. } else {
  6328. $this->template['infos']['acces_cat_thumb'] = '<span class="infosys_erreur">Le répertoire cache/cat_thumb/ n\'est pas accessible en écriture (' . substr(sprintf('%o', fileperms($f)), -4) . ').</span>';
  6329. }
  6330. }
  6331. }
  6332. /*
  6333. * Fonctions de template.
  6334. */
  6335. class template {
  6336. /* Données brutes issues du "moteur" */
  6337. var $data;
  6338. /* Variable interne temporaire utilisée par certaines boucles */
  6339. var $interne;
  6340. var $file;
  6341. /*
  6342. * Constructeur.
  6343. */
  6344. function template($data) {
  6345. $this->data = $data;
  6346. $this->file = (basename(GALERIE_URL) != 'index.php') ? basename(GALERIE_URL) : '';
  6347. }
  6348. function getVID($type = 0) {
  6349. switch ($type) {
  6350. case 0 :
  6351. echo '<input type="hidden" name="igalvid" value="' . $this->data['new_vid'] . '" />';
  6352. break;
  6353. case 1 :
  6354. echo '&amp;igalvid=' . $this->data['new_vid'];
  6355. break;
  6356. case 2 :
  6357. return '&amp;igalvid=' . $this->data['new_vid'];
  6358. break;
  6359. }
  6360. }
  6361. function getInputDisabled($f, $s = ' disabled="disabled"') {
  6362. if (isset($this->data['enabled'][$f]) && !$this->data['enabled'][$f])
  6363. { echo $s; }
  6364. }
  6365. function getTextDisabled($f, $s = ' class="disabled"') {
  6366. if (isset($this->data['enabled'][$f]) && !$this->data['enabled'][$f])
  6367. { echo $s; }
  6368. }
  6369. /*
  6370. * Version de la galerie.
  6371. */
  6372. function getGalerieVersion() {
  6373. }
  6374. /*
  6375. * Chemin du répertoire des albums.
  6376. */
  6377. function getAlbumsDir() {
  6378. $sn = dirname(dirname($_SERVER['SCRIPT_NAME']));
  6379. $sn = ($sn == '/' || $sn == '\\') ? '' : $sn;
  6380. echo $sn . '/' . preg_replace('`/$`', '', GALERIE_ALBUMS) . '/';
  6381. }
  6382. /*
  6383. * Permet de répeter un męme code avec un chiffre changeant.
  6384. */
  6385. function boucle($s, $n = 0, $m = 100) {
  6386. for ($i = $n; $i <= $m; $i++) {
  6387. printf($s, $i);
  6388. }
  6389. }
  6390. /*
  6391. * Mise en évidence d'un terme recherché dans un texte.
  6392. */
  6393. function highlight_search($text, $terme) {
  6394. if ($terme) {
  6395. $terme = preg_split('`\s+(?![\w\s]*[^-\s]")`i', $terme, -1, PREG_SPLIT_NO_EMPTY);
  6396. for ($i = 0; $i < count($terme); $i++) {
  6397. // On prépare la RegExp.
  6398. $terme[$i] = preg_quote(trim($terme[$i]));
  6399. $terme[$i] = preg_replace('`([lg])`', '~#ľ$1ľ#~', $terme[$i]);
  6400. $terme[$i] = preg_replace('`t`', '~#ľtľ#~', $terme[$i]);
  6401. $terme[$i] = preg_replace('`a`', '~#ľaľ#~', $terme[$i]);
  6402. $terme[$i] = preg_replace('`m`', '~#ľmľ#~', $terme[$i]);
  6403. $terme[$i] = preg_replace('`p`', '~#ľpľ#~', $terme[$i]);
  6404. $terme[$i] = preg_replace('`;`', '~#ľ;ľ#~', $terme[$i]);
  6405. $terme[$i] = str_replace('&', '&amp;', $terme[$i]);
  6406. $terme[$i] = str_replace('<', '&lt;', $terme[$i]);
  6407. $terme[$i] = str_replace('>', '&gt;', $terme[$i]);
  6408. $terme[$i] = preg_replace('`~#ľ([lg])ľ#~`', '$1(?!(?<=&$1)t;)', $terme[$i]);
  6409. $terme[$i] = str_replace('~#ľtľ#~', 't(?!(?<=&[lg]t);)', $terme[$i]);
  6410. $terme[$i] = str_replace('~#ľaľ#~', 'a(?!(?<=&a)mp;)', $terme[$i]);
  6411. $terme[$i] = str_replace('~#ľmľ#~', 'm(?!(?<=&am)p;)', $terme[$i]);
  6412. $terme[$i] = str_replace('~#ľpľ#~', 'p(?!(?<=&amp);)', $terme[$i]);
  6413. $terme[$i] = str_replace('~#ľ;ľ#~', '(?<!&[lg]t)(?<!&amp);', $terme[$i]);
  6414. // Accents.
  6415. $terme[$i] = outils::regexp_accents($terme[$i]);
  6416. // On supprime les éventuels guillemets.
  6417. $terme[$i] = str_replace('"', '', $terme[$i]);
  6418. // Jokers Ť * ť et Ť ? ť.
  6419. if (preg_match('`^(\x5C[*?])+$`', $terme[$i])) {
  6420. $terme[$i] = '(?:&amp;|&lt;|&gt;|.+)';
  6421. } else {
  6422. $terme[$i] = str_replace('\*', '(?:[^\s>]*(?:</?a[^\s>]*>(?:[^\s<]+</a>)?)?[^\s>]*?)', $terme[$i]);
  6423. $terme[$i] = str_replace('\?', '(&amp;|&[lg]t;|[^\W<>&])(?!(?:[^<]*>))', $terme[$i]);
  6424. }
  6425. // Espaces.
  6426. $terme[$i] = preg_replace('`\s+`', '(?:\s+(?:</?a[^>]*>)?|(?:</?a[^>]*>)?\s+)', $terme[$i]);
  6427. }
  6428. $terme = '(?:' . implode('|', $terme) . ')';
  6429. // On entoure les termes matchés par des balises <span>.
  6430. $casse = (isset($_REQUEST['s_casse'])) ? '' : 'i';
  6431. $text = preg_replace('`(?<!\w)(' . $terme . '(?![^<>]*>))(?!\w)`' . $casse, '<span class="s_hl">$1</span>', $text);
  6432. // On remet de l'ordre dans les balises si nécessaire.
  6433. $text = preg_replace('`(<span[^>]+>)([^<]*)(</?a[^>]*>)([^<]*)(</span>)`', '$1$2$5$3$1$4$5', $text);
  6434. }
  6435. return $text;
  6436. }
  6437. /* Informations générales. */
  6438. function getInfo($i, $s = '%s') {
  6439. if (isset($this->data['infos'][$i])) {
  6440. $info = ($i == 'type_nom') ? strip_tags($this->data['infos'][$i]) : $this->data['infos'][$i];
  6441. printf($s, $info);
  6442. }
  6443. }
  6444. /* Section actuelle. */
  6445. function getSectionActuel($p, $o = '') {
  6446. static $id;
  6447. $id = ($o) ? $o : $id;
  6448. if (preg_match('`' . $_GET['section'] . '(\s|$)`', $p)) {
  6449. echo $id;
  6450. }
  6451. }
  6452. /* Page actuelle. */
  6453. function getPageActuelle($p, $o = '') {
  6454. static $id;
  6455. $id = ($o) ? $o : $id;
  6456. if (empty($_REQUEST['page'])) {
  6457. echo $id;
  6458. $id = '';
  6459. } elseif ($_REQUEST['page'] == $p) {
  6460. echo $id;
  6461. }
  6462. }
  6463. /* On détermine quelle portion de code HTML l'on doit afficher. */
  6464. function display($type) {
  6465. switch ($type) {
  6466. case 'rapport' : if (!empty($this->data[$type])) { echo $this->data[$type]; } break;
  6467. case 'barre_nav' : if (isset($this->data['nav']['pages'][2])) { return TRUE; } break;
  6468. default : if (isset($this->data['display'][$type])) { return TRUE; }
  6469. }
  6470. }
  6471. /* Barres de navigation */
  6472. function getBarreNavPageNext($s = '%s %s %s') {
  6473. for ($i = 1; $i <= count($this->data['nav']['pages']); $i++) {
  6474. if (isset($this->data['infos']['page_actuelle']) && $this->data['infos']['page_actuelle'] == $i) {
  6475. $selected = ' selected="selected"';
  6476. } else {
  6477. $selected = '';
  6478. }
  6479. printf($s, $this->data['nav']['pages'][$i]['page'], $selected, $i);
  6480. }
  6481. }
  6482. /* Barre de navigation */
  6483. function getBarreNav($s, $type) {
  6484. static $clavier;
  6485. switch ($type) {
  6486. case 'first' :
  6487. $e = 'premiere'; $k = ' id="_nav_first"'; $l = '&lt;&lt;'; $t = 'Premičre page'; break;
  6488. case 'prev' :
  6489. $e = 'precedente'; $k = ' id="_nav_prev"'; $l = '&lt;'; $t = 'Page précédente'; break;
  6490. case 'next' :
  6491. $e = 'suivante'; $k = ' id="_nav_next"'; $l = '&gt;'; $t = 'Page suivante'; break;
  6492. default :
  6493. $e = 'derniere'; $k = ' id="_nav_last"'; $l = '&gt;&gt;'; $t = 'Derničre page';
  6494. }
  6495. if (empty($clavier)) {
  6496. $keys = $k;
  6497. if ($type == 'last') {
  6498. $clavier = 1;
  6499. }
  6500. } else {
  6501. $keys = '';
  6502. }
  6503. if (isset($this->data['nav'][$e][0])) {
  6504. $lien = $l;
  6505. $class = ' inactive';
  6506. } else {
  6507. $recherche = (isset($this->data['infos']['recherche'])) ? $this->data['infos']['recherche'] : '';
  6508. $lien = '<a' . $keys . ' href="?' . htmlentities($this->data['infos']['section'] . $recherche) . '&amp;startnum=' .
  6509. $this->data['nav'][$e][1] . '" title="' . $t . '">' . $l . '</a>';
  6510. $class = '';
  6511. }
  6512. printf($s, $class, $lien);
  6513. }
  6514. /* Activation/désactivation de la galerie. */
  6515. function getGalActiveLink() {
  6516. $mot = ($this->data['config']['active_galerie']) ? 'fermer' : 'ouvrir';
  6517. $arg = ($this->data['config']['active_galerie']) ? 'desactive': 'active';
  6518. $query_string = '';
  6519. foreach ($_REQUEST as $k => $v) {
  6520. if ($k == 'startnum' ||
  6521. $k == 'page' ||
  6522. $k == 'section' ||
  6523. $k == 'cat' ||
  6524. $k == 'img') {
  6525. $query_string .= $k . '=' . $v . '&';
  6526. }
  6527. }
  6528. echo '<a href="index.php?' . htmlspecialchars($query_string) . 'gal_' . $arg . '=1' . $this->getVID(2) . '">' . $mot . ' la galerie</a>';
  6529. }
  6530. /* Rapport des actions effectuées par l'utilisateur. */
  6531. function getRapport($s = '%s') {
  6532. if (isset($this->data['infos']['action'])) {
  6533. $rapport = '';
  6534. foreach ($this->data['infos']['action'] as $k => $v) {
  6535. $rapport .= '<span>' . $v . '</span>';
  6536. }
  6537. printf($s, '<div class="rapport_msg rapport_succes"><div>' . $rapport . '</div></div>');
  6538. }
  6539. if (isset($this->data['infos']['attention'])) {
  6540. $rapport = '';
  6541. foreach ($this->data['infos']['attention'] as $k => $v) {
  6542. $rapport .= '<span>' . $v . '</span>';
  6543. }
  6544. printf($s, '<div class="rapport_msg rapport_avert"><div>' . $rapport . '</div></div>');
  6545. }
  6546. if (isset($this->data['infos']['erreur'])) {
  6547. $rapport = '';
  6548. foreach ($this->data['infos']['erreur'] as $k => $v) {
  6549. $rapport .= '<span>' . $v . '</span>';
  6550. }
  6551. printf($s, '<div class="rapport_msg rapport_erreur"><div>' . $rapport . '</div></div>');
  6552. }
  6553. if (isset($this->data['infos']['info'])) {
  6554. $rapport = '';
  6555. foreach ($this->data['infos']['info'] as $k => $v) {
  6556. $rapport .= '<span>' . $v . '</span>';
  6557. }
  6558. printf($s, '<div class="rapport_msg rapport_infos"><div>' . $rapport . '</div></div>');
  6559. }
  6560. }
  6561. /*
  6562. *
  6563. * ======================================== COMMENTAIRES;
  6564. *
  6565. */
  6566. function getNextComment() {
  6567. if (!empty($this->data['comments'])) {
  6568. if (!isset($this->interne['comment_num'])) {
  6569. $this->interne['comment_num'] = 0;
  6570. } else {
  6571. $this->interne['comment_num']++;
  6572. }
  6573. if (isset($this->data['comments'][$this->interne['comment_num']]['commentaire_id'])) {
  6574. return TRUE;
  6575. }
  6576. }
  6577. }
  6578. /* Elements constituants chaque commentaire et informations commentaires */
  6579. function getComment($type, $o = '', $o2 = '') {
  6580. $section = 'href="index.php?section=commentaires&amp;page=display&amp;' . $this->data['infos']['obj_type'] . '=' . $this->data['infos']['obj'] . '&amp;startnum=' . $this->data['infos']['startnum'];
  6581. switch ($type) {
  6582. case 'date' :
  6583. echo outils::ladate($this->data['comments'][$this->interne['comment_num']]['commentaire_date'], '%A %d %B %Y ŕ %H:%M:%S');
  6584. break;
  6585. case 'auteur' :
  6586. $search = (isset($_REQUEST['search'])) ? $_REQUEST['search'] : '';
  6587. $texte = outils::html_specialchars($this->data['comments'][$this->interne['comment_num']]['commentaire_auteur']);
  6588. if (isset($_REQUEST['s_auteur'])) {
  6589. $texte = $this->highlight_search($texte, $search);
  6590. }
  6591. echo '<a href="?section=commentaires&amp;page=display&amp;u=1&amp;s=1&amp;cat=1&amp;search=' . urlencode('"' . $this->data['comments'][$this->interne['comment_num']]['commentaire_auteur'] . '"') . '&amp;s_auteur=on&amp;s_tous=on&amp;s_dnpc=0&amp;s_dnpd=j&amp;s_dnsc=5&amp;s_dnsd=j">' . $texte . '</a>';
  6592. break;
  6593. case 'courriel' :
  6594. $s = ($o) ? $o : '%s';
  6595. $search = (isset($_REQUEST['search'])) ? $_REQUEST['search'] : '';
  6596. $mail = $this->data['comments'][$this->interne['comment_num']]['commentaire_mail'];
  6597. if ($this->data['comments'][$this->interne['comment_num']]['user_id'] > 0) {
  6598. $mail = $this->data['comments'][$this->interne['comment_num']]['user_mail'];
  6599. }
  6600. if (!empty($mail)) {
  6601. if ($mail != $this->highlight_search($this->data['comments'][$this->interne['comment_num']]['commentaire_mail'], $search)
  6602. && isset($_REQUEST['s_mail'])) {
  6603. $mail = '<a href="mailto:' . htmlentities($mail) . '"><span class="s_hl">courriel</span></a>';
  6604. } else {
  6605. $mail = '<a href="mailto:' . htmlentities($mail) . '">courriel</a>';
  6606. }
  6607. printf($s, $mail);
  6608. }
  6609. break;
  6610. case 'site' :
  6611. $s = ($o) ? $o : '%s';
  6612. $search = (isset($_REQUEST['search'])) ? $_REQUEST['search'] : '';
  6613. $site = $this->data['comments'][$this->interne['comment_num']]['commentaire_web'];
  6614. if ($this->data['comments'][$this->interne['comment_num']]['user_id'] > 0) {
  6615. $site = $this->data['comments'][$this->interne['comment_num']]['user_web'];
  6616. }
  6617. if (!empty($site)) {
  6618. if ($site != $this->highlight_search($this->data['comments'][$this->interne['comment_num']]['commentaire_web'], $search)
  6619. && isset($_REQUEST['s_web'])) {
  6620. $site = '<a class="ex" href="' . htmlentities($site) . '"><span class="s_hl">site Web</span></a>';
  6621. } else {
  6622. $site = '<a class="ex" href="' . htmlentities($site) . '">site Web</a>';
  6623. }
  6624. printf($s, $site);
  6625. }
  6626. break;
  6627. case 'ip' :
  6628. $search = (isset($_REQUEST['search'])) ? $_REQUEST['search'] : '';
  6629. $texte = $this->data['comments'][$this->interne['comment_num']]['commentaire_ip'];
  6630. if (isset($_REQUEST['s_ip'])) {
  6631. $texte = $this->highlight_search($texte, $search);
  6632. }
  6633. echo '<a href="?section=commentaires&amp;page=display&amp;u=1&amp;s=1&amp;cat=1&amp;search=' . urlencode('"' . $this->data['comments'][$this->interne['comment_num']]['commentaire_ip'] . '"') . '&amp;s_ip=on&amp;s_tous=on&amp;s_dnpc=0&amp;s_dnpd=j&amp;s_dnsc=5&amp;s_dnsd=j">' . $texte . '</a>';
  6634. break;
  6635. case 'msg' :
  6636. $search = (isset($_REQUEST['search'])) ? $_REQUEST['search'] : '';
  6637. $texte = $this->data['comments'][$this->interne['comment_num']]['commentaire_message'];
  6638. $texte = outils::comment_format($texte);
  6639. if (isset($_REQUEST['s_msg'])) {
  6640. $texte = $this->highlight_search($texte, $search);
  6641. }
  6642. echo $texte;
  6643. break;
  6644. case 'image' :
  6645. $lien = '../' . $this->file . '?img=' . $this->data['comments'][$this->interne['comment_num']]['image_id'];
  6646. printf($o, $lien);
  6647. break;
  6648. case 'album' :
  6649. $s = ($o) ? $o : '<a href="../%s?alb=%s">%s</a>';
  6650. printf($s, $this->file, $this->data['comments'][$this->interne['comment_num']]['categorie_id'], strip_tags($this->data['comments'][$this->interne['comment_num']]['categorie_nom']));
  6651. break;
  6652. case 'id' :
  6653. echo $this->data['comments'][$this->interne['comment_num']]['commentaire_id'];
  6654. break;
  6655. case 'chemin' :
  6656. echo $this->data['comments'][$this->interne['comment_num']]['image_chemin'];
  6657. break;
  6658. case 'visible' :
  6659. if (empty($this->data['comments'][$this->interne['comment_num']]['commentaire_visible'])) {
  6660. echo '<a ' . $section . '&amp;active=' . $this->data['comments'][$this->interne['comment_num']]['commentaire_id'] . htmlentities($this->data['infos']['recherche']) . $this->getVID(2) . '">' . $o . '</a>';
  6661. } else {
  6662. echo '<a ' . $section . '&amp;desactive=' . $this->data['comments'][$this->interne['comment_num']]['commentaire_id'] . htmlentities($this->data['infos']['recherche']) . $this->getVID(2) . '">' . $o2 . '</a>';
  6663. }
  6664. break;
  6665. case 'ban_auteur' :
  6666. if (empty($this->data['comments'][$this->interne['comment_num']]['ban_auteur'])) {
  6667. echo '<a ' . $section . '&amp;ban_auteur=' . $this->data['comments'][$this->interne['comment_num']]['commentaire_id'] . htmlentities($this->data['infos']['recherche']) . $this->getVID(2) . '">' . $o2 . '</a>';
  6668. } else {
  6669. echo '<a ' . $section . '&amp;unban_auteur=' . $this->data['comments'][$this->interne['comment_num']]['commentaire_id'] . htmlentities($this->data['infos']['recherche']) . $this->getVID(2) . '">' . $o . '</a>';
  6670. }
  6671. break;
  6672. case 'ban_ip' :
  6673. if (empty($this->data['comments'][$this->interne['comment_num']]['ban_ip'])) {
  6674. echo '<a ' . $section . '&amp;ban_ip=' . $this->data['comments'][$this->interne['comment_num']]['commentaire_id'] . htmlentities($this->data['infos']['recherche']) . $this->getVID(2) . '">' . $o2 . '</a>';
  6675. } else {
  6676. echo '<a ' . $section . '&amp;unban_ip=' . $this->data['comments'][$this->interne['comment_num']]['commentaire_id'] . htmlentities($this->data['infos']['recherche']) . $this->getVID(2) . '">' . $o . '</a>';
  6677. }
  6678. break;
  6679. case 'supprime' :
  6680. $lien_sup = preg_replace('`^href="`', '', $section) . '&amp;supprime=' . $this->data['comments'][$this->interne['comment_num']]['commentaire_id'] . htmlentities($this->data['infos']['recherche']) . $this->getVID(2);
  6681. echo '<a href="javascript:confirm_sup_comment(\'' . $lien_sup . '\');" class="co_delete">' . $o . '</a>';
  6682. break;
  6683. case 'inactif' :
  6684. if (empty($this->data['comments'][$this->interne['comment_num']]['commentaire_visible'])) {
  6685. echo $o;
  6686. }
  6687. break;
  6688. case 'ih_search' :
  6689. $s = ($o2) ? $o2 : '%s';
  6690. if (isset($this->data['comments']['search'])) {
  6691. $inputs = '';
  6692. if ($o == 'inputs') {
  6693. foreach ($this->data['comments']['search'] as $k => $v) {
  6694. $inputs .= '<input type="hidden" name="' . $k . '" value="' . $v . '" />';
  6695. }
  6696. printf($s, $inputs);
  6697. }
  6698. if ($o == 'params') {
  6699. foreach ($this->data['comments']['search'] as $k => $v) {
  6700. $inputs .= '&amp;' . $k . '=' . $v;
  6701. }
  6702. printf($s, $inputs);
  6703. }
  6704. }
  6705. break;
  6706. case 'search_hl' :
  6707. if (isset($this->data['comments']['search']) && empty($this->data['comments']['no_comments'])) {
  6708. echo $o;
  6709. }
  6710. break;
  6711. case 'search_result' :
  6712. if (isset($this->data['comments']['search'])) {
  6713. if ($this->data['infos']['nb_objets']) {
  6714. printf($o, outils::html_specialchars($_REQUEST['search']));
  6715. } else {
  6716. printf($o2, outils::html_specialchars($_REQUEST['search']));
  6717. }
  6718. }
  6719. break;
  6720. case 'sortir' :
  6721. if (isset($this->data['comments']['search'])) {
  6722. printf($o, 'index.php?' . htmlentities($this->data['infos']['section']));
  6723. }
  6724. break;
  6725. case 'no_comments' :
  6726. if (isset($this->data['comments']['no_comments'])
  6727. && empty($this->data['comments']['search'])
  6728. && $this->data['infos']['obj'] == 1) {
  6729. $e = $this->data['infos']['comment_filtre'];
  6730. $e = ($e == 'tous') ? '' : ' ' . $e;
  6731. printf($o, $e);
  6732. }
  6733. break;
  6734. case 'sub' :
  6735. $objet = str_replace('image', 'img', $this->data['infos']['sub_objects']);
  6736. $objet = str_replace('categorie', 'cat', $objet);
  6737. echo $objet;
  6738. break;
  6739. case 'thumb' :
  6740. $s = ($o2) ? $o2 : '<a title="%s" href="%s"><img %s alt="%s" src="%s" /></a>';
  6741. $alt = htmlentities(strip_tags($this->data['comments'][$this->interne['comment_num']]['image_nom']));
  6742. $lien = '../' . $this->file . '?img=' . $this->data['comments'][$this->interne['comment_num']]['image_id'];
  6743. $img = $this->data['comments'][$this->interne['comment_num']]['image_chemin'];
  6744. $img = '../getimg.php?m=1&amp;img=' . $img;
  6745. $size = outils::thumb_size('img', $o, $this->data['comments'][$this->interne['comment_num']]['image_largeur'], $this->data['comments'][$this->interne['comment_num']]['image_hauteur']);
  6746. $taille = 'width="' . $size[0] . '" height="' . $size[1] . '"';
  6747. printf($s, $alt, $lien, $taille, $alt, $img);
  6748. break;
  6749. }
  6750. }
  6751. /* Affichage des commentaires : nombre par page */
  6752. function getCommentNb($s = '%s %s %s', $n = 10) {
  6753. for ($i = 1; $i <= $n; $i++) {
  6754. $selected = ($this->data['infos']['nb_comments'] == $i) ? ' selected="selected"' : '';
  6755. printf($s, $i, $selected, $i);
  6756. }
  6757. }
  6758. /* Ordre des commentaires */
  6759. function getCommentSortOrdre($type, $s = '%s', $o = ' selected="selected"') {
  6760. if ($this->data['infos']['comment_sort'] == $type) {
  6761. printf($s, $o);
  6762. }
  6763. }
  6764. function getCommentSortSens($type, $s = '%s', $o = ' selected="selected"') {
  6765. if ($this->data['infos']['comment_sens'] == $type) {
  6766. printf($s, $o);
  6767. }
  6768. }
  6769. /* Sous-éléments contenant des commentaires. */
  6770. function getCommentSubCats($s = '%s %s') {
  6771. $subcats = $this->data['comments']['sub_item'];
  6772. $objet = $this->data['infos']['sub_objects'];
  6773. for ($i = 0; $i < count($subcats); $i++) {
  6774. printf($s, $subcats[$i][$objet . '_id'], strip_tags($subcats[$i][$objet . '_nom']));
  6775. }
  6776. }
  6777. /* Liens de position. */
  6778. function getCommentPosition($s = '%s [%s] %s', $o1 = ' / ', $o2 = '|', $o3 = ' - page ') {
  6779. $pos = str_replace('%sep', $o1, $this->data['comments']['position']);
  6780. if ($this->data['infos']['nb_pages'] > 1) {
  6781. if (!isset($this->data['infos']['page_actuelle'])) {
  6782. header('Location:' . basename($_SERVER['PHP_SELF']) . '?' . preg_replace('`startnum=\d+`', 'startnum=0', $_SERVER['QUERY_STRING']));
  6783. }
  6784. $page = $o3 . $this->data['infos']['page_actuelle'] . $o2 . $this->data['infos']['nb_pages'];
  6785. } else {
  6786. $page = '';
  6787. }
  6788. printf($s, $pos, $this->data['infos']['nb_objets'], $page);
  6789. }
  6790. /* Filtre */
  6791. function getCommentFiltre($type, $s = '%s', $o = ' selected="selected"') {
  6792. if ($this->data['infos']['comment_filtre'] == $type) {
  6793. printf($s, $o);
  6794. }
  6795. }
  6796. /* Messages */
  6797. function getCommentMsgDisplay($type, $s = '%s', $o = ' selected="selected"') {
  6798. if ($this->data['config']['admin_comment_msg_display'] == $type) {
  6799. printf($s, $o);
  6800. }
  6801. }
  6802. /* Forumulaire de recherche */
  6803. function getCommentSearch($type, $defaut, $valeur = 0) {
  6804. if ($type == 's_dnpd' || $type == 's_dnsd') {
  6805. if ((isset($_GET['s']) && isset($_GET[$type]) && $_GET[$type] == $valeur)
  6806. || (!isset($_GET['s']) && $defaut)) {
  6807. echo ' selected="selected"';
  6808. }
  6809. } else {
  6810. if ((isset($_GET['s']) && isset($_GET[$type]))
  6811. || (!isset($_GET['s']) && $defaut)) {
  6812. echo ' checked="checked"';
  6813. }
  6814. }
  6815. }
  6816. function getCommentSearchNb($s, $n = 0, $m = 100, $type, $defaut = 0) {
  6817. for ($i = $n; $i <= $m; $i++) {
  6818. $selected = '';
  6819. if ((isset($_GET['s']) && isset($_GET[$type]) && $_GET[$type] == $i)
  6820. || (!isset($_GET['s']) && $defaut == $i)) {
  6821. $selected = ' selected="selected"';
  6822. }
  6823. printf($s, $i, $selected);
  6824. }
  6825. }
  6826. /*
  6827. *
  6828. * ======================================== COMMENTAIRES : OPTIONS;
  6829. *
  6830. */
  6831. /* Liste des auteurs et des IP bannis */
  6832. function getCommentBan($type, $s = '%s') {
  6833. $bans = $this->data['config']['admin_comment_ban'];
  6834. if (isset($bans[$type]) && count($bans[$type]) > 0) {
  6835. $b = '';
  6836. foreach ($bans[$type] as $k => $v) {
  6837. $b .= '<option value="' . htmlentities($k) . '">' . htmlentities($k) . '</option>';
  6838. }
  6839. printf($s, $b);
  6840. }
  6841. }
  6842. /* Modération des commentaires */
  6843. function getCommentMod($s) {
  6844. if ($this->data['config']['admin_comment_moderer']) {
  6845. echo $s;
  6846. }
  6847. }
  6848. /* Alerte par courriel */
  6849. function getCommentAlert($s) {
  6850. if ($this->data['config']['admin_comment_alert']) {
  6851. echo $s;
  6852. }
  6853. }
  6854. function getCommentAlertMail($s = '%s') {
  6855. if (!empty($this->data['config']['admin_comment_mail'])) {
  6856. printf($s, $this->data['config']['admin_comment_mail']);
  6857. }
  6858. }
  6859. function getCommentAlertObjet($s = '%s') {
  6860. if (!empty($this->data['config']['admin_comment_objet'])) {
  6861. printf($s, $this->data['config']['admin_comment_objet']);
  6862. }
  6863. }
  6864. function getCommentFac($type, $s) {
  6865. if ($this->data['config']['comment_' . $type]) {
  6866. echo $s;
  6867. }
  6868. }
  6869. /* Contrôles */
  6870. function getCommentAntiFlood($s = '%s') {
  6871. printf($s, $this->data['config']['comment_antiflood']);
  6872. }
  6873. function getCommentMaxMsg($s = '%s') {
  6874. printf($s, $this->data['config']['comment_maxmsg_nb']);
  6875. }
  6876. function getCommentMaxURL($s = '%s') {
  6877. printf($s, $this->data['config']['comment_maxurl']);
  6878. }
  6879. /* Page des commentaires */
  6880. function getPageComment() {
  6881. if ($this->data['config']['galerie_page_comments']) {
  6882. echo ' checked="checked"';
  6883. }
  6884. }
  6885. function getPageCommentNb($s = '%s %s %s', $n = 10) {
  6886. for ($i = 1; $i <= $n; $i++) {
  6887. $selected = ($this->data['config']['galerie_page_comments_nb'] == $i) ? ' selected="selected"' : '';
  6888. printf($s, $i, $selected, $i);
  6889. }
  6890. }
  6891. /*
  6892. *
  6893. * ======================================== OPTIONS : GENERAL;
  6894. *
  6895. */
  6896. /* Message de confirmation */
  6897. function getGeneralMaj($s = '%s') {
  6898. if (!empty($this->data['action_maj'])) {
  6899. printf($s, '<div class="rapport_msg rapport_succes"><div><span>Modifications enregistrées.</span></div></div>');
  6900. }
  6901. }
  6902. /* Themes */
  6903. function getGalerieThemes($s = '<option value="%1$s"%2$s>%1$s</option>', $o = ' selected="selected"') {
  6904. if (isset($this->data['themes'])) {
  6905. for ($i = 0; $i < count($this->data['themes']); $i++) {
  6906. $selected = ($this->data['themes'][$i] == $this->data['config']['galerie_template']) ? $o : '';
  6907. printf($s, $this->data['themes'][$i], $selected);
  6908. }
  6909. }
  6910. }
  6911. /* Styles */
  6912. function getGalerieStyles($s = '<option value="%1$s"%2$s>%1$s</option>', $o = ' selected="selected"') {
  6913. if (isset($this->data['styles'])) {
  6914. for ($i = 0; $i < count($this->data['styles']); $i++) {
  6915. $selected = ($this->data['styles'][$i] == $this->data['config']['galerie_style']) ? $o : '';
  6916. printf($s, $this->data['styles'][$i], $selected);
  6917. }
  6918. }
  6919. }
  6920. function getGalerieAddStyle() {
  6921. echo $this->data['config']['galerie_add_style'];
  6922. }
  6923. /* Liens */
  6924. function getActiveLiens($o = ' checked="checked"') {
  6925. if (!empty($this->data['config']['active_liens'])) {
  6926. echo $o;
  6927. }
  6928. }
  6929. function getLiens() {
  6930. if (!empty($this->data['config']['galerie_liens'])) {
  6931. $liens = @unserialize($this->data['config']['galerie_liens']);
  6932. if (is_array($liens)) {
  6933. for ($i = 0; $i < count($liens); $i++) {
  6934. echo $liens[$i] . "\r\n";
  6935. }
  6936. }
  6937. }
  6938. }
  6939. /* Formats de date */
  6940. function getGeneralFormatDate($type) {
  6941. $formats[1] = '%d-%m-%y';
  6942. $formats[2] = '%d/%m/%y';
  6943. $formats[3] = '%d-%m-%Y';
  6944. $formats[4] = '%d/%m/%Y';
  6945. $formats[5] = '%d %b %Y';
  6946. $formats[6] = '%d %B %Y';
  6947. $formats[7] = '%a %d %b %Y';
  6948. $formats[8] = '%a %d %B %Y';
  6949. $formats[9] = '%A %d %b %Y';
  6950. $formats[10] = '%A %d %B %Y';
  6951. $disabled = '';
  6952. if (($type == 'tb' && !$this->data['enabled']['date_format_thumbs'])
  6953. || ($type == 'im' && !$this->data['enabled']['date_format_images'])) {
  6954. $disabled = ' disabled="disabled"';
  6955. }
  6956. echo "\t\t\t\t\t\t\t\t\t\t" . '<select' . $disabled . ' name="g_f' . $type . 'date">';
  6957. for ($i = 1; $i <= count($formats); $i++) {
  6958. $selected = ($this->data['config']['galerie_' . $type . '_date_format'] == $formats[$i]) ? ' selected="selected"' : '';
  6959. echo "\n\t\t\t\t\t\t\t\t\t\t\t" . '<option' . $selected . ' value="' . $i . '">' . strftime($formats[$i]) . '</option>';
  6960. }
  6961. echo "\n\t\t\t\t\t\t\t\t\t\t" . '</select>';
  6962. }
  6963. /* Visites admin */
  6964. function getNoHits($s = ' checked="checked"') {
  6965. if ($this->data['config']['admin_no_hits']) {
  6966. echo $s;
  6967. }
  6968. }
  6969. function getNoHitsMode($type, $s = ' checked="checked"') {
  6970. if ($this->data['config']['admin_no_hits_mode'] == $type) {
  6971. echo $s;
  6972. }
  6973. }
  6974. function getNoHitsIP() {
  6975. echo $this->data['config']['admin_no_hits_ip'];
  6976. }
  6977. /* URL de la galerie */
  6978. function getGalerieHOST() {
  6979. echo 'http://' . $_SERVER['HTTP_HOST'];
  6980. }
  6981. function getGalerieURL() {
  6982. echo $this->data['config']['galerie_url'];
  6983. }
  6984. /* Type d'URL */
  6985. function getURLType() {
  6986. $types['normal'] = 'normal';
  6987. $types['query_string'] = 'QUERY_STRING';
  6988. $types['path_info'] = 'PATH_INFO';
  6989. $types['url_rewrite'] = 'URL rewrite';
  6990. foreach ($types as $value => $nom) {
  6991. $selected = ($this->data['config']['galerie_url_type'] == $value) ? ' selected="selected"' : '';
  6992. echo "\n\t\t\t\t\t\t\t\t\t\t\t" . '<option' . $selected . ' value="' . $value . '">' . $nom . '</option>';
  6993. }
  6994. }
  6995. function getIntegrated($s = ' checked="checked"') {
  6996. if (!empty($this->data['config']['galerie_integrated'])) {
  6997. echo $s;
  6998. }
  6999. }
  7000. /* Javascript des thčmes et styles */
  7001. function getGalerieJSStyles() {
  7002. echo '<script type="text/javascript">' . "\n";
  7003. echo '//<![CDATA[' . "\n";
  7004. echo 'var themes_styles = new Array();' . "\n";
  7005. foreach ($this->data['js_themes_styles'] as $theme => $styles) {
  7006. echo 'themes_styles["' . $theme . '"] = new Array();' . "\n";
  7007. for ($i = 0; $i < count($styles); $i++) {
  7008. echo 'themes_styles["' . $theme . '"][' . $i . '] = "' . $styles[$i] . '";' . "\n";
  7009. }
  7010. }
  7011. echo '//]]>' . "\n";
  7012. echo '</script>';
  7013. }
  7014. /* Nombre de vignettes par page */
  7015. function getNbThumbs($type, $n = 12, $s = '<option value="%1$s"%2$s>%1$s</option>', $o = ' selected="selected"') {
  7016. for ($i = 1; $i <= $n; $i++) {
  7017. $selected = ($this->data['config']['vignettes_' . $type] == $i) ? $o : '';
  7018. printf($s, $i, $selected);
  7019. }
  7020. }
  7021. /* Méthode d'affichage des images */
  7022. function getImgDisplay($type, $s = ' checked="checked"') {
  7023. if ($this->data['config']['galerie_images_window'] == $type) {
  7024. echo $s;
  7025. }
  7026. }
  7027. /* Redimensionnement des images */
  7028. function getImgResize($type, $valeur, $s = ' checked="checked"') {
  7029. switch ($type) {
  7030. case 'mode' :
  7031. if ($this->data['config']['galerie_images_resize'] == $valeur) {
  7032. echo $s;
  7033. }
  7034. break;
  7035. case 'html' :
  7036. $html = preg_split('`x`i', $this->data['config']['galerie_images_resize_max_html'], -1, PREG_SPLIT_NO_EMPTY);
  7037. echo ($valeur == 'l') ? $html[0] : $html[1];
  7038. break;
  7039. case 'gd' :
  7040. $gd = preg_split('`x`i', $this->data['config']['img_resize_gd'], -1, PREG_SPLIT_NO_EMPTY);
  7041. echo ($valeur == 'l') ? $gd[0] : $gd[1];
  7042. break;
  7043. }
  7044. }
  7045. /* Format de la date */
  7046. function getDateFormat() {
  7047. echo $this->data['config']['galerie_date_format'];
  7048. }
  7049. /* Images récentes */
  7050. function getImgRecentes($type, $o = ' checked="checked"') {
  7051. if ($type == 'etat') {
  7052. if ($this->data['config']['display_recentes'] > 0) {
  7053. echo $o;
  7054. }
  7055. } elseif ($type == 'nb') {
  7056. if ($this->data['config']['galerie_recent_nb']) {
  7057. echo $o;
  7058. }
  7059. } else {
  7060. echo $this->data['config']['galerie_recent'];
  7061. }
  7062. }
  7063. /* Métadonnés Exif & IPTC */
  7064. function getmetadata($type, $o = ' checked="checked"') {
  7065. if ($this->data['config']['active_' . $type]) {
  7066. echo $o;
  7067. }
  7068. }
  7069. /* Texte sur les images */
  7070. function getitextcheckbox($type, $o = ' checked="checked"') {
  7071. if (($type == 'active' && $this->data['config']['itext']) || !empty($this->data['config']['itext_params'][$type])) {
  7072. echo $o;
  7073. }
  7074. }
  7075. function getitexttext($type) {
  7076. echo ' value="' . str_replace('^', ' ', htmlspecialchars(str_replace("\'", "'", $this->data['config']['itext_params'][$type]))) . '"';
  7077. }
  7078. function getitextselect($type, $v, $o = ' selected="selected"') {
  7079. if ($this->data['config']['itext_params'][$type] == $v) {
  7080. echo $o;
  7081. }
  7082. }
  7083. function getitextfontes() {
  7084. if (isset($this->data['fontes'])) {
  7085. for ($i = 0; $i < count($this->data['fontes']); $i++) {
  7086. $selected = ($this->data['config']['itext_params'][4] == $this->data['fontes'][$i]) ? ' selected="selected"' : '';
  7087. echo '<option value="' . $this->data['fontes'][$i] . '"' . $selected . '>' . $this->data['fontes'][$i] . '</option>';
  7088. }
  7089. }
  7090. }
  7091. function getitextcolor($r, $g, $b) {
  7092. $rgb[0] = $this->data['config']['itext_params'][$r];
  7093. $rgb[1] = $this->data['config']['itext_params'][$g];
  7094. $rgb[2] = $this->data['config']['itext_params'][$b];
  7095. echo ' value="#' . outils::convert_rgb2html($rgb) . '"';
  7096. }
  7097. /* Ordre et sens d'affichage des vignettes */
  7098. function getThumbSort($type, $s = '%s', $o = ' selected="selected"') {
  7099. if ($this->data['config']['vignettes_ordre'] != $type) {
  7100. $o = '';
  7101. }
  7102. printf($s, $o);
  7103. }
  7104. function getThumbSens($type, $s = '%s', $o = ' selected="selected"') {
  7105. if ($this->data['config']['vignettes_sens'] == $type) {
  7106. printf($s, $o);
  7107. }
  7108. }
  7109. function getCatThumbSort($type, $s = '%s', $o = ' selected="selected"') {
  7110. if (!preg_match('`^categorie_' . $type . '`', $this->data['config']['vignettes_cat_ordre'])) {
  7111. $o = '';
  7112. }
  7113. printf($s, $o);
  7114. }
  7115. function getCatThumbSens($type, $s = '%s', $o = ' selected="selected"') {
  7116. if (preg_match('`^categorie_[a-z]+\s' . $type . ',`', $this->data['config']['vignettes_cat_ordre'])) {
  7117. printf($s, $o);
  7118. }
  7119. }
  7120. function getTbCatType() {
  7121. $type_alb = '';
  7122. $type_cat = '';
  7123. $type_sans = '';
  7124. if ($this->data['config']['vignettes_cat_type'] == 'type ASC,') {
  7125. $type_cat = ' selected="selected"';
  7126. } elseif ($this->data['config']['vignettes_cat_type'] == 'type DESC,') {
  7127. $type_alb = ' selected="selected"';
  7128. } else {
  7129. $type_sans = ' selected="selected"';
  7130. }
  7131. echo '<option' . $type_alb . ' value="alb">des albums avant celles des catégories</option>';
  7132. echo '<option' . $type_cat . ' value="cat">des catégories avant celles des albums</option>';
  7133. echo '<option' . $type_sans . ' value="sans">sans distinction entre albums et catégories</option>';
  7134. }
  7135. /* Informations sous les vignettes */
  7136. function getThumbInfo($info, $o = ' checked="checked"') {
  7137. if (!empty($this->data['config']['display_' . $info])) {
  7138. echo $o;
  7139. }
  7140. }
  7141. /* Dimensions des vignettes */
  7142. function getTbSizeMode($type, $mode) {
  7143. if ($this->data['config']['galerie_tb_' . $type . '_mode'] == $mode) {
  7144. echo ' checked="checked"';
  7145. }
  7146. }
  7147. /* Mode d'affichage des vignettes des catégories */
  7148. function getTbCatMode() {
  7149. $selected_etendue = '';
  7150. $selected_compact = '';
  7151. if ($this->data['config']['vignettes_cat_mode'] == 'compact') {
  7152. $selected_compact = ' selected="selected"';
  7153. } else {
  7154. $selected_etendue = ' selected="selected"';
  7155. }
  7156. echo '<option' . $selected_compact . ' value="compact">compacte</option>';
  7157. echo '<option' . $selected_etendue . ' value="etendue">étendue</option>';
  7158. }
  7159. /*
  7160. *
  7161. * ======================================== OPTIONS : TEXTES;
  7162. *
  7163. */
  7164. function getActiveContact() {
  7165. if ($this->data['config']['galerie_contact']) {
  7166. echo ' checked="checked"';
  7167. }
  7168. }
  7169. function getTextes($type) {
  7170. echo outils::html_specialchars($this->data['config']['galerie_' . $type]);
  7171. }
  7172. function getFooter($type, $o = ' checked="checked"') {
  7173. if ($type == 'message' && strstr($this->data['config']['galerie_footer'], '1')) {
  7174. echo $o;
  7175. }
  7176. if ($type == 'counter' && strstr($this->data['config']['galerie_footer'], '2')) {
  7177. echo $o;
  7178. }
  7179. }
  7180. /*
  7181. *
  7182. * ======================================== OPTIONS : FONCTIONS;
  7183. *
  7184. */
  7185. function getFonction($fonction, $o = ' checked="checked"') {
  7186. if (!empty($this->data['config'][$fonction])) {
  7187. echo $o;
  7188. }
  7189. }
  7190. function getFonctionOption($o) {
  7191. if (isset($this->data['config'][$o])) {
  7192. echo $this->data['config'][$o];
  7193. }
  7194. }
  7195. /*
  7196. *
  7197. * ======================================== OPTIONS : PERSONNALISATION;
  7198. *
  7199. */
  7200. function getPerso($info, $o = ' checked="checked"') {
  7201. if (!empty($this->data['config']['user_' . $info])) {
  7202. echo $o;
  7203. }
  7204. }
  7205. /*
  7206. *
  7207. * ======================================== OPTIONS : EXIF;
  7208. *
  7209. */
  7210. function getNextIptc() {
  7211. if (!empty($this->data['config']['infos_iptc'])) {
  7212. if (!isset($this->interne['iptc_num'])) {
  7213. $this->interne['iptc_num'] = 0;
  7214. $n = 0;
  7215. foreach ($this->data['config']['infos_iptc'] as $k => $v) {
  7216. $this->interne['infos_iptc'][$n] = $v;
  7217. $this->interne['infos_iptc'][$n]['champ'] = $k;
  7218. $n++;
  7219. }
  7220. } else {
  7221. $this->interne['iptc_num']++;
  7222. }
  7223. if (isset($this->interne['infos_iptc'][$this->interne['iptc_num']])) {
  7224. return TRUE;
  7225. }
  7226. }
  7227. }
  7228. function getIptc($type) {
  7229. switch ($type) {
  7230. case 'desc' :
  7231. echo htmlspecialchars($this->interne['infos_iptc'][$this->interne['iptc_num']]['nom']);
  7232. break;
  7233. case 'id' :
  7234. echo substr($this->interne['infos_iptc'][$this->interne['iptc_num']]['champ'], 2);
  7235. break;
  7236. case 'etat';
  7237. if ($this->interne['infos_iptc'][$this->interne['iptc_num']]['active']) {
  7238. echo ' checked="checked"';
  7239. }
  7240. break;
  7241. case 'inactive';
  7242. if (!$this->interne['infos_iptc'][$this->interne['iptc_num']]['active']) {
  7243. echo ' iptc_inactive';
  7244. }
  7245. break;
  7246. }
  7247. }
  7248. /*
  7249. *
  7250. * ======================================== OPTIONS : EXIF;
  7251. *
  7252. */
  7253. function getNextExif() {
  7254. if (!empty($this->data['config']['infos_exif'])) {
  7255. if (!isset($this->interne['exif_num'])) {
  7256. $this->interne['exif_num'] = 0;
  7257. } else {
  7258. $this->interne['exif_num']++;
  7259. }
  7260. if (isset($this->data['config']['infos_exif'][$this->interne['exif_num']])) {
  7261. return TRUE;
  7262. }
  7263. }
  7264. }
  7265. function getNextExifEnum() {
  7266. if (isset($this->data['config']['infos_exif'][$this->interne['exif_num']]['format'])
  7267. && is_array($this->data['config']['infos_exif'][$this->interne['exif_num']]['format'])) {
  7268. if (!isset($this->interne['exif_liste'])) {
  7269. $this->interne['exif_liste'] = 0;
  7270. } else {
  7271. $this->interne['exif_liste']++;
  7272. }
  7273. if (current($this->data['config']['infos_exif'][$this->interne['exif_num']]['format'])) {
  7274. return TRUE;
  7275. } else {
  7276. $this->interne['exif_liste'] = 0;
  7277. }
  7278. }
  7279. }
  7280. function getExif($type, $o = '') {
  7281. $disabled = '';
  7282. if (!$this->data['enabled']['exif']) {
  7283. $disabled = ' disabled="disabled"';
  7284. }
  7285. switch ($type) {
  7286. case 'etat' :
  7287. if ($this->data['config']['infos_exif'][$this->interne['exif_num']]['active']) {
  7288. echo ' checked="checked"';
  7289. }
  7290. break;
  7291. case 'desc' :
  7292. echo htmlspecialchars($this->data['config']['infos_exif'][$this->interne['exif_num']]['desc']);
  7293. break;
  7294. case 'id' :
  7295. echo $this->interne['exif_num'];
  7296. break;
  7297. case 'sections' :
  7298. $selected = ' selected="selected"';
  7299. $section = array(0=>'',1=>'',2=>'',3=>'',4=>'',5=>'');
  7300. switch ($this->data['config']['infos_exif'][$this->interne['exif_num']]['section']) {
  7301. case 'COMPUTED' : $section[0] = $selected; break;
  7302. case 'IFD0' : $section[1] = $selected; break;
  7303. case 'THUMBNAIL' : $section[2] = $selected; break;
  7304. case 'EXIF' : $section[3] = $selected; break;
  7305. case 'INTEROP' : $section[4] = $selected; break;
  7306. case 'MAKERNOTE' : $section[5] = $selected; break;
  7307. }
  7308. echo '<select' . $disabled . ' name="exif_param_section[' . $this->interne['exif_num'] . ']">
  7309. <option' . $section[0] . ' value="COMPUTED">COMPUTED</option>
  7310. <option' . $section[1] . ' value="IFD0">IFD0</option>
  7311. <option' . $section[2] . ' value="THUMBNAIL">THUMBNAIL</option>
  7312. <option' . $section[3] . ' value="EXIF">EXIF</option>
  7313. <option' . $section[4] . ' value="INTEROP">INTEROP</option>
  7314. <option' . $section[5] . ' value="MAKERNOTE">MAKERNOTE</option>
  7315. </select>';
  7316. break;
  7317. case 'method' :
  7318. $selected = ' selected="selected"';
  7319. $method = array(0=>'',1=>'',2=>'',3=>'',4=>'');
  7320. switch ($this->data['config']['infos_exif'][$this->interne['exif_num']]['method']) {
  7321. case 'simple' : $method[0] = $selected; break;
  7322. case 'date' : $method[1] = $selected; break;
  7323. case 'nombre' : $method[2] = $selected; break;
  7324. case 'liste' : $method[3] = $selected; break;
  7325. case 'version' : $method[4] = $selected; break;
  7326. }
  7327. echo '<select' . $disabled . ' name="exif_param_methode[' . $this->interne['exif_num'] . ']" onchange="exif_change_method(this,' . $this->interne['exif_num'] . ');">
  7328. <option' . $method[0] . ' value="simple">simple</option>
  7329. <option' . $method[1] . ' value="date">date</option>
  7330. <option' . $method[2] . ' value="nombre">nombre</option>
  7331. <option' . $method[3] . ' value="liste">liste</option>
  7332. <option' . $method[4] . ' value="version">version</option>
  7333. </select>';
  7334. break;
  7335. case 'tag' :
  7336. echo htmlspecialchars($this->data['config']['infos_exif'][$this->interne['exif_num']]['tag']);
  7337. break;
  7338. case 'format' :
  7339. if (isset($this->data['config']['infos_exif'][$this->interne['exif_num']]['format'])
  7340. && !is_array($this->data['config']['infos_exif'][$this->interne['exif_num']]['format'])) {
  7341. echo htmlspecialchars($this->data['config']['infos_exif'][$this->interne['exif_num']]['format']);
  7342. }
  7343. break;
  7344. case 'valeur' :
  7345. $method = $this->data['config']['infos_exif'][$this->interne['exif_num']]['method'];
  7346. if (
  7347. ($o == '' && $method == 'version')
  7348. || ($o == 'format' && $method == 'liste')
  7349. || ($o == 'liste' && ($method == 'date' || $method == 'simple' || $method == 'nombre'))
  7350. ) {
  7351. echo ' style="display:none"';
  7352. }
  7353. break;
  7354. case 'list_num' :
  7355. echo $this->interne['exif_liste'];
  7356. break;
  7357. case 'list_tag' :
  7358. echo htmlspecialchars(key($this->data['config']['infos_exif'][$this->interne['exif_num']]['format']));
  7359. break;
  7360. case 'list_display' :
  7361. echo htmlspecialchars(current($this->data['config']['infos_exif'][$this->interne['exif_num']]['format']));
  7362. next($this->data['config']['infos_exif'][$this->interne['exif_num']]['format']);
  7363. break;
  7364. case 'delete' :
  7365. $section = $this->data['config']['infos_exif'][$this->interne['exif_num']]['section'];
  7366. $tag = $this->data['config']['infos_exif'][$this->interne['exif_num']]['tag'];
  7367. printf($o, $section, $tag, $this->getVID(2));
  7368. break;
  7369. case 'inactive' :
  7370. if (!$this->data['config']['infos_exif'][$this->interne['exif_num']]['active']) {
  7371. if (isset($this->data['config']['infos_exif'][$this->interne['exif_num']]['new'])) {
  7372. echo ' exif_inactive exif_new';
  7373. } else {
  7374. echo ' exif_inactive';
  7375. }
  7376. }
  7377. break;
  7378. case 'focus_new' :
  7379. if (isset($this->data['config']['infos_exif'][$this->interne['exif_num']]['new'])) {
  7380. echo 'document.getElementById("exif_param_tag_' . $this->interne['exif_num'] . '").value="NouveauTag"; document.getElementById("exif_param_description_' . $this->interne['exif_num'] . '").focus(); //';
  7381. }
  7382. break;
  7383. case 'display' :
  7384. if (!isset($this->data['config']['infos_exif'][$this->interne['exif_num']]['new'])) {
  7385. echo 'style="display:none" ';
  7386. }
  7387. break;
  7388. }
  7389. }
  7390. /*
  7391. *
  7392. * ======================================== UTILISATEURS : GENERAL;
  7393. *
  7394. */
  7395. function getUsersGeneral($info, $o = ' checked="checked"') {
  7396. if (!empty($this->data['config']['users_' . $info])) {
  7397. echo $o;
  7398. }
  7399. }
  7400. function getUploadMaxSize($s = '%s %s') {
  7401. printf($s, $this->data['config']['users_upload_maxsize'], $this->data['config']['upload_max_filesize']);
  7402. }
  7403. function getUsersGeneralValues($o, $s = '%s') {
  7404. switch ($o) {
  7405. case 'maxwidth' :
  7406. case 'maxheight' :
  7407. printf($s, $this->data['config']['users_upload_' . $o]);
  7408. break;
  7409. }
  7410. }
  7411. /*
  7412. *
  7413. * ======================================== GALERIE;
  7414. *
  7415. */
  7416. function getNextObjet() {
  7417. if (!empty($this->data['objets'])) {
  7418. if (!isset($this->interne['objet_num'])) {
  7419. $this->interne['objet_num'] = 0;
  7420. } else {
  7421. $this->interne['objet_num']++;
  7422. }
  7423. $obj = ($this->data['infos']['objet_type'] == 'alb') ? 'image' : 'categorie' ;
  7424. if (isset($this->data['objets'][$this->interne['objet_num']][$obj . '_id'])) {
  7425. return TRUE;
  7426. }
  7427. }
  7428. }
  7429. function getObjetInfo($type, $s = '%s', $o = '') {
  7430. $obj = ($this->data['infos']['objet_type'] == 'alb') ? 'image' : 'categorie';
  7431. $section = ' href="index.php?section=galerie&amp;page=gestion&amp;cat=' . $this->data['infos']['cat'] . '&amp;startnum=' . $this->data['infos']['startnum'];
  7432. switch ($type) {
  7433. case 'id' :
  7434. echo $this->data['objets'][$this->interne['objet_num']][$obj . '_id'];
  7435. break;
  7436. case 'tb_cat' :
  7437. if ($obj == 'categorie') {
  7438. $id = $this->data['objets'][$this->interne['objet_num']]['image_representant_id'];
  7439. $lien = 'index.php?section=galerie&amp;page=gestion&amp;cat=' . $this->data['objets'][$this->interne['objet_num']]['categorie_id'];
  7440. $nom = strip_tags($this->data['objets'][$this->interne['objet_num']]['categorie_nom']);
  7441. $objet = ($this->data['objets'][$this->interne['objet_num']]['categorie_derniere_modif']) ? 'l\'album' : 'la catégorie' ;
  7442. if ($id) {
  7443. $size = outils::thumb_size('cat', $o, $this->data['representants'][$id]['image_largeur'], $this->data['representants'][$id]['image_hauteur']);
  7444. $img = '../getimg.php?m=1&amp;cat=' . $this->data['representants'][$id]['image_chemin'];
  7445. } else {
  7446. $size[0] = $o;
  7447. $size[1] = $o;
  7448. $type = ($this->data['objets'][$this->interne['objet_num']]['categorie_derniere_modif']) ? 'alb' : 'cat';
  7449. $img = './template/defaut/style/' . $type . '_vide.png';
  7450. }
  7451. $taille = 'width="' . $size[0] . '" height="' . $size[1] . '"';
  7452. printf($s, $lien, $taille, $nom, $objet, $img);
  7453. }
  7454. break;
  7455. case 'tb_img' :
  7456. if ($obj == 'image') {
  7457. $lien = $this->data['objets'][$this->interne['objet_num']]['image_chemin'];
  7458. $lien = (IMG_TEXTE) ? '../getitext.php?i=' . $lien : '../' . GALERIE_ALBUMS . '/' . $lien;
  7459. $size = outils::thumb_size('img', $o, $this->data['objets'][$this->interne['objet_num']]['image_largeur'], $this->data['objets'][$this->interne['objet_num']]['image_hauteur']);
  7460. $taille = 'width="' . $size[0] . '" height="' . $size[1] . '"';
  7461. $nom = strip_tags($this->data['objets'][$this->interne['objet_num']]['image_nom']);
  7462. $img = '../getimg.php?m=1&amp;img=' . $this->data['objets'][$this->interne['objet_num']]['image_chemin'];
  7463. printf($s, $lien, $taille, $nom, $img);
  7464. }
  7465. break;
  7466. case 'tb_onclick' :
  7467. if ($obj == 'categorie') {
  7468. $this->getObjetInfo('tb_cat', '%1$s');
  7469. } else {
  7470. $this->getObjetInfo('tb_img', '%1$s');
  7471. }
  7472. break;
  7473. case 'nom' :
  7474. echo outils::html_specialchars($this->data['objets'][$this->interne['objet_num']][$obj . '_nom']);
  7475. break;
  7476. case 'file_name' :
  7477. if ($this->data['infos']['objet_type'] == 'alb') {
  7478. printf($s, $this->data['objets'][$this->interne['objet_num']][$obj . '_id'], outils::html_specialchars(basename($this->data['objets'][$this->interne['objet_num']]['image_chemin'])));
  7479. }
  7480. break;
  7481. case 'f_type' :
  7482. echo ($this->data['infos']['objet_type'] == 'alb') ? 'img' : 'cat';
  7483. break;
  7484. case 'type' :
  7485. if ($this->data['infos']['objet_type'] == 'alb') {
  7486. echo 'image';
  7487. } else {
  7488. echo ($this->data['objets'][$this->interne['objet_num']][$obj . '_derniere_modif']) ? 'album' : 'catégorie';
  7489. }
  7490. break;
  7491. case 'description' :
  7492. echo outils::html_specialchars($this->data['objets'][$this->interne['objet_num']][$obj . '_description']);
  7493. break;
  7494. case 'thumb' :
  7495. if ($this->data['infos']['objet_type'] == 'cat' && ($this->data['objets'][$this->interne['objet_num']][$obj . '_images'] || $this->data['objets'][$this->interne['objet_num']][$obj . '_images_inactive'])) {
  7496. $cat = (!empty($_REQUEST['cat'])) ? $_REQUEST['cat'] : 1;
  7497. $lien = '<a href="index.php?section=representant&amp;cat=' . $cat . '&amp;str=' . $this->data['infos']['startnum'] . '&amp;obj=' . $this->data['objets'][$this->interne['objet_num']][$obj . '_id'] . '&amp;sub_obj=' . $this->data['objets'][$this->interne['objet_num']][$obj . '_id'] . '">représentant</a>';
  7498. printf($s, $lien);
  7499. }
  7500. break;
  7501. case 'infos' :
  7502. $votes = $this->data['objets'][$this->interne['objet_num']][$obj . '_votes'];
  7503. $votes = ($this->data['infos']['objet_type'] == 'alb') ? $votes : ($votes + $this->data['objets'][$this->interne['objet_num']][$obj . '_votes_inactive']);
  7504. $comments = $this->data['objets'][$this->interne['objet_num']][$obj . '_commentaires'];
  7505. $comments = ($this->data['infos']['objet_type'] == 'alb') ? $comments : ($comments + $this->data['objets'][$this->interne['objet_num']][$obj . '_commentaires_inactive']);
  7506. $type = ($this->data['infos']['objet_type'] == 'alb') ? 'img' : 'cat';
  7507. if ($comments) {
  7508. $comments = ' <a title="Afficher les commentaires" href="index.php?section=commentaires&amp;page=display&amp;' . $type . '=' . $this->data['objets'][$this->interne['objet_num']][$obj . '_id'] . '">' . $comments . '</a>';
  7509. }
  7510. if ($votes) {
  7511. $votes = ' <a title="Afficher les votes" href="index.php?section=votes&amp;' . $type . '=' . $this->data['objets'][$this->interne['objet_num']][$obj . '_id'] . '">' . $votes . '</a>';
  7512. }
  7513. echo '<table class="gal_objet_iv">';
  7514. if ($this->data['infos']['objet_type'] == 'alb') {
  7515. echo '<tr><td class="goivf">Poids</td><td>' . outils::poids($this->data['objets'][$this->interne['objet_num']][$obj . '_poids']) . '</td></tr>';
  7516. echo '<tr><td class="goivf">Dimensions</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_largeur'] . ' X ' . $this->data['objets'][$this->interne['objet_num']][$obj . '_hauteur'] . ' pixels' . '</td></tr>';
  7517. echo '<tr><td class="goivf">Visites</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_hits'] . '</td></tr>';
  7518. echo '<tr><td class="goivf">Commentaires</td><td>' . $comments . '</td></tr>';
  7519. echo '<tr><td class="goivf">Votes</td><td>' . $votes . '</td></tr>';
  7520. if ($votes) {
  7521. echo '<tr><td class="goivf">Note moyenne</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_note'] . '</td></tr>';
  7522. }
  7523. } else {
  7524. echo '<tr><th></th><th class="th">activés</th><th class="th">désactivés</th><th class="th">total</th></tr>';
  7525. echo '<tr><td class="goivf">Poids</td><td>' . outils::poids($this->data['objets'][$this->interne['objet_num']][$obj . '_poids']) . '</td><td>' . outils::poids($this->data['objets'][$this->interne['objet_num']][$obj . '_poids_inactive']) . '</td><td>' . outils::poids($this->data['objets'][$this->interne['objet_num']][$obj . '_poids'] + $this->data['objets'][$this->interne['objet_num']][$obj . '_poids_inactive']) . '</td></tr>';
  7526. echo '<tr><td class="goivf">Images</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_images'] . '</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_images_inactive'] . '</td><td>' . ($this->data['objets'][$this->interne['objet_num']][$obj . '_images'] + $this->data['objets'][$this->interne['objet_num']][$obj . '_images_inactive']) . '</td></tr>';
  7527. echo '<tr><td class="goivf">Visites</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_hits'] . '</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_hits_inactive'] . '</td><td>' . ($this->data['objets'][$this->interne['objet_num']][$obj . '_hits'] + $this->data['objets'][$this->interne['objet_num']][$obj . '_hits_inactive']) . '</td></tr>';
  7528. echo '<tr><td class="goivf">Commentaires</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_commentaires'] . '</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_commentaires_inactive'] . '</td><td>' . $comments . '</td></tr>';
  7529. echo '<tr><td class="goivf">Votes</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_votes'] . '</td><td>' . $this->data['objets'][$this->interne['objet_num']][$obj . '_votes_inactive'] . '</td><td>' . $votes . '</td></tr>';
  7530. }
  7531. echo '</table>';
  7532. if ($this->data['objets'][$this->interne['objet_num']]['user_id'] > 1) {
  7533. $nom = '<a href="?section=utilisateurs&amp;page=modif_user&amp;user='
  7534. . $this->data['objets'][$this->interne['objet_num']]['user_id'] . '">'
  7535. . str_replace('_', ' ', $this->data['objets'][$this->interne['objet_num']]['user_login']) . '</a>';
  7536. } else {
  7537. $nom = str_replace('_', ' ', $this->data['objets'][$this->interne['objet_num']]['user_login']);
  7538. }
  7539. if ($this->data['infos']['objet_type'] == 'alb') {
  7540. echo '<span class="gal_date_c">Ajoutée le ' . outils::ladate($this->data['objets'][$this->interne['objet_num']][$obj . '_date']) . ' par ' . $nom . '</span>';
  7541. } else {
  7542. $e = ($this->data['objets'][$this->interne['objet_num']][$obj . '_derniere_modif']) ? '': 'e';
  7543. echo '<span class="gal_date_c">Créé' . $e . ' le ' . outils::ladate($this->data['objets'][$this->interne['objet_num']][$obj . '_date']) . ' par ' . $nom . '</span>';
  7544. }
  7545. echo '<div class="zero_hits"><input id="reinit_hits_' . $this->data['objets'][$this->interne['objet_num']][$obj . '_id'] . '" name="reinit_hits[' . $this->data['objets'][$this->interne['objet_num']][$obj . '_id'] . ']" type="checkbox" /><label for="reinit_hits_' . $this->data['objets'][$this->interne['objet_num']][$obj . '_id'] . '"> Remettre ŕ zéro le compteur de visites.</label></div>';
  7546. break;
  7547. case 'image_tags' :
  7548. if (isset($this->data['objets'][$this->interne['objet_num']][$obj. '_tags'])) {
  7549. $tags = $this->data['objets'][$this->interne['objet_num']][$obj . '_tags'];
  7550. $tags = preg_replace('`^,(.+),$`', '$1', $tags);
  7551. printf($s, $tags);
  7552. }
  7553. break;
  7554. case 'etat' :
  7555. if ($obj == 'categorie' && ($this->data['objets'][$this->interne['objet_num']][$obj . '_images'] + $this->data['objets'][$this->interne['objet_num']][$obj . '_images_inactive']) == 0) {
  7556. break;
  7557. }
  7558. if ($this->data['objets'][$this->interne['objet_num']][$obj . '_visible']) {
  7559. $etat = 'desactive';
  7560. $mot = 'désactiver';
  7561. } else {
  7562. $etat = 'active';
  7563. $mot = 'activer';
  7564. }
  7565. if ($obj == 'categorie' && $this->data['objets'][$this->interne['objet_num']]['categorie_derniere_modif']) {
  7566. $type = 'album';
  7567. } else {
  7568. $type = $obj;
  7569. }
  7570. $lien = '<a ' . $section . '&amp;type=' . $type . '&amp;' . $etat . '=' . $this->data['objets'][$this->interne['objet_num']][$obj . '_id'] . $this->getVID(2) . '">' . $mot . '</a>';
  7571. printf($s, $lien);
  7572. break;
  7573. case 'delete' :
  7574. if ($obj == 'categorie' && $this->data['objets'][$this->interne['objet_num']]['categorie_derniere_modif']) {
  7575. $type = 'album';
  7576. } else {
  7577. $type = $obj;
  7578. }
  7579. $lien_sup = preg_replace('`^ href="`', '', $section) . '&amp;type=' . $type . '&amp;supprime=' . $this->data['objets'][$this->interne['objet_num']][$obj . '_id'] . $this->getVID(2);
  7580. $lien = '<a href="javascript:confirm_sup_obj(\'' . $lien_sup . '\',\'' . $type . '\');">supprimer</a>';
  7581. printf($s, $lien);
  7582. break;
  7583. case 'deplace_img' :
  7584. if ($this->data['infos']['objet_type'] == 'alb') {
  7585. if (strlen($this->data['nav']['deplace_img']) > 29) {
  7586. printf($s, $this->data['nav']['deplace_img']);
  7587. }
  7588. }
  7589. break;
  7590. case 'deplace_cat_lien' :
  7591. if ($this->data['infos']['objet_type'] == 'cat') {
  7592. printf($s, $this->data['objets'][$this->interne['objet_num']]['categorie_id']);
  7593. }
  7594. break;
  7595. case 'deplace_cat' :
  7596. if ($this->data['infos']['objet_type'] == 'cat') {
  7597. $list = '<select name="vers[' . $this->data['objets'][$this->interne['objet_num']]['categorie_id'] . ']">';
  7598. if ($this->data['infos']['objet_type'] == 'cat' && $this->data['infos']['cat'] > 1) {
  7599. $list .= '<option class="gal_hier_cat" value="1">galerie</option>';
  7600. }
  7601. for ($i = 0; $i < count($this->data['nav']['deplace_cat']); $i++) {
  7602. $path_obj = $this->data['objets'][$this->interne['objet_num']][$obj . '_chemin'];
  7603. $path_cat = $this->data['nav']['deplace_cat'][$i]['chemin'];
  7604. $space = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $this->data['nav']['deplace_cat'][$i]['space']);
  7605. if (!preg_match('`' . $path_obj . '.*`', $path_cat)
  7606. && $path_cat != dirname($path_obj) . '/') {
  7607. $list .= '<option class="gal_hier_cat" value="' . $this->data['nav']['deplace_cat'][$i]['id'] . '">' . $space . strip_tags($this->data['nav']['deplace_cat'][$i]['nom']) . '</option>';
  7608. }
  7609. }
  7610. $list .= '</select>';
  7611. if (strlen($list) > 38) {
  7612. printf($s, $list, $this->data['objets'][$this->interne['objet_num']]['categorie_id']);
  7613. } else {
  7614. echo ($this->data['objets'][$this->interne['objet_num']]['categorie_derniere_modif']) ? 'L\'album ne peut ętre déplacé.' : 'La catégorie ne peut ętre déplacée.';
  7615. }
  7616. }
  7617. break;
  7618. case 'is_inactive' :
  7619. if ($this->data['objets'][$this->interne['objet_num']][$obj . '_visible'] != '1') {
  7620. echo $s;
  7621. }
  7622. break;
  7623. case 'password' :
  7624. if ($obj != 'image') {
  7625. printf($s, $this->data['objets'][$this->interne['objet_num']][$obj . '_id'], preg_replace('`^\d+:(.*)`', '$1', $this->data['objets'][$this->interne['objet_num']][$obj . '_pass']));
  7626. }
  7627. break;
  7628. case 'tags' :
  7629. case 'date_creation' :
  7630. if ($obj == 'image') {
  7631. printf($s, $this->data['objets'][$this->interne['objet_num']][$obj . '_id']);
  7632. }
  7633. break;
  7634. }
  7635. }
  7636. /* Dimensions des vignettes des images */
  7637. function getImgThumbSize($type) {
  7638. if (THUMB_IMG_MODE == 'crop') {
  7639. $w = THUMB_IMG_CROP_WIDTH;
  7640. $h = THUMB_IMG_CROP_HEIGHT;
  7641. } else {
  7642. $w = THUMB_IMG_SIZE;
  7643. $h = THUMB_IMG_SIZE;
  7644. }
  7645. return ${$type};
  7646. }
  7647. /* Nombre d'objets par page */
  7648. function getObjetNb($s = '%s %s %s', $n = 10) {
  7649. for ($i = 1; $i <= $n; $i++) {
  7650. $selected = ($this->data['infos']['nb_limit'] == $i) ? ' selected="selected"' : '';
  7651. printf($s, $i, $selected, $i);
  7652. }
  7653. }
  7654. /* Options de trie des objets */
  7655. function getGalerieSort($s, $o = ' selected="selected"') {
  7656. $liste = $this->data['infos']['liste_trie'];
  7657. foreach ($liste as $k => $v) {
  7658. $selected = ($this->data['infos']['objets_ordre'] == $k) ? $o : '';
  7659. printf($s, $k, $selected, $v);
  7660. }
  7661. }
  7662. function getGalerieSens($s, $o = ' selected="selected"') {
  7663. $sens = array('croissant', 'décroissant');
  7664. $sens_value = array('ASC', 'DESC');
  7665. for ($i = 0; $i < count($sens); $i++) {
  7666. $selected = ($this->data['infos']['objets_sens'] == $sens_value[$i]) ? $o : '';
  7667. printf($s, $sens_value[$i], $selected, $sens[$i]);
  7668. }
  7669. }
  7670. /* Filtre */
  7671. function getGalerieFiltre($type, $s = '%s', $o = ' selected="selected"') {
  7672. if ($this->data['infos']['galerie_filtre'] == $type) {
  7673. printf($s, $o);
  7674. }
  7675. }
  7676. /* Barre de position. */
  7677. function getGaleriePosition($r = 1, $s = '%s [%s] %s', $o1 = ' / ', $o2 = '|', $o3 = ' - page ') {
  7678. $pos = str_replace('%sep', $o1, $this->data['galerie']['position']);
  7679. if ($this->data['infos']['nb_pages'] > 1) {
  7680. $page = $o3 . $this->data['infos']['page_actuelle'] . $o2 . $this->data['infos']['nb_pages'];
  7681. } else {
  7682. $page = '';
  7683. }
  7684. printf($s, $pos, $this->data['infos']['nb_objets'], $page);
  7685. }
  7686. /* Lien retour */
  7687. function getGalerieRetour($s = '<a id="retour" href="%s">retour</a>') {
  7688. if (isset($this->data['nav']['retour'])) {
  7689. printf($s, $this->data['nav']['retour']);
  7690. }
  7691. }
  7692. /* Affiche une liste déroulante pour un accčs direct ŕ une catégorie. */
  7693. function getGalerieHierarchie($s = '%s') {
  7694. if (isset($this->data['nav']['hierarchie'])) {
  7695. printf($s, $this->data['nav']['hierarchie']);
  7696. }
  7697. }
  7698. function getGalerieDeplace($s = '%s') {
  7699. printf($s, $this->data['nav']['deplace']);
  7700. }
  7701. // Renvoi le type de l'objet actuel : catégorie (cat) ou album (alb).
  7702. function getObjetType() {
  7703. return $this->data['infos']['objet_type'];
  7704. }
  7705. function isEXIF() {
  7706. if (function_exists('read_exif_data')) {
  7707. return TRUE;
  7708. }
  7709. }
  7710. function isGD() {
  7711. if (function_exists('imagetypes')) {
  7712. return TRUE;
  7713. }
  7714. }
  7715. /* Récupčre la date de création et génčre les listes numériques pour la date de création */
  7716. function getDateCreation($s = '%s') {
  7717. if ($this->data['infos']['objet_type'] != 'alb') {
  7718. return;
  7719. }
  7720. $date_creation = $this->data['objets'][$this->interne['objet_num']]['image_date_creation'];
  7721. if (!preg_match('`^\d{5,10}$`', $date_creation)) {
  7722. $date_creation = '';
  7723. }
  7724. $date = array();
  7725. $date['jour'] = -1;
  7726. $date['mois'] = -1;
  7727. $date['annee'] = -1;
  7728. if ($date_creation) {
  7729. $date_creation = getdate($date_creation);
  7730. $date['jour'] = $date_creation['mday'];
  7731. $date['mois'] = $date_creation['mon'];
  7732. $date['annee'] = $date_creation['year'];
  7733. }
  7734. // Jour.
  7735. $print_date = '<select name="date_creation_jour[' . $this->data['objets'][$this->interne['objet_num']]['image_id'] . ']">';
  7736. $print_date .= '<option value="">---</</option>';
  7737. for ($i = 1; $i <= 31; $i++) {
  7738. $selected = ($i == $date['jour']) ? ' selected="selected"' : '';
  7739. $print_date .= '<option' . $selected . ' value="' . $i . '">' . str_pad($i, 2, 0, STR_PAD_LEFT) . '</option>';
  7740. }
  7741. $print_date .= "</select>\n";
  7742. // Mois.
  7743. $print_date .= "\t\t\t\t\t\t\t\t" . '<select name="date_creation_mois[' . $this->data['objets'][$this->interne['objet_num']]['image_id'] . ']">';
  7744. $print_date .= '<option value="">---------</</option>';
  7745. for ($i = 1; $i <= 12; $i++) {
  7746. $selected = ($i == $date['mois']) ? ' selected="selected"' : '';
  7747. $print_date .= '<option' . $selected . ' value="' . $i . '">' . strftime('%B', mktime(0, 0, 0, $i, date('j'), date('Y'))) . '</option>';
  7748. }
  7749. $print_date .= "</select>\n";
  7750. // Année.
  7751. $print_date .= "\t\t\t\t\t\t\t\t" . '<select name="date_creation_annee[' . $this->data['objets'][$this->interne['objet_num']]['image_id'] . ']">';
  7752. $print_date .= '<option value="">-----</option>';
  7753. for ($i = 1970; $i <= date('Y'); $i++) {
  7754. $selected = ($i == $date['annee']) ? ' selected="selected"' : '';
  7755. $print_date .= '<option' . $selected . ' value="' . $i . '">' . $i . '</option>';
  7756. }
  7757. $print_date .= "</select>\n";
  7758. $date_exif = $this->data['objets'][$this->interne['objet_num']]['image_exif_datetimeoriginal'];
  7759. if ($date_exif) {
  7760. $print_date .= "\n\t\t\t\t\t\t\t\t" . '<span class="date_exif">Date Exif&nbsp;: ' . outils::ladate($date_exif) . '</span>';
  7761. }
  7762. printf($s, $print_date);
  7763. }
  7764. /*
  7765. *
  7766. * ======================================== GALERIE : REPRESENTANT;
  7767. *
  7768. */
  7769. function getVignettes($s) {
  7770. echo '<div id="gal_vignettes"><ul>';
  7771. for ($i = 0; $i < count($this->data['vignettes']); $i++) {
  7772. $thumb = '../getimg.php?m=1&amp;img=' . $this->data['vignettes'][$i]['image_chemin'];
  7773. $lien = 'index.php?section=galerie&amp;page=gestion&amp;cat=' . $_REQUEST['cat']
  7774. . '&amp;startnum=' . $_REQUEST['str']
  7775. . '&amp;obj=' . $_REQUEST['obj']
  7776. . '&amp;new_thumb=' . $this->data['vignettes'][$i]['image_id']
  7777. . $this->getVID(2);
  7778. $size = 'width="' . $this->getImgThumbSize('w') . '" height="' . $this->getImgThumbSize('h') . '"';
  7779. $alt = $this->data['vignettes'][$i]['image_nom'];
  7780. printf($s, $thumb, $lien, $size, $alt);
  7781. }
  7782. echo '</ul></div>';
  7783. }
  7784. /*
  7785. *
  7786. * ======================================== TAGS;
  7787. *
  7788. */
  7789. function getNullTag($s = '') {
  7790. if (!isset($this->data['tags']) || !is_array($this->data['tags'])) {
  7791. echo $s;
  7792. }
  7793. }
  7794. function displayTags() {
  7795. if (isset($this->data['tags']) && is_array($this->data['tags'])) {
  7796. return TRUE;
  7797. }
  7798. }
  7799. function getNextTag() {
  7800. static $f = 1;
  7801. if ($f) {
  7802. $f = 0;
  7803. } else {
  7804. $t = $this->data['tags'];
  7805. $t = end($t);
  7806. $tag = current($this->data['tags']);
  7807. if ($tag['tag_id'] == $t['tag_id']) {
  7808. return FALSE;
  7809. }
  7810. next($this->data['tags']);
  7811. }
  7812. return TRUE;
  7813. }
  7814. function getTag($o) {
  7815. $tag = current($this->data['tags']);
  7816. if ($o == 'id') {
  7817. echo md5($tag['tag_id']);
  7818. } else {
  7819. echo $tag[$o];
  7820. }
  7821. }
  7822. /*
  7823. *
  7824. * ======================================== UTILISATEURS : membres ;
  7825. *
  7826. */
  7827. function getMembres($type, $o = '', $o2 = '', $o3 = '') {
  7828. switch ($type) {
  7829. case 'zero' :
  7830. if ($this->data['infos']['nb_objets'] == 0) {
  7831. echo $o;
  7832. }
  7833. break;
  7834. case 'position' :
  7835. $this->data['infos']['nb_objets'];
  7836. $page = '';
  7837. if ($this->data['infos']['nb_pages'] > 1) {
  7838. $page = ' - page ' . $this->data['infos']['page_actuelle'] . '|' . $this->data['infos']['nb_pages'];
  7839. }
  7840. $groupe = '<strong>tous</strong> ';
  7841. if (isset($_REQUEST['groupe'])) {
  7842. if (isset($this->data['groupes'][$_REQUEST['groupe']])) {
  7843. $groupe = '<strong>' . $this->data['groupes'][$_REQUEST['groupe']] . '</strong> ';
  7844. }
  7845. }
  7846. echo $groupe . '[' . $this->data['infos']['nb_objets'] . ']' . $page . '';
  7847. break;
  7848. case 'nb_membres' :
  7849. for ($i = 1; $i <= $o2; $i++) {
  7850. $selected = ($this->data['config']['admin_membres_nb'] == $i) ? ' selected="selected"' : '';
  7851. printf($o, $i, $selected, $i);
  7852. }
  7853. break;
  7854. case 'ordre' :
  7855. if ($this->data['config']['admin_membres_ordre'] == $o) {
  7856. echo ' selected="selected"';
  7857. }
  7858. break;
  7859. case 'sens' :
  7860. if ($this->data['config']['admin_membres_sens'] == $o) {
  7861. echo ' selected="selected"';
  7862. }
  7863. break;
  7864. case 'groupe' :
  7865. echo '<select name="groupe">';
  7866. $selected = ($this->data['infos']['groupe_id'] == 0) ? ' selected="selected"' : '';
  7867. echo '<option value="0"' . $selected . '>* tous</option>';
  7868. foreach ($this->data['groupes'] as $id => $nom) {
  7869. $selected = ($this->data['infos']['groupe_id'] == $id) ? ' selected="selected"' : '';
  7870. echo '<option value="' . $id . '"' . $selected . '>' . $nom . '</option>';
  7871. }
  7872. echo '</select>';
  7873. break;
  7874. case 'search' :
  7875. if ($o == 's_date_creation' || $o == 's_date_derniere') {
  7876. if (isset($_GET['s_date_type'])) {
  7877. if (($o == 's_date_creation' && $_GET['s_date_type'] == 'creation') ||
  7878. ($o == 's_date_derniere' && $_GET['s_date_type'] == 'derniere')) {
  7879. echo ' checked="checked"';
  7880. }
  7881. } elseif ($o == 's_date_creation') {
  7882. echo ' checked="checked"';
  7883. }
  7884. } elseif ($o == 's_dnpd' || $o == 's_dnsd') {
  7885. if ((isset($_GET['s']) && isset($_GET[$o]) && $_GET[$o] == $o3)
  7886. || (!isset($_GET['s']) && $o2)) {
  7887. echo ' selected="selected"';
  7888. }
  7889. } else {
  7890. if ((isset($_GET['s']) && isset($_GET[$o]))
  7891. || (!isset($_GET['s']) && $o2)) {
  7892. echo ' checked="checked"';
  7893. }
  7894. }
  7895. break;
  7896. case 'search_date_nb' :
  7897. for ($i = 0; $i <= 30; $i++) {
  7898. $selected = '';
  7899. if ((isset($_GET['s']) && isset($_GET[$o2]) && $_GET[$o2] == $i)
  7900. || (!isset($_GET['s']) && $o3 == $i)) {
  7901. $selected = ' selected="selected"';
  7902. }
  7903. printf($o, $i, $selected);
  7904. }
  7905. break;
  7906. case 'search_result' :
  7907. if (isset($_REQUEST['search'])) {
  7908. if ($this->data['infos']['nb_objets']) {
  7909. printf($o, outils::html_specialchars($_REQUEST['search']));
  7910. } else {
  7911. printf($o2, outils::html_specialchars($_REQUEST['search']));
  7912. }
  7913. }
  7914. break;
  7915. case 'search_params' :
  7916. if (isset($_REQUEST['search'])) {
  7917. $s = ($o2) ? $o2 : '%s';
  7918. if ($o == 'inputs') {
  7919. $params = '<input type="hidden" name="search" value="' . htmlentities($_REQUEST['search']) . '" />';
  7920. foreach ($_REQUEST as $k => $v) {
  7921. if (substr($k, 0, 2) == 's_') {
  7922. $params .= '<input type="hidden" name="' . $k . '" value="' . $v . '" />';
  7923. }
  7924. }
  7925. }
  7926. if ($o == 'params') {
  7927. $params = htmlspecialchars($this->data['infos']['recherche']);
  7928. }
  7929. printf($s, $params);
  7930. }
  7931. break;
  7932. case 'groupe_param' :
  7933. if (isset($_REQUEST['groupe'])) {
  7934. $s = ($o2) ? $o2 : '%s';
  7935. if ($o == 'inputs') {
  7936. $params = '<input type="hidden" name="groupe" value="' . htmlentities($_REQUEST['groupe']) . '" />';
  7937. }
  7938. if ($o == 'params') {
  7939. $params = '&amp;groupe=' . $_REQUEST['groupe'];
  7940. }
  7941. printf($s, $params);
  7942. }
  7943. break;
  7944. }
  7945. }
  7946. function getNextMember() {
  7947. if (!empty($this->data['membres'])) {
  7948. if (!isset($this->interne['membre_num'])) {
  7949. $this->interne['membre_num'] = 0;
  7950. } else {
  7951. $this->interne['membre_num']++;
  7952. }
  7953. if (isset($this->data['membres'][$this->interne['membre_num']]['user_id'])) {
  7954. return TRUE;
  7955. }
  7956. }
  7957. }
  7958. function getMembre($type, $o = '') {
  7959. switch ($type) {
  7960. case 'nom' :
  7961. $nom = str_replace('_', ' ', $this->data['membres'][$this->interne['membre_num']]['user_login']);
  7962. echo '<a title="Modifier le profil de ce membre" href="index.php?section=utilisateurs&amp;page=modif_user&amp;user=' . $this->data['membres'][$this->interne['membre_num']]['user_id'] . '">'
  7963. . $nom . '</a>';
  7964. break;
  7965. case 'id' :
  7966. echo $this->data['membres'][$this->interne['membre_num']]['user_id'];
  7967. break;
  7968. case 'avatar' :
  7969. if ($this->data['membres'][$this->interne['membre_num']]['user_avatar']) {
  7970. echo '<a title="Modifier le profil de ce membre" href="index.php?section=utilisateurs&amp;page=modif_user&amp;user=' . $this->data['membres'][$this->interne['membre_num']]['user_id'] . '">'
  7971. . '<img src="../membres/avatars/avatar_'
  7972. . $this->data['membres'][$this->interne['membre_num']]['user_login'] . '_thumb.jpg" '
  7973. . 'width="50" height="50" alt="avatar de '
  7974. . $this->data['membres'][$this->interne['membre_num']]['user_login'] . '" /></a>';
  7975. } else {
  7976. echo '<a title="Modifier le profil de ce membre" href="index.php?section=utilisateurs&amp;page=modif_user&amp;user=' . $this->data['membres'][$this->interne['membre_num']]['user_id'] . '">'
  7977. . '<img src="template/defaut/style/avatar_default.png" '
  7978. . 'width="50" height="50" alt="pas d\'avatar" /></a>';
  7979. }
  7980. break;
  7981. case 'mail' :
  7982. if ($this->data['membres'][$this->interne['membre_num']]['user_mail']) {
  7983. echo '<a href="mailto:' . htmlentities($this->data['membres'][$this->interne['membre_num']]['user_mail']) . '">courriel</a>';
  7984. }
  7985. break;
  7986. case 'web' :
  7987. if ($this->data['membres'][$this->interne['membre_num']]['user_web']) {
  7988. if ($this->data['membres'][$this->interne['membre_num']]['user_mail']) {
  7989. echo $o;
  7990. }
  7991. echo '<a href="' . htmlentities($this->data['membres'][$this->interne['membre_num']]['user_web']) . '">site Web</a>';
  7992. } else {
  7993. echo '&nbsp;';
  7994. }
  7995. break;
  7996. case 'date_creation' :
  7997. echo outils::ladate($this->data['membres'][$this->interne['membre_num']]['user_date_creation']);
  7998. break;
  7999. case 'date_derniere_visite' :
  8000. echo outils::ladate($this->data['membres'][$this->interne['membre_num']]['user_date_derniere_visite'], '%A %d %B %Y ŕ partir de %H:%M:%S');
  8001. break;
  8002. case 'groupe' :
  8003. $user_id = $this->data['membres'][$this->interne['membre_num']]['user_id'];
  8004. $input = '';
  8005. $groupes = '<select name="membres[' . $user_id . '][groupe]">';
  8006. foreach ($this->data['groupes'] as $groupe_id => $nom) {
  8007. if ($this->data['membres'][$this->interne['membre_num']]['groupe_id'] == $groupe_id) {
  8008. $selected = ' selected="selected"';
  8009. $input = '<input type="hidden" name="membres[' . $user_id . '][groupe_actuel]" value="' . $groupe_id . '" />';
  8010. } else {
  8011. $selected = '';
  8012. }
  8013. $groupes .= '<option value="' . $groupe_id . '"' . $selected . '>' . $nom . '</option>';
  8014. }
  8015. $groupes .= '</select>';
  8016. echo $input . $groupes;
  8017. break;
  8018. case 'ip_creation' :
  8019. echo $this->data['membres'][$this->interne['membre_num']]['user_ip_creation'];
  8020. break;
  8021. case 'ip_derniere_visite' :
  8022. echo $this->data['membres'][$this->interne['membre_num']]['user_ip_derniere_visite'];
  8023. break;
  8024. }
  8025. }
  8026. /*
  8027. *
  8028. * ======================================== UTILISATEURS : modification du profil ;
  8029. *
  8030. */
  8031. function getProfil($o, $s = '%s') {
  8032. switch ($o) {
  8033. case 'nom' :
  8034. $user_nom = str_replace('_', ' ', $this->data['user'][0]['user_login']);
  8035. $user_nom = '<a href="../?profil=' . urlencode($this->data['user'][0]['user_login']) . '">' . $user_nom . '</a>';
  8036. printf($s, $user_nom);
  8037. break;
  8038. case 'avatar':
  8039. if ($this->data['user'][0]['user_avatar']) {
  8040. $img_file = '../membres/avatars/avatar_'
  8041. . $this->data['user'][0]['user_login'] . '.jpg';
  8042. $img_infos = getimagesize($img_file);
  8043. echo '<img src="' . $img_file . '" '
  8044. . $img_infos[3] . ' alt="avatar de '
  8045. . $this->data['user'][0]['user_login'] . '" />';
  8046. } else {
  8047. echo '<img src="template/defaut/style/avatar_default.png" '
  8048. . 'width="50" height="50" alt="pas d\'avatar" />';
  8049. }
  8050. break;
  8051. case 'courriel':
  8052. if (!empty($this->data['user'][0]['user_mail'])) {
  8053. echo ' value="' . $this->data['user'][0]['user_mail'] . '"';
  8054. }
  8055. break;
  8056. case 'web':
  8057. if (!empty($this->data['user'][0]['user_web'])) {
  8058. echo ' value="' . $this->data['user'][0]['user_web'] . '"';
  8059. }
  8060. break;
  8061. case 'lieu':
  8062. if (!empty($this->data['user'][0]['user_lieu'])) {
  8063. echo ' value="' . $this->data['user'][0]['user_lieu'] . '"';
  8064. }
  8065. break;
  8066. case 'courriel_visible':
  8067. if (!empty($this->data['user'][0]['user_mail_public'])) {
  8068. echo ' checked="checked"';
  8069. }
  8070. break;
  8071. case 'is_newsletter':
  8072. if ($this->data['user'][0]['groupe_newsletter']) {
  8073. return true;
  8074. }
  8075. break;
  8076. case 'newsletter':
  8077. if (!empty($this->data['user'][0]['user_newsletter'])) {
  8078. echo ' checked="checked"';
  8079. }
  8080. break;
  8081. case 'date_inscription' :
  8082. echo outils::ladate($this->data['user'][0]['user_date_creation']);
  8083. break;
  8084. case 'date_derniere_visite' :
  8085. echo outils::ladate($this->data['user'][0]['user_date_derniere_visite'], '%A %d %B %Y ŕ partir de %H:%M:%S');
  8086. break;
  8087. case 'ip_inscription' :
  8088. echo $this->data['user'][0]['user_ip_creation'];
  8089. break;
  8090. case 'ip_derniere_visite' :
  8091. echo $this->data['user'][0]['user_ip_derniere_visite'];
  8092. break;
  8093. case 'nb_commentaires' :
  8094. echo $this->data['user'][0]['nb_comments'];
  8095. break;
  8096. case 'nb_images' :
  8097. echo $this->data['user'][0]['nb_images'];
  8098. break;
  8099. case 'nb_favoris' :
  8100. echo $this->data['user'][0]['nb_favoris'];
  8101. break;
  8102. }
  8103. }
  8104. /*
  8105. *
  8106. * ======================================== UTILISATEURS : groupes ;
  8107. *
  8108. */
  8109. function getNextGroup() {
  8110. if (!empty($this->data['groupes'])) {
  8111. if (!isset($this->interne['groupe_num'])) {
  8112. $this->interne['groupe_num'] = 0;
  8113. } else {
  8114. $this->interne['groupe_num']++;
  8115. }
  8116. if (isset($this->data['groupes'][$this->interne['groupe_num']]['groupe_id'])) {
  8117. return TRUE;
  8118. }
  8119. }
  8120. }
  8121. function getGroupe($objet, $s = '%s') {
  8122. switch ($objet) {
  8123. case 'special' :
  8124. if ($this->data['groupes'][$this->interne['groupe_num']]['groupe_id'] < 4) {
  8125. echo $s;
  8126. }
  8127. break;
  8128. case 'nom' :
  8129. printf($s, $this->data['groupes'][$this->interne['groupe_num']]['groupe_nom']);
  8130. break;
  8131. case 'titre' :
  8132. printf($s, $this->data['groupes'][$this->interne['groupe_num']]['groupe_titre']);
  8133. break;
  8134. case 'nb_membres' :
  8135. $groupe_id = $this->data['groupes'][$this->interne['groupe_num']]['groupe_id'];
  8136. if ($groupe_id < 3) {
  8137. $nb_users = '/';
  8138. } else {
  8139. $nb_users = $this->data['groupes'][$this->interne['groupe_num']]['nb_users'];
  8140. if ($nb_users > 0) {
  8141. $pl = ($nb_users > 1) ? 's' : '';
  8142. $nb_users = '<a href="?section=utilisateurs&amp;page=membres&amp;groupe=' . $groupe_id . '">' . $nb_users . ' membre' . $pl . '</a>';
  8143. } else {
  8144. $nb_users = '0 membre';
  8145. }
  8146. }
  8147. printf($s, $nb_users);
  8148. break;
  8149. case 'actions' :
  8150. $groupe_id = $this->data['groupes'][$this->interne['groupe_num']]['groupe_id'];
  8151. $supprimer = '';
  8152. if ($groupe_id > 3) {
  8153. $supprimer = '<a onclick="return confirm_sup_groupe();" href="?section=utilisateurs&amp;page=groupes&amp;supprimer=' . $groupe_id . $this->getVID(2) . '">supprimer</a>';
  8154. }
  8155. $modifier = '<a href="?section=utilisateurs&amp;page=modif_groupe&amp;groupe=' . $groupe_id . '">modifier</a>';
  8156. printf($s, $modifier, $supprimer);
  8157. break;
  8158. case 'date_creation' :
  8159. if ($this->data['groupes'][$this->interne['groupe_num']]['groupe_id'] > 2) {
  8160. $date_creation = outils::ladate($this->data['groupes'][$this->interne['groupe_num']]['groupe_date_creation'], '%d %B %Y');
  8161. } else {
  8162. $date_creation = '/';
  8163. }
  8164. printf($s, $date_creation);
  8165. break;
  8166. }
  8167. }
  8168. /*
  8169. *
  8170. * ======================================== UTILISATEURS : modification de groupes ;
  8171. *
  8172. */
  8173. function getModifGroupe($p, $s = '%s') {
  8174. switch ($p) {
  8175. case 'nom' :
  8176. printf($s, $this->data['groupe'][0]['groupe_nom']);
  8177. break;
  8178. case 'titre' :
  8179. printf($s, $this->data['groupe'][0]['groupe_titre']);
  8180. break;
  8181. case 'commentaires' :
  8182. case 'votes' :
  8183. case 'perso' :
  8184. case 'recherche_avance' :
  8185. case 'newsletter' :
  8186. case 'upload' :
  8187. case 'upload_create' :
  8188. if ($this->data['groupe'][0]['groupe_' . $p]) {
  8189. echo ' checked="checked"';
  8190. }
  8191. break;
  8192. case 'direct' :
  8193. case 'attente' :
  8194. if ($this->data['groupe'][0]['groupe_upload_mode'] == $p) {
  8195. echo ' checked="checked"';
  8196. }
  8197. break;
  8198. case 'aucun' :
  8199. case 'tous' :
  8200. case 'select' :
  8201. if ($this->data['groupe'][0]['groupe_album_pass_mode'] == $p) {
  8202. echo ' checked="checked"';
  8203. }
  8204. break;
  8205. case 'pass_ver' :
  8206. $pass_dev = array();
  8207. if (!empty($this->data['groupe'][0]['groupe_album_pass'])) {
  8208. $pass_dev = unserialize($this->data['groupe'][0]['groupe_album_pass']);
  8209. }
  8210. if (is_array($this->data['passwords'])) {
  8211. for ($i = 0; $i < count($this->data['passwords']); $i++) {
  8212. if (!in_array($this->data['passwords'][$i]['categorie_pass'], $pass_dev)) {
  8213. echo '<option value="' . $this->data['passwords'][$i]['categorie_pass'] . '">'
  8214. . $this->data['passwords'][$i]['categorie_pass'] . '</option>';
  8215. }
  8216. }
  8217. }
  8218. break;
  8219. case 'pass_dev' :
  8220. if (!empty($this->data['groupe'][0]['groupe_album_pass'])) {
  8221. $passwords = unserialize($this->data['groupe'][0]['groupe_album_pass']);
  8222. for ($i = 0; $i < count($passwords); $i++) {
  8223. echo '<option value="' . $passwords[$i] . '">'
  8224. . $passwords[$i] . '</option>';
  8225. }
  8226. }
  8227. break;
  8228. }
  8229. }
  8230. /*
  8231. *
  8232. * ======================================== UTILISATEURS : images en attente;
  8233. *
  8234. */
  8235. function getImagesAtt($type, $o = '', $o2 = '') {
  8236. switch ($type) {
  8237. case 'position' :
  8238. $nb_images = $this->data['infos']['nb_objets'];
  8239. $s = ($nb_images > 1) ? '%s images en attente' : '%s image en attente';
  8240. printf($s, $nb_images);
  8241. break;
  8242. case 'nb_images' :
  8243. for ($i = 1; $i <= $o2; $i++) {
  8244. $selected = ($this->data['config']['admin_imgatt_nb'] == $i) ? ' selected="selected"' : '';
  8245. printf($o, $i, $selected, $i);
  8246. }
  8247. break;
  8248. case 'ordre' :
  8249. if ($this->data['config']['admin_imgatt_ordre'] == $o) {
  8250. echo ' selected="selected"';
  8251. }
  8252. break;
  8253. case 'sens' :
  8254. if ($this->data['config']['admin_imgatt_sens'] == $o) {
  8255. echo ' selected="selected"';
  8256. }
  8257. break;
  8258. case 'noimages' :
  8259. if ($this->data['infos']['nb_objets'] == 0) {
  8260. return true;
  8261. }
  8262. break;
  8263. }
  8264. }
  8265. function getNextImageAtt() {
  8266. if (!empty($this->data['images_attente'])) {
  8267. if (!isset($this->interne['imgatt_num'])) {
  8268. $this->interne['imgatt_num'] = 0;
  8269. } else {
  8270. $this->interne['imgatt_num']++;
  8271. }
  8272. if (isset($this->data['images_attente'][$this->interne['imgatt_num']]['img_att_id'])) {
  8273. return TRUE;
  8274. }
  8275. }
  8276. }
  8277. function getImageAtt($type, $s = '%s', $o = '') {
  8278. switch ($type) {
  8279. case 'lien' :
  8280. $session_id = md5($this->data['config']['session_id']);
  8281. $lien = 'image_att.php?sid=' . $session_id
  8282. . '&amp;img=' . $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_fichier'];
  8283. printf($s, $lien);
  8284. break;
  8285. case 'thumb' :
  8286. $session_id = md5($this->data['config']['session_id']);
  8287. $lien = 'image_att.php?sid=' . $session_id
  8288. . '&amp;img=' . $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_fichier'];
  8289. $hauteur = $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_hauteur'];
  8290. $largeur = $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_largeur'];
  8291. list($largeur, $hauteur) = outils::thumb_size('img', $o, $largeur, $hauteur);
  8292. $alt = (!empty($this->data['images_attente'][$this->interne['imgatt_num']]['img_att_nom']))
  8293. ? $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_nom']
  8294. : str_replace('_', ' ', $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_fichier']);
  8295. $src = 'image_att.php?sid=' . $session_id
  8296. . '&amp;tb=' . $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_fichier'];
  8297. $thumb = '<a href="' . $lien . '"><img src="' . $src . '" alt="' . $alt . '" width="' . $largeur . '" height="' . $hauteur . '" /></a>';
  8298. printf($s, $thumb);
  8299. break;
  8300. case 'id' :
  8301. printf($s, $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_id']);
  8302. break;
  8303. case 'user_nom' :
  8304. $login = $this->data['images_attente'][$this->interne['imgatt_num']]['user_login'];
  8305. $lien = GALERIE_PATH . '/index.php?profil=' . urlencode($login);
  8306. $nom = str_replace('_', ' ', $login);
  8307. $nom = '<a href="' . $lien . '">' . $nom . '</a>';
  8308. printf($s, $nom);
  8309. break;
  8310. case 'ip' :
  8311. printf($s, $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_ip']);
  8312. break;
  8313. case 'album' :
  8314. $nom = $this->data['images_attente'][$this->interne['imgatt_num']]['categorie_nom'];
  8315. $lien = GALERIE_PATH . '/index.php?alb=' . $this->data['images_attente'][$this->interne['imgatt_num']]['categorie_id'];
  8316. $album = '<a href="' . $lien . '">' . $nom . '</a>';
  8317. printf($s, $album);
  8318. break;
  8319. case 'fichier' :
  8320. printf($s, $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_fichier']);
  8321. break;
  8322. case 'date' :
  8323. $date = outils::ladate($this->data['images_attente'][$this->interne['imgatt_num']]['img_att_date']);
  8324. printf($s, $date);
  8325. break;
  8326. case 'nom' :
  8327. $nom = htmlentities($this->data['images_attente'][$this->interne['imgatt_num']]['img_att_nom']);
  8328. printf($s, $nom);
  8329. break;
  8330. case 'desc' :
  8331. $desc = htmlentities($this->data['images_attente'][$this->interne['imgatt_num']]['img_att_description']);
  8332. printf($s, $desc);
  8333. break;
  8334. case 'type' :
  8335. printf($s, $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_type']);
  8336. break;
  8337. case 'poids' :
  8338. $poids = outils::poids($this->data['images_attente'][$this->interne['imgatt_num']]['img_att_poids']);
  8339. printf($s, $poids);
  8340. break;
  8341. case 'taille' :
  8342. $hauteur = $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_hauteur'];
  8343. $largeur = $this->data['images_attente'][$this->interne['imgatt_num']]['img_att_largeur'];
  8344. $taille = $largeur . ' x ' . $hauteur . ' pixels';
  8345. printf($s, $taille);
  8346. break;
  8347. }
  8348. }
  8349. /*
  8350. *
  8351. * ======================================== VOTES;
  8352. *
  8353. */
  8354. function getNullVotes($s = '') {
  8355. if (!isset($this->data['votes']) || !is_array($this->data['votes'])) {
  8356. echo $s;
  8357. }
  8358. }
  8359. function displayVotes() {
  8360. if (isset($this->data['votes']) && is_array($this->data['votes'])) {
  8361. return TRUE;
  8362. }
  8363. }
  8364. function getNextVote() {
  8365. if (!isset($this->data['interne_id'])) {
  8366. $this->data['interne_id'] = -1;
  8367. }
  8368. if (isset($this->data['votes'][$this->data['interne_id']+1])) {
  8369. $this->data['interne_id']++;
  8370. return TRUE;
  8371. }
  8372. }
  8373. function getVotesParams($o = '') {
  8374. if ($o == 'input') {
  8375. foreach ($_GET as $name => $value) {
  8376. if ($name != 'startnum' && $name != 'delete') {
  8377. echo '<input type="hidden" name="' . $name . '" value="' . $value . '" />';
  8378. }
  8379. }
  8380. } else {
  8381. foreach ($_GET as $name => $value) {
  8382. if ($name != 'startnum' && $name != 'delete') {
  8383. echo '&amp;' . $name . '=' . $value;
  8384. }
  8385. }
  8386. }
  8387. }
  8388. function getVote($t, $s = '%s', $o = '') {
  8389. $obj = '';
  8390. if (isset($_GET['cat']) && $_GET['cat'] > 1) {
  8391. $obj = '&amp;cat=' . $_GET['cat'];
  8392. }
  8393. if (isset($_GET['img']) && $_GET['img'] > 1) {
  8394. $obj = '&amp;img=' . $_GET['img'];
  8395. }
  8396. switch ($t) {
  8397. case 'id' :
  8398. printf($s, $this->data['votes'][$this->data['interne_id']]['vote_id']);
  8399. break;
  8400. case 'image' :
  8401. $s = ($s) ? $s : '<a title="%s" href="%s"><img width="%s" height="%s" alt="%s" src="%s" /></a>';
  8402. $alt = htmlentities($this->data['votes'][$this->data['interne_id']]['image_nom']);
  8403. $href = '?section=votes&amp;img=' . $this->data['votes'][$this->data['interne_id']]['image_id'] . $obj;
  8404. $src = '../getimg.php?img=' . $this->data['votes'][$this->data['interne_id']]['image_chemin'];
  8405. // Dimensions de la vignette.
  8406. $size = outils::thumb_size('img', $o, $this->data['votes'][$this->data['interne_id']]['image_largeur'], $this->data['votes'][$this->data['interne_id']]['image_hauteur']);
  8407. printf($s, $alt, $href, $size[0], $size[1], $alt, $src);
  8408. break;
  8409. case 'image_lien' :
  8410. $lien = '?section=votes&amp;img=' . $this->data['votes'][$this->data['interne_id']]['image_id'] . $obj;
  8411. printf($s, $lien);
  8412. break;
  8413. case 'date' :
  8414. $ts = $this->data['votes'][$this->data['interne_id']]['vote_date'];
  8415. $date = outils::ladate($ts, '%d %B %Y ŕ %H:%M');
  8416. $date = '<a href="?section=votes&amp;date=' . $ts . $obj . '">' . $date . '</a>';
  8417. printf($s, $date);
  8418. break;
  8419. case 'album' :
  8420. $album_id = $this->data['votes'][$this->data['interne_id']]['categorie_id'];
  8421. $album_nom = $this->data['votes'][$this->data['interne_id']]['categorie_nom'];
  8422. $album = '<a href="?section=votes&amp;cat=' . $album_id . '">' . $album_nom . '</a>';
  8423. printf($s, $album);
  8424. break;
  8425. case 'ip' :
  8426. $ip = $this->data['votes'][$this->data['interne_id']]['vote_ip'];
  8427. $ip = '<a href="?section=votes&amp;ip=' . $ip . $obj . '">' . $ip . '</a>';
  8428. printf($s, $ip);
  8429. break;
  8430. case 'note' :
  8431. $note = sprintf('%1.0f', $this->data['votes'][$this->data['interne_id']]['vote_note']);
  8432. printf($s, $note);
  8433. break;
  8434. case 'sub' :
  8435. $objet = str_replace('image', 'img', $this->data['infos']['sub_objects']);
  8436. $objet = str_replace('categorie', 'cat', $objet);
  8437. echo $objet;
  8438. break;
  8439. }
  8440. }
  8441. function getVotesPosition($s = '%s%s[%s] %s', $o1 = ' / ', $o2 = '|', $o3 = ' - page ') {
  8442. $pos = str_replace('%sep', $o1, $this->data['votes']['position']);
  8443. if ($this->data['infos']['nb_pages'] > 1) {
  8444. if (!isset($this->data['infos']['page_actuelle'])) {
  8445. header('Location:' . basename($_SERVER['PHP_SELF']) . '?' . preg_replace('`startnum=\d+`', 'startnum=0', $_SERVER['QUERY_STRING']));
  8446. }
  8447. $page = $o3 . $this->data['infos']['page_actuelle'] . $o2 . $this->data['infos']['nb_pages'];
  8448. } else {
  8449. $page = '';
  8450. }
  8451. $ipdate = ' ';
  8452. if (isset($_GET['date'])) {
  8453. $ipdate = ' (<a href="?section=votes&amp;date=' . $_GET['date'] . '">' . strftime('%d %B %Y', $_GET['date']) . '</a>) ';
  8454. } elseif (isset($_GET['ip'])) {
  8455. $ipdate = ' (<a href="?section=votes&amp;ip=' . $_GET['ip'] . '">' . $_GET['ip'] . '</a>) ';
  8456. }
  8457. printf($s, $pos, $ipdate, $this->data['infos']['nb_objets'], $page);
  8458. }
  8459. function getVotesNb($s = '%s %s %s', $n = 10) {
  8460. for ($i = 1; $i <= $n; $i++) {
  8461. $selected = ($this->data['infos']['nb_votes'] == $i) ? ' selected="selected"' : '';
  8462. printf($s, $i, $selected, $i);
  8463. }
  8464. }
  8465. function getVoteSortOrdre($type, $s = '%s', $o = ' selected="selected"') {
  8466. if ($this->data['infos']['vote_sort'] == $type) {
  8467. printf($s, $o);
  8468. }
  8469. }
  8470. function getVoteSortSens($type, $s = '%s', $o = ' selected="selected"') {
  8471. if ($this->data['infos']['vote_sens'] == $type) {
  8472. printf($s, $o);
  8473. }
  8474. }
  8475. function getVoteSubCats($s = '%s %s') {
  8476. $subcats = $this->data['votes']['sub_item'];
  8477. $objet = $this->data['infos']['sub_objects'];
  8478. for ($i = 0; $i < count($subcats); $i++) {
  8479. printf($s, $subcats[$i][$objet . '_id'], strip_tags($subcats[$i][$objet . '_nom']));
  8480. }
  8481. }
  8482. function getVoteDeleteAll($s = '%s') {
  8483. $title = 'Supprimer tous les votes de ';
  8484. if (isset($_GET['img'])) {
  8485. $obj = 'cette%20image';
  8486. $title .= 'cette image';
  8487. } elseif (isset($_GET['cat']) && $_GET['cat'] > 1) {
  8488. if ($this->data['infos']['obj_type'] == 'alb') {
  8489. $obj = 'cet%20album';
  8490. $title .= 'cet album';
  8491. } else {
  8492. $obj = 'cette%20catégorie';
  8493. $title .= 'cette catégorie';
  8494. }
  8495. } else {
  8496. $obj = 'la%20galerie';
  8497. $title .= 'la galerie';
  8498. }
  8499. if (isset($_GET['ip'])) {
  8500. $obj .= '%20correspondant%20ŕ%20cette%20IP';
  8501. $title .= ' correspondant ŕ cette IP';
  8502. } elseif (isset($_GET['date'])) {
  8503. $obj .= '%20correspondant%20ŕ%20cette%20date';
  8504. $title .= ' correspondant ŕ cette date';
  8505. }
  8506. $lien = '?delete=all';
  8507. foreach ($_GET as $name => $value) {
  8508. if ($name != 'startnum' && $name != 'delete') {
  8509. $lien .= '&amp;' . $name . '=' . $value;
  8510. }
  8511. }
  8512. printf($s, $title, $lien . $this->getVID(2), $obj);
  8513. }
  8514. /*
  8515. *
  8516. * ======================================== CONFIGURATION;
  8517. *
  8518. */
  8519. function getConfig($i) {
  8520. switch($i) {
  8521. case 'g_mail' : echo $this->data['config']['admin_mail']; break;
  8522. case 'g_dir_alb' : echo $this->data['config']['galerie_albums_dir']; break;
  8523. case 'g_dir_tb' : echo $this->data['config']['galerie_repertoire_vignettes']; break;
  8524. case 'g_pref_tb' : echo $this->data['config']['galerie_prefixe_vignettes']; break;
  8525. case 'g_size_tb_alb' : echo $this->data['config']['galerie_tb_alb_size']; break;
  8526. case 'g_size_tb_img' : echo $this->data['config']['galerie_tb_img_size']; break;
  8527. case 'g_tb_alb_crop_width' : echo $this->data['config']['galerie_tb_alb_crop_width']; break;
  8528. case 'g_tb_alb_crop_height' : echo $this->data['config']['galerie_tb_alb_crop_height']; break;
  8529. case 'g_tb_img_crop_width' : echo $this->data['config']['galerie_tb_img_crop_width']; break;
  8530. case 'g_tb_img_crop_height' : echo $this->data['config']['galerie_tb_img_crop_height']; break;
  8531. }
  8532. }
  8533. }
  8534. ?>