summaryrefslogtreecommitdiff
path: root/appli_3_alpha_old/sendmail.php
diff options
context:
space:
mode:
Diffstat (limited to 'appli_3_alpha_old/sendmail.php')
-rw-r--r--appli_3_alpha_old/sendmail.php101
1 files changed, 78 insertions, 23 deletions
diff --git a/appli_3_alpha_old/sendmail.php b/appli_3_alpha_old/sendmail.php
index e739884..631fa99 100644
--- a/appli_3_alpha_old/sendmail.php
+++ b/appli_3_alpha_old/sendmail.php
@@ -17,24 +17,74 @@ generate_html_divs_menu();
</p>
</div>
<?php generate_html_div_help();
-if( isset($_GET['envoi']) )
+if( isset($_POST['idR']) )
{
- // TODO : code d'envoi
- echo '<div id="contenu"><pre>';
- print_r($_REQUEST);
- echo '</div></body></html>';
- exit();
+ $idR=addslashes($_POST['idR']);
}
-
-if( isset($_GET['idR']) )
+else
{
- $idR=addslashes($_GET['idR']);
+?>
+ <div id="errmsg">
+ Erreur lors de l'émission de l'email : Paramètre manquant ou érroné
+ </div></body></html>
+<?php
+ exit();
}
-else
+
+if( isset($_POST['envoi']) )
{
- $errmsg="";
+ include 'include/ludo/config.inc.php';
+
+ if ( !isset($_POST['msgObject']) || !isset($_POST['msgText']) || !is_array($_POST['dataParticipants']) )
+ {
+ $errmsg = "Erreur lors de l'émission de l'email : Paramètre manquant ou érroné";
+ }
+ else
+ {
+ if ( !isset($CONFIG['automatedMail']) )
+ {
+ $errmsg = "Erreur lors de l'émission de l'email : Erreur de configuration par l'administrateur";
+ }
+ else
+ {
+ // Potentiellement dangereux...
+ $query='SELECT nomP, prenomP, courrielP FROM Personne WHERE idP=\'' . implode("' OR idP='", $_POST['dataParticipants']) . "'";
+ //~ echo " DEBUG : QUERY : $query\n";
+ $result = mysql_query($query);
+ if ( ! $result )
+ {
+ $errmsg = "Erreur lors de l'émission de l'email : Erreur de base de données";
+ }
+ else
+ {
+ $to=array();
+ while ( list($nomP, $prenomP, $courrielP) = mysql_fetch_row($result) )
+ {
+ $to[]="$nomP $prenomP <$courrielP>";
+ }
+ $to=implode(', ',$to);
+
+
+ if ( ! mail ( $to, $_POST['msgObject'], $_POST['msgText'], 'From: ' . $CONFIG['automatedMail'] . "\r\n" ) )
+ {
+ $errmsg = "Erreur lors de l'émission de l'email : Erreur inconnue";
+ }
+ }
+ }
+ }
+
+ if ( isset($errmsg) )
+ {
+ echo '<div id="errmsg">' . $errmsg .'</div></body></html>';
+ }
+ else
+ {
+ echo '<div id="contenu">Le courriel à bien été envoyé</div></body></html>';
+ }
+ exit();
}
+
$result = mysql_query("SELECT idL FROM Reunion WHERE idR='$idR'");
if (mysql_num_rows($result)===1)
{
@@ -46,16 +96,16 @@ else
}
-if ( isset($errmsg) )
+ if ( isset($errmsg) )
{
- echo '<div id="contenu">' . $errmsg .'</div></body></html>';
+ echo '<div id="errmsg">' . $errmsg .'</div></body></html>';
exit();
}
?>
<div id="contenu">
- <form id="formmail" action="sendmail.php" method="get" onsubmit="return dataListe('participants','dataParticipants');">
+ <form id="formmail" action="sendmail.php" method="post" onsubmit="return dataListe('participants','dataParticipants');">
<table>
<tbody>
<tr>
@@ -77,11 +127,12 @@ if ( isset($errmsg) )
{
list($idP, $courrielP, $nomP, $prenomP) = mysql_fetch_array($result);
$personnes[$idP]=array($courrielP, $nomP, $prenomP);
- echo '<option value="'.$idP.'" onDblClick="addPers(this.form);">';
+ echo '<option value="'.$idP.'" ondblclick="addPers(this.form);">';
echo $nomP . " " . $prenomP;
echo "</option>\n";
}
}
+
?>
</select>
</td>
@@ -96,9 +147,9 @@ if ( isset($errmsg) )
<?php
foreach( $personnes as $idP=>$p)
{
- if ( isset($_GET['mail_idP' . $idP] ) )
+ if ( isset($_POST['mail_idP' . $idP] ) )
{
- echo '<option value="'.$idP.'" onDblClick="addPers(this.form);">';
+ echo '<option value="'.$idP.'">';
echo $p[1] . " " . $p[2];
echo "</option>\n";
}
@@ -110,24 +161,28 @@ if ( isset($errmsg) )
</tbody>
</table>
<div>
- Modèle :&nbsp;
+ Modèle :&nbsp;
<?php
echo '<select name="modelsList" id="modelsList" onchange="loadlist(\'include/ludo/mail_textarea.php?idR=';
- echo $idR . "&model=','modelsList','divMsg');\">\n";
+ echo $idR . "&amp;model=','modelsList','divMsg');\">\n";
?>
<option value="empty">Vierge</option>
- <option value="cree">Nouvelle Réunion</option>
- <option value="modif">Réunion modifiée</option>
- <option value="annul">Réunion annulée</option>
- <option value="fixee">Réunion fixée</option>
+ <option value="cree">Nouvelle Réunion</option>
+ <option value="modif">Réunion modifiée</option>
+ <option value="annul">Réunion annulée</option>
+ <option value="fixee">Réunion fixée</option>
</select>
</div>
<div>
Objet :&nbsp;<input name="msgObject" type="text" size="40" value="AWOR : Courriel de notification" />
+ </div>
<div id='divMsg'>
<?php include 'include/ludo/mail_textarea.php'; ?>
</div>
<div>
+ <?php
+ echo '<input name="idR" type="hidden" value="' . $idR . '" />' . "\n";
+ ?>
<input name="envoi" type="hidden" value="1" />
<input type="submit" value="Envoyer" />
</div>