Ignore:
Timestamp:
Jan 26, 2011, 3:59:23 PM (13 years ago)
Author:
cljosse
Message:

[Mail_Supervisor] compatibility with piwigo 2.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Mail_supervisor/main.inc.php

    r7050 r8917  
    22/*
    33Plugin Name: Mail supervisor
    4 Version: 1.4.2
     4Version: 1.4.4 Beta
    55Description: Mail supervisor surveille l'envoie des mails.
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=315
     
    1616
    1717 global $conf ;
    18 
    19  
    2018add_event_handler('send_mail', 'clj_mail',EVENT_HANDLER_PRIORITY_NEUTRAL - 1 , 6);
    2119function clj_mail($result, $mailto, $subject, $content, $headers, $args)
     
    2321    global $conf, $user, $lang_info,  $conf_mail,$mails_options,$mails_donnees , $template,$page ,$erreur_message,$infos_message, $lang;
    2422        // lecture config table -------------
    25         include_once (MAIL_SUPERV_PATH.'include/fonctions.php');
     23         include_once (MAIL_SUPERV_PATH.'include/fonctions.php');
    2624     load_language('plugin.lang', MAIL_SUPERV_PATH);
     25         
     26         if (isset($_POST["Submit"]) )
     27         {
     28         if ($_POST["Submit"] != l10n('Sv_Envoyer') ) return true ;
     29         }
     30        $message ="";
     31        if (!isset($infos_message))
     32        {
     33        $infos_message = "";
     34        }
     35if (!isset($erreur_message))
     36        {
     37        $erreur_message = '';
     38        }       
    2739         $mails_options = explode("," , $conf['mail_superv']);
    2840//======== verification si envoie de mail ou blocage connexion =====================
     
    5163        }
    5264       
    53         $message ="";
    54         if (!isset($infos_message))
    55         {
    56         $infos_message = "";
    57         }
    58 if (!isset($erreur_message))
    59         {
    60         $erreur_message = '';
    61         }
     65
    6266        // lecture donnees       -------------
    6367    $mails_donnees = Get_Datas();
     
    96100 if ($mailto<>"" )            $nb_destinataires +=1;
    97101
    98                 if (!empty($args['Bcc']))  { 
    99                         $nb_destinataires += count($args['Bcc']);
    100                         }
    101                 if (!empty($args['Cc']))  {   
    102                         $nb_destinataires += count($args['Cc']);
    103                         }
    104    //================= reecriture de l'entête ===============================
    105 if ( $nb_destinataires  == 1 )
    106         {
    107                 if ($mailto == "" )
     102                if (!empty($args['Bcc'])) { $nb_destinataires += count($args['Bcc']);   }
     103                if (!empty($args['Cc']))  {     $nb_destinataires += count($args['Cc']);        }
     104
     105   
     106        $infos_message .= "<hr> Theme :" . ($args['theme'] ) ."<br />";
     107    $infos_message .="nombre de destinataire:".$nb_destinataires." <br />" ;
     108
     109   //================= reecriture de l'entete ===============================
     110    $match=array("<",">");
     111    $string=array("&lt;","&gt;") ;     
     112       
     113if ( $nb_destinataires  == 1 && $mailto != "" )
     114        {   
     115    $infos_message .="--> Mailto: " . $mailto." \n" ;
     116   
     117                if ($mailto != "" )
    108118                  {
    109                           if (!empty($args['Cc']) and count($args['Cc']) > 0 )  $mailto  = get_strict_email_list(implode(',', $args['Cc'])) ;
    110                           if (!empty($args['Bcc']) and count($args['Bcc']) > 0 ) $mailto  = get_strict_email_list(implode(',', $args['Bcc'])) ;
    111                          
    112                                 $headers = preg_replace('/.*Bcc(.*).\n/i', '', $headers);
    113                                 $headers = preg_replace('/.*Cc(.*).\n/i', '', $headers);
    114                                
     119
     120                 $mailto  = $mailto ." \n"  ;
     121                $headers =  preg_replace('/.*Bcc(.*).\n/i', '', $headers);
     122                                $headers =  preg_replace('/.*Cc(.*).\n/i', '', $headers);
     123               
     124                       
    115125                  }
     126     //=============================================================================
     127             
     128           
     129                if (!empty($args['Bcc']) ) $infos_message .="Bcc: " . memo_var($args['Bcc']) ." \n";
     130                if (!empty($args['Cc']) ) $infos_message .="Cc: " . memo_var($args['Cc'])." \n" ;
     131                $infos_message .="Mailto: [" . $mailto . "]"." \n".$headers;             
     132         
    116133        }else{
    117    
    118  
    119      }
    120 
    121 //=============================================================================         
    122 if (!empty($args['Cc']))
    123                         {
    124                          $headers= corrige_header('Cc',$headers,$args);
    125                         }
    126                 if (!empty($args['Bcc']))
    127                         {   
    128                                    $headers     = corrige_header('Bcc',$headers,$args);
    129                         }
    130 //=============================================================================                 
     134//=== plusieurs destinataires ===========
     135$cl_list_mail="";
     136
     137  if ($mailto !="") $infos_message .="To: " . $mailto . " "." /n" ;     
     138        if (!empty($args['Cc'])) {
     139        $ret= corrige_header('Cc',$headers,$args,$cl_list_mail);
     140          $headers = $ret->headers;
     141          $infos_message .="Cc: " .  ( $ret->list_mail)."  <br />" ;
     142        }
     143        if (!empty($args['Bcc'])){
     144           $ret = corrige_header('Bcc',$headers,$args,$cl_list_mail);
     145         
     146           $headers = $ret->headers ;
     147           $infos_message .="Bcc: " . ( $ret->list_mail) ."  <br />";
     148        }
     149     
     150        $infos_message .=  " " ;
     151}
     152// $infos_message .= $content ;
     153//=============================================================================
    131154if ($mails_options[check_header_text]=='on')   {
    132155
     
    145168 
    146169$ret=false;
    147        
     170
    148171            //======== Non mise en quarantaine =============
    149172                ob_start();
    150173                $ret = false;
    151174                 if ($nb_destinataires > 0) {
    152                    $ret = mail($mailto, $subject, $content, $headers);
    153 
     175                 // corrige erreur 'mail dropped, bare LF found'
     176                 $content = str_replace("\n.", "\n..", $content);
     177                 $headers = str_replace("\n.", "\n..", $headers);
     178                 $subject = str_replace("\n.", "\n..", $subject);
     179                 $mailto = str_replace("\n.", "\n..", $mailto);
     180             $ret = mail($mailto, $subject, $content, $headers);
     181       
    154182                        }else{
    155183                           $message .= l10n('Sv_no_receiver_available');
     
    204232
    205233                }
    206  $infos_message = l10n('Sv_mail_not_send');
     234 $infos_message .= l10n('Sv_mail_not_send');
    207235 
    208236 }                     
     
    219247    $match=array("<",">");
    220248    $string=array("&lt;","&gt;") ;       
    221 
    222249//Warning: mail() has been disabled for security reasons
    223250       
     
    229256                $pos1 = strpos(strtolower($message), 'bad recipient address syntax');
    230257                if (  !($pos1 === false) ){
    231                         $erreur_message .= l10n('Sv_detection_de').' : Bad recipient address syntax .';
     258                        $erreur_message .= l10n('Sv_detection_de').' Bad recipient address syntax .';
    232259                        $erreur_message .= l10n('Sv_verifiez_les_destinataires').' (Bcc,Cc,To)<br />';
    233260                        }       
    234261       
    235         $erreur_message .= sprintf(l10n('Sv_debug_message %s %s %s %s %s'),($ret==true)? "true" : "false",$message,$mailto,$headers,$nb_destinataires);
    236        //=============== La fonction mail à retourneeune erreur =========================               
     262        $erreur_message .= sprintf(l10n('Sv_debug_message'),
     263        ($ret==true)? "true" : "false",
     264        $message ,
     265        $mailto ,
     266        $headers ,
     267        $nb_destinataires );
     268       //=============== La fonction mail   retourneeune erreur =========================               
    237269
    238270                               
     
    260292
    261293                        }
    262  
    263  
    264 
    265  
    266294 $ret=true;
    267295 return $ret ;
     
    289317    include_once (MAIL_SUPERV_PATH.'include/fonctions.php');
    290318        $mails_options = explode("," , $conf['mail_superv']);
    291          
     319
    292320//==========================================================================================
    293321if ($mails_options[set_id]=='on'  ) {
     
    301329//Liableelard
    302330include_once (MAIL_SUPERV_PATH.'include/fonctions.php');
     331
    303332if ( isset($_POST['submit'])) {
    304333        $mail  =  $_POST['mail_address'] ;
     
    308337        $user_name = $user['username'];
    309338}
    310 $user_name =""; // suppression du test sur user name.
     339 $user_name =""; // suppression du test sur user name.
    311340 $ip='0';
     341 
    312342                if (test_spam($ip,$user_name ,$mail ))
    313343                 {
    314                  if (test_spam($ip,$user_name ,"" )) {
    315                   $err[] = $user_name . " ". l10n('Sv_is_a_login_spam')   ;
    316                 }else           
     344                 //if (test_spam($ip,$user_name ,"" )) {
     345                 // $err[] = $user_name . " ". l10n('Sv_is_a_login_spam')   ;
     346                // }else                 
    317347                    $err[] = $user_name . " : " .$mail . " ". l10n('Sv_is_a_spam')   ;
    318348                 }
     
    320350return $err ;
    321351}
     352
     353
    322354?>
Note: See TracChangeset for help on using the changeset viewer.