Changeset 10822 for extensions/Mail_supervisor/main.inc.php
- Timestamp:
- May 9, 2011, 11:23:06 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Mail_supervisor/main.inc.php
r10816 r10822 173 173 } 174 174 175 $content= cl_pwg_mail($args); 176 177 178 if ( !preg_match('/'. $conf_mail['boundary_key'] .'/', $headers)){ 179 $erreur_message .= "ERREUR manque : boundary_key dans le headers <br />"; 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 185 if (!preg_match('/'. $conf_mail['boundary_key'] .'/', $headers)){ 186 $erreur_message .= "<br />ERREUR manque : boundary_key dans le headers <br />"; 180 187 $infos_message = l10n('Sv_mail_not_send'); 181 $envoie_ok= false ; 182 } 183 184 185 186 if( isset($conf['debug_mail']) && $conf['debug_mail']=="true") { 187 188 // $erreur_message .="DEBUG:"."<br />Theme: ". $file. "<br />"; 189 190 $content1 = htmlspecialchars( var_export($headers, true ) ); 191 $erreur_message .="<br />DEBUG -> "." Header: <br />". $content1 ."<br />"; 192 193 $content1 = htmlspecialchars( var_export($mailto, true ) ); 194 $erreur_message .="<br />DEBUG -> "." Mail to: <br />". $content1 ."<br />"; 195 196 $content1 = htmlspecialchars( var_export($subject ,true ) ); 197 $erreur_message .="<br />DEBUG -> "." Sujet: <br />". $content1 ."<br />"; 198 199 $content1 = htmlspecialchars( var_export($content, true ) ); 200 $erreur_message .="<br />DEBUG -> "." Contenu:<br />" . $content1 ."<br />"; 201 } 202 203 204 $ret=false; 188 $envoie_ok= false ; 189 } 190 $ret=false; 191 ob_start(); 205 192 //======== Non mise en quarantaine ============= 206 207 208 ob_start();193 //echo "warning spam" ; 194 // echo " Warning: mail() has been disabled for security reasons"; 195 209 196 if ($nb_destinataires > 0) { 210 197 if( $envoie_ok) $ret = mail($mailto, $subject,$content, $headers); … … 217 204 trigger_event('mail_supervisor_mail', $arg_trigg ); 218 205 $mails_donnees['message']=$message; 219 Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto );206 Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content); 220 207 } else { 221 208 //================== Est en quarantaine ======================= … … 260 247 } 261 248 //=========================================================================================== 262 function Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto ){249 function Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content){ 263 250 global $conf, $user, $conf_mail,$mails_options,$mails_donnees , $template,$page ,$infos_message,$erreur_message,$args,$lang, $lang_info; 264 251 $match=array("<",">"); 265 $string=array("<",">") ; 266 //Warning: mail() has been disabled for security reasons 267 268 $est_un_spam =!(strpos(strtolower($message), 'spam') === false); 269 $headers=str_replace( $match,$string, $headers); 270 252 $string=array("<",">") ; 253 // $headers=str_replace( $match,$string, $headers); 254 // Warning: mail() has been disabled for security reasons 255 $est_un_spam =!(strpos(strtolower($message), 'spam') === false); 271 256 if ( ($ret==false) || ($est_un_spam==true) || ($nb_destinataires == 0) ) { 272 ;// Bad recipient address syntax257 // Bad recipient address syntax 273 258 $pos1 = strpos(strtolower($message), 'bad recipient address syntax'); 274 259 if ( !($pos1 === false) ){ 275 260 $erreur_message .= l10n('Sv_detection_de').' Bad recipient address syntax .'; 276 261 $erreur_message .= l10n('Sv_verifiez_les_destinataires').' (Bcc,Cc,To)<br />'; 277 } 278 279 $erreur_message .= sprintf(l10n('Sv_debug_message'), 280 ($ret==true)? "true" : "false", 281 $message , 282 $mailto , 283 $headers , 284 $nb_destinataires ); 285 //=============== La fonction mail retourne une erreur ========================= 286 } 287 288 if ($est_un_spam == false) 289 { 262 } 263 264 $erreur_message .=sprintf(l10n('Sv_debug_message'), 265 ($ret==true)? "true" : "false", 266 htmlspecialchars($message) , 267 htmlspecialchars( $mailto) , 268 htmlspecialchars($subject) , 269 htmlspecialchars($headers) , 270 htmlspecialchars($content) , 271 $nb_destinataires ); 272 273 Mail_supervisor_log($mailto,$erreur_message) ; 274 //=============== La fonction mail retourne une erreur ========================= 275 }else{ 276 277 if( isset($mails_options['debug_mail']) && $mails_options['debug_mail']=="on") { 278 $erreur_message .="DEBUG : <br />" .sprintf(l10n('Sv_debug_message'), 279 "DEBUG", 280 htmlspecialchars( $message) , 281 htmlspecialchars( $mailto) , 282 htmlspecialchars($subject) , 283 htmlspecialchars($headers) , 284 htmlspecialchars($content) , 285 $nb_destinataires ); 286 287 Mail_supervisor_log($mailto,$erreur_message) ; 288 } 289 } 290 291 292 293 if ($est_un_spam == false){ 290 294 if ($mails_donnees['nb_mails']==0) { $mails_donnees['date_mail'] = time(); } 291 295 $mails_donnees['nb_mails'] += $nb_destinataires; 292 } 293 else 294 { 296 } else { 295 297 $mails_donnees['nb_spams'] += $nb_destinataires; 296 298 //--- Detection de spam ------------------ … … 308 310 $ret=true; 309 311 return $ret ; 312 } 313 //============================================================ 314 global $ms_file_log; 315 $dir=$conf['local_data_dir'].'/Mail_supervisor_log'; 316 if (!is_dir($dir)){ 317 $umask = umask(0); 318 $mkd = @mkdir($dir, 0755, true ); 319 umask($umask); 320 321 if ($mkd==false){ 322 fatal_error( "$dir ".l10n('no write access')); 323 return false; 324 } 325 $file = $dir.'/.htaccess'; 326 @file_put_contents( $file, 'allow from all' ); 327 328 } 329 if($ms_file_log=="") $ms_file_log=$dir."/"."pw1.html"; 330 331 332 //============================================================ 333 function Mail_supervisor_log($label_,$lines){ 334 global $ms_file_log,$conf; 335 $nb_lignes=300 ; 336 $t= var_export( $lines, true ); 337 $s = htmlspecialchars( $lines); 338 $s = ( $lines); 339 if (!file_exists($ms_file_log)) { 340 $handle = fopen($ms_file_log, 'w'); 341 fwrite($handle, "\n"); 342 fclose($handle); 343 } 344 $tableau=file($ms_file_log); 345 $handle = fopen($ms_file_log, 'a'); 346 $nb=count ($tableau); 347 if($nb>$nb_lignes) { 348 $handle = fopen($ms_file_log, 'w'); 349 fwrite($handle, $nb. " > " . $nb_lignes . " RAZ " ."\n"); 350 } 351 //rewind ($handle); // Go back to the beginning 352 //fwrite ($handle, sprintf("%5d ", $nb)); // Don't forget to increment the counter 353 $s="\n".date('Y m d H:m:s ')."\n".$s; 354 355 356 $s= nl2br($s); 357 358 if( $s !="") fwrite($handle,$s ); 359 fclose($handle); 310 360 } 311 361 … … 432 482 unset_make_full_url(); 433 483 434 $pattern = '/(http:\/\/)([0-9].*)([0-9]\/)/'; 435 if(preg_match($pattern, $content)){ 436 //remplace 192.168.1.25 par rien ?? 437 $replacement = '${1}'; 438 $content = preg_replace( $pattern, $replacement, $content ); 439 //$content1 = htmlspecialchars( var_export($content, true ) ); 440 } 441 442 $content= preg_replace('#(?<!\r)\n#si', "\r\n", $content); //drop LF barre 484 443 485 444 486 return $content;
Note: See TracChangeset
for help on using the changeset viewer.