[6] | 1 | <?php |
---|
| 2 | /*********************************************************************** |
---|
| 3 | |
---|
| 4 | Copyright (C) 2005 Terrell Russell (punbb@terrellrussell.com) |
---|
| 5 | |
---|
| 6 | Copyright (C) 2006 FoxMaSk (foxmask@punbb.fr) |
---|
| 7 | |
---|
| 8 | This file is part of PunBB. |
---|
| 9 | |
---|
| 10 | PunBB is free software; you can redistribute it and/or modify it |
---|
| 11 | under the terms of the GNU General Public License as published |
---|
| 12 | by the Free Software Foundation; either version 2 of the License, |
---|
| 13 | or (at your option) any later version. |
---|
| 14 | |
---|
| 15 | PunBB is distributed in the hope that it will be useful, but |
---|
| 16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | GNU General Public License for more details. |
---|
| 19 | |
---|
| 20 | You should have received a copy of the GNU General Public License |
---|
| 21 | along with this program; if not, write to the Free Software |
---|
| 22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
| 23 | MA 02111-1307 USA |
---|
| 24 | |
---|
| 25 | ************************************************************************/ |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | /*********************************************************************** |
---|
| 29 | 18 Mai 2006 - Auteur FoxMask - AP_Email_Global_Plus v 1.0 |
---|
| 30 | |
---|
| 31 | adapteé du plugin AP_Email_Global.php de Terrell Russell |
---|
| 32 | |
---|
| 33 | ce plugin permet d'envoyer des mails en masse à un groupe d'utilisateurs donné |
---|
| 34 | et ajoute le groupe administrateur pour 'accuser' reception du mail de masse. |
---|
| 35 | |
---|
| 36 | ************************************************************************/ |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | // Make sure no one attempts to run this script "directly" |
---|
| 40 | if (!defined('PUN')) |
---|
| 41 | exit; |
---|
| 42 | |
---|
| 43 | // Tell admin_loader.php that this is indeed a plugin and that it is loaded |
---|
| 44 | define('PUN_PLUGIN_LOADED', 1); |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | // -------------------------------------------------------------------- |
---|
| 49 | |
---|
| 50 | // Confirm Page |
---|
| 51 | |
---|
| 52 | if (isset($_POST['confirm'])) |
---|
| 53 | { |
---|
| 54 | // Make sure message body was entered |
---|
| 55 | if (trim($_POST['message_body']) == '') |
---|
| 56 | message('Vous n\'avez pas écrit de message!'); |
---|
| 57 | |
---|
| 58 | // Make sure message subject was entered |
---|
| 59 | if (trim($_POST['message_subject']) == '') |
---|
| 60 | message('Vous n\'avez pas précisé le sujet!'); |
---|
| 61 | |
---|
| 62 | // Display the admin navigation menu |
---|
| 63 | generate_admin_menu($plugin); |
---|
| 64 | |
---|
| 65 | $preview_message_body = nl2br(pun_htmlspecialchars($_POST['message_body'])); |
---|
| 66 | |
---|
| 67 | if (! is_numeric($_POST['group_id']) ) message('tsss tsss tsss!!!'); |
---|
| 68 | |
---|
| 69 | // envoi à tous les groupes sauf invité |
---|
| 70 | if ($_POST['group_id'] == '0' ) |
---|
| 71 | $sql = "SELECT count(*) AS usercount |
---|
| 72 | FROM ".$db->prefix."users |
---|
| 73 | WHERE group_id <> '3' ORDER BY username"; |
---|
| 74 | else |
---|
| 75 | // envoi à un groupe en particulier |
---|
| 76 | $sql = "SELECT count(*) AS usercount |
---|
| 77 | FROM ".$db->prefix."users |
---|
| 78 | WHERE group_id = '".$_POST['group_id']."'" . |
---|
| 79 | " ORDER BY username"; |
---|
| 80 | |
---|
| 81 | $result = $db->query($sql) or error('Ne peut trouver le nombre d\'utilisateur dans la base de données', __FILE__, __LINE__, $db->error()); |
---|
| 82 | $row = $db->fetch_assoc($result); |
---|
| 83 | |
---|
| 84 | ?> |
---|
| 85 | <div id="exampleplugin" class="blockform"> |
---|
| 86 | <h2><span>Mail de Masse - Confirmation</span></h2> |
---|
| 87 | <div class="box"> |
---|
| 88 | <div class="inbox"> |
---|
| 89 | <p>Merci de confirmer votre message ci-dessous.<br /><br />Pour d'éventuelles corrections: <a href="javascript: history.go(-1)">Retour</a>.</p> |
---|
| 90 | </div> |
---|
| 91 | </div> |
---|
| 92 | |
---|
| 93 | <h2 class="block2"><span>Confirmation de l'envoi du Message</span></h2> |
---|
| 94 | <div class="box"> |
---|
| 95 | <form id="broadcastemail" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>"> |
---|
| 96 | <div class="inform"> |
---|
| 97 | <input type="hidden" name="message_subject" value="<?php echo pun_htmlspecialchars($_POST['message_subject']) ?>" /> |
---|
| 98 | <input type="hidden" name="message_body" value="<?php echo pun_htmlspecialchars($_POST['message_body']) ?>" /> |
---|
| 99 | <input type="hidden" name="group_id" value="<?php echo $_POST['group_id']; ?>"/> |
---|
| 100 | <fieldset> |
---|
| 101 | <legend>Destinataires</legend> |
---|
| 102 | <div class="infldset"> |
---|
| 103 | [ <strong><?php echo $row['usercount'] ?></strong> ] membres vont recevoir ce message (Administrateur inclu). |
---|
| 104 | </div> |
---|
| 105 | </fieldset> |
---|
| 106 | </div> |
---|
| 107 | <div class="inform"> |
---|
| 108 | <fieldset> |
---|
| 109 | <legend>Contenu du message</legend> |
---|
| 110 | <div class="infldset"> |
---|
| 111 | <table class="aligntop" cellspacing="0"> |
---|
| 112 | <tr> |
---|
| 113 | <th scope="row">Sujet</th> |
---|
| 114 | <td> |
---|
| 115 | <?php echo pun_htmlspecialchars($_POST['message_subject']) ?> |
---|
| 116 | </td> |
---|
| 117 | </tr> |
---|
| 118 | <tr> |
---|
| 119 | <th scope="row">Corps du message</th> |
---|
| 120 | <td> |
---|
| 121 | <?php echo $preview_message_body ?> |
---|
| 122 | </td> |
---|
| 123 | </tr> |
---|
| 124 | </table> |
---|
| 125 | <div class="fsetsubmit"><input type="submit" name="send_message" value="Confirmer - Envoyer." tabindex="3" /></div> |
---|
| 126 | <p class="topspace">A n'effectuer qu'une seule fois. La patience est une vertu.</p> |
---|
| 127 | </div> |
---|
| 128 | </fieldset> |
---|
| 129 | </div> |
---|
| 130 | </form> |
---|
| 131 | </div> |
---|
| 132 | </div> |
---|
| 133 | <?php |
---|
| 134 | |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | // -------------------------------------------------------------------- |
---|
| 138 | |
---|
| 139 | // Send the Message |
---|
| 140 | |
---|
| 141 | else if (isset($_POST['send_message'])) |
---|
| 142 | { |
---|
| 143 | |
---|
| 144 | require_once PUN_ROOT.'include/email.php'; |
---|
| 145 | |
---|
| 146 | // Display the admin navigation menu |
---|
| 147 | generate_admin_menu($plugin); |
---|
| 148 | |
---|
| 149 | if (! is_numeric($_POST['group_id']) ) message ('tsss tsss tsss!!!'); |
---|
| 150 | |
---|
| 151 | // envoi à tous les groupes sauf invité |
---|
| 152 | if ($_POST['group_id'] == '0' ) |
---|
| 153 | $sql = "SELECT username, email |
---|
| 154 | FROM ".$db->prefix."users |
---|
| 155 | WHERE group_id <> '3' ORDER BY username"; |
---|
| 156 | |
---|
| 157 | // envoi au groupe administrateur seulement |
---|
| 158 | elseif ($_POST['group_id'] == '1' ) |
---|
| 159 | |
---|
| 160 | $sql = "SELECT username, email |
---|
| 161 | FROM ".$db->prefix."users |
---|
| 162 | WHERE group_id = '1'" . |
---|
| 163 | " ORDER BY username"; |
---|
| 164 | |
---|
| 165 | else |
---|
| 166 | // envoi à un groupe en particulier + groupe administrateur |
---|
| 167 | $sql = "SELECT username, email |
---|
| 168 | FROM ".$db->prefix."users |
---|
| 169 | WHERE group_id = '".$_POST['group_id']."' or group_id = '1'" . |
---|
| 170 | " ORDER BY username"; |
---|
| 171 | |
---|
| 172 | $result = $db->query($sql) or error('Ne peut trouver les utilisateurs dans la base de données', __FILE__, __LINE__, $db->error()); |
---|
| 173 | while($row = $db->fetch_assoc($result)) |
---|
| 174 | { |
---|
| 175 | $addresses[$row['username']] = $row['email']; |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | $usercount = count($addresses); |
---|
| 179 | |
---|
| 180 | foreach ($addresses as $recipientname => $recipientemail) |
---|
| 181 | { |
---|
| 182 | |
---|
| 183 | $mail_to = $recipientname." <".$recipientemail.">"; |
---|
| 184 | $mail_subject = pun_htmlspecialchars($_POST['message_subject']); |
---|
| 185 | $mail_message = pun_htmlspecialchars($_POST['message_body']); |
---|
| 186 | |
---|
| 187 | pun_mail($mail_to, $mail_subject, $mail_message); |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | |
---|
| 191 | |
---|
| 192 | ?> |
---|
| 193 | <div class="block"> |
---|
| 194 | <h2><span>Mail de Masse - Message Envoyé</span></h2> |
---|
| 195 | <div class="box"> |
---|
| 196 | <div class="inbox"> |
---|
| 197 | <p>Ce message a été envoyé à [ <strong><?php echo $usercount ?></strong> ] membres.</p> |
---|
| 198 | <p>En tant qu'administrateur, vous allez recevoir une copie de celui-ci.</p> |
---|
| 199 | <p>Vous pouvez considérer cette copie comme une confirmation de l'envoi.</p> |
---|
| 200 | </div> |
---|
| 201 | </div> |
---|
| 202 | </div> |
---|
| 203 | <?php |
---|
| 204 | |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | // -------------------------------------------------------------------- |
---|
| 208 | |
---|
| 209 | // Display the Main Page |
---|
| 210 | |
---|
| 211 | else |
---|
| 212 | { |
---|
| 213 | // Display the admin navigation menu |
---|
| 214 | generate_admin_menu($plugin); |
---|
| 215 | |
---|
| 216 | ?> |
---|
| 217 | <div id="exampleplugin" class="blockform"> |
---|
| 218 | <h2><span>Mail de Masse</span></h2> |
---|
| 219 | <div class="box"> |
---|
| 220 | <div class="inbox"> |
---|
| 221 | <p>Ce plugin permet à l'administrateur d'envoyer un mail général à tous les membres d'un groupe du forum.</p> |
---|
| 222 | <p>Une page récapitulative de confirmation succédera à celle-ci.</p> |
---|
| 223 | </div> |
---|
| 224 | </div> |
---|
| 225 | |
---|
| 226 | <h2 class="block2"><span>Rédiger un Message</span></h2> |
---|
| 227 | <div class="box"> |
---|
| 228 | <form id="broadcastemail" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>"> |
---|
| 229 | <div class="inform"> |
---|
| 230 | <fieldset> |
---|
| 231 | <legend>Contenu du message</legend> |
---|
| 232 | <div class="infldset"> |
---|
| 233 | <table class="aligntop" cellspacing="0"> |
---|
| 234 | <tr> |
---|
| 235 | <th scope="row">Groupe</th> |
---|
| 236 | <td> |
---|
| 237 | <select name="group_id"> |
---|
| 238 | <option value="0" select="selected">Tous</option> |
---|
| 239 | <?php |
---|
| 240 | // on ne prend pas le groupe 'invité'. |
---|
| 241 | $sql_group = "SELECT * FROM ".$db->prefix."groups WHERE g_id <> '3' ORDER BY g_id"; |
---|
| 242 | $result_group = $db->query($sql_group) or error('ne peut trouver la liste des groupes d\'utilisateurs',__FILE__, __LINE__, $db->error()); |
---|
| 243 | while ($row_group = $db->fetch_assoc($result_group)) { |
---|
| 244 | ?> |
---|
| 245 | <option value="<?php echo $row_group['g_id']; ?>"><?php echo $row_group['g_title']; ?></option> |
---|
| 246 | <?php } ?> |
---|
| 247 | </select> |
---|
| 248 | </td> |
---|
| 249 | </tr> |
---|
| 250 | <tr> |
---|
| 251 | <th scope="row">Sujet</th> |
---|
| 252 | <td> |
---|
| 253 | <input type="text" name="message_subject" size="50" tabindex="1" /> |
---|
| 254 | </td> |
---|
| 255 | </tr> |
---|
| 256 | <tr> |
---|
| 257 | <th scope="row">Corps du message</th> |
---|
| 258 | <td> |
---|
| 259 | <textarea name="message_body" rows="14" cols="48" tabindex="2"></textarea> |
---|
| 260 | </td> |
---|
| 261 | </tr> |
---|
| 262 | </table> |
---|
| 263 | <div class="fsetsubmit"><input type="submit" name="confirm" value="Continuer vers Confirmation" tabindex="3" /></div> |
---|
| 264 | </div> |
---|
| 265 | </fieldset> |
---|
| 266 | </div> |
---|
| 267 | </form> |
---|
| 268 | </div> |
---|
| 269 | </div> |
---|
| 270 | <?php |
---|
| 271 | |
---|
| 272 | } |
---|
| 273 | |
---|
| 274 | // -------------------------------------------------------------------- |
---|
| 275 | |
---|
| 276 | // Note that the script just ends here. The footer will be included by admin_loader.php. |
---|