Fix encoding for To and Subject headers
This commit is contained in:
parent
63837ebd55
commit
848dcc5370
@ -122,12 +122,12 @@ if (isset($_POST["boutonnouveautitre"]) || isset($_POST["boutonnouveautitre_x"])
|
|||||||
|
|
||||||
//envoi du mail pour prevenir l'admin de sondage
|
//envoi du mail pour prevenir l'admin de sondage
|
||||||
if ($connect->Execute($sql, array($nouveautitre, $numsondage))) {
|
if ($connect->Execute($sql, array($nouveautitre, $numsondage))) {
|
||||||
mail ($adresseadmin,
|
sendEmail( $adresseadmin,
|
||||||
_("[ADMINISTRATOR] New title for your poll") . ' ' . NOMAPPLICATION,
|
_("[ADMINISTRATOR] New title for your poll") . ' ' . NOMAPPLICATION,
|
||||||
_("You have changed the title of your poll. \nYou can modify this poll with this link") .
|
_("You have changed the title of your poll. \nYou can modify this poll with this link") .
|
||||||
" :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" .
|
" :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" .
|
||||||
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
|
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
|
||||||
$headers);
|
$headers );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,12 +145,12 @@ if (isset($_POST["boutonnouveauxcommentaires"]) || isset($_POST["boutonnouveauxc
|
|||||||
|
|
||||||
if ($connect->Execute($sql, array($commentaires, $numsondage))) {
|
if ($connect->Execute($sql, array($commentaires, $numsondage))) {
|
||||||
//envoi du mail pour prevenir l'admin de sondage
|
//envoi du mail pour prevenir l'admin de sondage
|
||||||
mail ($adresseadmin,
|
sendEmail( $adresseadmin,
|
||||||
_("[ADMINISTRATOR] New comments for your poll") . ' ' . NOMAPPLICATION,
|
_("[ADMINISTRATOR] New comments for your poll") . ' ' . NOMAPPLICATION,
|
||||||
_("You have changed the comments of your poll. \nYou can modify this poll with this link") .
|
_("You have changed the comments of your poll. \nYou can modify this poll with this link") .
|
||||||
" :\n\n".getUrlSondage($numsondageadmin, true)." \n\n" .
|
" :\n\n".getUrlSondage($numsondageadmin, true)." \n\n" .
|
||||||
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
|
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
|
||||||
$headers);
|
$headers );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,12 +168,12 @@ if (isset($_POST["boutonnouvelleadresse"]) || isset($_POST["boutonnouvelleadress
|
|||||||
|
|
||||||
if ($connect->Execute($sql, array($nouvelleadresse, $numsondage))) {
|
if ($connect->Execute($sql, array($nouvelleadresse, $numsondage))) {
|
||||||
//envoi du mail pour prevenir l'admin de sondage
|
//envoi du mail pour prevenir l'admin de sondage
|
||||||
mail ($_POST['nouvelleadresse'],
|
sendEmail( $_POST['nouvelleadresse'],
|
||||||
_("[ADMINISTRATOR] New email address for your poll") . ' ' . NOMAPPLICATION,
|
_("[ADMINISTRATOR] New email address for your poll") . ' ' . NOMAPPLICATION,
|
||||||
_("You have changed your email address in your poll. \nYou can modify this poll with this link") .
|
_("You have changed your email address in your poll. \nYou can modify this poll with this link") .
|
||||||
" :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" .
|
" :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" .
|
||||||
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
|
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
|
||||||
$headers);
|
$headers );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -329,12 +329,12 @@ if (isset($_POST["confirmesuppression"]) || isset($_POST["confirmesuppression_x"
|
|||||||
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, 'admin/logs_studs.txt');
|
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, 'admin/logs_studs.txt');
|
||||||
|
|
||||||
//envoi du mail a l'administrateur du sondage
|
//envoi du mail a l'administrateur du sondage
|
||||||
mail ($adresseadmin,
|
sendEmail( $adresseadmin,
|
||||||
_("[ADMINISTRATOR] Removing of your poll") . ' ' . NOMAPPLICATION,
|
_("[ADMINISTRATOR] Removing of your poll") . ' ' . NOMAPPLICATION,
|
||||||
_("You have removed your poll. \nYou can make new polls with this link") .
|
_("You have removed your poll. \nYou can make new polls with this link") .
|
||||||
" :\n\n".get_server_name()."index.php \n\n" .
|
" :\n\n".get_server_name()."index.php \n\n" .
|
||||||
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
|
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
|
||||||
$headers);
|
$headers );
|
||||||
|
|
||||||
//affichage de l'ecran de confirmation de suppression de sondage
|
//affichage de l'ecran de confirmation de suppression de sondage
|
||||||
print_header();
|
print_header();
|
||||||
@ -478,10 +478,10 @@ if (isset($_POST["ajoutercolonne_x"]) && issetAndNoEmpty('nouvellecolonne') && (
|
|||||||
if ($connect->Execute($sql, array($nouveauxsujets, $numsondage))) {
|
if ($connect->Execute($sql, array($nouveauxsujets, $numsondage))) {
|
||||||
//envoi d'un mail pour prévenir l'administrateur du changement
|
//envoi d'un mail pour prévenir l'administrateur du changement
|
||||||
$headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit";
|
$headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit";
|
||||||
mail ("$adresseadmin", "" . _("[ADMINISTRATOR] New column for your poll").NOMAPPLICATION, "" .
|
sendEmail( "$adresseadmin", "" . _("[ADMINISTRATOR] New column for your poll").NOMAPPLICATION, "" .
|
||||||
_("You have added a new column in your poll. \nYou can inform the voters of this change with this link") .
|
_("You have added a new column in your poll. \nYou can inform the voters of this change with this link") .
|
||||||
" : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,
|
" : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,
|
||||||
$headers);
|
$headers );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,11 +592,11 @@ if (isset($_POST["ajoutercolonne_x"]) && ($dsondage->format == "D" || $dsondage-
|
|||||||
//envoi d'un mail pour prévenir l'administrateur du changement
|
//envoi d'un mail pour prévenir l'administrateur du changement
|
||||||
$adresseadmin = $dsondage->mail_admin;
|
$adresseadmin = $dsondage->mail_admin;
|
||||||
|
|
||||||
mail ($adresseadmin,
|
sendEmail( $adresseadmin,
|
||||||
_("[ADMINISTRATOR] New column for your poll"),
|
_("[ADMINISTRATOR] New column for your poll"),
|
||||||
_("You have added a new column in your poll. \nYou can inform the voters of this change with this link").
|
_("You have added a new column in your poll. \nYou can inform the voters of this change with this link").
|
||||||
" : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,
|
" : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,
|
||||||
$headers);
|
$headers );
|
||||||
} else {
|
} else {
|
||||||
$erreur_ajout_date="yes";
|
$erreur_ajout_date="yes";
|
||||||
}
|
}
|
||||||
@ -1257,4 +1257,4 @@ echo '<div class="separateur"> </div>';
|
|||||||
bandeau_pied_mobile();
|
bandeau_pied_mobile();
|
||||||
echo '</form>'."\n";
|
echo '</form>'."\n";
|
||||||
echo '</body>'."\n";
|
echo '</body>'."\n";
|
||||||
echo '</html>'."\n";
|
echo '</html>'."\n";
|
||||||
|
@ -56,10 +56,10 @@ if ((isset($_POST['envoiquestion']) || isset($_POST['envoiquestion_x'])) && isse
|
|||||||
if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) {
|
if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) {
|
||||||
$headers .= "\r\n".'Reply-To: '.$_POST['adresse_mail'];
|
$headers .= "\r\n".'Reply-To: '.$_POST['adresse_mail'];
|
||||||
}
|
}
|
||||||
mail (ADRESSEMAILADMIN, "" . _("[CONTACT] You have sent a question ") . "".NOMAPPLICATION, "" . _("You have a question from a user ") . " ".NOMAPPLICATION."\n\n" . _("User") . " : ".$_POST["nom"]."\n\n" . _("User's email address") . " : $_POST[adresse_mail]\n\n" . _("Message") . " :".$message,$headers);
|
sendEmail( ADRESSEMAILADMIN, "" . _("[CONTACT] You have sent a question ") . "".NOMAPPLICATION, "" . _("You have a question from a user ") . " ".NOMAPPLICATION."\n\n" . _("User") . " : ".$_POST["nom"]."\n\n" . _("User's email address") . " : $_POST[adresse_mail]\n\n" . _("Message") . " :".$message,$headers );
|
||||||
if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) {
|
if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) {
|
||||||
$headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit";
|
$headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit";
|
||||||
mail ("$_POST[adresse_mail]", "" . _("[COPY] Someone has sent a question ") . "".NOMAPPLICATION, "" . _("Here is a copy of your question") . " :\n\n".$message." \n\n" . _("We're going to answer your question shortly.") . "\n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers);
|
sendEmail( "$_POST[adresse_mail]", "" . _("[COPY] Someone has sent a question ") . "".NOMAPPLICATION, "" . _("Here is a copy of your question") . " :\n\n".$message." \n\n" . _("We're going to answer your question shortly.") . "\n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers );
|
||||||
}
|
}
|
||||||
|
|
||||||
//affichage de la page de confirmation d'envoi
|
//affichage de la page de confirmation d'envoi
|
||||||
@ -148,4 +148,4 @@ framanav();
|
|||||||
bandeau_pied();
|
bandeau_pied();
|
||||||
echo '</body>'."\n";
|
echo '</body>'."\n";
|
||||||
echo '</html>'."\n";
|
echo '</html>'."\n";
|
||||||
}
|
}
|
||||||
|
@ -118,8 +118,8 @@ function ajouter_sondage()
|
|||||||
$message_admin = sprintf($message_admin, getUrlSondage($sondage_admin, true));
|
$message_admin = sprintf($message_admin, getUrlSondage($sondage_admin, true));
|
||||||
|
|
||||||
if (validateEmail($_SESSION['adresse'])) {
|
if (validateEmail($_SESSION['adresse'])) {
|
||||||
mail ("$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin, $headers);
|
sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin, $headers );
|
||||||
mail ("$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message, $headers);
|
sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message, $headers );
|
||||||
}
|
}
|
||||||
|
|
||||||
$date=date('H:i:s d/m/Y:');
|
$date=date('H:i:s d/m/Y:');
|
||||||
@ -127,4 +127,4 @@ function ajouter_sondage()
|
|||||||
header("Location:".getUrlSondage($sondage));
|
header("Location:".getUrlSondage($sondage));
|
||||||
exit();
|
exit();
|
||||||
session_unset();
|
session_unset();
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,29 @@ function validateEmail($email)
|
|||||||
return (bool)preg_match($pattern, $email);
|
return (bool)preg_match($pattern, $email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Envoi un courrier avec un codage correct de To et Subject
|
||||||
|
# Les en-têtes complémentaires ne sont pas gérés
|
||||||
|
# Inspiré de http://geoland.org/2007/12/utf8-ready-php-mail-function/
|
||||||
|
|
||||||
|
function sendEmail( $to, $subject, $body, $headers, $param)
|
||||||
|
{
|
||||||
|
$to_list = explode( ',', $to ) ;
|
||||||
|
$to = "" ;
|
||||||
|
$first = 1 ;
|
||||||
|
|
||||||
|
foreach ( $to_list as $one ) {
|
||||||
|
if ( $first == 0 ) $to .= ',' ;
|
||||||
|
$to_cut = explode( '<' ,$one, 2 ) ;
|
||||||
|
$to .= '=?UTF-8?B?' . base64_encode( $to_cut[ 0 ] ) . '?= <' . $to_cut[ 1 ] ;
|
||||||
|
$first = 0 ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
$subject = '=?UTF-8?B?' . base64_encode( $subject ) . '?=' ;
|
||||||
|
|
||||||
|
mail( $to, $subject, $body, $headers, $param ) ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau
|
* Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau
|
||||||
@ -216,4 +239,4 @@ define('NO_POLL_ID', 0x0001000000);
|
|||||||
define('INVALID_EMAIL', 0x0010000000);
|
define('INVALID_EMAIL', 0x0010000000);
|
||||||
define('TITLE_EMPTY', 0x0100000000);
|
define('TITLE_EMPTY', 0x0100000000);
|
||||||
define('INVALID_DATE', 0x1000000000);
|
define('INVALID_DATE', 0x1000000000);
|
||||||
$err = 0;
|
$err = 0;
|
||||||
|
@ -172,13 +172,13 @@ if (!is_error(NO_POLL) && (isset($_POST["boutonp"]) || isset($_POST["boutonp_x"]
|
|||||||
|
|
||||||
if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=="yes" || $dsondage->mailsonde=="true") {
|
if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=="yes" || $dsondage->mailsonde=="true") {
|
||||||
$headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit";
|
$headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit";
|
||||||
mail ("$dsondage->mail_admin",
|
sendEmail( "$dsondage->mail_admin",
|
||||||
"[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8')."",
|
"[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8')."",
|
||||||
html_entity_decode("\"$nom\" ", ENT_QUOTES, 'UTF-8').
|
html_entity_decode("\"$nom\" ", ENT_QUOTES, 'UTF-8').
|
||||||
_("has filled a line.\nYou can find your poll at the link") . " :\n\n".
|
_("has filled a line.\nYou can find your poll at the link") . " :\n\n".
|
||||||
getUrlSondage($numsondage)." \n\n" .
|
getUrlSondage($numsondage)." \n\n" .
|
||||||
_("Thanks for your confidence.") . "\n". NOMAPPLICATION,
|
_("Thanks for your confidence.") . "\n". NOMAPPLICATION,
|
||||||
$headers);
|
$headers );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -308,7 +308,7 @@ if ($testmodifier) {
|
|||||||
|
|
||||||
if ($dsondage->mailsonde=="yes") {
|
if ($dsondage->mailsonde=="yes") {
|
||||||
$headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit";
|
$headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit";
|
||||||
mail ("$dsondage->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8'), "\"".html_entity_decode($data->nom, ENT_QUOTES, 'UTF-8')."\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n".getUrlSondage($numsondage)." \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers);
|
sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8'), "\"".html_entity_decode($data->nom, ENT_QUOTES, 'UTF-8')."\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n".getUrlSondage($numsondage)." \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user