[4020] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Mail supervisor |
---|
[9702] | 4 | Version: auto |
---|
[4225] | 5 | Description: Mail supervisor surveille l'envoie des mails. |
---|
[4023] | 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=315 |
---|
[4020] | 7 | Author: cljosse |
---|
[4199] | 8 | Author URI:http://cljosse.free.fr |
---|
[4020] | 9 | */ |
---|
| 10 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
[9702] | 11 | if (!defined('mail_superv_DIR')) define('mail_superv_DIR' , basename(dirname(__FILE__))); |
---|
[4041] | 12 | if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
[10385] | 13 | |
---|
| 14 | $MAIL_SUPERV_PATH_ABS = str_replace('\\','/',dirname(__FILE__) ); |
---|
[9702] | 15 | if (!defined('MAIL_SUPERV_PATH_ABS')) define( 'MAIL_SUPERV_PATH_ABS', $MAIL_SUPERV_PATH_ABS."/"); |
---|
[10385] | 16 | |
---|
[9702] | 17 | global $conf,$mails_options ; |
---|
[10419] | 18 | include_once (MAIL_SUPERV_PATH.'include/constants.php'); |
---|
[9702] | 19 | include_once(MAIL_SUPERV_PATH.'mail_super.inc.php'); |
---|
[10385] | 20 | |
---|
[9702] | 21 | $mail_supervisor = new mail_supervisor(); |
---|
| 22 | add_event_handler('get_admin_plugin_menu_links', array(&$mail_supervisor,'admin_menu') ); |
---|
[4020] | 23 | |
---|
[11807] | 24 | mail_supervisor::Get_Options($mails_options,"mail_superv"); |
---|
| 25 | |
---|
[10419] | 26 | /* EVENT_HANDLER_PRIORITY_NEUTRAL */ |
---|
[9702] | 27 | // |
---|
| 28 | // |
---|
[10385] | 29 | include_once (PHPWG_ROOT_PATH.'include/functions_mail.inc.php' ); |
---|
[10419] | 30 | include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); |
---|
[11807] | 31 | //===============loc_begin_index |
---|
| 32 | //==== loc_begin_page_header |
---|
| 33 | //========== loc_after_page_header |
---|
[10564] | 34 | add_event_handler('loc_after_page_header', array(&$mail_supervisor,'init') ); |
---|
[9702] | 35 | add_event_handler('loc_begin_page_tail', array(&$mail_supervisor,'affiche_message') ); |
---|
[4020] | 36 | |
---|
[11807] | 37 | include_once(MAIL_SUPERV_PATH.'mail_send.inc.php'); |
---|
| 38 | $clj = new clj(); |
---|
| 39 | |
---|
| 40 | add_event_handler('send_mail',array(&$clj,'send_mail'),EVENT_HANDLER_PRIORITY_NEUTRAL - 1, 6); |
---|
| 41 | add_event_handler('send_mail_to',array(&$clj,'send_mail_to') ); |
---|
| 42 | add_event_handler('send_mail_subject',array(&$clj,'send_mail_subject') ); |
---|
| 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 ); |
---|
| 45 | |
---|
[9702] | 46 | //========================================================================================== |
---|
[11807] | 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) { |
---|
[10419] | 50 | global $conf, $user, $lang_info; |
---|
[10385] | 51 | global $conf_mail,$mails_options,$mails_donnees ; |
---|
[10419] | 52 | global $template,$page ,$erreur_message,$infos_message, $lang; |
---|
[10385] | 53 | global $errors; |
---|
| 54 | // lecture config table ------------- |
---|
[11807] | 55 | |
---|
| 56 | |
---|
[10419] | 57 | include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); |
---|
| 58 | load_language('plugin.lang', MAIL_SUPERV_PATH); |
---|
| 59 | |
---|
[10816] | 60 | $arg_trigg= array($mailto, $subject, $content, $headers, $args); |
---|
| 61 | |
---|
| 62 | trigger_event('mail_supervisor_clj_mail',$arg_trigg); |
---|
| 63 | |
---|
[10419] | 64 | // remove_event_handler('send_mail', 'pwg_send_mail'); |
---|
| 65 | $message =""; |
---|
| 66 | if (!isset($infos_message)) { $infos_message = ""; } |
---|
| 67 | if (!isset($erreur_message)) { $erreur_message = ''; } |
---|
| 68 | |
---|
[10385] | 69 | // $mails_options = explode("," , $conf['mail_superv']); |
---|
| 70 | $envoie_ok=true ; |
---|
| 71 | //======== verification si envoie de mail ou blocage connexion ===================== |
---|
[9702] | 72 | |
---|
[10419] | 73 | if ($mails_options['no_mail_list']=='on' || $mails_options['no_connect'] == 'on' ) { |
---|
[10816] | 74 | if (kill_list()) { |
---|
[9702] | 75 | $nb_destinataires=0; ; |
---|
| 76 | $envoie_ok= false ; |
---|
| 77 | $erreur_message .= "<BR />".l10n('Sv_is_a_spam') ; |
---|
[10419] | 78 | $infos_message = l10n('Sv_mail_not_send')."<BR />"; |
---|
[10816] | 79 | if ($mails_options['no_connect'] == 'on' ){ |
---|
[10419] | 80 | if ($user['status'] == 'webmaster'){ |
---|
| 81 | //---------- continuer si web master ---------- |
---|
| 82 | }else{ |
---|
[10816] | 83 | trigger_event('mail_supervisor_send_mail', "DIE(KILL) : " . $ip . ' = ' . $user['status']); |
---|
[10419] | 84 | if (!isset($_GET['admin'])) { |
---|
| 85 | die('Blacklist : <br />' .$erreur_message. '<br /> Hacking attempt!'); |
---|
| 86 | }elseif ($_GET['admin'] != 'piwigo') |
---|
| 87 | { |
---|
| 88 | die('blacklist Hacking attempt!'); |
---|
| 89 | } |
---|
| 90 | } |
---|
[10385] | 91 | } |
---|
[10816] | 92 | trigger_event('mail_supervisor_send_mail', "Kill : " . $ip . ' = ' . $user['status'] . "noconnect==off"); |
---|
| 93 | return true; |
---|
| 94 | } |
---|
[10419] | 95 | } |
---|
[10385] | 96 | // lecture donnees ------------- |
---|
[10419] | 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'] ; |
---|
| 101 | $rest_mail = $mails_donnees['rest_mail'] ; |
---|
| 102 | if ($rest_mail <=0 || $mails_donnees['nb_mails'] ==0 ){ |
---|
| 103 | $mails_donnees['nb_mails'] =0 ; |
---|
| 104 | $mails_donnees['date_mail'] = time(); |
---|
| 105 | } |
---|
| 106 | $rest_spam = $mails_donnees['rest_spam'] ; |
---|
| 107 | if ($rest_spam <=0 || $mails_donnees['nb_spams'] ==0 ){ |
---|
| 108 | $mails_donnees['nb_spams'] =0 ; |
---|
| 109 | $mails_donnees['date_spam'] = time(); |
---|
| 110 | } |
---|
| 111 | $alerte = ( $mails_donnees['reste'] >0 ) ? true : false ; |
---|
| 112 | $alerte_mail = ( $mails_donnees['nb_mails'] > $mails_donnees['nb_mails_maxi']-1 ) ? true : false ; |
---|
| 113 | $alerte_spam = ( $mails_donnees['nb_spams'] > $mails_donnees['nb_spams_maxi']-1 ) ? true : false ; |
---|
[4049] | 114 | |
---|
[10419] | 115 | if ( ( !$alerte && !$alerte_spam && !$alerte_mail ) ) { |
---|
| 116 | $nb_destinataires=0; |
---|
[10385] | 117 | //==================================================== |
---|
[10419] | 118 | $match_email = $conf_mail['email_webmaster']; |
---|
| 119 | |
---|
[10385] | 120 | $new_args=array(); |
---|
[10388] | 121 | if( isset($args['Bcc'])) |
---|
[10419] | 122 | foreach($args['Bcc'] as $key => $val){ |
---|
| 123 | if (!preg_match('/'. $match_email.'/', $val)){ |
---|
[10385] | 124 | array_push($new_args, $val); |
---|
| 125 | }else{ |
---|
[10419] | 126 | $mailto = $match_email; |
---|
[10385] | 127 | } |
---|
| 128 | } |
---|
| 129 | $args['Bcc']=$new_args; |
---|
| 130 | //======================================================================= |
---|
| 131 | $nb_destinataires=0; |
---|
[10419] | 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 ) { |
---|
[10385] | 141 | $mailto = $conf_mail['email_webmaster']; |
---|
| 142 | $nb_destinataires ++; |
---|
| 143 | } |
---|
[8917] | 144 | |
---|
[10419] | 145 | if ($mails_options['check_mailto'] == 'on') { |
---|
| 146 | if ($mailto == "" && $nb_destinataires > 1 ) $mailto = $conf_mail['email_webmaster']; |
---|
| 147 | } |
---|
[8917] | 148 | |
---|
[10419] | 149 | $infos_message .= "nb_destinataires : $nb_destinataires Theme :" . ($args['theme'] ) ."{". $lang_info['language_name'] ."}"."<br />"; |
---|
[11807] | 150 | //================= réecriture de l'entete =============================== |
---|
[10385] | 151 | $match=array("<",">"); |
---|
[10419] | 152 | $string=array("<",">") ; |
---|
| 153 | if ( $nb_destinataires == 1 ) { |
---|
| 154 | if ($mailto == "" ) { |
---|
| 155 | if (!empty($args['Bcc'])){ |
---|
[10385] | 156 | $mailto = get_strict_email_list(implode(',', $args['Bcc'])); |
---|
| 157 | $args['Bcc']=array(); |
---|
[10419] | 158 | }else{ |
---|
[10385] | 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 | //============================================================================= |
---|
[10419] | 170 | |
---|
[10385] | 171 | }else{ |
---|
| 172 | //=== plusieurs destinataires =========== |
---|
| 173 | $cl_list_mail=""; |
---|
[10419] | 174 | if ($mailto !="") $infos_message .="To: " . $mailto . " "."<br />" ; |
---|
[10385] | 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 />" ; |
---|
[10419] | 179 | |
---|
[10385] | 180 | } |
---|
[10419] | 181 | if (!empty($args['Bcc'])){ |
---|
| 182 | $ret = corrige_header('Bcc',$headers,$args,$cl_list_mail,$mailto); |
---|
[10385] | 183 | $headers = $ret->headers ; |
---|
| 184 | if($ret->list_mail!="") $infos_message .="Bcc: " . ( $ret->list_mail) ." <br />"; |
---|
[10419] | 185 | |
---|
| 186 | } |
---|
| 187 | $infos_message .= " " ; |
---|
[10385] | 188 | } |
---|
[10816] | 189 | |
---|
[11807] | 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 | $pattern ="#(?<!\r)\n#si" ; |
---|
| 209 | if( preg_match($pattern, $content) ){ |
---|
| 210 | $infos_message .= $pattern. " <br />"; |
---|
[11808] | 211 | $content= preg_replace( $pattern, "\r\n", $content); // |
---|
| 212 | //$content = str_replace("\n.", "\n..", $content); |
---|
[11807] | 213 | } |
---|
| 214 | |
---|
| 215 | |
---|
| 216 | }else{ |
---|
| 217 | $pattern="/hotmail/"; |
---|
| 218 | if( preg_match($pattern, $mailto) || preg_match($pattern, $headers) ){ |
---|
| 219 | // |
---|
| 220 | }else{ |
---|
| 221 | $pattern="/free.fr|club/"; |
---|
| 222 | if( preg_match($pattern, $mailto) || preg_match($pattern, $headers) ){ |
---|
| 223 | $content= preg_replace('#(?<!\r)\n#si', "\r\n", $content); //drop LF barre |
---|
| 224 | }else{ |
---|
| 225 | |
---|
| 226 | } |
---|
| 227 | } |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | //===================================================================== |
---|
[10822] | 231 | if (!preg_match('/'. $conf_mail['boundary_key'] .'/', $headers)){ |
---|
| 232 | $erreur_message .= "<br />ERREUR manque : boundary_key dans le headers <br />"; |
---|
[10816] | 233 | $infos_message = l10n('Sv_mail_not_send'); |
---|
[10822] | 234 | $envoie_ok= false ; |
---|
[11807] | 235 | return false ; |
---|
| 236 | |
---|
[10816] | 237 | } |
---|
[11807] | 238 | //===================================================================== |
---|
| 239 | $ret="false"; |
---|
[10822] | 240 | ob_start(); |
---|
[10419] | 241 | //======== Non mise en quarantaine ============= |
---|
[10822] | 242 | //echo "warning spam" ; |
---|
| 243 | // echo " Warning: mail() has been disabled for security reasons"; |
---|
| 244 | |
---|
[10419] | 245 | if ($nb_destinataires > 0) { |
---|
[11807] | 246 | if( $envoie_ok) { |
---|
| 247 | $ret = mail($mailto, $subject,$content, $headers); |
---|
| 248 | } |
---|
[10816] | 249 | }else{ |
---|
| 250 | $message .= l10n('Sv_no_receiver_available'); |
---|
| 251 | } |
---|
| 252 | $message .= ob_get_contents(); |
---|
| 253 | ob_end_clean(); |
---|
| 254 | $arg_trigg= array("Nb destinataires: " . $nb_destinataires,"Mail to: ".$mailto,"content: ".$content, " Reponse : " . $message); |
---|
| 255 | trigger_event('mail_supervisor_mail', $arg_trigg ); |
---|
| 256 | $mails_donnees['message']=$message; |
---|
[11807] | 257 | $ret= Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content); |
---|
[9702] | 258 | } else { |
---|
[10419] | 259 | //================== Est en quarantaine ======================= |
---|
[11807] | 260 | |
---|
[10419] | 261 | $erreur_message .= l10n('Sv_To_day_is')."<br />"; |
---|
| 262 | if ($alerte_spam ) { |
---|
| 263 | $type="Spams"; |
---|
| 264 | $d1=$mails_donnees['nb_spams'] . ' \\ ' . $mails_donnees['nb_spams_maxi']; |
---|
| 265 | $d2=$mails_donnees['nb_spams']; |
---|
| 266 | $d3= $mails_donnees['rest_spam']; |
---|
| 267 | $d4=time()+$d3 ; |
---|
| 268 | } |
---|
| 269 | if ($alerte_mail) { |
---|
| 270 | $type="Mails"; |
---|
[9702] | 271 | $d1=$mails_donnees['nb_mails']. ' \\ ' . $mails_donnees['nb_mails_maxi'];; |
---|
| 272 | $d2=$mails_donnees['date_mail']; |
---|
| 273 | $d3= $mails_donnees['rest_mail']; |
---|
| 274 | $d4=time()+$d3 ; |
---|
[10419] | 275 | } |
---|
| 276 | if ($alerte) { |
---|
| 277 | $type="Spams(Quarantaine)"; |
---|
| 278 | $d1=$mails_donnees['nb_spams'] . ' \\ ' . $mails_donnees['nb_spams_maxi']; |
---|
| 279 | $d2=$mails_donnees['date_quarantaine']; |
---|
| 280 | $d3= $mails_donnees['reste']; |
---|
| 281 | $d4=time()+$d3 ; |
---|
| 282 | } |
---|
[9702] | 283 | $d2=date(l10n('Sv_formatdate'),$d2); |
---|
| 284 | $d3=int_to_heure($d3) ; |
---|
| 285 | $d4=date(l10n('Sv_formatdate'),$d4); |
---|
| 286 | if ($alerte_mail) { |
---|
[10419] | 287 | $erreur_message .='<br />'.sprintf(l10n('Sv_alerte_mail %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'<br />'; |
---|
[9702] | 288 | }else{ |
---|
[10419] | 289 | $erreur_message .='<br />'.sprintf(l10n('Sv_mise_en_quarantaine %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'<br />'; |
---|
[9702] | 290 | } |
---|
[11807] | 291 | $ret = "Error ". $type." : "; |
---|
| 292 | $ret .= l10n('Sv_mail_not_send'); |
---|
| 293 | |
---|
[10419] | 294 | $infos_message .= l10n('Sv_mail_not_send'); |
---|
| 295 | } |
---|
[10816] | 296 | $infos_message .= "<hr>"; |
---|
| 297 | trigger_event('mail_supervisor_message', $infos_message ); |
---|
[9702] | 298 | mail_supervisor::sauve_donnees(); |
---|
| 299 | mail_supervisor::affiche_message(); |
---|
[10816] | 300 | |
---|
[11807] | 301 | return $ret ;// |
---|
[4029] | 302 | } |
---|
[10419] | 303 | //=========================================================================================== |
---|
[10822] | 304 | function Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content){ |
---|
[10419] | 305 | global $conf, $user, $conf_mail,$mails_options,$mails_donnees , $template,$page ,$infos_message,$erreur_message,$args,$lang, $lang_info; |
---|
[9702] | 306 | $match=array("<",">"); |
---|
[10822] | 307 | $string=array("<",">") ; |
---|
| 308 | // $headers=str_replace( $match,$string, $headers); |
---|
| 309 | // Warning: mail() has been disabled for security reasons |
---|
| 310 | $est_un_spam =!(strpos(strtolower($message), 'spam') === false); |
---|
[10419] | 311 | if ( ($ret==false) || ($est_un_spam==true) || ($nb_destinataires == 0) ) { |
---|
[11807] | 312 | //=============== La fonction mail retourne une erreur ========================= |
---|
| 313 | $ret="Error"; |
---|
[10822] | 314 | // Bad recipient address syntax |
---|
[10419] | 315 | $pos1 = strpos(strtolower($message), 'bad recipient address syntax'); |
---|
| 316 | if ( !($pos1 === false) ){ |
---|
| 317 | $erreur_message .= l10n('Sv_detection_de').' Bad recipient address syntax .'; |
---|
| 318 | $erreur_message .= l10n('Sv_verifiez_les_destinataires').' (Bcc,Cc,To)<br />'; |
---|
[10822] | 319 | } |
---|
[11807] | 320 | $erreur_message .=$ret . " : <br />".sprintf(l10n('Sv_debug_message'), |
---|
[10822] | 321 | ($ret==true)? "true" : "false", |
---|
| 322 | htmlspecialchars($message) , |
---|
| 323 | htmlspecialchars( $mailto) , |
---|
| 324 | htmlspecialchars($subject) , |
---|
| 325 | htmlspecialchars($headers) , |
---|
| 326 | htmlspecialchars($content) , |
---|
| 327 | $nb_destinataires ); |
---|
[10419] | 328 | |
---|
[10822] | 329 | Mail_supervisor_log($mailto,$erreur_message) ; |
---|
| 330 | |
---|
[11807] | 331 | }else{ |
---|
[10822] | 332 | if( isset($mails_options['debug_mail']) && $mails_options['debug_mail']=="on") { |
---|
[11807] | 333 | $infos_message .="DEBUG : <br />" .sprintf(l10n('Sv_debug_message'), |
---|
| 334 | ($ret==true)? "true" : "false", |
---|
[10822] | 335 | htmlspecialchars( $message) , |
---|
| 336 | htmlspecialchars( $mailto) , |
---|
| 337 | htmlspecialchars($subject) , |
---|
| 338 | htmlspecialchars($headers) , |
---|
| 339 | htmlspecialchars($content) , |
---|
| 340 | $nb_destinataires ); |
---|
| 341 | |
---|
[11807] | 342 | Mail_supervisor_log($mailto,$infos_message) ; |
---|
[10822] | 343 | } |
---|
| 344 | } |
---|
[11807] | 345 | //================================================================= |
---|
[10822] | 346 | |
---|
| 347 | |
---|
| 348 | if ($est_un_spam == false){ |
---|
[10419] | 349 | if ($mails_donnees['nb_mails']==0) { $mails_donnees['date_mail'] = time(); } |
---|
| 350 | $mails_donnees['nb_mails'] += $nb_destinataires; |
---|
[10822] | 351 | } else { |
---|
[11807] | 352 | $ret="Error spam"; |
---|
[10419] | 353 | $mails_donnees['nb_spams'] += $nb_destinataires; |
---|
| 354 | //--- Detection de spam ------------------ |
---|
| 355 | if ($mails_donnees['nb_spams']==0) {$mails_donnees['date_spam'] = time(); } |
---|
| 356 | |
---|
| 357 | $trop_de_spam =!(strpos(strtolower($message), 'trop de spam') === false); |
---|
| 358 | if ( $trop_de_spam ) { |
---|
| 359 | $mails_donnees['nb_spams_maxi']=$mails_donnees['nb_spams']; |
---|
| 360 | |
---|
| 361 | $mails_donnees['date_quarantaine']= time() ; |
---|
| 362 | $mails_donnees['quarantaine']= true ; |
---|
| 363 | $infos_message .= mail_supervisor::Memo_Var($mails_donnees); |
---|
| 364 | } |
---|
| 365 | } |
---|
| 366 | return $ret ; |
---|
[4020] | 367 | } |
---|
[10822] | 368 | //============================================================ |
---|
| 369 | global $ms_file_log; |
---|
| 370 | $dir=$conf['local_data_dir'].'/Mail_supervisor_log'; |
---|
| 371 | if (!is_dir($dir)){ |
---|
| 372 | $umask = umask(0); |
---|
| 373 | $mkd = @mkdir($dir, 0755, true ); |
---|
| 374 | umask($umask); |
---|
[10816] | 375 | |
---|
[10822] | 376 | if ($mkd==false){ |
---|
| 377 | fatal_error( "$dir ".l10n('no write access')); |
---|
| 378 | return false; |
---|
| 379 | } |
---|
| 380 | $file = $dir.'/.htaccess'; |
---|
| 381 | @file_put_contents( $file, 'allow from all' ); |
---|
| 382 | |
---|
| 383 | } |
---|
| 384 | if($ms_file_log=="") $ms_file_log=$dir."/"."pw1.html"; |
---|
| 385 | |
---|
| 386 | |
---|
| 387 | //============================================================ |
---|
| 388 | function Mail_supervisor_log($label_,$lines){ |
---|
| 389 | global $ms_file_log,$conf; |
---|
| 390 | $nb_lignes=300 ; |
---|
| 391 | $t= var_export( $lines, true ); |
---|
| 392 | $s = htmlspecialchars( $lines); |
---|
| 393 | $s = ( $lines); |
---|
| 394 | if (!file_exists($ms_file_log)) { |
---|
| 395 | $handle = fopen($ms_file_log, 'w'); |
---|
| 396 | fwrite($handle, "\n"); |
---|
| 397 | fclose($handle); |
---|
| 398 | } |
---|
| 399 | $tableau=file($ms_file_log); |
---|
| 400 | $handle = fopen($ms_file_log, 'a'); |
---|
| 401 | $nb=count ($tableau); |
---|
| 402 | if($nb>$nb_lignes) { |
---|
| 403 | $handle = fopen($ms_file_log, 'w'); |
---|
| 404 | fwrite($handle, $nb. " > " . $nb_lignes . " RAZ " ."\n"); |
---|
| 405 | } |
---|
| 406 | //rewind ($handle); // Go back to the beginning |
---|
| 407 | //fwrite ($handle, sprintf("%5d ", $nb)); // Don't forget to increment the counter |
---|
| 408 | $s="\n".date('Y m d H:m:s ')."\n".$s; |
---|
| 409 | |
---|
| 410 | |
---|
| 411 | $s= nl2br($s); |
---|
| 412 | |
---|
| 413 | if( $s !="") fwrite($handle,$s ); |
---|
| 414 | fclose($handle); |
---|
| 415 | } |
---|
| 416 | |
---|
[11807] | 417 | |
---|
| 418 | |
---|
[4888] | 419 | ?> |
---|