diff --git a/adminstuds.php b/adminstuds.php index a1e98ad..45c7c0b 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -103,13 +103,7 @@ $dsondage=$sondage->FetchObject(false); //si la valeur du nouveau titre est valide et que le bouton est activé $adresseadmin = $dsondage->mail_admin; -$headers_str = << -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit -EOF; -$headers = sprintf($headers_str, NOMAPPLICATION, ADRESSEMAILADMIN); - +$headers = makeHeaders() ; if (isset($_POST["boutonnouveautitre"]) || isset($_POST["boutonnouveautitre_x"])) { if(issetAndNoEmpty('nouveautitre') === false) { @@ -477,7 +471,8 @@ 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="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; + $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, diff --git a/contacts.php b/contacts.php index 3ca5f48..ef6c9a3 100644 --- a/contacts.php +++ b/contacts.php @@ -52,13 +52,14 @@ if ((isset($_POST['envoiquestion']) || isset($_POST['envoiquestion_x'])) && isse $message=str_replace("\\","",$_POST["question"]); //envoi des mails - $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\r\nContent-Transfer-Encoding: 8bit"; + $headers = makeHeaders() ; + if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) { $headers .= "\r\n".'Reply-To: '.$_POST['adresse_mail']; } 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="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; + $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 ); } diff --git a/creation_sondage.php b/creation_sondage.php index 38ae7fe..beb8487 100644 --- a/creation_sondage.php +++ b/creation_sondage.php @@ -82,7 +82,7 @@ function ajouter_sondage() $date_fin = time()+15552000; } - $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; + $headers = makeHeaders() ; global $connect; diff --git a/fonctions.php b/fonctions.php index c601097..1e720fa 100644 --- a/fonctions.php +++ b/fonctions.php @@ -188,6 +188,22 @@ function sendEmail( $to, $subject, $body, $headers, $param) } +function makeHeaders() { + + $headers_str = << +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 diff --git a/studs.php b/studs.php index f8446e0..c74052b 100644 --- a/studs.php +++ b/studs.php @@ -171,7 +171,7 @@ 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="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; + $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'). @@ -307,7 +307,7 @@ if ($testmodifier) { $connect->Execute($sql, array($nouveauchoix, $data->nom, $data->id_users)); if ($dsondage->mailsonde=="yes") { - $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; + $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 ); } }