source: extensions/Mail_supervisor/include/function_test_send.php @ 13572

Last change on this file since 13572 was 13572, checked in by cljosse, 12 years ago

[extensions] mail_supervisorcompatibility with PHP 5.4, jquery 1.7.1

File size: 7.7 KB
RevLine 
[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
[9702]24if ( !defined('PHPWG_ROOT_PATH'))   die('Hacking attempt!');
[10419]25function test_envoie($message,$group_name,$group_id){
[9702]26  global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_donnees,$args,$lang ;
[10419]27    $mailto="";
[4054]28 load_language('plugin.lang', MAIL_SUPERV_PATH);
[10419]29
[4043]30//==================================================================================
31if (!isset($infos_message))
[10419]32    {
33        $infos_message = "";
34    }
[4043]35if (!isset($erreur_message))
[10419]36    {
37        $erreur_message = '';
38    }
[7050]39if (!isset($mails_donnees))
[10419]40    {
[13572]41        $mails_donnees =  $mail_supervisor->Get_Datas();
[10419]42    }
[4043]43if (!isset($conf_mail))
44  {
[10419]45        $conf_mail = get_mail_configuration();
[4043]46  }
[10419]47      if (isset($args))
48  {
[13572]49    $infos_message= $mail_supervisor->Memo_Var($args);
[4043]50  }else{
[10419]51    $args = array();
52    }
[4043]53//=====================================================================================================
54
55
[10419]56
[10816]57$groups=get_liste($group_id).dest;
[4043]58
59//=======================================================================================
60  if (count($groups) > 0)
61  {
[4054]62       $args['Bcc']=$groups;
63   }   else {
[10419]64       $mailto = $conf_mail['formated_email_webmaster'];
65   }
66
[5670]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;
[4323]69      if (function_exists('get_user_language_desc') and isset($message) and $message <> '')
70        $message = get_user_language_desc($message)."\n\n";
[10419]71
72    //==================================================================
73     $message_texte=sprintf(
[4879]74        l10n('Sv_message_texte %s %s %s %s'),
[4043]75        format_date( date("Y-m-d H:i:s")),
[10419]76        $group_name,
77        $message,
78        $args['from']
79        );
80    //==================================================================
81    $message_html .= "</br>" . $message . "</br>" . $message_texte;
[4043]82 //==========================================================================
83
[10419]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    }
[4043]101}
102//===============================================================================================================
[9702]103function mail_attachement($args){
[7050]104 global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_donnees,$lang ;
[4043]105
[13572]106    $mails_donnees =  $mail_supervisor->Get_Datas();
[10419]107      if (!isset($conf_mail))
[4043]108  {
109    $conf_mail = get_mail_configuration();
110  }
111
[4054]112 load_language('plugin.lang', MAIL_SUPERV_PATH);
[4043]113
[10419]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'];
[4043]125$to="";
126
127     $message_texte=sprintf(
[4879]128        l10n('Sv_message_texte %s %s %s'),
[4043]129        format_date( date("Y-m-d H:i:s")),
[10419]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
[9702]138  echo str_replace("\n","<br />",$message_texte);
[10419]139
[9702]140  $message_html .= ob_get_contents()."\n";
141  //ob_flush();
142  ob_end_clean();
[4043]143
[10419]144  $limite=$conf_mail['boundary_key'];
145  $headers =   date("Y-m-d H:i:s") ."\n";
[4043]146
147  //=======================================================================================
[9702]148    $headers = "From: ".$args['from']."\n";
149    $headers.= "Reply-To: ".$args['from']."\n";
150    $nb_destinataires=0;
[10419]151    $destinataire = $conf_mail['email_webmaster'];
[9702]152    if (!empty($args['Cc'])){
153      $nb_destinataires += count($args['Cc']);
154      $to= explode(',', $args['Cc']);
[10419]155      $headers  .= get_strict_email_list($to) ;
156    }
157    if (!empty($args['Bcc'])){
158      $nb_destinataires += count($args['Bcc']);
[9702]159      $to = implode(',', $args['Bcc']);
[10419]160      $headers  .= 'Bcc :'.get_strict_email_list($to)."\n" ;
[9702]161    }
[4043]162
[9702]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";
[10419]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";
[9702]187    $ret=false;
188    ob_start();
[10419]189    $ret= mail( $destinataire, $args['subject'], $texte.$attachement, $headers);
[9702]190    $message =  ob_get_contents() ;
191  //ob_flush();
192  ob_end_clean();
193  if (($message)<>"") {
194    $erreur_message .=  $message ;
195    $infos_message =  "-------------------";
196  }
[10419]197  return  $ret;
[4043]198}
[9702]199?>
Note: See TracBrowser for help on using the repository browser.