Changeset 10419 for extensions/Mail_supervisor/main.inc.php
- Timestamp:
- Apr 16, 2011, 3:53:31 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Mail_supervisor/main.inc.php
r10388 r10419 16 16 17 17 global $conf,$mails_options ; 18 include_once (MAIL_SUPERV_PATH.'include/constants.php'); 18 include_once (MAIL_SUPERV_PATH.'include/constants.php'); 19 19 include_once(MAIL_SUPERV_PATH.'mail_super.inc.php'); 20 20 … … 23 23 24 24 $mails_options = mail_supervisor::Get_Options($mails_options,"mail_superv"); 25 /* EVENT_HANDLER_PRIORITY_NEUTRAL */ 25 /* EVENT_HANDLER_PRIORITY_NEUTRAL */ 26 26 // 27 27 // 28 28 include_once (PHPWG_ROOT_PATH.'include/functions_mail.inc.php' ); 29 include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 29 include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 30 30 //===============loc_begin_index==============loc_after_page_header============================================================= 31 31 add_event_handler('loc_begin_page_header', array(&$mail_supervisor,'init') ); … … 35 35 add_event_handler('send_mail', 'clj_mail',EVENT_HANDLER_PRIORITY_NEUTRAL - 10, 6); 36 36 function clj_mail($result, $mailto, $subject, $content, $headers, $args) { 37 global $conf, $user, $lang_info; 37 global $conf, $user, $lang_info; 38 38 global $conf_mail,$mails_options,$mails_donnees ; 39 global $template,$page ,$erreur_message,$infos_message, $lang; 39 global $template,$page ,$erreur_message,$infos_message, $lang; 40 40 global $errors; 41 41 // lecture config table ------------- 42 include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 43 load_language('plugin.lang', MAIL_SUPERV_PATH); 44 if (isset($_POST["Submit"]) ) { 45 if ($_POST["Submit"] != l10n('Sv_Envoyer') ) return true ; 46 } 47 // remove_event_handler('send_mail', 'pwg_send_mail'); 48 $message =""; 49 if (!isset($infos_message)) { $infos_message = ""; } 50 if (!isset($erreur_message)) { $erreur_message = ''; } 51 42 include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 43 load_language('plugin.lang', MAIL_SUPERV_PATH); 44 trigger_event('cl_begin_send_mail'); 45 46 // remove_event_handler('send_mail', 'pwg_send_mail'); 47 $message =""; 48 if (!isset($infos_message)) { $infos_message = ""; } 49 if (!isset($erreur_message)) { $erreur_message = ''; } 50 52 51 // $mails_options = explode("," , $conf['mail_superv']); 53 52 $envoie_ok=true ; 54 53 //======== verification si envoie de mail ou blocage connexion ===================== 55 54 56 if ($mails_options['no_mail_list']=='on' || $mails_options['no_connect'] == 'on' ) {57 55 if ($mails_options['no_mail_list']=='on' || $mails_options['no_connect'] == 'on' ) { 56 if (kill_list()) { 58 57 $nb_destinataires=0; ; 59 58 $envoie_ok= false ; 60 59 $erreur_message .= "<BR />".l10n('Sv_is_a_spam') ; 61 $infos_message = l10n('Sv_mail_not_send')."<BR />"; 60 $infos_message = l10n('Sv_mail_not_send')."<BR />"; 62 61 if ($mails_options['no_connect'] == 'on' ){ 63 if ($user['status'] == 'webmaster'){ 64 65 66 67 68 69 70 71 } 72 } 62 if ($user['status'] == 'webmaster'){ 63 //---------- continuer si web master ---------- 64 }else{ 65 if (!isset($_GET['admin'])) { 66 die('Blacklist : <br />' .$erreur_message. '<br /> Hacking attempt!'); 67 }elseif ($_GET['admin'] != 'piwigo') 68 { 69 die('blacklist Hacking attempt!'); 70 } 71 } 73 72 } 74 return true; 75 } 76 } 73 trigger_event('cl_kill_send_mail', $ip); 74 return true; 75 } 76 } 77 77 // lecture donnees ------------- 78 $mails_donnees = mail_supervisor::Get_Datas(); 79 $nb_mails =$mails_donnees['nb_mails'] ;80 $next_day = $mails_donnees['date_mail'] ; 81 $reste = $mails_donnees['reste'] ; 82 $rest_mail = $mails_donnees['rest_mail'] ; 83 84 85 86 } 87 88 89 90 91 } 92 $alerte = ( $mails_donnees['reste'] >0 ) ? true : false ; 93 94 95 96 if ( ( !$alerte && !$alerte_spam && !$alerte_mail ) ) { 97 $nb_destinataires=0; 78 $mails_donnees = mail_supervisor::Get_Datas(); 79 $nb_mails = $mails_donnees['nb_mails'] ; 80 $next_day = $mails_donnees['date_mail'] ; 81 $reste = $mails_donnees['reste'] ; 82 $rest_mail = $mails_donnees['rest_mail'] ; 83 if ($rest_mail <=0 || $mails_donnees['nb_mails'] ==0 ){ 84 $mails_donnees['nb_mails'] =0 ; 85 $mails_donnees['date_mail'] = time(); 86 } 87 $rest_spam = $mails_donnees['rest_spam'] ; 88 if ($rest_spam <=0 || $mails_donnees['nb_spams'] ==0 ){ 89 $mails_donnees['nb_spams'] =0 ; 90 $mails_donnees['date_spam'] = time(); 91 } 92 $alerte = ( $mails_donnees['reste'] >0 ) ? true : false ; 93 $alerte_mail = ( $mails_donnees['nb_mails'] > $mails_donnees['nb_mails_maxi']-1 ) ? true : false ; 94 $alerte_spam = ( $mails_donnees['nb_spams'] > $mails_donnees['nb_spams_maxi']-1 ) ? true : false ; 95 96 if ( ( !$alerte && !$alerte_spam && !$alerte_mail ) ) { 97 $nb_destinataires=0; 98 98 //==================================================== 99 $match_email = $conf_mail['email_webmaster']; 99 $match_email = $conf_mail['email_webmaster']; 100 100 101 $new_args=array(); 101 102 if( isset($args['Bcc'])) 102 foreach($args['Bcc'] as $key => $val){ 103 if (!preg_match('/'. $match_email.'/', $val)){ 103 foreach($args['Bcc'] as $key => $val){ 104 if (!preg_match('/'. $match_email.'/', $val)){ 104 105 array_push($new_args, $val); 105 106 }else{ 106 107 $mailto = $match_email; 107 108 } 108 109 } … … 110 111 //======================================================================= 111 112 $nb_destinataires=0; 112 if ($mailto<>"" ) $nb_destinataires +=1; 113 if (!empty($args['Cc'])) { 114 $nb_destinataires += count($args['Cc']); 115 116 } 117 if (!empty($args['Bcc'])) { 118 $nb_destinataires += count($args['Bcc']); 119 } 120 if ($mailto == "" && $nb_destinataires==0 ) 113 if ($mailto<>"" ) $nb_destinataires +=1; 114 if (!empty($args['Cc'])) { 115 $nb_destinataires += count($args['Cc']); 116 117 } 118 if (!empty($args['Bcc'])) { 119 $nb_destinataires += count($args['Bcc']); 120 } 121 if ($mailto == "" && $nb_destinataires==0 ) { 121 122 $mailto = $conf_mail['email_webmaster']; 122 123 $nb_destinataires ++; 123 124 } 124 125 125 126 if ($mailto == "" && $nb_destinataires > 1 )$mailto = $conf_mail['email_webmaster'];127 } 128 129 $infos_message .= "nb_destinataires : $nb_destinataires Theme :" . ($args['theme'] )."<br />";126 if ($mails_options['check_mailto'] == 'on') { 127 if ($mailto == "" && $nb_destinataires > 1 ) $mailto = $conf_mail['email_webmaster']; 128 } 129 130 $infos_message .= "nb_destinataires : $nb_destinataires Theme :" . ($args['theme'] ) ."{". $lang_info['language_name'] ."}"."<br />"; 130 131 //================= réecriture de l'entete =============================== 131 132 $match=array("<",">"); 132 $string=array("<",">") ; 133 if ( $nb_destinataires == 1 ) { 134 if ($mailto == "" ) { 135 if (!empty($args['Bcc'])){ 133 $string=array("<",">") ; 134 if ( $nb_destinataires == 1 ) { 135 if ($mailto == "" ) { 136 if (!empty($args['Bcc'])){ 136 137 $mailto = get_strict_email_list(implode(',', $args['Bcc'])); 137 138 $args['Bcc']=array(); 138 }else{ 139 }else{ 139 140 if (!empty($args['Cc']) ){ $mailto=get_strict_email_list(implode(',', $args['Cc'])); 140 141 $args['Cc']=array(); … … 148 149 $infos_message .="Destinataire:" .$mailto ; 149 150 //============================================================================= 150 151 151 152 }else{ 152 153 //=== plusieurs destinataires =========== 153 154 $cl_list_mail=""; 154 if ($mailto !="") $infos_message .="To: " . $mailto . " "."<br />" ; 155 if ($mailto !="") $infos_message .="To: " . $mailto . " "."<br />" ; 155 156 if (!empty($args['Cc'])) { 156 157 $ret= corrige_header('Cc',$headers,$args,$cl_list_mail,$mailto); 157 158 $headers = $ret->headers; 158 159 if($ret->list_mail!="") $infos_message .="Cc: " . ( $ret->list_mail)." <br />" ; 159 160 160 161 } 161 if (!empty($args['Bcc'])){ 162 $ret = corrige_header('Bcc',$headers,$args,$cl_list_mail,$mailto);162 if (!empty($args['Bcc'])){ 163 $ret = corrige_header('Bcc',$headers,$args,$cl_list_mail,$mailto); 163 164 $headers = $ret->headers ; 164 165 if($ret->list_mail!="") $infos_message .="Bcc: " . ( $ret->list_mail) ." <br />"; 165 166 } 167 168 } 169 170 166 167 } 168 $infos_message .= " " ; 169 } 170 171 171 172 //============================================================================= 172 173 if ($mails_options['check_header_text']=='on') { 173 $texte = "This is a multi-part message in MIME format.\n"; 174 $texte .= "-----=".$conf_mail['boundary_key']."\n"; 175 $texte .= "Ceci est un message est au format MIME.\n"; 176 $texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n"; 177 $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 178 $texte .= $mails_donnees['header_text']; // A voir texte brut... 179 $texte .= "\n\n"; 174 $texte = "This is a multi-part message in MIME format.\n"; 175 $texte .= "-----=".$conf_mail['boundary_key']."\n"; 176 $texte .= "Ceci est un message est au format MIME.\n"; 177 $texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n"; 178 $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 179 $texte .= $mails_donnees['header_text']; // A voir texte brut... 180 $texte .= "\n\n"; 180 181 $content =$texte .$content ; 181 } 182 } 182 183 // corrige erreur 'mail dropped, bare LF found' 183 /* if ( preg_match('/\n\./',$content)){ 184 /* if ( preg_match('/\n\./',$content)){ 184 185 $content=preg_replace('/\n\./', '/\n\.\./', $content); 185 186 … … 187 188 } 188 189 $content = str_replace("\n.", "\n/./.", $content); 189 $headers = str_replace("\n.", "\n..", $headers); 190 $headers = str_replace("\n.", "\n..", $headers); 190 191 $subject = str_replace("\n.", "\n..", $subject); 191 192 $mailto = str_replace("\n.", "\n..", $mailto); 192 193 */ 193 194 $ret=false; 195 //======== Non mise en quarantaine =============196 197 198 199 if ($nb_destinataires > 0) { 200 201 if( $envoie_ok) $ret = mail($mailto, $subject,$content, $headers); 202 194 195 $ret=false; 196 //======== Non mise en quarantaine ============= 197 198 199 ob_start(); 200 if ($nb_destinataires > 0) { 201 202 if( $envoie_ok) $ret = mail($mailto, $subject,$content, $headers); 203 203 204 }else{ 204 205 $message .= l10n('Sv_no_receiver_available'); … … 206 207 $message .= ob_get_contents(); 207 208 ob_end_clean(); 208 $mails_donnees['message']=$message; 209 $mails_donnees['message']=$message; 209 210 Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto); 210 211 } else { 211 //================== Est en quarantaine ======================= 212 $erreur_message .=l10n('Sv_To_day_is')."<br />";213 if ($alerte_spam ) { 214 $type="Spams"; 215 216 217 218 219 }220 221 $type="Mails"; 212 //================== Est en quarantaine ======================= 213 $erreur_message .= l10n('Sv_To_day_is')."<br />"; 214 if ($alerte_spam ) { 215 $type="Spams"; 216 $d1=$mails_donnees['nb_spams'] . ' \\ ' . $mails_donnees['nb_spams_maxi']; 217 $d2=$mails_donnees['nb_spams']; 218 $d3= $mails_donnees['rest_spam']; 219 $d4=time()+$d3 ; 220 } 221 if ($alerte_mail) { 222 $type="Mails"; 222 223 $d1=$mails_donnees['nb_mails']. ' \\ ' . $mails_donnees['nb_mails_maxi'];; 223 224 $d2=$mails_donnees['date_mail']; 224 225 $d3= $mails_donnees['rest_mail']; 225 226 $d4=time()+$d3 ; 226 227 228 229 230 231 232 233 }227 } 228 if ($alerte) { 229 $type="Spams(Quarantaine)"; 230 $d1=$mails_donnees['nb_spams'] . ' \\ ' . $mails_donnees['nb_spams_maxi']; 231 $d2=$mails_donnees['date_quarantaine']; 232 $d3= $mails_donnees['reste']; 233 $d4=time()+$d3 ; 234 } 234 235 $d2=date(l10n('Sv_formatdate'),$d2); 235 236 $d3=int_to_heure($d3) ; 236 237 $d4=date(l10n('Sv_formatdate'),$d4); 237 238 if ($alerte_mail) { 238 239 $erreur_message .='<br />'.sprintf(l10n('Sv_alerte_mail %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'<br />'; 239 240 }else{ 240 241 } 242 $infos_message .= l10n('Sv_mail_not_send'); 243 } 244 $infos_message .= "<hr>"; 241 $erreur_message .='<br />'.sprintf(l10n('Sv_mise_en_quarantaine %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'<br />'; 242 } 243 $infos_message .= l10n('Sv_mail_not_send'); 244 } 245 $infos_message .= "<hr>"; 245 246 mail_supervisor::sauve_donnees(); 246 247 mail_supervisor::affiche_message(); 247 248 return true ; 248 249 } 249 //=========================================================================================== 250 function Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto){ 251 global $conf, $user, $conf_mail,$mails_options,$mails_donnees , $template,$page ,$infos_message,$erreur_message,$args,$lang, $lang_info; 250 //=========================================================================================== 251 function Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto){ 252 global $conf, $user, $conf_mail,$mails_options,$mails_donnees , $template,$page ,$infos_message,$erreur_message,$args,$lang, $lang_info; 252 253 $match=array("<",">"); 253 $string=array("<",">") ; 254 //Warning: mail() has been disabled for security reasons 255 256 257 $headers=str_replace( $match,$string, $headers); 258 259 260 ; // Bad recipient address syntax 261 262 263 264 265 }266 267 268 269 270 271 272 273 //=============== La fonction mail retourne une erreur ========================= 274 } 275 276 if ($est_un_spam == false)277 278 if ($mails_donnees['nb_mails']==0) { $mails_donnees['date_mail'] = time(); }279 280 281 282 283 $mails_donnees['nb_spams'] += $nb_destinataires; 284 285 if ($mails_donnees['nb_spams']==0) {$mails_donnees['date_spam'] = time();}286 287 288 289 290 291 $mails_donnees['date_quarantaine']= time() ; 292 $mails_donnees['quarantaine']= true ; 293 294 295 254 $string=array("<",">") ; 255 //Warning: mail() has been disabled for security reasons 256 257 $est_un_spam =!(strpos(strtolower($message), 'spam') === false); 258 $headers=str_replace( $match,$string, $headers); 259 260 if ( ($ret==false) || ($est_un_spam==true) || ($nb_destinataires == 0) ) { 261 ; // Bad recipient address syntax 262 $pos1 = strpos(strtolower($message), 'bad recipient address syntax'); 263 if ( !($pos1 === false) ){ 264 $erreur_message .= l10n('Sv_detection_de').' Bad recipient address syntax .'; 265 $erreur_message .= l10n('Sv_verifiez_les_destinataires').' (Bcc,Cc,To)<br />'; 266 } 267 268 $erreur_message .= sprintf(l10n('Sv_debug_message'), 269 ($ret==true)? "true" : "false", 270 $message , 271 $mailto , 272 $headers , 273 $nb_destinataires ); 274 //=============== La fonction mail retourne une erreur ========================= 275 } 276 277 if ($est_un_spam == false) 278 { 279 if ($mails_donnees['nb_mails']==0) { $mails_donnees['date_mail'] = time(); } 280 $mails_donnees['nb_mails'] += $nb_destinataires; 281 } 282 else 283 { 284 $mails_donnees['nb_spams'] += $nb_destinataires; 285 //--- Detection de spam ------------------ 286 if ($mails_donnees['nb_spams']==0) {$mails_donnees['date_spam'] = time(); } 287 288 $trop_de_spam =!(strpos(strtolower($message), 'trop de spam') === false); 289 if ( $trop_de_spam ) { 290 $mails_donnees['nb_spams_maxi']=$mails_donnees['nb_spams']; 291 292 $mails_donnees['date_quarantaine']= time() ; 293 $mails_donnees['quarantaine']= true ; 294 $infos_message .= mail_supervisor::Memo_Var($mails_donnees); 295 } 296 } 296 297 $ret=true; 297 return $ret ; 298 return $ret ; 298 299 } 299 300 ?>
Note: See TracChangeset
for help on using the changeset viewer.