1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
<?php
require('include/ludo/session_verify.inc.php');
require_once('include/ludo/html_elements.inc.php');
require_once('include/connect.inc.php');
include 'include/ludo/config.inc.php';
generate_html_doctype_and_head("Envoi de courriel");
echo "<body>\n";
generate_html_divs_menu();
?>
<div id="sous_menu">
<p class="arbre">
> <a href="index.php">Accueil</a>
> <a href="index.php">Réunions</a>
> Envoi de courriel
</p>
</div>
<?php generate_html_div_help();
if( isset($_POST['idR']) )
{
$idR=addslashes($_POST['idR']);
}
else
{
?>
<div id="errmsg">
Erreur lors de l'émission de l'email : Paramètre manquant ou érroné
</div></body></html>
<?php
exit();
}
if( isset($_POST['envoi']) )
{
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 AWOR_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[]=htmlentities($nomP, ENT_QUOTES) . ' ' . htmlentities($prenomP, ENT_QUOTES) . ' <' . htmlentities($courrielP, ENT_QUOTES) . '>"';
}
$to=implode(', ',$to);
if ( ! mail ( $to, stripslashes_if_needed($_POST['msgObject']), wordwrap(stripslashes_if_needed($_POST['msgText']),70), '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é<br />';
echo '<a href="details_reunion.php?idR=' . $idR . '">Retour au détail de la réunion</a></div></body></html>';
}
exit();
}
$result = mysql_query("SELECT idL FROM AWOR_Reunion WHERE idR='$idR'");
if (mysql_num_rows($result)===1)
{
list($idL) = mysql_fetch_array($result);
}
else
{
$errmsg="";
}
if ( isset($errmsg) )
{
echo '<div id="errmsg">' . $errmsg .'</div></body></html>';
exit();
}
?>
<div id="contenu">
<form id="formmail" action="sendmail.php" method="post" onsubmit="return dataListe('participants','dataParticipants');">
<table summary="Contacts disponibles et participants">
<tbody>
<tr>
<td>Contacts disponibles</td>
<td> </td>
<td>Destinataires</td>
</tr>
<tr>
<td>
<select name="contactDispo" size="10" id="contactDispo">
<?php
$personnes = array();
$req = 'SELECT P.idP , P.courrielP , P.nomP , P.prenomP FROM AWOR_Personne P, AWOR_Appartenir A WHERE P.idP=A.idP AND A.idL=' . $idL;
$result = mysql_query($req) ;
if (mysql_num_rows($result)>0)
{
for($i=0;$i<mysql_num_rows($result);$i++)
{
list($idP, $courrielP, $nomP, $prenomP) = mysql_fetch_array($result);
$courrielP=htmlentities($courrielP, ENT_QUOTES);
$nomP=htmlentities($nomP, ENT_QUOTES);
$prenomP=htmlentities($prenomP, ENT_QUOTES);
$personnes[$idP]=array($courrielP, $nomP, $prenomP);
echo '<option value="'.$idP.'" ondblclick="addPers(this.form);">';
echo $nomP . " " . $prenomP;
echo "</option>\n";
}
}
?>
</select>
</td>
<td>
<input name="AjouterParticipant" id="AjouterParticipant" value="Ajouter" onclick="addPers(this.form);" type="button" />
<br />
<br />
<input name="supprimerParticipant" id="supprimerParticipant" value="Retirer" onclick="removePers(this.form);" type="button" />
</td>
<td>
<select name="participants" size="10" id="participants">
<?php
foreach( $personnes as $idP=>$p)
{
if ( isset($_POST['mail_idP' . $idP] ) )
{
echo '<option value="'.$idP.'">';
echo $p[1] . " " . $p[2];
echo "</option>\n";
}
}
?>
</select>
</td>
</tr>
</tbody>
</table>
<?php
if ( isset($CONFIG['MAIL']['TEMPLATES']) && is_array($CONFIG['MAIL']['TEMPLATES']) )
{
echo ' <div>' . "\n";
echo ' Modèle : ' . "\n";
echo ' <select name="modelsList" id="modelsList" onchange="loadlist(\'include/ludo/mail_textarea.php?idR=';
echo $idR . "&model=','modelsList','divMsg');\">\n";
echo ' <option value="empty">Vierge</option>';
foreach( $CONFIG['MAIL']['TEMPLATES'] as $mail_model_id => $mail_model_par )
{
echo ' <option value="' . $mail_model_id . '">' . $mail_model_par['caption'] . "</option>\n";
}
echo ' </select>' . "\n";
echo ' </div>' . "\n";
}
?>
<div>
Objet : <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>
</form>
</div>
<?php generate_html_div_footer(); ?>
<div id="msg"></div>
</body>
</html>
|