root/trunk/newsletter.php

Revision 421, 3.8 kB (checked in by bobe, 2 years ago)

Ajout option textCharset pour modifier le codage des caractères de la réponse

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * Copyright (c) 2002-2006 Aurélien Maille
4  *
5  * This file is part of Wanewsletter.
6  *
7  * Wanewsletter is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * Wanewsletter is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Wanewsletter; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  *
21  * @package Wanewsletter
22  * @author  Bobe <wascripts@phpcodeur.net>
23  * @link    http://phpcodeur.net/wascripts/wanewsletter/
24  * @license http://www.gnu.org/copyleft/gpl.html  GNU General Public License
25  * @version $Id$
26  */
27
28 if( !defined('IN_WA_FORM') && !defined('IN_SUBSCRIBE') )
29 {
30     exit('<b>No hacking</b>');
31 }
32
33 define('IN_NEWSLETTER', true);
34
35 //
36 // Compatibilité avec les version < 2.3.x
37 //
38 if( !defined('WA_ROOTDIR') )
39 {
40     if( !isset($waroot) )
41     {
42         exit("Le répertoire de Wanewsletter n'est pas défini!");
43     }
44     
45     define('WA_ROOTDIR', rtrim($waroot, '/'));
46 }
47
48 $default_magic_quotes_runtime = get_magic_quotes_runtime();
49 $default_error_reporting      = error_reporting(E_ALL);
50
51 require WA_ROOTDIR . '/start.php';
52 require WA_ROOTDIR . '/includes/functions.validate.php';
53
54 if( !empty($language) && validate_lang($language) )
55 {
56     load_settings(array('admin_lang' => $language));
57 }
58 else
59 {
60     load_settings();
61 }
62
63 $action  = ( !empty($_REQUEST['action']) ) ? trim($_REQUEST['action']) : '';
64 $email   = ( !empty($_REQUEST['email']) ) ? trim($_REQUEST['email']) : '';
65 $format  = ( isset($_REQUEST['format']) ) ? intval($_REQUEST['format']) : 0;
66 $liste   = ( isset($_REQUEST['liste']) ) ? intval($_REQUEST['liste']) : 0;
67 $message = '';
68 $code    = '';
69
70 if( empty($action) && preg_match('/([a-z0-9]{20})(?:&|$)/i', $_SERVER['QUERY_STRING'], $match) )
71 {
72     $code = $match[1];
73 }
74
75 //
76 // Compatibilité avec les version < 2.3.x
77 //
78 else if( !empty($action) && !empty($email) && strlen($code) == 32 )
79 {
80     $code = substr($code, 0, 20);
81 }
82
83 if( !empty($action) || !empty($code) )
84 {
85     //
86     // Purge des éventuelles inscriptions dépassées
87     // pour parer au cas d'une réinscription
88     //
89     purge_liste();
90     
91     require WA_ROOTDIR . '/includes/class.form.php';
92     
93     if( !empty($action) )
94     {
95         if( in_array($action, array('inscription', 'setformat', 'desinscription')) )
96         {
97             $sql = "SELECT liste_id, liste_format, sender_email, liste_alias, limitevalidate,
98                     liste_name, form_url, return_email, liste_sig, use_cron, confirm_subscribe
99                 FROM " . LISTE_TABLE . "
100                 WHERE liste_id = " $liste;
101             if( !($result = $db->query($sql)) )
102             {
103                 trigger_error('Impossible d\'obtenir les données sur la liste', ERROR);
104             }
105             
106             if( $listdata = $result->fetch() )
107             {
108                 $wanewsletter =& new Wanewsletter($listdata);
109                 $wanewsletter->message =& $message;
110                 $wanewsletter->do_action($action, $email, $format);
111             }
112             else
113             {
114                 $message = $lang['Message']['Unknown_list'];
115             }
116         }
117         else
118         {
119             $message = $lang['Message']['Invalid_action'];
120         }
121     }
122     else
123     {
124         $wanewsletter =& new Wanewsletter();
125         $wanewsletter->message =& $message;
126         $wanewsletter->check_code($code);
127     }
128 }
129
130 if( defined('IN_WA_FORM') )
131 {
132     //
133     // On réactive le gestionnaire d'erreur précédent
134     //
135     @restore_error_handler();
136     
137     // Si besoin, conversion du message vers le charset demandé
138     if( !empty($textCharset) ) {
139         $message = iconv($lang['CHARSET'], $textCharset, $message);
140     }
141     
142     echo nl2br($message);
143 }
144
145 //
146 // remise des paramêtres par défaut
147 //
148 error_reporting($default_error_reporting);
149
150 set_magic_quotes_runtime($default_magic_quotes_runtime);
151
152 ?>
Note: See TracBrowser for help on using the browser.