Changeset 11807


Ignore:
Timestamp:
Jul 21, 2011, 5:57:36 PM (13 years ago)
Author:
cljosse
Message:

[extensions] mail_supervisor add 'title' and subject in tab test

Location:
extensions/Mail_supervisor
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • extensions/Mail_supervisor/admin/mail_black_liste.tpl

    r10419 r11807  
    2323<input name="info1" type="hidden" />
    2424 <fieldset >
    25 <legend>{'Sv_black_liste'|translate}</legend>
     25<legend>{'Sv_set_black_liste'|translate}</legend>
    2626<table>
    2727 <td><input name="ip_black" id = "ip_black_test" type="text" value="{$ip_black}"     />
  • extensions/Mail_supervisor/admin/mail_superv_admin.php

    r10822 r11807  
    118118
    119119
     120
    120121$aff_nb=true;
    121122// *************************************************************************
     
    155156
    156157
    157     if ($mails_donnees['quarantaine'] == false)
    158     { $mails_donnees['reste'] = 0;
     158            if ($mails_donnees['quarantaine'] == false) {
     159              $mails_donnees['reste'] = 0;
    159160      $mails_donnees['date_quarantaine']=time();
    160161     }
    161162     $infos_message .=  l10n('Sv_refresh') .'<br />';
     163             echo "156 super_admin.php ";
    162164     mail_supervisor::sauve_donnees();
    163165     $aff_nb = false ;
    164 
    165 
    166     }
    167 
    168     if ( $_POST['submit'] == l10n('Sv_raz')   ) {
     166    }
     167
     168        if ( $_POST['submit'] == l10n('Sv_raz')   ) {
    169169      $mails_donnees['date_quarantaine']=time();
    170170      $mails_donnees['nb_mails'] = 0  ;
     
    178178    }
    179179
     180    if ( $_POST['submit'] == l10n('Sv_Valider') ) {
    180181  //===================================================================
    181     if ( $_POST['submit'] == l10n('Sv_Valider') ) {
    182182      $mails_options['check_mailto'] = isset($_POST['check_mailto']) ? $_POST['check_mailto'] : 'off' ;
    183183      $mails_options['check_header_carbon'] = isset($_POST['check_header_carbon']) ? $_POST['check_header_carbon'] : 'off' ;
    184184      $mails_options['check_header_text'] = isset($_POST['check_header_text']) ? $_POST['check_header_text'] : 'off' ;
     185      $mails_options['no_ipaddress'] = isset($_POST['no_ipaddress']) ? $_POST['no_ipaddress'] : 'off' ;
     186
    185187
    186188      //donnees
     
    194196      $mails_donnees['message'] = isset($_POST['content']) ? $_POST['content'] :  $mails_donnees['message']  ;
    195197      $mails_donnees['header_text'] = isset($_POST['header_text']) ? $_POST['header_text'] :  $mails_donnees['header_text']  ;
    196       //=======================================================================================================
     198      //=========================================================================
    197199      verif_mails_donnees();
    198200      mail_supervisor::sauve_options();
     
    216218                        'check_header_carbons' => ($mails_options['check_header_carbon'] == 'on') ? 'checked="checked"' : '' ,
    217219                        'check_header_text' => ($mails_options['check_header_text'] == 'on') ? 'checked="checked"' : '' ,
    218 
     220                        'no_ipaddress' => ($mails_options['no_ipaddress'] == 'on') ? 'checked="checked"' : '' ,
    219221
    220222                        'nb_mails' => $mails_donnees['nb_mails'] ,
     
    249251     $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    250252 break;
    251   // *************************************************************************
    252 //                        TEST                                             |
    253 // *************************************************************************
     253/*************************************************************************
     254*                     TEST                                             |
     255*************************************************************************/
    254256
    255257   case 'mail_superv_test':
     
    272274// info by email to an access granted group of category informations
    273275
    274 
    275 if (isset($_POST['Submit']) and !empty($_POST['group']))
    276 {
     276if (isset($_POST['Submit']) and !empty($_POST['group'])){
     277
    277278  set_make_full_url();
    278 
    279   /* TODO: if $category['representative_picture_id']
    280     is empty find child representative_picture_id */
    281 
    282 
    283     if (function_exists('get_user_language_desc') ) $titre = get_user_language_desc($conf['gallery_title']);
    284     else $titre=$conf['gallery_title'];
    285 
    286279    $message = empty($_POST['MAIL_CONTENT']) ? $mails_donnees['message_test'] : stripslashes($_POST['MAIL_CONTENT']);
    287 
    288  if (function_exists('get_user_language_desc') ) $message = get_user_language_desc($message);
     280    $titre=empty($_POST['titre'])?$mails_donnees['titre']: stripslashes($_POST['titre']);
     281    $sujet=empty($_POST['sujet'])?$mails_donnees['sujet']: stripslashes($_POST['sujet']);
     282
     283 if (function_exists('get_user_language_desc') ){
     284    $message = get_user_language_desc($message);
     285    $sujet = get_user_language_desc($sujet);
     286    $titre = get_user_language_desc($titre);
     287  }
     288
     289  $mails_donnees['message_test']= str_replace('"',"'",$message) ;     
     290  $mails_donnees['titre']= str_replace('"',"'",$titre) ;   
     291  $mails_donnees['sujet']= str_replace('"',"'",$sujet) ; 
     292
     293  if ( $_POST['Submit']!= l10n('Sv_refresh') ) {
     294  mail_supervisor::sauve_donnees();
     295      $modif=false ;
     296      } else{   
     297    $mails_donnees=mail_supervisor::Get_Datas();
     298    }
     299
    289300
    290301if ( $_POST['Submit']==l10n('Sv_Valider') ) {
    291   $mails_donnees['message_test']= str_replace('"',"'",$message) ;     
    292   mail_supervisor::sauve_donnees();
    293302  $mails_options['debug_mail'] = isset($_POST['debug_mail']) ? "on" : "off" ;
    294303  mail_supervisor::sauve_options();
    295304  $_POST['Submit']="";
    296305 }else if ( $_POST['Submit']==l10n('Sv_Envoyer') ) {
    297      /*
     306     /*************************************************************
    298307     * send en email to user's group
    299308     *
     
    308317     *
    309318     * @return boolean (Ok or not)
    310     */
     319     ************************************************************/
    311320    pwg_mail_group(
    312321            $_POST['group'],
    313322            get_str_email_format(true),
    314             get_l10n_args('[%s] %s', array($conf['gallery_title'],'Test Mail_supervisor') ), //sujet
     323            get_l10n_args('[%s] %s', array($conf['gallery_title'],$sujet) ), //sujet
    315324            MAIL_SUPERV_PATH_ABS . 'admin/cat_group_info',  // template
    316             array    ( 'titre' => 'Mail_supervisor',
     325            array    ( 'titre' => $titre,
    317326                       'CPL_CONTENT' => $message,
    318327                       'signature' => $user['username']
     
    350359  $result = pwg_query($query);
    351360//----------------------------------------------------------------
    352   while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
    353   {    $groups[$row['id']] = $row['name'];  }
     361  while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {   
     362  $groups[$row['id']] = $row['name'];  }
    354363 //---------------------------------------------------------------
    355364if ( isset($_POST['Submit'])) $group_id=-1;
     
    385394                        'MAIL_SUPERV_PATH_ABS' => MAIL_SUPERV_PATH_ABS,
    386395                        'MAIL_SUPERV_PATH' => MAIL_SUPERV_PATH ,
     396                        'sujet' => $mails_donnees['sujet'],
     397                        'titre' =>  $mails_donnees['titre']
    387398                        )
    388399                    );
     
    486497                        'REGION' =>  $region ,
    487498                        'version' =>     $version ,
    488                         'MAIL_SUPERV_PATH_ABS' => MAIL_SUPERV_PATH_ABS,
     499                'MAIL_SUPERV_PATH_ABS' => MAIL_SUPERV_PATH_ABS
    489500
    490501                    )
     
    522533 //====================================================================
    523534  }
    524 //================================================================================
    525 
    526 
    527 
    528535    if  ( $mails_donnees['reste'] < 0 ) {
    529536        $mails_donnees['quarantaine'] =false ;
     
    548555       $modif = true ;
    549556    }
     557    //======================================================
    550558    if ( $modif == true )   {
    551559                mail_supervisor::sauve_donnees();
    552560                $modif = false ;
    553561        }
    554 
     562   //======================================================
    555563        if ($aff_nb == true) {
    556564         $infos_message .= 'Mails    : '.$mails_donnees['nb_mails']. '  \\  ' . $mails_donnees['nb_mails_maxi'];
  • extensions/Mail_supervisor/admin/mail_superv_admin.tpl

    r10419 r11807  
    1414
    1515    <table>
    16 <tr><td><input type="checkbox" name="check_mailto" value="on" {$check_mailto} />&nbsp;{'Sv_check_mailto'|translate}</td><td><input type="checkbox" name="check_header_carbon" value="on" {$check_header_carbons} />&nbsp;{'Sv_check_header_carbon'|translate}</td>
    17   { if  $PHPWG_VERSION <= '2.0.4' }
    18 <td><input type="checkbox" name="check_header_text" value="on" {$check_header_text} />&nbsp;
     16<tr>
     17<td><input type="checkbox" name="check_mailto" value="on" {$check_mailto} />&nbsp;{'Sv_check_mailto'|translate}</td>
     18<td><input type="checkbox" name="check_header_carbon" value="on" {$check_header_carbons} />&nbsp;{'Sv_check_header_carbon'|translate}</td>
     19 <td><input type="checkbox" name="no_ipaddress" value="on" {$no_ipaddress} />&nbsp;{'Sv_no_ipaddress'|translate}</td>
     20  { if  $PHPWG_VERSION <= '2.0.4' }
     21<td><input type="checkbox" name="check_header_text" value="off" {$check_header_text} />&nbsp;
    1922{'Sv_check_header_text'|translate}</td>
    2023<td><input type="text" name="header_text"  value={$header_text} /></td>
  • extensions/Mail_supervisor/admin/mail_superv_test.tpl

    r10822 r11807  
    2424      <td  >
    2525          {if not empty($liste)}
    26            
    2726         {foreach from=$liste item=group name=group_loop }
    28          
    2927          {$group.username}&lt{$group.email}><br />
    3028         {/foreach}
     
    3533    <table>
    3634    <tr>
    37       <td><strong>{'Sv_mail_content'|@translate}</strong></td>
    38       <td>
     35        <td style="width:30%">
     36          <span>{'subject'|@translate} </span> <input type="text" name="sujet" value="{$sujet}" size="60" ></input> </td>
     37        <td style="width:30%">
     38          <span>{'title'|@translate}</span>  <input type="text" name="titre" value="{$titre}" size="60"></input> </td>
     39      </tr>
     40    </table>
     41      <table>
     42    <tr><td><strong>{'Sv_mail_content'|@translate}</strong></td><td>
    3943        <textarea name="MAIL_CONTENT" id="MAIL_CONTENT" class="description">{$MAIL_CONTENT}</textarea>
    4044      </td>
  • extensions/Mail_supervisor/include/Scripts.js

    r10816 r11807  
    22 var revHeader = document.getElementById(headerId);
    33 var revContent = document.getElementById(contentId);
    4 
     4 if (revContent==null ) return;
    55 if (revContent.style.display == 'none') {
    66  revContent.style.display = 'block';
  • extensions/Mail_supervisor/include/constants.php

    r10419 r11807  
    2222  "message_test",
    2323  "header_text",
     24  "sujet",
     25  "titre"
    2426        );
    2527
     
    4042                    "TEXT"  ,
    4143                    "TEXT"  ,
    42 
     44                    "TEXT" ,
     45                    "TEXT"
    4346                    );
    4447
  • extensions/Mail_supervisor/include/fonctions.php

    r10816 r11807  
    118118   '"'.l10n('Sv_supervisor').'"',
    119119    '"'.l10n('hello').'"',
     120        '"Test Mail_supervisor"',
     121        '"Information"'
    120122     );
    121123    ajout_ligne(mail_superv_TABLE,$superv_champs, $valeurs,false ) ;
    122124}
    123 //=================================================================================
    124 
    125 
    126125//=========================================
    127126function Get_colonnes_de($table)
     
    137136  return $columns_of;
    138137}
    139 
     138//=========================================
    140139function get_liste($group_id){
    141140global $conf ;
     
    196195
    197196}
    198 function ajust_table($nom_table,$champs,$types)  //mail_superv_TABLE
    199 {
     197//===========================================================
     198function ajust_table($nom_table,$champs,$types){  //mail_superv_TABLE
    200199global $infos_message ;
    201200$colonnes = Get_colonnes_de($nom_table);
     
    203202    $i=0;
    204203    $valeurs=array();
    205 foreach ( $champs as $champ)
    206    {
     204    foreach ( $champs as $champ) {
    207205     $champ = trim($champ);
    208206      if (!in_array( $champ,$colonnes)) {
     
    238236        $count = 0 ;
    239237}
    240 
    241   if ($count == 0)
    242   {
     238$data=array();
     239
     240  $query = " SELECT *    FROM `".$nom_table."`        ;";   
     241      $datas = pwg_query($query);
     242    if (!empty($datas)) {
     243    while ($row = mysql_fetch_array($datas,MYSQL_ASSOC)){
     244    array_push($data,$row);   
     245    }
     246  }
     247$count=  count($data);
     248  if ($count == 0) {
    243249      $n_champs=implode(",",$champs);
    244250      $n_valeurs=implode(",",$valeurs);
     
    248254
    249255        if (pwg_query($query)) return ;
    250         die($query);
    251 
    252   }
     256        die("fonction.php 256".$query);
     257
     258  }
     259 
    253260}
    254261//=====================================================================
     
    487494                       pwg_query($query );
    488495            }
    489          $erreur_message .= $pays . $ip ." <br />User Name :".$user['username']."<br />User Mail :".$user['email'] . ' -----> ' . l10n('Sv_black_liste') ;
     496         $erreur_message .= $pays . $ip ." <br />User Name :".$user['username']."<br />User Mail :".$user['email'] . ' -----> ' . l10n('Sv_set_black_liste') ;
    490497       // die($nb." ".$ip." ".$user['username']." ".$user['email']);
    491498
  • extensions/Mail_supervisor/language/en_UK/plugin.lang.php

    r10822 r11807  
    11<?php
    22global $lang ;
     3$lang['Sv_no_ipaddress']="rename local ip adresse to localhost";
     4$lang['subject']="Subject";
    35//===================================================
    46if( !isset($lang['Minute'])) $lang['Minute'] =   l10n('Minute') ;
     
    3941$lang['Sv_IP_adress'] = 'Your IP address';
    4042$lang['Sv_liste_ip']="IP list (history)";
    41 $lang['Sv_black_liste']="IP blacklisting";
     43$lang['Sv_set_black_liste']="IP blacklisting";
    4244$lang['Sv_blackliste']="Blacklisting";
    4345
     
    6365$lang['Sv_check_mailto'] = 'If the "To" field in the mail heading is empty, send a copy to the Webmaster.';
    6466$lang['Sv_check_header_carbon'] = 'Change the Bcc, Cc in the header';
    65 $lang['Sv_check_header_text'] = 'Add a "text" block in the mail header.';
     67$lang['Sv_check_header_text'] = 'Format text.';
    6668
    6769$lang['Sv_admin'] = 'Exclude administrator from mailings.';
     
    116118$lang['Sv_debug_message']=  '<div style="border: 1px solid red; color: green;">
    117119    '.$ms_f1.' :<div style="background-color:white;color: black;"> %s </div>
    118     '.$ms_f2.' :<div style="background-color:white; color: black;"> %s </div>
     120    '.$ms_f2.' :<div style="background-color:white; color: black;"> %s&nbsp; </div>
    119121    '.$ms_f3.' :<div style="background-color:white; color: black;"> %s </div>
    120122    '.$ms_f4.' :<div style="background-color:white; color: black;"> %s </div>
  • extensions/Mail_supervisor/language/fr_FR/plugin.lang.php

    r10822 r11807  
    11<?php
    22global $lang ;
     3$lang['Sv_no_ipaddress']="renomme Ip local en localhost";
     4$lang['subject']="Sujet";
    35//===================================================
    46if( !isset($lang['Minute'])) $lang['Minute'] =   l10n('Minute') ;
     
    4244$lang['Sv_IP_adress'] = 'Votre adresse IP';
    4345$lang['Sv_liste_ip']="Liste des IP (historique)";
    44 $lang['Sv_black_liste']="Liste noire des IP";
     46$lang['Sv_set_black_liste']="Liste noire des IP";
    4547$lang['Sv_blackliste']="Liste noire";
    4648
     
    6668$lang['Sv_check_mailto'] = 'Si le champ "To" dans l\'entête est vide, envoyer une copie vers le WebMaster.';
    6769$lang['Sv_check_header_carbon'] = 'Modifier le code  Bcc , Ccc   dans le header';
    68 $lang['Sv_check_header_text'] = 'Ajouter un bloc "texte" dans l\'entête du mail.';
     70$lang['Sv_check_header_text'] = 'Envoie en format texte.';
    6971
    7072$lang['Sv_admin'] = 'Exclure l\'administrateur des envoies.';
     
    118120$lang['Sv_debug_message']=  '<div style="border: 1px solid red; color: green;">
    119121    '.$ms_f1.' :<div style="background-color:white;color: black;"> %s </div>
    120     '.$ms_f2.' :<div style="background-color:white; color: black;"> %s </div>
     122    '.$ms_f2.' :<div style="background-color:white; color: black;"> %s&nbsp; </div>
    121123    '.$ms_f3.' :<div style="background-color:white; color: black;"> %s </div>
    122124    '.$ms_f4.' :<div style="background-color:white; color: black;"> %s </div>
  • extensions/Mail_supervisor/mail_super.inc.php

    r10822 r11807  
    3939 */
    4040 static public function init() {
    41   global  $template,$version,$icon_path;
     41  global  $template,$version,$icon_path,$page;
    4242  $action_spam = pwg_get_session_var('action_spam') ;
    4343  $theme="default";
     
    230230    }
    231231  //==========================================================
    232   function Get_Options($parametres,$str_index){
    233     global $conf,$mails_options ;
     232  function Get_Options(&$parametres,$str_index){
     233    global $conf ;
    234234    $mails_options=  $conf[$str_index];
    235235     if(isset($mails_options))
     
    238238       else{
    239239         $parametres=explode(",",$mails_options);
    240 
     240        }     
     241        //====== par defaut =======================
     242         $new_val=false;
    241243        $def_para->check_mailto="on";
    242244        $def_para->check_header_carbon="on";
    243         $def_para->check_header_text="on";
     245        $def_para->check_header_text="off";
     246        $def_para->no_ipaddress="off";  // interdiction adresse ip
     247
    244248        $def_para->no_mail_list="on";
    245249        $def_para->no_connect="on"; // empeche l'ip de se connecter au site.
    246250        $def_para->set_auto="on";       // Test a l'ouverture et enregistrement
    247         $def_para->ip="127.0.0.1";      // dernièrre adresse IP
     251        $def_para->ip="127.0.0.1";      // derniére adresse IP
    248252        $def_para->set_id="on";       // enregistrment nouvel
    249253        $def_para->debug_mail="off";       // debogage
    250         $i=0;
    251254        foreach ($def_para as $key => $value) {
    252             $value=$parametres[$i];
    253             unset( $parametres[$i]) ;
    254             $parametres[$key]= $value  ;
    255             $i++;
     255          if(isset($parametres[$key])){
     256              $value=$parametres[$key];
     257           } else {
     258              $new_val=true;
    256259        }
    257       }
    258     return mail_supervisor::Set_Options($parametres,$str_index);
     260           $new_val= isset($_POST[$key]) && $new_val ;
     261            unset( $parametres[$key]) ;
     262            $parametres[$key]= (isset($_POST[$key]))? "on" : $value ;       
     263        }
     264
     265        if($new_val){
     266            sauve_options();
     267      }
     268    return $parametres ;
    259269  }
    260270  //==========================================================
     
    269279  //==========================================================
    270280function sauve_options(){
    271 global $options,$infos_message,$conf,$mails_options  ;
    272 $infos_message .=l10n("save_config")."<br>";
    273  $mails_parametres=mail_supervisor::Set_Options($mails_options,"mail_superv");
     281  global $options,$infos_message,$conf,$mails_options  ;
     282  $infos_message .=l10n("save_config")."<br>";
     283  $mails_parametres=mail_supervisor::Set_Options($mails_options,"mail_superv");
    274284
    275285 if ( isset($mails_parametres) )
     
    284294 }
    285295
    286   //=================================================================================
     296 /****************************************
     297 * sauve_donnees()
     298 ****************************************/
    287299  function sauve_donnees(){
    288300  global $mails_donnees,$superv_champs,$superv_type,$erreur_message ;
     
    291303  $valeurs = array();
    292304  foreach ( $clefs as $champ){
    293         $champ = trim($champ);
     305     $champ = trim($champ);
     306        if($champ !="id")
    294307        if ( isset($mails_donnees[  $champ ]) ) {
    295308          $sep= (is_string($mails_donnees[ $champ ])) ? '"' : '' ;
     
    299312        }
    300313      }
     314
    301315  $valeurs = implode(", ",$valeurs) ;
    302316  //=====================================================================
     
    307321          ;
    308322  ob_start();
    309   $ret=  pwg_query($query)    ;
    310   $m= ob_get_contents();
     323      $ret=  pwg_query($query)    ;
     324      $m= ob_get_contents();
     325      if($m!="") $m="Mail_super.inc.php sauve_donnees() l:323<br />".$m;
    311326  ob_end_clean() ;
    312327  $erreur_message .= $m ;
     
    315330  function Get_Datas(){
    316331    global $superv_champs ;
     332     verif_base();
    317333    $champs = implode(",",$superv_champs );
    318334      $query = "SELECT ".$champs."
     
    320336      ;";
    321337        $result = @pwg_query($query);
     338           
    322339    if (!$result) {
    323340            verif_base();
  • extensions/Mail_supervisor/main.inc.php

    r10822 r11807  
    2222add_event_handler('get_admin_plugin_menu_links', array(&$mail_supervisor,'admin_menu')  );
    2323
    24 $mails_options = mail_supervisor::Get_Options($mails_options,"mail_superv");
     24mail_supervisor::Get_Options($mails_options,"mail_superv");
     25
    2526/* EVENT_HANDLER_PRIORITY_NEUTRAL  */
    2627//
     
    2829include_once (PHPWG_ROOT_PATH.'include/functions_mail.inc.php' );
    2930include_once (MAIL_SUPERV_PATH.'include/fonctions.php');
    30 //===============loc_begin_index====loc_begin_page_header==========loc_after_page_header=============================================================
     31//===============loc_begin_index
     32//====           loc_begin_page_header
     33//==========     loc_after_page_header
    3134add_event_handler('loc_after_page_header',  array(&$mail_supervisor,'init')  );
    3235add_event_handler('loc_begin_page_tail',  array(&$mail_supervisor,'affiche_message')  );
    3336
     37include_once(MAIL_SUPERV_PATH.'mail_send.inc.php');
     38$clj = new clj();
     39
     40add_event_handler('send_mail',array(&$clj,'send_mail'),EVENT_HANDLER_PRIORITY_NEUTRAL - 1, 6);
     41add_event_handler('send_mail_to',array(&$clj,'send_mail_to') );
     42add_event_handler('send_mail_subject',array(&$clj,'send_mail_subject') );
     43add_event_handler('send_mail_content',array(&$clj,'send_mail_content') );
     44add_event_handler('send_mail_headers',array(&$clj,'send_mail_headers'),EVENT_HANDLER_PRIORITY_NEUTRAL,6 );
     45
    3446//==========================================================================================
    35 add_event_handler('send_mail', 'clj_mail',EVENT_HANDLER_PRIORITY_NEUTRAL - 10, 6);
    36 function clj_mail($result, $mailto, $subject, $content, $headers, $args) {
     47//add_event_handler('send_mail', 'clj_send_mail',EVENT_HANDLER_PRIORITY_NEUTRAL - 10, 6);
     48
     49function clj_send_mail($result, $mailto, $subject, $content, $headers, $args) {
    3750  global $conf, $user, $lang_info;
    3851  global $conf_mail,$mails_options,$mails_donnees ;
     
    4053  global $errors;
    4154  // lecture config table -------------
     55 
     56
    4257  include_once (MAIL_SUPERV_PATH.'include/fonctions.php');
    4358  load_language('plugin.lang', MAIL_SUPERV_PATH);
     
    173188    }
    174189   
    175      $pattern = '/(http:\/\/)([0-9].*)([0-9]\/)/';
    176      //---- si adresse avec ip , certaine boite aux lettres traite ces messages en spam (orange+windowsmail)
    177   if(preg_match($pattern, $content)){
    178       // remplace 192.168.1.25 par rien ??
    179       $replacement = '${1}';
    180       $content = preg_replace( $pattern, $replacement,  $content );     
    181 }
    182 
    183       $content= preg_replace('#(?<!\r)\n#si', "\r\n", $content); //drop LF barre
    184 
     190     //======================================================
     191     // si adresse avec ip , certaine boite aux lettres traite ces messages
     192     //  en spam (orange+windowsmail)
     193     //======================================================
     194      if ( $mails_options['no_ipaddress'] == 'on' ){   
     195        $pattern ="/(http:\/\/)(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]|[1-9])\.){1}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9])\.){2}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9]){1}))/" ;       
     196        if(preg_match($pattern, $content)){
     197          $replacement = "http://localhost";
     198          $content = preg_replace( $pattern, $replacement,  $content );     
     199        }
     200      }
     201      //======================================================
     202      // drop LF barre 
     203      //======================================================
     204      $pattern="/xxxxx/";
     205      if(  preg_match($pattern, $mailto) ||  preg_match($pattern, $headers) ){
     206        $pattern="---=";
     207        $pattern ="/" . preg_quote($pattern, '/')."/" ;
     208
     209      // site legtux ; adresse @lextux OK
     210       //  $content=$content                                          // Ok legtux
     211       //  $content= preg_replace('#(?<!\r)\n#si', "\n", $content); // Ok legtux
     212
     213        $pattern ="#(?<!\r)\n#si" ;
     214        if(  preg_match($pattern, $content)  ){
     215            $infos_message .= $pattern. " <br />";   
     216        }
     217       
     218        $content= preg_replace('#(?<!\r)\n#si', "\r\n", $content);   // 
     219        $content = str_replace("\n.", "\n..", $content);
     220
     221    $message = "<h2>local</h2> ";
     222    $nheaders = 'From: cl_josse@orange.fr' . "\r\n" .
     223    'Reply-To: cl_josse@orange.fr' . "\r\n" .
     224    'X-Mailer: PHP/' . phpversion();
     225
     226
     227     mail("cl_josse@hotmail.fr", $subject, "Test1  ".$message);
     228  mail("cl_josse@hotmail.fr", $subject,"TEST 2 ". $message,$nheaders);
     229
     230     return true ;
     231
     232
     233
     234
     235       if(  preg_match($pattern, $content)  ){
     236            $infos_message .= "OK". " <br />";   
     237        }
     238
     239      }else{
     240          $pattern="/hotmail/";
     241          if(  preg_match($pattern, $mailto) ||  preg_match($pattern, $headers) ){
     242             // 
     243          }else{
     244            $pattern="/free.fr|club/";
     245            if(  preg_match($pattern, $mailto) ||  preg_match($pattern, $headers) ){
     246                $content= preg_replace('#(?<!\r)\n#si', "\r\n", $content); //drop LF barre   
     247            }else{
     248               
     249            }
     250          }
     251      }
     252
     253  //=====================================================================
    185254    if (!preg_match('/'. $conf_mail['boundary_key'] .'/', $headers)){
    186255        $erreur_message .=   "<br />ERREUR manque : boundary_key dans le headers <br />";
    187256        $infos_message = l10n('Sv_mail_not_send');
    188257        $envoie_ok= false ;
    189     }
    190             $ret=false; 
     258        return false ;
     259
     260    }
     261  //=====================================================================
     262            $ret="false"; 
    191263             ob_start();
    192264            //======== Non mise en quarantaine =============
     
    195267         
    196268              if ($nb_destinataires > 0) {
    197                 if( $envoie_ok)  $ret = mail($mailto, $subject,$content, $headers);
     269                if( $envoie_ok) {
     270                  $ret = mail($mailto, $subject,$content, $headers);   
     271                }
    198272              }else{
    199273                $message .= l10n('Sv_no_receiver_available');
     
    204278              trigger_event('mail_supervisor_mail', $arg_trigg );
    205279              $mails_donnees['message']=$message;
    206               Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content);
     280              $ret= Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content);
    207281            } else {
    208282                //================== Est en quarantaine =======================
     283               
    209284                $erreur_message .=  l10n('Sv_To_day_is')."<br />";
    210285                if ($alerte_spam ) {
     
    237312                $erreur_message .='<br />'.sprintf(l10n('Sv_mise_en_quarantaine %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'<br />';
    238313            }
     314                $ret = "Error ". $type." : ";
     315                $ret .=  l10n('Sv_mail_not_send');
     316               
    239317            $infos_message .= l10n('Sv_mail_not_send');
    240318            }
     
    244322    mail_supervisor::affiche_message();
    245323   
    246     return true ;
     324    return $ret  ;//
    247325}
    248326//===========================================================================================
     
    255333    $est_un_spam =!(strpos(strtolower($message), 'spam') === false); 
    256334    if ( ($ret==false) || ($est_un_spam==true) || ($nb_destinataires == 0) ) {
     335     //=============== La fonction mail retourne une erreur =========================
     336        $ret="Error";
    257337        // Bad recipient address syntax
    258338        $pos1 = strpos(strtolower($message), 'bad recipient address syntax');
     
    261341            $erreur_message .= l10n('Sv_verifiez_les_destinataires').' (Bcc,Cc,To)<br />';
    262342            }               
    263 
    264     $erreur_message .=sprintf(l10n('Sv_debug_message'),
     343        $erreur_message .=$ret . " : <br />".sprintf(l10n('Sv_debug_message'),
    265344                              ($ret==true)? "true" : "false",
    266345                              htmlspecialchars($message) ,
     
    272351
    273352     Mail_supervisor_log($mailto,$erreur_message) ;   
    274      //=============== La fonction mail retourne une erreur =========================
    275       }else{
    276353           
     354      }else{           
    277355    if( isset($mails_options['debug_mail']) && $mails_options['debug_mail']=="on") {
    278         $erreur_message .="DEBUG : <br />" .sprintf(l10n('Sv_debug_message'),
    279                                   "DEBUG",
     356              $infos_message .="DEBUG : <br />" .sprintf(l10n('Sv_debug_message'),
     357                                  ($ret==true)? "true" : "false",
    280358                                  htmlspecialchars( $message) ,
    281359                                  htmlspecialchars( $mailto) ,
     
    285363                                  $nb_destinataires );
    286364
    287          Mail_supervisor_log($mailto,$erreur_message) ;
    288         }
    289       }
    290 
     365               Mail_supervisor_log($mailto,$infos_message) ;
     366        }
     367      }
     368      //=================================================================
    291369
    292370
     
    295373                $mails_donnees['nb_mails'] += $nb_destinataires;
    296374            } else {
     375                $ret="Error spam";
    297376                $mails_donnees['nb_spams'] += $nb_destinataires;
    298377                //--- Detection de spam ------------------
     
    308387                    }
    309388            }
    310  $ret=true;
    311389 return $ret ;
    312390}
     
    361439
    362440/*
    363  *
     441 * sends an email, using Piwigo specific informations
    364442 *
    365443 * @param:
    366  *    
     444 *   - to: receiver(s) of the mail (list separated by comma).
    367445 *   - args: function params of mail function:
    368446 *       o from: sender [default value webmaster email]
     
    377455 * @return boolean (Ok or not)
    378456 */
    379 function cl_pwg_mail(  $args = array())
    380 {
    381   global $conf, $conf_mail, $lang_info, $page;   
    382   global $erreur_message ;
    383   if (!isset($conf_mail)) {
     457function cl_pwg_mail($to, $args = array()){
     458  global $conf, $conf_mail, $lang_info, $page;
     459  if (empty($to) and empty($args['Cc']) and empty($args['Bcc'])) {
     460    return true;
     461  }
     462  if (!isset($conf_mail))  {
    384463    $conf_mail = get_mail_configuration();
    385464  }
    386   if (empty($args['email_format']))  {
     465  if (empty($args['email_format'])) {
    387466    $args['email_format'] = $conf_mail['default_email_format'];
    388467  }
    389468  // Compute root_path in order have complete path
    390   set_make_full_url();
    391   if (!isset($args['content'])) {
     469  set_make_full_url();
     470  if (empty($args['from']))  {
     471    $args['from'] = $conf_mail['formated_email_webmaster'];
     472  }  else  {
     473    $args['from'] = format_email('', $args['from']);
     474  }
     475  if (empty($args['subject']))  {
     476    $args['subject'] = 'Piwigo';
     477  }
     478  // Spring cleaning
     479  $cvt_subject = trim(preg_replace('#[\n\r]+#s', '', $args['subject']));
     480  // Ascii convertion
     481  $cvt_subject = encode_mime_header($cvt_subject);
     482
     483  if (!isset($args['content']))  {
    392484    $args['content'] = '';
    393485  }
     486
    394487  if (empty($args['content_format']))  {
    395     $args['content_format'] = 'text/plain';  }
     488    $args['content_format'] = 'text/plain';
     489  }
     490
     491  if ($conf_mail['send_bcc_mail_webmaster'])  {
     492    $args['Bcc'][] = $conf_mail['formated_email_webmaster'];
     493  }
     494
    396495  if (empty($args['theme']))  {
    397496    $args['theme'] = get_default_theme();
    398497  }
     498
     499  $headers = 'From: '.$args['from']."\n";
     500  $headers.= 'Reply-To: '.$args['from']."\n";
     501
     502  if (!empty($args['Cc']))  {
     503    $headers.= 'Cc: '.implode(',', $args['Cc'])."\n";
     504  }
     505
     506  if (!empty($args['Bcc']))  {
     507    $headers.= 'Bcc: '.implode(',', $args['Bcc'])."\n";
     508  }
     509
     510  $headers.= 'Content-Type: multipart/alternative;'."\n";
     511  $headers.= '  boundary="---='.$conf_mail['boundary_key'].'";'."\n";
     512  $headers.= '  reply-type=original'."\n";
     513  $headers.= 'MIME-Version: 1.0'."\n";
     514  $headers.= 'X-Mailer: Piwigo Mailer'."\n";
    399515
    400516  // List on content-type
     
    403519    $content_type_list[] = $conf_mail['alternative_email_format'];
    404520  }
     521
    405522  $content = '';
    406   foreach (array_unique($content_type_list) as $content_type)
    407   {
     523
     524  foreach (array_unique($content_type_list) as $content_type)  {
    408525    // key compose of indexes witch allow ti cache mail data
    409526    $cache_key = $content_type.'-'.$lang_info['code'].'-'.$args['theme'];
    410     unset($conf_mail[$cache_key]);
    411     if (!isset($conf_mail[$cache_key])){
    412       if (!isset($conf_mail[$cache_key]['theme'])){
     527
     528    if (!isset($conf_mail[$cache_key]))    {
     529      if (!isset($conf_mail[$cache_key]['theme']))      {
    413530        $conf_mail[$cache_key]['theme'] = get_mail_template($content_type, $args['theme']);
    414531      }
     532
    415533      $conf_mail[$cache_key]['theme']->set_filename('mail_header', 'header.tpl');
    416534      $conf_mail[$cache_key]['theme']->set_filename('mail_footer', 'footer.tpl');
     535
    417536      $conf_mail[$cache_key]['theme']->assign(
    418537        array(
     
    434553          ));
    435554
    436       if ($content_type == 'text/html'){
    437         if ($conf_mail[$cache_key]['theme']->smarty->template_exists('global-mail-css.tpl')){
     555      if ($content_type == 'text/html')     {
     556        if ($conf_mail[$cache_key]['theme']->smarty->template_exists('global-mail-css.tpl'))
     557        {
    438558          $conf_mail[$cache_key]['theme']->set_filename('css', 'global-mail-css.tpl');
    439559          $conf_mail[$cache_key]['theme']->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css');
     
    441561
    442562        $file = PHPWG_ROOT_PATH.'themes/'.$args['theme'].'/mail-css.tpl';
    443         if (is_file($file)){
     563        if (is_file($file))   {
    444564          $conf_mail[$cache_key]['theme']->set_filename('css', realpath($file));
    445565          $conf_mail[$cache_key]['theme']->assign_var_from_handle('MAIL_CSS', 'css');
    446566        }
    447       } 
     567      }
    448568
    449569      // what are displayed on the header of each mail ?
     
    457577
    458578    // Header
    459    $content.= $conf_mail[$cache_key]['header'];
    460        // Content
    461     if (($args['content_format'] == 'text/plain') and ($content_type == 'text/html')){
     579    $content.= $conf_mail[$cache_key]['header'];
     580
     581    // Content
     582    if (($args['content_format'] == 'text/plain') and ($content_type == 'text/html'))    {
    462583      $content.= '<p>'.
    463584                  nl2br(
     
    466587                                 htmlspecialchars($args['content']))).
    467588                  '</p>';
    468     } else if (($args['content_format'] == 'text/html') and ($content_type == 'text/plain')) {
     589    }
     590    else if (($args['content_format'] == 'text/html') and ($content_type == 'text/plain'))
     591    {
    469592      // convert html text to plain text
    470593      $content.= strip_tags($args['content']);
    471     } else {
     594    }    else    {
    472595      $content.= $args['content'];
    473596    }
    474597
    475     // Footer 
    476     $content.= $conf_mail[$cache_key]['footer']."\n\n";
    477    
    478     // Close boundary
    479     $content.= "\n\n".'-----='.$conf_mail['boundary_key'].'--'."\n\n";
    480   }
     598    // Footer
     599    $content.= $conf_mail[$cache_key]['footer'];
     600
     601  // Close boundary
     602  $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'."\n";
     603  }
     604
     605  //~ // Close boundary
     606  //~ $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'."\n";
     607
    481608   // Undo Compute root_path in order have complete path
    482   unset_make_full_url();
    483 
    484 
    485 
    486   return    $content;
    487  
     609  unset_make_full_url();
     610
     611  return
     612    trigger_event('send_mail',
     613      false, /* Result */
     614      trigger_event('send_mail_to', get_strict_email_list($to)),
     615      trigger_event('send_mail_subject', $cvt_subject),
     616      trigger_event('send_mail_content', $content),
     617      trigger_event('send_mail_headers', $headers),
     618      $args
     619    );
    488620}
    489621
     622
    490623?>
  • extensions/Mail_supervisor/maintain.inc.php

    r10822 r11807  
    3131    $my_para['check_mailto']="on";
    3232    $my_para['check_header_carbon']="on";
    33     $my_para['check_header_text']="on";
     33    $my_para['check_header_text']="off";
     34    $my_para['no_ipaddress']="off";  // interdiction adresse ip
     35
    3436    $my_para['no_mail_list']="on";
    3537    $my_para['no_connect']="off";   // empeche l'ip de se connecter au site.
    3638    $my_para['set_auto']="on";      // Test a l'ouverture et enregistrement
    37     $my_para['ip']="127.0.0.1";     // dernièrre adresse IP
     39    $my_para['ip']="127.0.0.1";     // derniere adresse IP
    3840    $my_para['set_id']="on";          // enregistrment nouvel
    3941    $my_para['debug_mail']="off";    // debogage
Note: See TracChangeset for help on using the changeset viewer.