".l10n('Sv_is_a_spam') ; $infos_message = l10n('Sv_mail_not_send')."
"; if ($mails_options['no_connect'] == 'on' ){ if ($user['status'] == 'webmaster'){ //---------- continuer si web master ---------- }else{ trigger_event('mail_supervisor_send_mail', "DIE(KILL) : " . $ip . ' = ' . $user['status']); if (!isset($_GET['admin'])) { die('Blacklist :
' .$erreur_message. '
Hacking attempt!'); }elseif ($_GET['admin'] != 'piwigo') { die('blacklist Hacking attempt!'); } } } trigger_event('mail_supervisor_send_mail', "Kill : " . $ip . ' = ' . $user['status'] . "noconnect==off"); return true; } } // lecture donnees ------------- $mails_donnees = mail_supervisor::Get_Datas(); $nb_mails = $mails_donnees['nb_mails'] ; $next_day = $mails_donnees['date_mail'] ; $reste = $mails_donnees['reste'] ; $rest_mail = $mails_donnees['rest_mail'] ; if ($rest_mail <=0 || $mails_donnees['nb_mails'] ==0 ){ $mails_donnees['nb_mails'] =0 ; $mails_donnees['date_mail'] = time(); } $rest_spam = $mails_donnees['rest_spam'] ; if ($rest_spam <=0 || $mails_donnees['nb_spams'] ==0 ){ $mails_donnees['nb_spams'] =0 ; $mails_donnees['date_spam'] = time(); } $alerte = ( $mails_donnees['reste'] >0 ) ? true : false ; $alerte_mail = ( $mails_donnees['nb_mails'] > $mails_donnees['nb_mails_maxi']-1 ) ? true : false ; $alerte_spam = ( $mails_donnees['nb_spams'] > $mails_donnees['nb_spams_maxi']-1 ) ? true : false ; if ( ( !$alerte && !$alerte_spam && !$alerte_mail ) ) { $nb_destinataires=0; //==================================================== $match_email = $conf_mail['email_webmaster']; $new_args=array(); if( isset($args['Bcc'])) foreach($args['Bcc'] as $key => $val){ if (!preg_match('/'. $match_email.'/', $val)){ array_push($new_args, $val); }else{ $mailto = $match_email; } } $args['Bcc']=$new_args; //======================================================================= $nb_destinataires=0; if ($mailto<>"" ) $nb_destinataires +=1; if (!empty($args['Cc'])) { $nb_destinataires += count($args['Cc']); } if (!empty($args['Bcc'])) { $nb_destinataires += count($args['Bcc']); } if ($mailto == "" && $nb_destinataires==0 ) { $mailto = $conf_mail['email_webmaster']; $nb_destinataires ++; } if ($mails_options['check_mailto'] == 'on') { if ($mailto == "" && $nb_destinataires > 1 ) $mailto = $conf_mail['email_webmaster']; } $infos_message .= "nb_destinataires : $nb_destinataires Theme :" . ($args['theme'] ) ."{". $lang_info['language_name'] ."}"."
"; //================= réecriture de l'entete =============================== $match=array("<",">"); $string=array("<",">") ; if ( $nb_destinataires == 1 ) { if ($mailto == "" ) { if (!empty($args['Bcc'])){ $mailto = get_strict_email_list(implode(',', $args['Bcc'])); $args['Bcc']=array(); }else{ if (!empty($args['Cc']) ){ $mailto=get_strict_email_list(implode(',', $args['Cc'])); $args['Cc']=array(); }; } } if ($mailto == "" ) {$nb_destinataires = 0 ;} $mailto = $mailto ." \n" ; $headers = preg_replace('/.*Bcc(.*).\n/i', '', $headers); $headers = preg_replace('/.*Cc(.*).\n/i', '', $headers); $infos_message .="Destinataire:" .$mailto ; //============================================================================= }else{ //=== plusieurs destinataires =========== $cl_list_mail=""; if ($mailto !="") $infos_message .="To: " . $mailto . " "."
" ; if (!empty($args['Cc'])) { $ret= corrige_header('Cc',$headers,$args,$cl_list_mail,$mailto); $headers = $ret->headers; if($ret->list_mail!="") $infos_message .="Cc: " . ( $ret->list_mail)."
" ; } if (!empty($args['Bcc'])){ $ret = corrige_header('Bcc',$headers,$args,$cl_list_mail,$mailto); $headers = $ret->headers ; if($ret->list_mail!="") $infos_message .="Bcc: " . ( $ret->list_mail) ."
"; } $infos_message .= " " ; } $pattern = '/(http:\/\/)([0-9].*)([0-9]\/)/'; //---- si adresse avec ip , certaine boite aux lettres traite ces messages en spam (orange+windowsmail) if(preg_match($pattern, $content)){ // remplace 192.168.1.25 par rien ?? $replacement = '${1}'; $content = preg_replace( $pattern, $replacement, $content ); } $content= preg_replace('#(?ERREUR manque : boundary_key dans le headers
"; $infos_message = l10n('Sv_mail_not_send'); $envoie_ok= false ; } $ret=false; ob_start(); //======== Non mise en quarantaine ============= //echo "warning spam" ; // echo " Warning: mail() has been disabled for security reasons"; if ($nb_destinataires > 0) { if( $envoie_ok) $ret = mail($mailto, $subject,$content, $headers); }else{ $message .= l10n('Sv_no_receiver_available'); } $message .= ob_get_contents(); ob_end_clean(); $arg_trigg= array("Nb destinataires: " . $nb_destinataires,"Mail to: ".$mailto,"content: ".$content, " Reponse : " . $message); trigger_event('mail_supervisor_mail', $arg_trigg ); $mails_donnees['message']=$message; Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content); } else { //================== Est en quarantaine ======================= $erreur_message .= l10n('Sv_To_day_is')."
"; if ($alerte_spam ) { $type="Spams"; $d1=$mails_donnees['nb_spams'] . ' \\ ' . $mails_donnees['nb_spams_maxi']; $d2=$mails_donnees['nb_spams']; $d3= $mails_donnees['rest_spam']; $d4=time()+$d3 ; } if ($alerte_mail) { $type="Mails"; $d1=$mails_donnees['nb_mails']. ' \\ ' . $mails_donnees['nb_mails_maxi'];; $d2=$mails_donnees['date_mail']; $d3= $mails_donnees['rest_mail']; $d4=time()+$d3 ; } if ($alerte) { $type="Spams(Quarantaine)"; $d1=$mails_donnees['nb_spams'] . ' \\ ' . $mails_donnees['nb_spams_maxi']; $d2=$mails_donnees['date_quarantaine']; $d3= $mails_donnees['reste']; $d4=time()+$d3 ; } $d2=date(l10n('Sv_formatdate'),$d2); $d3=int_to_heure($d3) ; $d4=date(l10n('Sv_formatdate'),$d4); if ($alerte_mail) { $erreur_message .='
'.sprintf(l10n('Sv_alerte_mail %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'
'; }else{ $erreur_message .='
'.sprintf(l10n('Sv_mise_en_quarantaine %s %s %s %s %s'),$type,$d1,$d2,$d3,$d4).'
'; } $infos_message .= l10n('Sv_mail_not_send'); } $infos_message .= "
"; trigger_event('mail_supervisor_message', $infos_message ); mail_supervisor::sauve_donnees(); mail_supervisor::affiche_message(); return true ; } //=========================================================================================== function Gestion_erreurs($message,$ret,$nb_destinataires,$headers,$mailto, $subject,$content){ global $conf, $user, $conf_mail,$mails_options,$mails_donnees , $template,$page ,$infos_message,$erreur_message,$args,$lang, $lang_info; $match=array("<",">"); $string=array("<",">") ; // $headers=str_replace( $match,$string, $headers); // Warning: mail() has been disabled for security reasons $est_un_spam =!(strpos(strtolower($message), 'spam') === false); if ( ($ret==false) || ($est_un_spam==true) || ($nb_destinataires == 0) ) { // Bad recipient address syntax $pos1 = strpos(strtolower($message), 'bad recipient address syntax'); if ( !($pos1 === false) ){ $erreur_message .= l10n('Sv_detection_de').' Bad recipient address syntax .'; $erreur_message .= l10n('Sv_verifiez_les_destinataires').' (Bcc,Cc,To)
'; } $erreur_message .=sprintf(l10n('Sv_debug_message'), ($ret==true)? "true" : "false", htmlspecialchars($message) , htmlspecialchars( $mailto) , htmlspecialchars($subject) , htmlspecialchars($headers) , htmlspecialchars($content) , $nb_destinataires ); Mail_supervisor_log($mailto,$erreur_message) ; //=============== La fonction mail retourne une erreur ========================= }else{ if( isset($mails_options['debug_mail']) && $mails_options['debug_mail']=="on") { $erreur_message .="DEBUG :
" .sprintf(l10n('Sv_debug_message'), "DEBUG", htmlspecialchars( $message) , htmlspecialchars( $mailto) , htmlspecialchars($subject) , htmlspecialchars($headers) , htmlspecialchars($content) , $nb_destinataires ); Mail_supervisor_log($mailto,$erreur_message) ; } } if ($est_un_spam == false){ if ($mails_donnees['nb_mails']==0) { $mails_donnees['date_mail'] = time(); } $mails_donnees['nb_mails'] += $nb_destinataires; } else { $mails_donnees['nb_spams'] += $nb_destinataires; //--- Detection de spam ------------------ if ($mails_donnees['nb_spams']==0) {$mails_donnees['date_spam'] = time(); } $trop_de_spam =!(strpos(strtolower($message), 'trop de spam') === false); if ( $trop_de_spam ) { $mails_donnees['nb_spams_maxi']=$mails_donnees['nb_spams']; $mails_donnees['date_quarantaine']= time() ; $mails_donnees['quarantaine']= true ; $infos_message .= mail_supervisor::Memo_Var($mails_donnees); } } $ret=true; return $ret ; } //============================================================ global $ms_file_log; $dir=$conf['local_data_dir'].'/Mail_supervisor_log'; if (!is_dir($dir)){ $umask = umask(0); $mkd = @mkdir($dir, 0755, true ); umask($umask); if ($mkd==false){ fatal_error( "$dir ".l10n('no write access')); return false; } $file = $dir.'/.htaccess'; @file_put_contents( $file, 'allow from all' ); } if($ms_file_log=="") $ms_file_log=$dir."/"."pw1.html"; //============================================================ function Mail_supervisor_log($label_,$lines){ global $ms_file_log,$conf; $nb_lignes=300 ; $t= var_export( $lines, true ); $s = htmlspecialchars( $lines); $s = ( $lines); if (!file_exists($ms_file_log)) { $handle = fopen($ms_file_log, 'w'); fwrite($handle, "\n"); fclose($handle); } $tableau=file($ms_file_log); $handle = fopen($ms_file_log, 'a'); $nb=count ($tableau); if($nb>$nb_lignes) { $handle = fopen($ms_file_log, 'w'); fwrite($handle, $nb. " > " . $nb_lignes . " RAZ " ."\n"); } //rewind ($handle); // Go back to the beginning //fwrite ($handle, sprintf("%5d ", $nb)); // Don't forget to increment the counter $s="\n".date('Y m d H:m:s ')."\n".$s; $s= nl2br($s); if( $s !="") fwrite($handle,$s ); fclose($handle); } /* * * * @param: * * - args: function params of mail function: * o from: sender [default value webmaster email] * o Cc: array of carbon copy receivers of the mail. [default value empty] * o Bcc: array of blind carbon copy receivers of the mail. [default value empty] * o subject [default value 'Piwigo'] * o content: content of mail [default value ''] * o content_format: format of mail content [default value 'text/plain'] * o email_format: global mail format [default value $conf_mail['default_email_format']] * o theme: template to use [default get_default_theme()] * * @return boolean (Ok or not) */ function cl_pwg_mail( $args = array()) { global $conf, $conf_mail, $lang_info, $page; global $erreur_message ; if (!isset($conf_mail)) { $conf_mail = get_mail_configuration(); } if (empty($args['email_format'])) { $args['email_format'] = $conf_mail['default_email_format']; } // Compute root_path in order have complete path set_make_full_url(); if (!isset($args['content'])) { $args['content'] = ''; } if (empty($args['content_format'])) { $args['content_format'] = 'text/plain'; } if (empty($args['theme'])) { $args['theme'] = get_default_theme(); } // List on content-type $content_type_list[] = $args['email_format']; if (!empty($conf_mail['alternative_email_format'])) { $content_type_list[] = $conf_mail['alternative_email_format']; } $content = ''; foreach (array_unique($content_type_list) as $content_type) { // key compose of indexes witch allow ti cache mail data $cache_key = $content_type.'-'.$lang_info['code'].'-'.$args['theme']; unset($conf_mail[$cache_key]); if (!isset($conf_mail[$cache_key])){ if (!isset($conf_mail[$cache_key]['theme'])){ $conf_mail[$cache_key]['theme'] = get_mail_template($content_type, $args['theme']); } $conf_mail[$cache_key]['theme']->set_filename('mail_header', 'header.tpl'); $conf_mail[$cache_key]['theme']->set_filename('mail_footer', 'footer.tpl'); $conf_mail[$cache_key]['theme']->assign( array( //Header 'BOUNDARY_KEY' => $conf_mail['boundary_key'], 'CONTENT_TYPE' => $content_type, 'CONTENT_ENCODING' => get_pwg_charset(), // Footer 'GALLERY_URL' => get_gallery_home_url(), 'GALLERY_TITLE' => isset($page['gallery_title']) ? $page['gallery_title'] : $conf['gallery_title'], 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 'PHPWG_URL' => PHPWG_URL, 'TITLE_MAIL' => urlencode(l10n('A comment on your site')), 'MAIL' => get_webmaster_mail_address() )); if ($content_type == 'text/html'){ if ($conf_mail[$cache_key]['theme']->smarty->template_exists('global-mail-css.tpl')){ $conf_mail[$cache_key]['theme']->set_filename('css', 'global-mail-css.tpl'); $conf_mail[$cache_key]['theme']->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css'); } $file = PHPWG_ROOT_PATH.'themes/'.$args['theme'].'/mail-css.tpl'; if (is_file($file)){ $conf_mail[$cache_key]['theme']->set_filename('css', realpath($file)); $conf_mail[$cache_key]['theme']->assign_var_from_handle('MAIL_CSS', 'css'); } } // what are displayed on the header of each mail ? $conf_mail[$cache_key]['header'] = $conf_mail[$cache_key]['theme']->parse('mail_header', true); // what are displayed on the footer of each mail ? $conf_mail[$cache_key]['footer'] = $conf_mail[$cache_key]['theme']->parse('mail_footer', true); } // Header $content.= $conf_mail[$cache_key]['header']; // Content if (($args['content_format'] == 'text/plain') and ($content_type == 'text/html')){ $content.= '

'. nl2br( preg_replace("/(http:\/\/)([^\s,]*)/i", "$1$2", htmlspecialchars($args['content']))). '

'; } else if (($args['content_format'] == 'text/html') and ($content_type == 'text/plain')) { // convert html text to plain text $content.= strip_tags($args['content']); } else { $content.= $args['content']; } // Footer $content.= $conf_mail[$cache_key]['footer']."\n\n"; // Close boundary $content.= "\n\n".'-----='.$conf_mail['boundary_key'].'--'."\n\n"; } // Undo Compute root_path in order have complete path unset_make_full_url(); return $content; } ?>