Headers separation fix

Fix the header separating character (needs to be \r\n).
Merge header creation with sendEmail.
This commit is contained in:
Jean-Philippe Guérard 2012-01-11 20:34:37 +01:00
parent 2bd0fd2da1
commit bebfc4b4e7
5 changed files with 24 additions and 43 deletions

View File

@ -103,7 +103,6 @@ $dsondage=$sondage->FetchObject(false);
//si la valeur du nouveau titre est valide et que le bouton est activé
$adresseadmin = $dsondage->mail_admin;
$headers = makeHeaders() ;
if (isset($_POST["boutonnouveautitre"]) || isset($_POST["boutonnouveautitre_x"])) {
if(issetAndNoEmpty('nouveautitre') === false) {
@ -120,8 +119,7 @@ if (isset($_POST["boutonnouveautitre"]) || isset($_POST["boutonnouveautitre_x"])
_("[ADMINISTRATOR] New title for your poll") . ' ' . NOMAPPLICATION,
_("You have changed the title of your poll. \nYou can modify this poll with this link") .
" :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" .
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
$headers );
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION );
}
}
}
@ -143,8 +141,7 @@ if (isset($_POST["boutonnouveauxcommentaires"]) || isset($_POST["boutonnouveauxc
_("[ADMINISTRATOR] New comments for your poll") . ' ' . NOMAPPLICATION,
_("You have changed the comments of your poll. \nYou can modify this poll with this link") .
" :\n\n".getUrlSondage($numsondageadmin, true)." \n\n" .
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
$headers );
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION );
}
}
}
@ -166,8 +163,7 @@ if (isset($_POST["boutonnouvelleadresse"]) || isset($_POST["boutonnouvelleadress
_("[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") .
" :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" .
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
$headers );
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION );
}
}
}
@ -327,8 +323,7 @@ if (isset($_POST["confirmesuppression"]) || isset($_POST["confirmesuppression_x"
_("[ADMINISTRATOR] Removing of your poll") . ' ' . NOMAPPLICATION,
_("You have removed your poll. \nYou can make new polls with this link") .
" :\n\n".get_server_name()."index.php \n\n" .
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
$headers );
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION );
//affichage de l'ecran de confirmation de suppression de sondage
print_header();
@ -471,12 +466,10 @@ if (isset($_POST["ajoutercolonne_x"]) && issetAndNoEmpty('nouvellecolonne') && (
$sql = $connect->Prepare($sql);
if ($connect->Execute($sql, array($nouveauxsujets, $numsondage))) {
//envoi d'un mail pour prévenir l'administrateur du changement
$headers = makeHeaders() ;
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") .
" : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,
$headers );
" : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION );
}
}
@ -590,8 +583,7 @@ if (isset($_POST["ajoutercolonne_x"]) && ($dsondage->format == "D" || $dsondage-
sendEmail( $adresseadmin,
_("[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").
" : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,
$headers );
" : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION );
} else {
$erreur_ajout_date="yes";
}

View File

@ -52,15 +52,16 @@ if ((isset($_POST['envoiquestion']) || isset($_POST['envoiquestion_x'])) && isse
$message=str_replace("\\","",$_POST["question"]);
//envoi des mails
$headers = makeHeaders() ;
if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) {
$headers .= "\r\n".'Reply-To: '.$_POST['adresse_mail'];
$headers = 'Reply-To: '.$_POST['adresse_mail'];
} else {
$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'])) {
$headers = makeHeaders() ;
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 );
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 );
}
//affichage de la page de confirmation d'envoi

View File

@ -82,8 +82,6 @@ function ajouter_sondage()
$date_fin = time()+15552000;
}
$headers = makeHeaders() ;
global $connect;
$sql = 'INSERT INTO sondage
@ -118,8 +116,8 @@ function ajouter_sondage()
$message_admin = sprintf($message_admin, getUrlSondage($sondage_admin, true));
if (validateEmail($_SESSION['adresse'])) {
sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin, $headers );
sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message, $headers );
sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin );
sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message );
}
$date=date('H:i:s d/m/Y:');

View File

@ -183,28 +183,21 @@ function sendEmail( $to, $subject, $body, $headers, $param)
} ;
$subject = '=?UTF-8?B?' . base64_encode( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ) ) . '?=' ;
$encoded_app = '=?UTF-8?B?' . base64_encode( NOMAPPLICATION ) . '?=' ;
if ( $headers ) $headers .= "\r\n"
$headers .= sprintf( "From: %s <%s>\r\n", $encoded_app, ADRESSEMAILADMIN )
$headers .= "MIME-Version: 1.0\r\n"
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n"
$headers .= "Content-Transfer-Encoding: 8bit"
$body = html_entity_decode( $body, ENT_QUOTES, 'UTF-8' ) ;
mail( $to, $subject, $body, $headers, $param ) ;
}
function makeHeaders() {
$headers_str = <<<EOF
From: %s <%s>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
EOF;
$encoded_app = '=?UTF-8?B?' . base64_encode( NOMAPPLICATION ) . '?=' ;
$headers = sprintf( $headers_str, $encoded_app, ADRESSEMAILADMIN ) ;
return $headers ;
}
/**
* Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau

View File

@ -171,14 +171,12 @@ if (!is_error(NO_POLL) && (isset($_POST["boutonp"]) || isset($_POST["boutonp_x"]
$connect->Execute($sql, array($nom, $numsondage, $nouveauchoix));
if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=="yes" || $dsondage->mailsonde=="true") {
$headers = makeHeaders() ;
sendEmail( "$dsondage->mail_admin",
"[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->titre, 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".
getUrlSondage($numsondage)." \n\n" .
_("Thanks for your confidence.") . "\n". NOMAPPLICATION,
$headers );
_("Thanks for your confidence.") . "\n". NOMAPPLICATION );
}
}
} else {
@ -307,8 +305,7 @@ if ($testmodifier) {
$connect->Execute($sql, array($nouveauchoix, $data->nom, $data->id_users));
if ($dsondage->mailsonde=="yes") {
$headers = makeHeaders() ;
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 );
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 );
}
}