3 * Fichier pour le signalement d'une page
7 * LODEL - Logiciel d'Edition ELectronique.
9 * Copyright (c) 2001-2002, Ghislain Picard, Marin Dacos
10 * Copyright (c) 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
11 * Copyright (c) 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
12 * Copyright (c) 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
13 * Copyright (c) 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
14 * Copyright (c) 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
15 * Copyright (c) 2008, Marin Dacos, Bruno Cénou, Pierre-Alain Mignot, Inès Secondat de Montesquieu, Jean-François Rivière
16 * Copyright (c) 2009, Marin Dacos, Bruno Cénou, Pierre-Alain Mignot, Inès Secondat de Montesquieu, Jean-François Rivière
18 * Home page: http://www.lodel.org
20 * E-Mail: lodel@lodel.org
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 2 of the License, or
27 * (at your option) any later version.
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
38 * @author Ghislain Picard
40 * @author Pierre-Alain Mignot
41 * @copyright 2001-2002, Ghislain Picard, Marin Dacos
42 * @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
43 * @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
44 * @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
45 * @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
46 * @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
47 * @copyright 2008, Marin Dacos, Bruno Cénou, Pierre-Alain Mignot, Inès Secondat de Montesquieu, Jean-François Rivière
48 * @copyright 2009, Marin Dacos, Bruno Cénou, Pierre-Alain Mignot, Inès Secondat de Montesquieu, Jean-François Rivière
49 * @licence http://www.gnu.org/copyleft/gpl.html
51 * @package lodel/source
54 require 'siteconfig.php';
58 //gestion de l'authentification
61 // record the url if logged
62 if (C
::get('visitor', 'lodeluser')) {
65 $context =& C
::getC();
66 $context['signaler_recaptcha'] = C
::get('signaler_recaptcha', 'cfg');
67 $context['recaptcha_publickey'] = C
::get('recaptcha_publickey', 'cfg');
68 include 'recaptchalib.php';
70 // identifié ? accès à tous les documents
71 $critere = C
::get('rights', 'lodeluser') > LEVEL_VISITOR ?
'' : "AND #_TP_entities.status>0 AND #_TP_types.status>0";
72 function_exists("filtered_mysql_fetch_assoc") ||
include_once 'filterfunc.php';
74 $site = C
::get('site', 'cfg');
75 defined('INC_CONNECT') ||
include 'connect.php';
77 $result = $db->Execute(lq("
78 SELECT #_TP_textes.*, #_TP_entities.*,type
79 FROM #_entitiestypesjoin_ JOIN #_TP_textes ON #_TP_entities.id = #_TP_textes.identity
80 WHERE #_TP_entities.id='$id'
82 or trigger_error("SQL ERROR :<br />".$GLOBALS['db']->ErrorMsg(), E_USER_ERROR
);
84 if ($result->RecordCount() < 1) {
86 $context['notfound'] = 1;
87 View
::getView()->render('signaler');
91 $context = array_merge($context, filtered_mysql_fetch_assoc($context, $result));
94 if (isset($context['envoi'])) {
95 if($context['signaler_recaptcha'] === true
) {
97 $resp = recaptcha_check_answer (C
::get('recaptcha_privatekey', 'cfg'),
98 $_SERVER["REMOTE_ADDR"],
99 $_POST["recaptcha_challenge_field"],
100 $_POST["recaptcha_response_field"]);
102 if (!$resp->is_valid
) {
103 $context['recaptcha_error'] = $resp->error
;
104 C
::set('nocache', true
);
105 View
::getView()->render('signaler');
112 // on vérifie que les mails fournies sont correctes
113 if (empty($context['to']) ||
!preg_match("/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/", $context['to'])) {
114 $err = $context['error_to'] = 1;
116 if (empty($context['from']) ||
!preg_match("/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/", $context['from'])) {
117 $err = $context['error_from'] = 1;
123 $row = $db->getRow(lq("SELECT url FROM #_MTP_sites WHERE name='{$site}'"));
124 $context['subject'] = 'Un article de ' . $context['options']['metadonneessite']['titresite'] . " sur {$row['url']} signalé par ";
125 if(!empty($context['nom_expediteur']))
126 $context['subject'] .= $context['nom_expediteur'];
128 $context['subject'] .= "un ami (" . $context['from'] . ").";
130 class_exists('View') ||
include 'View.php'; // should be included by the autoload
133 $GLOBALS['nodesk'] = true
; // on veut pas le desk pour la génération du mail !
134 // on utilise pas le cache pour le mail généré !!
135 C
::set('nocache', true
);
136 insert_template($context, 'signaler-mail');
137 $content = ob_get_clean();
140 if (true
!== send_mail ($context['to'], $content, $context['subject'], $context['from'], $context['nom_expediteur'])) {
141 $context['error_mail']=1;
144 header ('location: '. makeurlwithid($id, 'index'));
149 View
::getView()->renderCached('signaler');
151 catch(LodelException
$e)
153 echo $e->getContent();