Changeset 11835
- Timestamp:
- Jul 26, 2011, 12:42:48 PM (13 years ago)
- Location:
- extensions/Mail_supervisor
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Mail_supervisor/admin/mail_superv_admin.php
r11807 r11835 182 182 $mails_options['check_mailto'] = isset($_POST['check_mailto']) ? $_POST['check_mailto'] : 'off' ; 183 183 $mails_options['check_header_carbon'] = isset($_POST['check_header_carbon']) ? $_POST['check_header_carbon'] : 'off' ; 184 $mails_options['check_ header_text'] = isset($_POST['check_header_text']) ? $_POST['check_header_text'] : 'off' ;184 $mails_options['check_send_webmaster'] = isset($_POST['check_send_webmaster']) ? $_POST['check_send_webmaster'] : 'off' ; 185 185 $mails_options['no_ipaddress'] = isset($_POST['no_ipaddress']) ? $_POST['no_ipaddress'] : 'off' ; 186 186 … … 203 203 $infos_message = l10n('Sv_save_config') . " : " . l10n('Sv_Datas') . "<br />" ; 204 204 $erreur_message = ""; 205 $mails_donnees = mail_supervisor::Get_Datas() ;205 206 206 } 207 207 } … … 217 217 'check_mailto' => ($mails_options['check_mailto'] == 'on') ? 'checked="checked"' : '' , 218 218 'check_header_carbons' => ($mails_options['check_header_carbon'] == 'on') ? 'checked="checked"' : '' , 219 'check_ header_text' => ($mails_options['check_header_text'] == 'on') ? 'checked="checked"' : '' ,219 'check_send_webmaster' => ($mails_options['check_send_webmaster'] == 'on') ? 'checked="checked"' : '' , 220 220 'no_ipaddress' => ($mails_options['no_ipaddress'] == 'on') ? 'checked="checked"' : '' , 221 221 … … 492 492 'set_auto' => ($mails_options['set_auto'] == 'on') ? 'checked="checked"' : '' , 493 493 'set_id' => ($mails_options['set_id'] == 'on') ? 'checked="checked"' : '' , 494 494 495 'IP' => $ip , 495 496 'PAYS' => $pays , -
extensions/Mail_supervisor/admin/mail_superv_admin.tpl
r11807 r11835 18 18 <td><input type="checkbox" name="check_header_carbon" value="on" {$check_header_carbons} /> {'Sv_check_header_carbon'|translate}</td> 19 19 <td><input type="checkbox" name="no_ipaddress" value="on" {$no_ipaddress} /> {'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} /> 22 {'Sv_check_header_text'|translate}</td> 23 <td><input type="text" name="header_text" value={$header_text} /></td> 20 21 <td><input type="checkbox" name="check_send_webmaster" value="off" {$check_send_webmaster} /> 22 {'Sv_check_send_webmaster'|translate}</td> 23 { if $PHPWG_VERSION <= '2.0.4' } 24 <td><input type="text" name="header_text" value={$header_text} /></td> 24 25 {/if} 25 26 </tr> -
extensions/Mail_supervisor/admin/mail_superv_help.tpl
r10419 r11835 55 55 <li>{'Sv_hlp_2_2'|translate}</li> 56 56 </ul> 57 <li><span class="throw">{'Sv_check_ header_text'|translate}</span> </li>57 <li><span class="throw">{'Sv_check_send_webmaster'|translate}</span> </li> 58 58 <ul> 59 59 <li>{'Sv_hlp_2_3'|translate}</li> -
extensions/Mail_supervisor/include/fonctions.php
r11811 r11835 31 31 global $lang ; 32 32 global $template ; 33 33 34 //=============================================== 34 35 function corrige_header($Carbonne,$headers,$args,$cl_list_mail,$mailto="") { -
extensions/Mail_supervisor/language/en_UK/help/plugin.lang.php
r9397 r11835 19 19 $lang['Sv_Options']='Options'; 20 20 21 $lang['Sv_hlp_2_1']='Send a copy of the mail to the Webmaster .';21 $lang['Sv_hlp_2_1']='Send a copy of the mail to the Webmaster if Maito is empty.'; 22 22 $lang['Sv_hlp_2_2']='Change Cc addressees structure if default \'bad syntax\''; //Didn't understand this one :-/ 23 $lang['Sv_hlp_2_3']=' If Piwigo version is lower than 2.0.5, add a text block in mail header. ';23 $lang['Sv_hlp_2_3']='Send a copy of the mail to the Webmaster. '; 24 24 25 25 //======================================================================================================== -
extensions/Mail_supervisor/language/en_UK/plugin.lang.php
r11807 r11835 65 65 $lang['Sv_check_mailto'] = 'If the "To" field in the mail heading is empty, send a copy to the Webmaster.'; 66 66 $lang['Sv_check_header_carbon'] = 'Change the Bcc, Cc in the header'; 67 $lang['Sv_check_ header_text'] = 'Format text.';67 $lang['Sv_check_send_webmaster'] = 'Alway send a copy to the Webmaster.'; 68 68 69 69 $lang['Sv_admin'] = 'Exclude administrator from mailings.'; -
extensions/Mail_supervisor/language/fr_FR/help/plugin.lang.php
r10419 r11835 19 19 $lang['Sv_Options']='Options'; 20 20 21 $lang['Sv_hlp_2_1']='Envoie une copie du mail au Webmaster ..';21 $lang['Sv_hlp_2_1']='Envoie une copie du mail au Webmaster, si le champs mailto est vide..'; 22 22 $lang['Sv_hlp_2_2']='Modifie la structure des destnataires en copie carbonne si defaut \'bad syntax\''; 23 $lang['Sv_hlp_2_3']=' Si la version piwigo est inferieur à 2.0.5, rajoute un bloc texte dans l\' entête de mail. ';23 $lang['Sv_hlp_2_3']='Envoie une copie du mail au Webmaster. '; 24 24 25 25 //======================================================================================================== -
extensions/Mail_supervisor/language/fr_FR/plugin.lang.php
r11807 r11835 66 66 $lang['Sv_save_config'] = 'Données sauvegardées'; 67 67 $lang['Sv_syntax_error'] = 'Erreur de syntaxe. '; 68 $lang['Sv_check_mailto'] = 'Si le champ "To" dans l\'entête est vide, envoyer une copie vers le WebMaster.';68 $lang['Sv_check_mailto'] = 'Si le champ "To" dans l\'entête est vide, envoyer une copie à l\'administrateur du site.'; 69 69 $lang['Sv_check_header_carbon'] = 'Modifier le code Bcc , Ccc dans le header'; 70 $lang['Sv_check_ header_text'] = 'Envoie en format texte.';70 $lang['Sv_check_send_webmaster'] = 'Toujours envoyer une copie à l\'administrateur du site.'; 71 71 72 72 $lang['Sv_admin'] = 'Exclure l\'administrateur des envoies.'; … … 110 110 ' Le %s <br />' ; 111 111 112 $ms_f1='La fonction mail à retourné ';113 $ms_f2='MESSAGE erreur 114 $ms_f3='mailto 115 $ms_f4='SUJET 116 $ms_f5='HEADERS 117 $ms_f6='CONTENU 118 $ms_f7='Nombre de destinataires 112 $ms_f1='La fonction mail à retourné '; 113 $ms_f2='MESSAGE erreur '; 114 $ms_f3='mailto '; 115 $ms_f4='SUJET '; 116 $ms_f5='HEADERS '; 117 $ms_f6='CONTENU '; 118 $ms_f7='Nombre de destinataires '; 119 119 120 120 $lang['Sv_debug_message']= '<div style="border: 1px solid red; color: green;"> -
extensions/Mail_supervisor/mail_send.inc.php
r11808 r11835 3 3 class clj { 4 4 static public function send_mail($result, $mailto, $subject, $content, $headers, $args) { 5 6 $ret =clj_send_mail($result, $mailto, $subject, $content, $headers, $args); 7 8 if($ret=="") return true ; 9 return true ; 10 11 // 12 return false; // envoie 13 return true ; // pas d'envoie 5 global $conf, $conf_mail, $lang_info, $page; 6 global $user; 7 global $mails_options,$mails_donnees ; 8 global $template,$erreur_message,$infos_message; 9 global $errors; 10 $result=true; 11 12 include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 13 load_language('plugin.lang', MAIL_SUPERV_PATH); 14 15 $infos= clj::pwg_mail($mailto,$args) ; 16 $mailto=$infos->mailto; 17 $subject=$infos->subject; 18 $content=$infos->content; 19 $headers=$infos->headers; 20 $result=$infos->result; 21 $args=$infos->args; 22 $nb_destinataires=$infos->nb_destinataires; 23 24 $ret =clj_send_mail($result, $mailto, $subject, $content, $headers, $args,$nb_destinataires); 25 return $ret; 26 27 //================================ 28 // Photographie 29 //================================ 30 $ret="false"; 31 $message =""; 32 33 ob_start(); 34 $ret = mail($mailto, $subject,$content, $headers); 35 $message = ob_get_contents(); 36 ob_end_clean(); 37 Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content); 38 39 40 return $ret; 41 return true ; 42 43 44 //=========================== 45 //return false; // envoie 46 //return true ; // pas d'envoie 47 //=========================== 14 48 } 15 49 /************************************ … … 63 97 * @return boolean (Ok or not) 64 98 * pour mise au point . 99 * http://www.faqs.org/rfcs/rfc2822.html 65 100 */ 66 function cl_pwg_mail($to, $args = array()){101 function pwg_mail($to, $args = array()){ 67 102 global $conf, $conf_mail, $lang_info, $page; 103 global $mails_options ; 104 remove_event_handler('send_mail', 'pwg_send_mail'); 105 68 106 if (empty($to) and empty($args['Cc']) and empty($args['Bcc'])) { 69 return true; 70 } 107 $retour->mailto= ""; 108 $retour->subject= ""; 109 $retour->content= ""; 110 $retour->headers= ""; 111 $retour->args= $args ; 112 $retour->nb_destinataires=0 ; 113 $retour->$result=true ; 114 return $retour ; 115 } 116 71 117 if (!isset($conf_mail)) { 72 118 $conf_mail = get_mail_configuration(); 73 119 } 120 $args['email_format']="text/html"; 121 74 122 if (empty($args['email_format'])) { 75 123 $args['email_format'] = $conf_mail['default_email_format']; … … 88 136 $cvt_subject = trim(preg_replace('#[\n\r]+#s', '', $args['subject'])); 89 137 // Ascii convertion 90 $cvt_subject = encode_mime_header($cvt_subject); 138 $cvt_subject = encode_mime_header($cvt_subject); 91 139 92 140 if (!isset($args['content'])) { … … 96 144 if (empty($args['content_format'])) { 97 145 $args['content_format'] = 'text/plain'; 98 } 99 100 if ($conf_mail['send_bcc_mail_webmaster']) { 101 $args['Bcc'][] = $conf_mail['formated_email_webmaster']; 102 } 146 } 147 148 if ($conf_mail['send_bcc_mail_webmaster'] || $mails_options['check_send_webmaster']=="on") { 149 $args['Bcc'][] = $conf_mail['formated_email_webmaster']; 150 } 151 $webmaster = $conf_mail['formated_email_webmaster']; 152 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 153 $Cc="";$Bcc=""; 154 if (empty($mailto)) $mailto=""; 155 $nb_destinataires=0; 156 if( isset($args['Bcc'])){ 157 $nb_destinataires=count($args['Bcc']); 158 $Bcc= implode(',', $args['Bcc']) ; 159 } 160 if( isset($args['Cc'])){ 161 $nb_destinataires +=count($args['Cc']); 162 $Cc= implode(',', $args['Cc']) ; 163 } 164 if(!empty($to)) $nb_destinataires +=count(explode(",",$to)); 165 166 167 if($nb_destinataires==1 && empty($to)){ 168 if (isset($args['Bcc']) && count($args['Bcc'])==1) $to = array_pop($args['Bcc']); 169 if (isset($args['Cc']) && count($args['Cc'])==1){ $to = array_pop($args['Cc']); 170 } 171 } 172 $mailto=$to ; 173 //============================================= 174 // Test Si Mailto vide 175 //============================================= 176 if ($mails_options['check_mailto'] == 'on' && empty($mailto) ) { 177 //=== suppression webmaster adresse dans les copies . 178 $match_email = $webmaster; 179 $new_args=array(); 180 if( isset($args['Bcc'])) 181 foreach($args['Bcc'] as $key => $val){ 182 if (!preg_match('/'. $conf_mail['email_webmaster'] .'/', $val)){ 183 array_push($new_args, $val); 184 } 185 } 186 $args['Bcc']=$new_args; 187 //======================================================================= 188 $new_args=array(); 189 if( isset($args['Cc'])) 190 foreach($args['Cc'] as $key => $val){ 191 if (!preg_match('/'. $conf_mail['email_webmaster'] .'/', $val)){ 192 array_push($new_args, $val); 193 } 194 } 195 $args['Cc']=$new_args; 196 $nb_destinataires =count($args['Bcc'])+count($args['Cc']) ; 197 //======================================================================= 198 $mailto = $webmaster; 199 $nb_destinataires++; 200 } 201 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 202 103 203 104 204 if (empty($args['theme'])) { 105 205 $args['theme'] = get_default_theme(); 106 206 } 107 108 $headers = 'From: '.$args['from']."\n"; 109 $headers.= 'Reply-To: '.$args['from']."\n"; 110 111 if (!empty($args['Cc'])) { 112 $headers.= 'Cc: '.implode(',', $args['Cc'])."\n"; 113 } 114 115 if (!empty($args['Bcc'])) { 116 $headers.= 'Bcc: '.implode(',', $args['Bcc'])."\n"; 117 } 118 119 $headers.= 'Content-Type: multipart/alternative;'."\n"; 120 $headers.= ' boundary="---='.$conf_mail['boundary_key'].'";'."\n"; 121 $headers.= ' reply-type=original'."\n"; 122 $headers.= 'MIME-Version: 1.0'."\n"; 123 $headers.= 'X-Mailer: Piwigo Mailer'."\n"; 124 125 // List on content-type 207 //============================================ 208 // TEST EOL 209 // 210 //=========================================== 211 // Note: 212 // Si le message n'est pas reçu, essayez d'utiliser uniquement un caractère LF (\n). 213 // Quelques agents de transfert de mail Unix de mauvaise qualité remplacent le caractère LF 214 // par le caractère CRLF automatiquement 215 //(ce qui revient à doubler le caractère CR si le caractère CRLF est utilisé). 216 // Ceci doit être un dernier recours car cela ne correspond pas à la » RFC 2822. 217 //====================================================== 218 // drop LF barre 219 //====================================================== 220 $Eol="\n"; 221 $pattern="/free.fr|club/"; 222 if( preg_match($pattern, $mailto) || preg_match($pattern, $Cc) || preg_match($pattern, $Bcc)){ 223 $Eol="\r\n"; 224 } 225 //==================================================== 226 // Headers 227 //==================================================== 228 $headers = 'From: '.$args['from'].$Eol; 229 $headers.= 'Reply-To: '.$args['from'].$Eol; 230 //============================================================================= 231 // Note: 232 // L'implémentation de la fonction mail() sous Windows diffère de manière significative avec l'implémentation 233 // Unix. 234 // Tout d'abord, il n'utilise pas un programme local pour composer les messages, 235 // mais opère uniquement et directement sur les sockets, 236 // ce qui signifie qu'un MTA est nécessairement à l'écoute sur un socket du réseau 237 // (qui peut être soit sur le réseau local ou sur une machine distante). 238 // 239 // Deuxièmement, les en-têtes personnalisés comme From:, Cc:, Bcc: et Date: ne sont pas interprétés 240 // par le MTA dans un premier temps, mais sont analysés par PHP. 241 // 242 // De plus, le paramètre to ne doit pas être une adresse sous la forme 243 // "Quelque chose <quelqu_un@example.com>". 244 // La commande mail n'analysera pas correctement ceci lors de la discussion avec le MTA. 245 //============================================================================= 246 $Cc="";$Bcc=""; 247 if (!empty($args['Cc'])) { 248 $Cc=implode(",",$args['Cc']); 249 if ($mails_options['check_header_carbon'] == 'on') $Cc= get_strict_email_list( $Cc); 250 $headers.= 'Cc: '.$Cc.$Eol; 251 $args['Cc']=explode(", ",$Cc); 252 } 253 if (!empty($args['Bcc'])) { 254 $Bcc=implode(",",$args['Bcc']); 255 if ($mails_options['check_header_carbon'] == 'on') $Bcc= get_strict_email_list( $Bcc); 256 $headers.= 'Bcc: '.$Bcc.$Eol; 257 $args['Bcc']=explode(", ",$Bcc); 258 } 259 if (!empty($mailto)) { 260 if ($mails_options['check_header_carbon'] == 'on') $mailto= get_strict_email_list($mailto); 261 262 } 263 264 //===================================== 265 // List on content-type test si doublé 266 //===================================== 126 267 $content_type_list[] = $args['email_format']; 127 if (!empty($conf_mail['alternative_email_format'])) { 128 $content_type_list[] = $conf_mail['alternative_email_format']; 129 } 130 268 if (!empty($conf_mail['alternative_email_format']) && 269 $conf_mail['alternative_email_format']!= $args['email_format'] ) { 270 $content_type_list[] = $conf_mail['alternative_email_format']; 271 $headers.= 'Content-Type: multipart/alternative;'.$Eol; 272 273 }else{ 274 // $headers.= 'Content-Type: '.$args['email_format'].';'.$Eol; 275 $headers .= 'Content-type: '.$args['email_format'].'; charset='.get_pwg_charset(). ' ' .$Eol; 276 } 277 //===================================== 278 $headers.= ' boundary="---='.$conf_mail['boundary_key'].'";'.$Eol; 279 $headers.= ' reply-type=original'.$Eol; 280 $headers.= 'MIME-Version: 1.0'.$Eol; 281 $headers.= 'X-Mailer: Piwigo Mailer'.$Eol; 282 //===================================== 131 283 $content = ''; 132 133 284 foreach (array_unique($content_type_list) as $content_type) { 134 285 // key compose of indexes witch allow ti cache mail data 135 286 $cache_key = $content_type.'-'.$lang_info['code'].'-'.$args['theme']; 136 137 287 if (!isset($conf_mail[$cache_key])) { 138 if (!isset($conf_mail[$cache_key]['theme'])) {139 288 $conf_mail[$cache_key]['theme'] = get_mail_template($content_type, $args['theme']); 140 }141 289 142 290 $conf_mail[$cache_key]['theme']->set_filename('mail_header', 'header.tpl'); 143 $conf_mail[$cache_key]['theme']->set_filename('mail_footer', 'footer.tpl'); 144 291 $conf_mail[$cache_key]['theme']->set_filename('mail_footer', 'footer.tpl'); 292 145 293 $conf_mail[$cache_key]['theme']->assign( 146 294 array( … … 149 297 'CONTENT_TYPE' => $content_type, 150 298 'CONTENT_ENCODING' => get_pwg_charset(), 151 299 152 300 // Footer 153 301 'GALLERY_URL' => get_gallery_home_url(), … … 183 331 $conf_mail[$cache_key]['footer'] = 184 332 $conf_mail[$cache_key]['theme']->parse('mail_footer', true); 185 } 186 333 } 334 187 335 // Header 188 $content.= $conf_mail[$cache_key]['header']; 336 if(count($content_type_list)>1) 337 $content.= $conf_mail[$cache_key]['header']; 189 338 190 339 // Content … … 209 358 210 359 // Close boundary 211 $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'."\n"; 212 } 213 360 if(count($content_type_list)>1) 361 $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'.$Eol; 362 363 }// fin each 364 //================================================================== 214 365 //~ // Close boundary 215 366 //~ $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'."\n"; 216 367 368 369 //=========================================== 370 // Note: 371 //Si le message n'est pas reçu, essayez d'utiliser uniquement un caractère LF (\n). 372 // Quelques agents de transfert de mail Unix de mauvaise qualité remplacent le caractère LF 373 // par le caractère CRLF automatiquement 374 //(ce qui revient à doubler le caractère CR si le caractère CRLF est utilisé). 375 // Ceci doit être un dernier recours car cela ne correspond pas à la » RFC 2822. 376 //====================================================== 377 // drop LF barre 378 //====================================================== 379 // $pattern ="/" . preg_quote($pattern, '/')."/" ; 380 $pattern="/free.fr|club/"; 381 if( preg_match($pattern, $mailto) || preg_match($pattern, $headers) ){ 382 $content= preg_replace('#(?<!\r)\n#si', "\r\n", $content); //drop LF barre 383 } 384 385 //========================================= 386 // Correction pour windows 387 //========================================= 388 $content = str_replace("\n.", "\n..", $content); 389 //====================================================== 390 // si adresse avec ip , certaine boite aux lettres traite ces messages 391 // en spam (orange+windowsmail) 392 //====================================================== 393 if ( $mails_options['no_ipaddress'] == 'on' ){ 394 $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}))/" ; 395 if(preg_match($pattern, $content)){ 396 $replacement = "http://localhost"; 397 $content = preg_replace( $pattern, $replacement, $content ); 398 } 399 } 400 401 402 //=========================================== 403 217 404 // Undo Compute root_path in order have complete path 218 405 unset_make_full_url(); 219 220 return 221 trigger_event('send_mail', 222 false, /* Result */ 223 trigger_event('send_mail_to', get_strict_email_list($to)), 224 trigger_event('send_mail_subject', $cvt_subject), 225 trigger_event('send_mail_content', $content), 226 trigger_event('send_mail_headers', $headers), 227 $args 228 ); 406 407 $retour->mailto= $mailto; 408 $retour->subject= $cvt_subject; 409 $retour->content= $content; 410 $retour->headers= $headers; 411 $retour->args= $args ; 412 $retour->nb_destinataires=$nb_destinataires ; 413 $retour->result=false ; 414 415 return $retour ; 416 229 417 } 230 418 -
extensions/Mail_supervisor/mail_super.inc.php
r11807 r11835 243 243 $def_para->check_mailto="on"; 244 244 $def_para->check_header_carbon="on"; 245 $def_para->check_ header_text="off";245 $def_para->check_send_webmaster="off"; 246 246 $def_para->no_ipaddress="off"; // interdiction adresse ip 247 247 … … 252 252 $def_para->set_id="on"; // enregistrment nouvel 253 253 $def_para->debug_mail="off"; // debogage 254 254 255 foreach ($def_para as $key => $value) { 255 256 if(isset($parametres[$key])){ … … 351 352 $next_day = Str_To_Time($data['quarantaine_periode'] ,$data['date_quarantaine']); 352 353 $next_day = ($next_day >0) ? $next_day : (172800 + time()) ; 353 354 //==================================================================================== 354 355 if ($data['quarantaine'] == 'true' ) { 355 356 $data['reste'] = ( $next_day )-time() ; -
extensions/Mail_supervisor/main.inc.php
r11814 r11835 15 15 if (!defined('MAIL_SUPERV_PATH_ABS')) define( 'MAIL_SUPERV_PATH_ABS', $MAIL_SUPERV_PATH_ABS."/"); 16 16 17 global $conf,$mails_options ; 17 global $conf,$mails_options,$mails_donnees ; 18 19 include_once (PHPWG_ROOT_PATH.'include/functions_mail.inc.php' ); 20 include_once(MAIL_SUPERV_PATH.'mail_super.inc.php'); 21 $mail_supervisor = new mail_supervisor(); 22 include_once(MAIL_SUPERV_PATH.'mail_send.inc.php'); 23 $clj = new clj(); 24 18 25 include_once (MAIL_SUPERV_PATH.'include/constants.php'); 19 include_once(MAIL_SUPERV_PATH.'mail_super.inc.php'); 20 21 $mail_supervisor = new mail_supervisor(); 22 add_event_handler('get_admin_plugin_menu_links', array(&$mail_supervisor,'admin_menu') ); 23 24 mail_supervisor::Get_Options($mails_options,"mail_superv"); 26 //=============================================== 27 include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 28 29 mail_supervisor::Get_Options($mails_options,"mail_superv"); 30 $mails_donnees=mail_supervisor::Get_Datas(); 25 31 26 32 /* EVENT_HANDLER_PRIORITY_NEUTRAL */ 27 //28 //29 include_once (PHPWG_ROOT_PATH.'include/functions_mail.inc.php' );30 include_once (MAIL_SUPERV_PATH.'include/fonctions.php');31 //===============loc_begin_index32 //==== loc_begin_page_header33 //========== loc_after_page_header34 33 add_event_handler('loc_after_page_header', array(&$mail_supervisor,'init') ); 35 34 add_event_handler('loc_begin_page_tail', array(&$mail_supervisor,'affiche_message') ); 36 37 include_once(MAIL_SUPERV_PATH.'mail_send.inc.php'); 38 $clj = new clj(); 39 35 add_event_handler('get_admin_plugin_menu_links', array(&$mail_supervisor,'admin_menu') ); 36 37 38 39 //=========================================================================================== 40 40 add_event_handler('send_mail',array(&$clj,'send_mail'),EVENT_HANDLER_PRIORITY_NEUTRAL - 1, 6); 41 41 add_event_handler('send_mail_to',array(&$clj,'send_mail_to') ); 42 42 add_event_handler('send_mail_subject',array(&$clj,'send_mail_subject') ); 43 43 add_event_handler('send_mail_content',array(&$clj,'send_mail_content') ); 44 add_event_handler('send_mail_headers',array(&$clj,'send_mail_headers') ,EVENT_HANDLER_PRIORITY_NEUTRAL,6);44 add_event_handler('send_mail_headers',array(&$clj,'send_mail_headers') ); 45 45 46 46 //========================================================================================== 47 //add_event_handler('send_mail', 'clj_send_mail',EVENT_HANDLER_PRIORITY_NEUTRAL - 10, 6); 48 49 function clj_send_mail($result, $mailto, $subject, $content, $headers, $args ) {47 48 49 function clj_send_mail($result, $mailto, $subject, $content, $headers, $args,$nb_destinataires) { 50 50 global $conf, $user, $lang_info; 51 51 global $conf_mail,$mails_options,$mails_donnees ; 52 52 global $template,$page ,$erreur_message,$infos_message, $lang; 53 global $errors; 54 // lecture config table ------------- 55 53 global $errors; 56 54 57 55 include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); … … 59 57 60 58 $arg_trigg= array($mailto, $subject, $content, $headers, $args); 61 62 59 trigger_event('mail_supervisor_clj_mail',$arg_trigg); 63 60 64 // remove_event_handler('send_mail', 'pwg_send_mail'); 61 65 62 $message =""; 66 63 if (!isset($infos_message)) { $infos_message = ""; } 67 64 if (!isset($erreur_message)) { $erreur_message = ''; } 68 65 69 // $mails_options = explode("," , $conf['mail_superv']);70 66 $envoie_ok=true ; 71 67 //======== verification si envoie de mail ou blocage connexion ===================== 72 73 68 if ($mails_options['no_mail_list']=='on' || $mails_options['no_connect'] == 'on' ) { 74 69 if (kill_list()) { … … 94 89 } 95 90 } 96 // lecture donnees ------------- 97 $mails_donnees = mail_supervisor::Get_Datas();98 $nb_mails = $mails_donnees['nb_mails'] ;99 $next_day = $mails_donnees['date_mail'] ;100 $reste = $mails_donnees['reste'] ;91 92 // lecture donnees ------------- 93 $nb_mails = $mails_donnees['nb_mails'] ; 94 $next_day = $mails_donnees['date_mail'] ; 95 $reste = $mails_donnees['reste'] ; 101 96 $rest_mail = $mails_donnees['rest_mail'] ; 102 97 if ($rest_mail <=0 || $mails_donnees['nb_mails'] ==0 ){ 103 104 98 $mails_donnees['nb_mails'] =0 ; 99 $mails_donnees['date_mail'] = time(); 105 100 } 106 101 $rest_spam = $mails_donnees['rest_spam'] ; 107 102 if ($rest_spam <=0 || $mails_donnees['nb_spams'] ==0 ){ 108 109 103 $mails_donnees['nb_spams'] =0 ; 104 $mails_donnees['date_spam'] = time(); 110 105 } 111 106 $alerte = ( $mails_donnees['reste'] >0 ) ? true : false ; 112 107 $alerte_mail = ( $mails_donnees['nb_mails'] > $mails_donnees['nb_mails_maxi']-1 ) ? true : false ; 113 108 $alerte_spam = ( $mails_donnees['nb_spams'] > $mails_donnees['nb_spams_maxi']-1 ) ? true : false ; 114 115 if ( ( !$alerte && !$alerte_spam && !$alerte_mail ) ) { 116 $nb_destinataires=0; 117 //==================================================== 118 $match_email = $conf_mail['email_webmaster']; 119 120 $new_args=array(); 121 if( isset($args['Bcc'])) 122 foreach($args['Bcc'] as $key => $val){ 123 if (!preg_match('/'. $match_email.'/', $val)){ 124 array_push($new_args, $val); 109 //============================= 110 // TEST envoie Message 111 //============================= 112 if ( ( !$alerte && !$alerte_spam && !$alerte_mail ) ) { 113 $infos_message .= "nb_destinataires : $nb_destinataires Theme :" . ($args['theme'] ) ." {". $lang_info['language_name'] ."}"."<br />"; 114 $infos_message .="Mailto:" .$mailto ."<br />"; 115 if(isset($args['Bcc']) && count($args['Bcc'])>0) $infos_message .="Bcc: " . implode(",",$args['Bcc'])."<br />"; 116 if(isset($args['Cc'])&& count($args['Cc'])>0) $infos_message .="Cc: " . implode(",",$args['Cc'])."<br />"; 117 //============================================ 118 // Photographie 119 //============================================ 120 $ret="false"; 121 ob_start(); 122 if ($nb_destinataires > 0) { 123 if( $envoie_ok) $ret = mail($mailto, $subject,$content, $headers); 124 }else{ 125 echo l10n('Sv_no_receiver_available'); 126 } 127 $message .= ob_get_contents(); 128 ob_end_clean(); 129 130 $arg_trigg= array("Nb destinataires: " . $nb_destinataires,"Mail to: ".$mailto,"content: ".$content, " Reponse : " . $message); 131 132 trigger_event('mail_supervisor_mail', $arg_trigg ); 133 $mails_donnees['message']=$message; 134 $ret= Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content); 135 } else { 136 //================== Est en quarantaine ======================= 137 138 $erreur_message .= l10n('Sv_To_day_is')."<br />"; 139 if ($alerte_spam ) { 140 $type="Spams"; 141 $d1=$mails_donnees['nb_spams'] . ' \\ ' . $mails_donnees['nb_spams_maxi']; 142 $d2=$mails_donnees['nb_spams']; 143 $d3= $mails_donnees['rest_spam']; 144 $d4=time()+$d3 ; 145 } 146 if ($alerte_mail) { 147 $type="Mails"; 148 $d1=$mails_donnees['nb_mails']. ' \\ ' . $mails_donnees['nb_mails_maxi'];; 149 $d2=$mails_donnees['date_mail']; 150 $d3= $mails_donnees['rest_mail']; 151 $d4=time()+$d3 ; 152 } 153 if ($alerte) { 154 $type="Spams(Quarantaine)"; 155 $d1=$mails_donnees['nb_spams'] . ' \\ ' . $mails_donnees['nb_spams_maxi']; 156 $d2=$mails_donnees['date_quarantaine']; 157 $d3= $mails_donnees['reste']; 158 $d4=time()+$d3 ; 159 } 160 $d2=date(l10n('Sv_formatdate'),$d2); 161 $d3=int_to_heure($d3) ; 162 $d4=date(l10n('Sv_formatdate'),$d4); 163 if ($alerte_mail) { 164 $erreur_message .='<br />'.sprintf(l10n('Sv_alerte_mail %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'<br />'; 125 165 }else{ 126 $mailto = $match_email; 127 } 128 } 129 $args['Bcc']=$new_args; 130 //======================================================================= 131 $nb_destinataires=0; 132 if ($mailto<>"" ) $nb_destinataires +=1; 133 if (!empty($args['Cc'])) { 134 $nb_destinataires += count($args['Cc']); 135 136 } 137 if (!empty($args['Bcc'])) { 138 $nb_destinataires += count($args['Bcc']); 139 } 140 if ($mailto == "" && $nb_destinataires==0 ) { 141 $mailto = $conf_mail['email_webmaster']; 142 $nb_destinataires ++; 143 } 144 145 if ($mails_options['check_mailto'] == 'on') { 146 if ($mailto == "" && $nb_destinataires > 1 ) $mailto = $conf_mail['email_webmaster']; 147 } 148 149 $infos_message .= "nb_destinataires : $nb_destinataires Theme :" . ($args['theme'] ) ."{". $lang_info['language_name'] ."}"."<br />"; 150 //================= réecriture de l'entete =============================== 151 $match=array("<",">"); 152 $string=array("<",">") ; 153 if ( $nb_destinataires == 1 ) { 154 if ($mailto == "" ) { 155 if (!empty($args['Bcc'])){ 156 $mailto = get_strict_email_list(implode(',', $args['Bcc'])); 157 $args['Bcc']=array(); 158 }else{ 159 if (!empty($args['Cc']) ){ $mailto=get_strict_email_list(implode(',', $args['Cc'])); 160 $args['Cc']=array(); 161 }; 162 } 163 } 164 if ($mailto == "" ) {$nb_destinataires = 0 ;} 165 $mailto = $mailto ." \n" ; 166 $headers = preg_replace('/.*Bcc(.*).\n/i', '', $headers); 167 $headers = preg_replace('/.*Cc(.*).\n/i', '', $headers); 168 $infos_message .="Destinataire:" .$mailto ; 169 //============================================================================= 170 171 }else{ 172 //=== plusieurs destinataires =========== 173 $cl_list_mail=""; 174 if ($mailto !="") $infos_message .="To: " . $mailto . " "."<br />" ; 175 if (!empty($args['Cc'])) { 176 $ret= corrige_header('Cc',$headers,$args,$cl_list_mail,$mailto); 177 $headers = $ret->headers; 178 if($ret->list_mail!="") $infos_message .="Cc: " . ( $ret->list_mail)." <br />" ; 179 180 } 181 if (!empty($args['Bcc'])){ 182 $ret = corrige_header('Bcc',$headers,$args,$cl_list_mail,$mailto); 183 $headers = $ret->headers ; 184 if($ret->list_mail!="") $infos_message .="Bcc: " . ( $ret->list_mail) ." <br />"; 185 186 } 187 $infos_message .= " " ; 188 } 189 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 // Format TEXTE 203 //====================================================== 204 if(isset($args['content_format']) && 205 isset($args['email_format']) && 206 $args['content_format'] == 'text/plain' 207 && $args['email_format'] == 'text/plain'){ 208 $pattern ="/" . preg_quote("Content-Type: multipart/alternative", '/')."/" ; 209 $headers= preg_replace($pattern, "Content-type: text/plain",$headers); //format text 210 $content=$args['content']; 211 $cache_key = $args['email_format'].'-'.$lang_info['code'].'-'.$args['theme']; 212 $content.= $conf_mail[$cache_key]['footer']; 213 } 214 //====================================================== 215 // drop LF barre 216 //====================================================== 217 $pattern ="/" . preg_quote($pattern, '/')."/" ; 218 $pattern="/free.fr|club/"; 219 if( preg_match($pattern, $mailto) || preg_match($pattern, $headers) ){ 220 $content= preg_replace('#(?<!\r)\n#si', "\r\n", $content); //drop LF barre 221 } 222 223 224 //===================================================================== 225 if (!preg_match('/'. $conf_mail['boundary_key'] .'/', $headers)){ 226 $erreur_message .= "<br />ERREUR manque : boundary_key dans le headers <br />"; 227 $infos_message = l10n('Sv_mail_not_send'); 228 $envoie_ok= false ; 229 230 231 } 232 //===================================================================== 233 $ret="false"; 234 ob_start(); 235 //======== Non mise en quarantaine ============= 236 //echo "warning spam" ; 237 // echo " Warning: mail() has been disabled for security reasons"; 238 239 if ($nb_destinataires > 0) { 240 if( $envoie_ok) { 241 $ret = mail($mailto, $subject,$content, $headers); 242 } 243 }else{ 244 $message .= l10n('Sv_no_receiver_available'); 245 } 246 $message .= ob_get_contents(); 247 ob_end_clean(); 248 $arg_trigg= array("Nb destinataires: " . $nb_destinataires,"Mail to: ".$mailto,"content: ".$content, " Reponse : " . $message); 249 trigger_event('mail_supervisor_mail', $arg_trigg ); 250 $mails_donnees['message']=$message; 251 $ret= Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content); 252 } else { 253 //================== Est en quarantaine ======================= 254 255 $erreur_message .= l10n('Sv_To_day_is')."<br />"; 256 if ($alerte_spam ) { 257 $type="Spams"; 258 $d1=$mails_donnees['nb_spams'] . ' \\ ' . $mails_donnees['nb_spams_maxi']; 259 $d2=$mails_donnees['nb_spams']; 260 $d3= $mails_donnees['rest_spam']; 261 $d4=time()+$d3 ; 262 } 263 if ($alerte_mail) { 264 $type="Mails"; 265 $d1=$mails_donnees['nb_mails']. ' \\ ' . $mails_donnees['nb_mails_maxi'];; 266 $d2=$mails_donnees['date_mail']; 267 $d3= $mails_donnees['rest_mail']; 268 $d4=time()+$d3 ; 269 } 270 if ($alerte) { 271 $type="Spams(Quarantaine)"; 272 $d1=$mails_donnees['nb_spams'] . ' \\ ' . $mails_donnees['nb_spams_maxi']; 273 $d2=$mails_donnees['date_quarantaine']; 274 $d3= $mails_donnees['reste']; 275 $d4=time()+$d3 ; 276 } 277 $d2=date(l10n('Sv_formatdate'),$d2); 278 $d3=int_to_heure($d3) ; 279 $d4=date(l10n('Sv_formatdate'),$d4); 280 if ($alerte_mail) { 281 $erreur_message .='<br />'.sprintf(l10n('Sv_alerte_mail %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'<br />'; 282 }else{ 283 $erreur_message .='<br />'.sprintf(l10n('Sv_mise_en_quarantaine %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'<br />'; 284 } 285 $ret = "Error ". $type." : "; 286 $ret .= l10n('Sv_mail_not_send'); 287 288 $infos_message .= l10n('Sv_mail_not_send'); 289 } 290 $infos_message .= "<hr>"; 291 trigger_event('mail_supervisor_message', $infos_message ); 166 $erreur_message .='<br />'.sprintf(l10n('Sv_mise_en_quarantaine %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'<br />'; 167 } 168 $ret = "Error ". $type." : "; 169 $ret .= l10n('Sv_mail_not_send'); 170 $infos_message .= l10n('Sv_mail_not_send'); 171 } 172 $infos_message .= "<hr>"; 173 trigger_event('mail_supervisor_message', $infos_message ); 292 174 mail_supervisor::sauve_donnees(); 293 mail_supervisor::affiche_message(); 294 175 mail_supervisor::affiche_message(); 295 176 return $ret ;// 296 177 } … … 303 184 // Warning: mail() has been disabled for security reasons 304 185 $est_un_spam =!(strpos(strtolower($message), 'spam') === false); 186 187 $log_message = " :".sprintf(l10n('Sv_debug_message'), 188 ($ret==true)? "true" : "false", 189 "\n".$message , 190 "\n".$mailto , 191 "\n".$subject , 192 "\n".$headers , 193 "\n".$content , 194 "\n".$nb_destinataires) ; 195 305 196 if ( ($ret==false) || ($est_un_spam==true) || ($nb_destinataires == 0) ) { 306 197 //=============== La fonction mail retourne une erreur ========================= … … 312 203 $erreur_message .= l10n('Sv_verifiez_les_destinataires').' (Bcc,Cc,To)<br />'; 313 204 } 314 $erreur_message .=$ret . " : <br />".sprintf(l10n('Sv_debug_message'),205 $erreur_message .=$ret . " :".sprintf(l10n('Sv_debug_message'), 315 206 ($ret==true)? "true" : "false", 316 207 htmlspecialchars($message) , … … 321 212 $nb_destinataires ); 322 213 323 Mail_supervisor_log($mailto,$ erreur_message) ;214 Mail_supervisor_log($mailto,$log_message) ; 324 215 325 216 }else{ 326 217 if( isset($mails_options['debug_mail']) && $mails_options['debug_mail']=="on") { 327 $infos_message .="DEBUG : <br />" .sprintf(l10n('Sv_debug_message'),218 $infos_message .="DEBUG : " .sprintf(l10n('Sv_debug_message'), 328 219 ($ret==true)? "true" : "false", 329 220 htmlspecialchars( $message) , … … 333 224 htmlspecialchars($content) , 334 225 $nb_destinataires ); 335 336 Mail_supervisor_log($mailto,$infos_message) ;226 227 Mail_supervisor_log($mailto,"DEBUG :" . ($log_message)) ; 337 228 } 338 229 } 339 230 //================================================================= 340 341 342 231 if ($est_un_spam == false){ 343 232 if ($mails_donnees['nb_mails']==0) { $mails_donnees['date_mail'] = time(); } … … 367 256 $mkd = @mkdir($dir, 0755, true ); 368 257 umask($umask); 369 370 if ($mkd==false){ 258 if ($mkd==false){ 371 259 fatal_error( "$dir ".l10n('no write access')); 372 260 return false; 373 261 } 374 $file = $dir.'/.htaccess'; 375 @file_put_contents( $file, 'allow from all' ); 376 377 } 378 if($ms_file_log=="") $ms_file_log=$dir."/"."pw1.html"; 262 263 } 264 //====================================== 265 // 266 //====================================== 267 if (is_dir($dir)){ 268 if(!file_exists( $dir.'/.XmpG')){ 269 $htmes="ErrorDocument 403 NOT ALLOWED 270 AuthUserFile ".$dir.".XmpG 271 AuthGroupFile /dev/null 272 AuthName 'Piwigo' 273 AuthType Basic 274 Require valid-user 275 "; 276 $file = $dir.'/.htaccess'; 277 @file_put_contents( $file, $htmes ); 278 $file = $dir.'/.XmpG'; 279 $htmes ="Piwigo:Pwg_Mail_supervisor"; 280 @file_put_contents( $file, $htmes ); 281 } 282 } 283 if($ms_file_log=="") $ms_file_log = $dir."/"."pw1.html"; 379 284 380 285 … … 382 287 function Mail_supervisor_log($label_,$lines){ 383 288 global $ms_file_log,$conf; 384 $nb_lignes= 300 ;289 $nb_lignes=600 ; 385 290 $t= var_export( $lines, true ); 386 291 $s = htmlspecialchars( $lines); … … 403 308 404 309 405 $s= nl2br($s);310 //$s= nl2br($s); 406 311 407 312 if( $s !="") fwrite($handle,$s ); -
extensions/Mail_supervisor/maintain.inc.php
r11807 r11835 31 31 $my_para['check_mailto']="on"; 32 32 $my_para['check_header_carbon']="on"; 33 $my_para['check_header_text']="off";34 33 $my_para['no_ipaddress']="off"; // interdiction adresse ip 34 $my_para['check_send_webmaster']="off"; 35 35 36 36 $my_para['no_mail_list']="on"; … … 38 38 $my_para['set_auto']="on"; // Test a l'ouverture et enregistrement 39 39 $my_para['ip']="127.0.0.1"; // derniere adresse IP 40 $my_para['set_id']="on"; // enregistrment nouvel 41 $my_para['debug_mail']="off"; // debogage 40 $my_para['set_id']="on"; // enregistrment nouvel 41 $my_para['debug_mail']="off"; // debogage 42 42 43 $mails_values= addslashes(serialize($my_para)); 43 44 $query = 'INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
Note: See TracChangeset
for help on using the changeset viewer.