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