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')) die('Hacking attempt!'); |
---|
25 | function test_envoie($message,$group_name,$group_id){ |
---|
26 | global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_donnees,$args,$lang ; |
---|
27 | $mailto=""; |
---|
28 | load_language('plugin.lang', MAIL_SUPERV_PATH); |
---|
29 | |
---|
30 | //================================================================================== |
---|
31 | if (!isset($infos_message)) |
---|
32 | { |
---|
33 | $infos_message = ""; |
---|
34 | } |
---|
35 | if (!isset($erreur_message)) |
---|
36 | { |
---|
37 | $erreur_message = ''; |
---|
38 | } |
---|
39 | if (!isset($mails_donnees)) |
---|
40 | { |
---|
41 | $mails_donnees = mail_supervisor::Get_Datas(); |
---|
42 | } |
---|
43 | if (!isset($conf_mail)) |
---|
44 | { |
---|
45 | $conf_mail = get_mail_configuration(); |
---|
46 | } |
---|
47 | if (isset($args)) |
---|
48 | { |
---|
49 | $infos_message=mail_supervisor::Memo_Var($args); |
---|
50 | }else{ |
---|
51 | $args = array(); |
---|
52 | } |
---|
53 | //===================================================================================================== |
---|
54 | |
---|
55 | |
---|
56 | |
---|
57 | $groups=get_liste($group_id); |
---|
58 | |
---|
59 | //======================================================================================= |
---|
60 | if (count($groups) > 0) |
---|
61 | { |
---|
62 | $args['Bcc']=$groups; |
---|
63 | } else { |
---|
64 | $mailto = $conf_mail['formated_email_webmaster']; |
---|
65 | } |
---|
66 | |
---|
67 | $args['from'] =(function_exists('get_user_language_desc')) ? get_user_language_desc($conf_mail['formated_email_webmaster']):$conf_mail['formated_email_webmaster']; |
---|
68 | $message_html =$message; |
---|
69 | if (function_exists('get_user_language_desc') and isset($message) and $message <> '') |
---|
70 | $message = get_user_language_desc($message)."\n\n"; |
---|
71 | |
---|
72 | //================================================================== |
---|
73 | $message_texte=sprintf( |
---|
74 | l10n('Sv_message_texte %s %s %s %s'), |
---|
75 | format_date( date("Y-m-d H:i:s")), |
---|
76 | $group_name, |
---|
77 | $message, |
---|
78 | $args['from'] |
---|
79 | ); |
---|
80 | //================================================================== |
---|
81 | $message_html .= "</br>" . $message . "</br>" . $message_texte; |
---|
82 | //========================================================================== |
---|
83 | |
---|
84 | $args['subject']="Plugin Piwigo TEST"; |
---|
85 | $args['content']=$message_html; |
---|
86 | $infos_message .="To :" . $mailto; |
---|
87 | |
---|
88 | $ret= pwg_mail($mailto , $args); |
---|
89 | if ( $group_name <> '' or $mailto <> '' ) |
---|
90 | { |
---|
91 | if ($group_name<>'') { |
---|
92 | $infos_message .= '<br />'. sprintf( l10n('An information email was sent to group "%s"'), $group_name ).'<br />'; |
---|
93 | } |
---|
94 | if ($mailto <> '') { |
---|
95 | $infos_message .= '<br />'. sprintf( l10n('Sv_mail_sent_to'), $mailto ).'<br />'; |
---|
96 | } |
---|
97 | |
---|
98 | }else{ |
---|
99 | $infos_message .='<br />'.l10n('Sv_no_receiver_available') ; |
---|
100 | } |
---|
101 | } |
---|
102 | //=============================================================================================================== |
---|
103 | function mail_attachement($args){ |
---|
104 | global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_donnees,$lang ; |
---|
105 | |
---|
106 | $mails_donnees = mail_supervisor::Get_Datas(); |
---|
107 | if (!isset($conf_mail)) |
---|
108 | { |
---|
109 | $conf_mail = get_mail_configuration(); |
---|
110 | } |
---|
111 | |
---|
112 | load_language('plugin.lang', MAIL_SUPERV_PATH); |
---|
113 | |
---|
114 | $nom ='piwigo_logo_sombre_214x100.png'; |
---|
115 | $fichier=PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png' ; |
---|
116 | $typemime='image/jpeg'; |
---|
117 | |
---|
118 | $fd = fopen( $fichier, "r" ); |
---|
119 | $contenu = fread( $fd, filesize( $fichier ) ); |
---|
120 | fclose( $fd ); |
---|
121 | $piecejointe = chunk_split(base64_encode($contenu)); |
---|
122 | |
---|
123 | |
---|
124 | $from=$args['from']; |
---|
125 | $to=""; |
---|
126 | |
---|
127 | $message_texte=sprintf( |
---|
128 | l10n('Sv_message_texte %s %s %s'), |
---|
129 | format_date( date("Y-m-d H:i:s")), |
---|
130 | $to, |
---|
131 | $from |
---|
132 | ); |
---|
133 | |
---|
134 | |
---|
135 | $message_html = '<img src="'.PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png" />'; |
---|
136 | ob_start(); |
---|
137 | |
---|
138 | echo str_replace("\n","<br />",$message_texte); |
---|
139 | |
---|
140 | $message_html .= ob_get_contents()."\n"; |
---|
141 | //ob_flush(); |
---|
142 | ob_end_clean(); |
---|
143 | |
---|
144 | $limite=$conf_mail['boundary_key']; |
---|
145 | $headers = date("Y-m-d H:i:s") ."\n"; |
---|
146 | |
---|
147 | //======================================================================================= |
---|
148 | $headers = "From: ".$args['from']."\n"; |
---|
149 | $headers.= "Reply-To: ".$args['from']."\n"; |
---|
150 | $nb_destinataires=0; |
---|
151 | $destinataire = $conf_mail['email_webmaster']; |
---|
152 | if (!empty($args['Cc'])){ |
---|
153 | $nb_destinataires += count($args['Cc']); |
---|
154 | $to= explode(',', $args['Cc']); |
---|
155 | $headers .= get_strict_email_list($to) ; |
---|
156 | } |
---|
157 | if (!empty($args['Bcc'])){ |
---|
158 | $nb_destinataires += count($args['Bcc']); |
---|
159 | $to = implode(',', $args['Bcc']); |
---|
160 | $headers .= 'Bcc :'.get_strict_email_list($to)."\n" ; |
---|
161 | } |
---|
162 | |
---|
163 | $headers.= 'Content-Type: multipart/alternative;'."\n"; |
---|
164 | $headers.= ' boundary="---='.$limite.'";'."\n"; |
---|
165 | $headers.= ' reply-type=original'."\n"; |
---|
166 | $headers.= 'MIME-Version: 1.0'."\n"; |
---|
167 | $headers.= 'X-Mailer: Piwigo Mailer'."\n"; |
---|
168 | //Le message en texte simple pour les navigateurs qui n'acceptent pas le HTML |
---|
169 | $texte = "This is a multi-part message in MIME format.\n"; |
---|
170 | $texte .= "-----=".$limite."\n"; |
---|
171 | $texte .= "Ceci est un message est au format MIME.\n"; |
---|
172 | $texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n"; |
---|
173 | $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; |
---|
174 | $texte .= $message_texte ; |
---|
175 | $texte .= "\n\n"; |
---|
176 | $texte .= "-----=".$limite."\n"; |
---|
177 | $texte .= 'Content-Type: text/html; charset="UTF-8"'."\n"; |
---|
178 | $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; |
---|
179 | $texte .= $message_html; |
---|
180 | $texte .= "\n\n"; |
---|
181 | $attachement = "-----=".$limite."\n"; |
---|
182 | $attachement .= "Content-Type: ".$typemime."; name=\"".$nom."\"\n"; |
---|
183 | $attachement .= "Content-Transfer-Encoding: base64\n"; |
---|
184 | $attachement .= "Content-Disposition: attachment; filename=\"".$nom."\"\n\n"; |
---|
185 | $attachement .= $piecejointe; |
---|
186 | $attachement .= "\n\n\n-----=".$limite."\n"; |
---|
187 | $ret=false; |
---|
188 | ob_start(); |
---|
189 | $ret= mail( $destinataire, $args['subject'], $texte.$attachement, $headers); |
---|
190 | $message = ob_get_contents() ; |
---|
191 | //ob_flush(); |
---|
192 | ob_end_clean(); |
---|
193 | if (($message)<>"") { |
---|
194 | $erreur_message .= $message ; |
---|
195 | $infos_message = "-------------------"; |
---|
196 | } |
---|
197 | return $ret; |
---|
198 | } |
---|
199 | ?> |
---|