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