Changeset 10385 for extensions/Mail_supervisor/main.inc.php
- Timestamp:
- Apr 15, 2011, 4:09:41 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Mail_supervisor/main.inc.php
r9702 r10385 11 11 if (!defined('mail_superv_DIR')) define('mail_superv_DIR' , basename(dirname(__FILE__))); 12 12 if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); 13 $MAIL_SUPERV_PATH_ABS=str_replace('\\','/',dirname(__FILE__) ); 13 14 $MAIL_SUPERV_PATH_ABS = str_replace('\\','/',dirname(__FILE__) ); 14 15 if (!defined('MAIL_SUPERV_PATH_ABS')) define( 'MAIL_SUPERV_PATH_ABS', $MAIL_SUPERV_PATH_ABS."/"); 16 15 17 global $conf,$mails_options ; 16 18 include_once (MAIL_SUPERV_PATH.'include/constants.php'); 17 19 include_once(MAIL_SUPERV_PATH.'mail_super.inc.php'); 20 18 21 $mail_supervisor = new mail_supervisor(); 19 22 add_event_handler('get_admin_plugin_menu_links', array(&$mail_supervisor,'admin_menu') ); … … 23 26 // 24 27 // 28 include_once (PHPWG_ROOT_PATH.'include/functions_mail.inc.php' ); 25 29 include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 26 30 //===============loc_begin_index==============loc_after_page_header============================================================= 27 add_event_handler('loc_ after_page_header', array(&$mail_supervisor,'init') );31 add_event_handler('loc_begin_page_header', array(&$mail_supervisor,'init') ); 28 32 add_event_handler('loc_begin_page_tail', array(&$mail_supervisor,'affiche_message') ); 29 33 … … 31 35 add_event_handler('send_mail', 'clj_mail',EVENT_HANDLER_PRIORITY_NEUTRAL - 10, 6); 32 36 function clj_mail($result, $mailto, $subject, $content, $headers, $args) { 33 global $conf, $user, $lang_info; 34 global $conf_mail,$mails_options,$mails_donnees ; 35 global $template,$page ,$erreur_message,$infos_message, $lang; 36 global $errors; 37 38 // lecture config table ------------- 39 include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 40 load_language('plugin.lang', MAIL_SUPERV_PATH); 41 if (isset($_POST["Submit"]) ) { 42 if ($_POST["Submit"] != l10n('Sv_Envoyer') ) return true ; 43 } 44 // remove_event_handler('send_mail', 'pwg_send_mail'); 45 46 $message =""; 47 if (!isset($infos_message)) { $infos_message = ""; } 48 if (!isset($erreur_message)) { $erreur_message = ''; } 37 global $conf, $user, $lang_info; 38 global $conf_mail,$mails_options,$mails_donnees ; 39 global $template,$page ,$erreur_message,$infos_message, $lang; 40 global $errors; 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 = ''; } 49 51 50 51 52 //======== verification si envoie de mail ou blocage connexion =====================53 54 52 // $mails_options = explode("," , $conf['mail_superv']); 53 $envoie_ok=true ; 54 //======== verification si envoie de mail ou blocage connexion ===================== 55 56 if ($mails_options['no_mail_list']=='on' || $mails_options['no_connect'] == 'on' ) { 55 57 if (kill_list()) { 56 58 $nb_destinataires=0; ; … … 58 60 $erreur_message .= "<BR />".l10n('Sv_is_a_spam') ; 59 61 $infos_message = l10n('Sv_mail_not_send')."<BR />"; 60 if ($mails_options['no_connect'] == 'on' ){ 61 if ($user['status'] == 'webmaster' ) { 62 //---------- continuer si web master ---------- 63 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 72 } 73 74 } 75 62 if ($mails_options['no_connect'] == 'on' ){ 63 if ($user['status'] == 'webmaster'){ 64 //---------- continuer si web master ---------- 65 }else{ 66 if (!isset($_GET['admin'])) { 67 die('Blacklist : <br />' .$erreur_message. '<br /> Hacking attempt!'); 68 }elseif ($_GET['admin'] != 'piwigo') 69 { 70 die('blacklist Hacking attempt!'); 71 } 72 } 73 } 76 74 return true; 77 75 } 78 76 } 79 // lecture donnees ------------- 80 $mails_donnees = mail_supervisor::Get_Datas(); 81 82 $nb_mails = $mails_donnees['nb_mails'] ; 83 $next_day = $mails_donnees['date_mail'] ; 84 85 $reste = $mails_donnees['reste'] ; 86 87 88 $rest_mail = $mails_donnees['rest_mail'] ; 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'] ; 89 83 if ($rest_mail <=0 || $mails_donnees['nb_mails'] ==0 ){ 90 84 $mails_donnees['nb_mails'] =0 ; 91 85 $mails_donnees['date_mail'] = time(); 92 } 93 86 } 94 87 $rest_spam = $mails_donnees['rest_spam'] ; 95 88 if ($rest_spam <=0 || $mails_donnees['nb_spams'] ==0 ){ 96 89 $mails_donnees['nb_spams'] =0 ; 97 90 $mails_donnees['date_spam'] = time(); 98 } 99 100 $alerte = ( $mails_donnees['reste'] >0 ) ? true : false ; 101 91 } 92 $alerte = ( $mails_donnees['reste'] >0 ) ? true : false ; 102 93 $alerte_mail = ( $mails_donnees['nb_mails'] > $mails_donnees['nb_mails_maxi']-1 ) ? true : false ; 103 $alerte_spam = ( $mails_donnees['nb_spams'] > $mails_donnees['nb_spams_maxi']-1 ) ? true : false ; 104 105 106 if ( ( !$alerte && !$alerte_spam && !$alerte_mail ) ) { 107 $nb_destinataires=0; 108 if ($mails_options['check_mailto'] == 'on') { 109 if ($mailto == "" ) $mailto = $conf_mail['email_webmaster']; 110 } 111 if ($mailto<>"" ) $nb_destinataires +=1; 112 if (!empty($args['Bcc'])) { $nb_destinataires += count($args['Bcc']); } 113 if (!empty($args['Cc'])) { $nb_destinataires += count($args['Cc']); } 114 115 116 $infos_message .= "<hr> Theme :" . ($args['theme'] ) ."<br />"; 117 $infos_message .="nombre de destinataire:".$nb_destinataires." <br />" ; 118 119 //================= reecriture de l'entete =============================== 120 $match=array("<",">"); 121 $string=array("<",">") ; 122 123 if ( $nb_destinataires == 1 && $mailto != "" ) 124 { 125 $infos_message .="--> Mailto: " . $mailto." \n" ; 126 127 if ($mailto != "" ) 128 { 129 130 $mailto = $mailto ." \n" ; 131 $headers = preg_replace('/.*Bcc(.*).\n/i', '', $headers); 132 $headers = preg_replace('/.*Cc(.*).\n/i', '', $headers); 133 134 135 } 136 //============================================================================= 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 //==================================================== 99 $match_email = $conf_mail['email_webmaster']; 100 $new_args=array(); 101 foreach($args['Bcc'] as $key => $val){ 102 if (!preg_match('/'. $match_email.'/', $val)){ 103 array_push($new_args, $val); 104 }else{ 105 $mailto = $match_email; 106 } 107 } 108 $args['Bcc']=$new_args; 109 //======================================================================= 110 $nb_destinataires=0; 111 if ($mailto<>"" ) $nb_destinataires +=1; 112 if (!empty($args['Cc'])) { 113 $nb_destinataires += count($args['Cc']); 114 115 } 116 if (!empty($args['Bcc'])) { 117 $nb_destinataires += count($args['Bcc']); 118 } 119 if ($mailto == "" && $nb_destinataires==0 ) { 120 $mailto = $conf_mail['email_webmaster']; 121 $nb_destinataires ++; 122 } 123 124 if ($mails_options['check_mailto'] == 'on') { 125 if ($mailto == "" && $nb_destinataires > 1 ) $mailto = $conf_mail['email_webmaster']; 126 } 127 128 $infos_message .= "nb_destinataires : $nb_destinataires Theme :" . ($args['theme'] ) ."<br />"; 129 //================= réecriture de l'entete =============================== 130 $match=array("<",">"); 131 $string=array("<",">") ; 132 if ( $nb_destinataires == 1 ) { 133 if ($mailto == "" ) { 134 if (!empty($args['Bcc'])){ 135 $mailto = get_strict_email_list(implode(',', $args['Bcc'])); 136 $args['Bcc']=array(); 137 }else{ 138 if (!empty($args['Cc']) ){ $mailto=get_strict_email_list(implode(',', $args['Cc'])); 139 $args['Cc']=array(); 140 }; 141 } 142 } 143 if ($mailto == "" ) {$nb_destinataires = 0 ;} 144 $mailto = $mailto ." \n" ; 145 $headers = preg_replace('/.*Bcc(.*).\n/i', '', $headers); 146 $headers = preg_replace('/.*Cc(.*).\n/i', '', $headers); 147 $infos_message .="Destinataire:" .$mailto ; 148 //============================================================================= 149 150 }else{ 151 //=== plusieurs destinataires =========== 152 $cl_list_mail=""; 153 if ($mailto !="") $infos_message .="To: " . $mailto . " "."<br />" ; 154 if (!empty($args['Cc'])) { 155 $ret= corrige_header('Cc',$headers,$args,$cl_list_mail,$mailto); 156 $headers = $ret->headers; 157 if($ret->list_mail!="") $infos_message .="Cc: " . ( $ret->list_mail)." <br />" ; 137 158 138 139 if (!empty($args['Bcc']) ) $infos_message .="Bcc: " . mail_supervisor::Memo_Var($args['Bcc']) ." \n"; 140 if (!empty($args['Cc']) ) $infos_message .="Cc: " . mail_supervisor::Memo_Var($args['Cc'])." \n" ; 141 $infos_message .="Mailto: [" . $mailto . "]"." \n".$headers; 142 143 }else{ 144 //=== plusieurs destinataires =========== 145 $cl_list_mail=""; 146 147 if ($mailto !="") $infos_message .="To: " . $mailto . " "." /n" ; 148 if (!empty($args['Cc'])) { 149 $ret= corrige_header('Cc',$headers,$args,$cl_list_mail); 150 $headers = $ret->headers; 151 $infos_message .="Cc: " . ( $ret->list_mail)." <br />" ; 152 } 153 if (!empty($args['Bcc'])){ 154 $ret = corrige_header('Bcc',$headers,$args,$cl_list_mail); 155 156 $headers = $ret->headers ; 157 $infos_message .="Bcc: " . ( $ret->list_mail) ." <br />"; 158 } 159 } 160 if (!empty($args['Bcc'])){ 161 $ret = corrige_header('Bcc',$headers,$args,$cl_list_mail,$mailto); 162 $headers = $ret->headers ; 163 if($ret->list_mail!="") $infos_message .="Bcc: " . ( $ret->list_mail) ." <br />"; 164 165 } 166 $infos_message .= " " ; 167 } 168 159 169 160 $infos_message .= " " ;161 }162 // $infos_message .= $content ;163 170 //============================================================================= 164 171 if ($mails_options['check_header_text']=='on') { … … 171 178 $texte .= "\n\n"; 172 179 $content =$texte .$content ; 173 } 174 175 $ret=false; 176 //======== Non mise en quarantaine ============= 180 } 181 // corrige erreur 'mail dropped, bare LF found' 182 /* if ( preg_match('/\n\./',$content)){ 183 $content=preg_replace('/\n\./', '/\n\.\./', $content); 184 185 // $infos_message .= $content ; 186 } 187 $content = str_replace("\n.", "\n/./.", $content); 188 $headers = str_replace("\n.", "\n..", $headers); 189 $subject = str_replace("\n.", "\n..", $subject); 190 $mailto = str_replace("\n.", "\n..", $mailto); 191 */ 192 193 $ret=false; 194 //======== Non mise en quarantaine ============= 195 196 177 197 ob_start(); 178 $ret = false; 179 if ($nb_destinataires > 0) { 180 // corrige erreur 'mail dropped, bare LF found' 181 $content = str_replace("\n.", "\n..", $content); 182 $headers = str_replace("\n.", "\n..", $headers); 183 $subject = str_replace("\n.", "\n..", $subject); 184 $mailto = str_replace("\n.", "\n..", $mailto); 185 if( $envoie_ok) $ret = mail($mailto, $subject, $content, $headers); 186 187 }else{ 188 $message .= l10n('Sv_no_receiver_available'); 189 } 190 $message .= ob_get_contents(); 191 ob_end_clean(); 192 $mails_donnees['message']=$message; 193 Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto); 198 if ($nb_destinataires > 0) { 199 200 if( $envoie_ok) $ret = mail($mailto, $subject,$content, $headers); 201 202 }else{ 203 $message .= l10n('Sv_no_receiver_available'); 204 } 205 $message .= ob_get_contents(); 206 ob_end_clean(); 207 $mails_donnees['message']=$message; 208 Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto); 194 209 } else { 195 210 //================== Est en quarantaine ======================= … … 225 240 } 226 241 $infos_message .= l10n('Sv_mail_not_send'); 227 } 242 } 243 $infos_message .= "<hr>"; 228 244 mail_supervisor::sauve_donnees(); 229 245 mail_supervisor::affiche_message();
Note: See TracChangeset
for help on using the changeset viewer.