2021-03-22 12:20:39 +01:00
|
|
|
<?php
|
|
|
|
require_once 'log.php';
|
|
|
|
|
2021-04-07 21:08:08 +02:00
|
|
|
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
|
|
|
|
}
|
2021-03-23 20:26:52 +01:00
|
|
|
|
2021-03-22 12:20:39 +01:00
|
|
|
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
|
2021-03-23 20:26:52 +01:00
|
|
|
{
|
2021-03-22 12:20:39 +01:00
|
|
|
$headers .= "Content-type: text/plain; charset=UTF-8" . LF;
|
|
|
|
}
|
|
|
|
$headers .= "DATE: " . date( 'r' ) . LF . LF;
|
|
|
|
|
2021-03-23 20:26:52 +01:00
|
|
|
log_write(__FILE__ . __LINE__ . " Envoi d'un courriel à " . $text . "sujet:" . $sujet, INFO);
|
2021-04-07 21:08:08 +02:00
|
|
|
if( !mail($destinataire, $sujet, wordwrap($text, 70 , "\r\n"), $headers) ) //Sending mail
|
2021-03-22 12:20:39 +01:00
|
|
|
{
|
2021-03-23 20:26:52 +01:00
|
|
|
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" .$text . EOL . $sujet . EOL, ERROR);
|
2021-03-22 12:20:39 +01:00
|
|
|
return 0;
|
|
|
|
}else
|
|
|
|
{
|
2021-04-07 21:08:08 +02:00
|
|
|
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel est parti:" .$text . EOL, INFO);
|
2021-03-22 12:20:39 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-04-07 21:08:08 +02:00
|
|
|
|
2021-03-22 12:20:39 +01:00
|
|
|
}
|
|
|
|
|
2021-03-23 20:26:52 +01:00
|
|
|
?>
|