73 lines
1.8 KiB
PHP
73 lines
1.8 KiB
PHP
<?php
|
|
require_once 'log.php';
|
|
|
|
function getLang( $lang )
|
|
{
|
|
$dico = array();
|
|
$fh = fopen('lang/'.$lang, 'r');
|
|
$str = fgets($fh);
|
|
fclose($fh);
|
|
$dico = json_decode($str, true);
|
|
return $dico;
|
|
}
|
|
|
|
function courrielEnvoi( $db )
|
|
{
|
|
$dicoExpe = getLang( $db->expeLang );
|
|
$dicoDest = getLang( $db->destLang );
|
|
$expediteurIndex = "Notification_denvoi_Expediteur";
|
|
//print "envoi du courriel" . EOL;
|
|
if ( $db->expeKnown == false )
|
|
{
|
|
$destinataireIndex = "Notification_denvoi_Destinataire_ExpediteurConnu";
|
|
}else
|
|
{
|
|
$destinataireIndex = "Notification_denvoi_Destinataire_ExpediteurAnonyme";
|
|
}
|
|
$indexObjet = "Objet_" . $expediteurIndex;
|
|
$objetMail = $dicoExpe[$indexObjet];
|
|
$mailText = $dicoExpe[$expediteurIndex] .EOL .EOL ;
|
|
|
|
envoiMail( $db->expeMail, $objetMail, $mailText, true);
|
|
|
|
$indexObjet = "Objet_" . $destinataireIndex;
|
|
$objetMail = $dicoExpe[$indexObjet];
|
|
$mailText = $dicoExpe[$destinataireIndex] .EOL .EOL ;
|
|
//sleep (1);
|
|
envoiMail( $db->destMail, $objetMail, $mailText, true);
|
|
}
|
|
|
|
function courrielArrivee($uid)
|
|
{
|
|
//TODO
|
|
}
|
|
|
|
function envoiMail($destinataire, $sujet, $text, $html=false)
|
|
{
|
|
|
|
$headers = "From: contact@avion-poe.me" . LF;
|
|
if ($html)
|
|
{
|
|
$headers .= "Content-type: text/html; charset=UTF-8" . LF;
|
|
}else
|
|
{
|
|
$headers .= "Content-type: text/plain; charset=UTF-8" . LF;
|
|
}
|
|
$headers .= "DATE: " . date( 'r' ) . LF . LF;
|
|
|
|
log_write(__FILE__ . __LINE__ . " Envoi d'un courriel à " . $text . "sujet:" . $sujet, INFO);
|
|
if( !mail($destinataire, $sujet, wordwrap($text, 70 , "\r\n"), $headers) ) //Sending mail
|
|
{
|
|
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" .$text . EOL . $sujet . EOL, ERROR);
|
|
return 0;
|
|
}else
|
|
{
|
|
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel est parti:" .$text . EOL, INFO);
|
|
return 1;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
?>
|