1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | if ( !defined('PHPWG_ROOT_PATH')) |
---|
25 | { |
---|
26 | die('Hacking attempt!'); |
---|
27 | } |
---|
28 | if (!defined('MAILl_SUPERV_DIR')) define('MAILl_SUPERV_DIR' , basename(dirname(__FILE__))); |
---|
29 | if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
30 | |
---|
31 | function test_envoie($message,$group_name,$group_id) |
---|
32 | { |
---|
33 | global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_données,$args ; |
---|
34 | $mailto=""; |
---|
35 | |
---|
36 | |
---|
37 | //================================================================================== |
---|
38 | if (!isset($infos_message)) |
---|
39 | { |
---|
40 | $infos_message = ""; |
---|
41 | } |
---|
42 | if (!isset($erreur_message)) |
---|
43 | { |
---|
44 | $erreur_message = ''; |
---|
45 | } |
---|
46 | if (!isset($mails_données)) |
---|
47 | { |
---|
48 | $mails_données = Get_Datas(); |
---|
49 | } |
---|
50 | if (!isset($conf_mail)) |
---|
51 | { |
---|
52 | $conf_mail = get_mail_configuration(); |
---|
53 | } |
---|
54 | if (isset($args)) |
---|
55 | { |
---|
56 | $infos_message=memo_var($args); |
---|
57 | }else{ |
---|
58 | $args = array(); |
---|
59 | } |
---|
60 | //===================================================================================================== |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | $groups=get_liste($group_id); |
---|
66 | |
---|
67 | |
---|
68 | //======================================================================================= |
---|
69 | if (count($groups) > 0) |
---|
70 | { |
---|
71 | //=========================================================== |
---|
72 | $args['Bcc']=$groups; |
---|
73 | $args['from'] = $conf_mail['formated_email_webmaster']; |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | //================================================================== |
---|
78 | $message_texte=sprintf( |
---|
79 | l10n('message_texte %s %s %s %s'), |
---|
80 | format_date( date("Y-m-d H:i:s")), |
---|
81 | $group_name, |
---|
82 | $message, |
---|
83 | $args['from'] |
---|
84 | ); |
---|
85 | $message_texte .=$message; |
---|
86 | //================================================================== |
---|
87 | $message_html=$message_texte; |
---|
88 | // $message_html .= '<img src="'.PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png" />'; |
---|
89 | |
---|
90 | |
---|
91 | //========================================================================== |
---|
92 | |
---|
93 | $args['subject']="Plugin Piwigo TEST"; |
---|
94 | $args['content']=$message_html; |
---|
95 | $ret= pwg_mail($mailto , $args); |
---|
96 | |
---|
97 | $infos_message .= sprintf( l10n('An information email was sent to group "%s"'), $group_name ).'<br />'; |
---|
98 | |
---|
99 | |
---|
100 | }else{ |
---|
101 | $infos_message .=l10n('no_receiver_available') ; |
---|
102 | } |
---|
103 | |
---|
104 | } |
---|
105 | //=============================================================================================================== |
---|
106 | function mail_attachement($args) |
---|
107 | { |
---|
108 | global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_données ; |
---|
109 | |
---|
110 | $mails_données = Get_Datas(); |
---|
111 | if (!isset($conf_mail)) |
---|
112 | { |
---|
113 | $conf_mail = get_mail_configuration(); |
---|
114 | } |
---|
115 | |
---|
116 | |
---|
117 | |
---|
118 | $nom ='piwigo_logo_sombre_214x100.png'; |
---|
119 | $fichier=PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png' ; |
---|
120 | $typemime='image/jpeg'; |
---|
121 | |
---|
122 | $fd = fopen( $fichier, "r" ); |
---|
123 | $contenu = fread( $fd, filesize( $fichier ) ); |
---|
124 | fclose( $fd ); |
---|
125 | $piecejointe = chunk_split(base64_encode($contenu)); |
---|
126 | |
---|
127 | |
---|
128 | $from=$args['from']; |
---|
129 | $to=""; |
---|
130 | |
---|
131 | $message_texte=sprintf( |
---|
132 | l10n('message_texte %s %s %s'), |
---|
133 | format_date( date("Y-m-d H:i:s")), |
---|
134 | $to, |
---|
135 | $from |
---|
136 | ); |
---|
137 | |
---|
138 | |
---|
139 | $message_html = '<img src="'.PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png" />'; |
---|
140 | ob_start(); |
---|
141 | |
---|
142 | echo str_replace("\n","<br />",$message_texte); |
---|
143 | |
---|
144 | $message_html .= ob_get_contents()."\n"; |
---|
145 | //ob_flush(); |
---|
146 | ob_end_clean(); |
---|
147 | |
---|
148 | $limite=$conf_mail['boundary_key']; |
---|
149 | $headers = date("Y-m-d H:i:s") ."\n"; |
---|
150 | |
---|
151 | //======================================================================================= |
---|
152 | $headers = "From: ".$args['from']."\n"; |
---|
153 | $headers.= "Reply-To: ".$args['from']."\n"; |
---|
154 | $nb_destinataires=0; |
---|
155 | $destinataire = $conf_mail['email_webmaster']; |
---|
156 | |
---|
157 | |
---|
158 | if (!empty($args['Cc'])) |
---|
159 | {$nb_destinataires += count($args['Cc']); |
---|
160 | $to= explode(',', $args['Cc']); |
---|
161 | $headers .= get_strict_email_list($to) ; |
---|
162 | |
---|
163 | } |
---|
164 | if (!empty($args['Bcc'])) |
---|
165 | { $nb_destinataires += count($args['Bcc']); |
---|
166 | $to = implode(',', $args['Bcc']); |
---|
167 | $headers .= 'Bcc :'.get_strict_email_list($to)."\n" ; |
---|
168 | |
---|
169 | } |
---|
170 | |
---|
171 | $headers.= 'Content-Type: multipart/alternative;'."\n"; |
---|
172 | $headers.= ' boundary="---='.$limite.'";'."\n"; |
---|
173 | $headers.= ' reply-type=original'."\n"; |
---|
174 | $headers.= 'MIME-Version: 1.0'."\n"; |
---|
175 | $headers.= 'X-Mailer: Piwigo Mailer'."\n"; |
---|
176 | |
---|
177 | //Le message en texte simple pour les navigateurs qui n'acceptent pas le HTML |
---|
178 | $texte = "This is a multi-part message in MIME format.\n"; |
---|
179 | |
---|
180 | $texte .= "-----=".$limite."\n"; |
---|
181 | $texte .= "Ceci est un message est au format MIME.\n"; |
---|
182 | $texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n"; |
---|
183 | $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; |
---|
184 | $texte .= $message_texte ; |
---|
185 | $texte .= "\n\n"; |
---|
186 | |
---|
187 | $texte .= "-----=".$limite."\n"; |
---|
188 | $texte .= 'Content-Type: text/html; charset="UTF-8"'."\n"; |
---|
189 | $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; |
---|
190 | $texte .= $message_html; |
---|
191 | $texte .= "\n\n"; |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | $attachement = "-----=".$limite."\n"; |
---|
196 | $attachement .= "Content-Type: ".$typemime."; name=\"".$nom."\"\n"; |
---|
197 | $attachement .= "Content-Transfer-Encoding: base64\n"; |
---|
198 | $attachement .= "Content-Disposition: attachment; filename=\"".$nom."\"\n\n"; |
---|
199 | $attachement .= $piecejointe; |
---|
200 | $attachement .= "\n\n\n-----=".$limite."\n"; |
---|
201 | |
---|
202 | |
---|
203 | $ret=false; |
---|
204 | |
---|
205 | ob_start(); |
---|
206 | |
---|
207 | $ret= mail( $destinataire, $args['subject'], $texte.$attachement, $headers); |
---|
208 | $message = ob_get_contents() ; |
---|
209 | //ob_flush(); |
---|
210 | ob_end_clean(); |
---|
211 | if (($message)<>"") { |
---|
212 | $erreur_message .= $message ; |
---|
213 | $infos_message = "-------------------"; |
---|
214 | } |
---|
215 | |
---|
216 | |
---|
217 | return $ret; |
---|
218 | |
---|
219 | } |
---|
220 | |
---|
221 | |
---|
222 | ?> |
---|