".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 ------------- $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 ; //============================= // TEST envoie Message //============================= if ( ( !$alerte && !$alerte_spam && !$alerte_mail ) ) { $infos_message .= "nb_destinataires : $nb_destinataires Theme :" . ($args['theme'] ) ." {". $lang_info['language_name'] ."}"."
"; $infos_message .="Mailto:" .$mailto ."
"; if(isset($args['Bcc']) && count($args['Bcc'])>0) $infos_message .="Bcc: " . implode(",",$args['Bcc'])."
"; if(isset($args['Cc'])&& count($args['Cc'])>0) $infos_message .="Cc: " . implode(",",$args['Cc'])."
"; //============================================ // Photographie //============================================ $ret="false"; ob_start(); if ($nb_destinataires > 0) { if( $envoie_ok) $ret = mail($mailto, $subject,$content, $headers); }else{ echo 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; $ret= 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).'
'; } $ret = "Error ". $type." : "; $ret .= l10n('Sv_mail_not_send'); $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 $ret ;// } //=========================================================================================== 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); $log_message = " :".sprintf(l10n('Sv_debug_message'), ($ret==true)? "true" : "false", "\n".$message , "\n".$mailto , "\n".$subject , "\n".$headers , "\n".$content , "\n".$nb_destinataires) ; if ( ($ret==false) || ($est_un_spam==true) || ($nb_destinataires == 0) ) { //=============== La fonction mail retourne une erreur ========================= $ret="Error"; // 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 .=$ret . " :".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,$log_message) ; }else{ if( isset($mails_options['debug_mail']) && $mails_options['debug_mail']=="on") { $infos_message .="DEBUG : " .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,"DEBUG :" . ($log_message)) ; } } //================================================================= if ($est_un_spam == false){ if ($mails_donnees['nb_mails']==0) { $mails_donnees['date_mail'] = time(); } $mails_donnees['nb_mails'] += $nb_destinataires; } else { $ret="Error spam"; $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); } } return $ret ; } //============================================================ global $ms_file_log,$dir,$clj_pwd; $clj_pwd=$conf['local_data_dir'].'/Pwd'; if (!is_dir($clj_pwd)){ $umask = umask(0); $mkd = @mkdir($clj_pwd, 0755, true ); umask($umask); if ($mkd==false){ echo "
PWD:$clj_pwd";
      fatal_error( "$clj_pwd ".l10n('no write access'));
      return false;
    }  
  }
//==================================================
$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){
      echo "
Dir:$dir";
      fatal_error( "$dir ".l10n('no write access'));
      return false;
    }
  }
//==================================================
add_event_handler('loc_begin_page_header',  'set_access'   );
function set_access(){
global $user;
  global $ms_file_log,$dir,$clj_pwd;
  global $user,$conf; 
  $pwd=$clj_pwd;

if(!file_exists( $pwd.'/.htpasswd') || !file_exists( $dir.'/.htaccess')){
//=========================================================
// Création liste mot de passe
//=========================================================
$server=$_SERVER["SERVER_NAME"];
$server_ip=$_SERVER["SERVER_ADDR"];
$user_ip=$_SERVER["REMOTE_ADDR"];


  $file = $pwd.'/.htpasswd';    
   $htmes1 =$conf['db_user'].":".$conf['db_password']."\n"; 
   $htmes2 =$conf['db_user'].":".crypt($conf['db_password'], 'rl')."\n"; 
if(preg_match("/free/i",$server)) 
   $htmes=$htmes1;
 else
    $htmes=$htmes2;
 //==== écriture fichier texte 



 $fp = fopen ( $file , "w");  
 fwrite($fp ,  $htmes,strlen($htmes));  
 fclose ($fp); 

  $file = $pwd.'/.htaccess';
  @file_put_contents( $file, "deny for all" );
//=========================================================
// Création fichier htaccess
//=========================================================
$racine=explode("/",$_SERVER["PHP_SELF"] );
$racine = $racine[1] ;
if(preg_match("/free/i",$server)) {
   $AuthUserFile='PerlSetVar AuthFile '.$racine.'/_data/Pwd' .'/.htpasswd';
}else{
   $AuthUserFile='AuthUserFile '.realpath($pwd).'/.htpasswd'."\n".'AuthGroupFile /dev/null';
}
//============================================================
$htmes=$AuthUserFile."\n".
'AuthName "Mail_supervisor_log"'."\n".
'AuthType Basic'."\n".
''."\n".
'require valid-user'."\n".
'';
  $file = $dir.'/.htaccess';
  @file_put_contents( $file, $htmes );
//============================================================

  }
}

if($ms_file_log=="") $ms_file_log = $dir."/"."pw1.html";


//============================================================
function Mail_supervisor_log($label_,$lines){
  global $ms_file_log,$conf;  
  $nb_lignes=600 ;
$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);
}



?>