diff options
author | citizenz7 <citizenz7@protonmail.com> | 2017-04-20 18:50:55 +0200 |
---|---|---|
committer | citizenz7 <citizenz7@protonmail.com> | 2017-04-20 18:50:55 +0200 |
commit | 5fd9fa480f302902328b81f912dd67ce378284f8 (patch) | |
tree | 66234843ae2857fda12442e4f7577c527d48977c /Html/admin/messages_envoyer_tous.php | |
parent | ebe731862c7c741171138b1083906f391fc35aff (diff) | |
download | freetorrent-5fd9fa480f302902328b81f912dd67ce378284f8.tar.xz freetorrent-5fd9fa480f302902328b81f912dd67ce378284f8.zip |
V.1.4.6
Diffstat (limited to 'Html/admin/messages_envoyer_tous.php')
-rw-r--r-- | Html/admin/messages_envoyer_tous.php | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/Html/admin/messages_envoyer_tous.php b/Html/admin/messages_envoyer_tous.php new file mode 100644 index 0000000..daaec2e --- /dev/null +++ b/Html/admin/messages_envoyer_tous.php @@ -0,0 +1,114 @@ +<?php +require_once('../includes/config.php'); + +if(!$user->is_logged_in()) { + header('Location: login.php'); +} + +//Il n'y a que l'admin qui accède à cette page +if(isset($_SESSION['userid'])) { + if($_SESSION['userid'] != 1) { + header('Location: '.SITEURL); + } +} + +$pagetitle = 'Message groupé à tous les membres'; + +include_once('../includes/header.php'); + +?> + +<body> + +<div id="container"> + + <?php + include_once('../includes/header-logo.php'); + include_once('../includes/nav.php'); + ?> + + <div id="body"> + + <div id="content"> + +<?php +// on teste si le formulaire a bien été soumis +if (isset($_POST['go']) && $_POST['go'] == 'Envoyer') { + + if (empty($_POST['titre'])) { + $error[] = 'Veuillez entrer un titre pour votre message.'; + } + + if (empty($_POST['message'])) { + $error[] = 'Votre message est vide ??!'; + } + + try { + + //On cherche tous les membres sauf l'admin (1) et le Visiteur (32) + $getusers = $db->query('SELECT * FROM blog_members WHERE memberID != 1 AND memberID != 32 AND active = "yes"'); + + while($result = $getusers->fetch(PDO::FETCH_ASSOC)) { + + $stmt = $db->prepare('INSERT INTO blog_messages (messages_id_expediteur,messages_id_destinataire,messages_date,messages_titre,messages_message) VALUES (:messages_id_expediteur,:messages_id_destinataire,:messages_date,:messages_titre,:messages_message)'); + $stmt->execute(array( + ':messages_id_expediteur' => 1, + ':messages_id_destinataire' => $result['memberID'], + ':messages_date' => date("Y-m-d H:i:s"), + ':messages_titre' => html($_POST['titre']), + ':messages_message' => html($_POST['message']) + )); + + } //while + + header('Location: index.php?&message=envoye'); + $stmt->closeCursor(); + exit(); + } + + catch(PDOException $e) { + echo $e->getMessage(); + } +} +?> + +<form action="messages_envoyer_tous.php" method="post"> +Message à tous les membres : + +<br /> + +<?php +//S'il y a des erreurs, on les affiche +if(isset($error)){ + foreach($error as $error){ + echo '<div class="alert-msg rnd8 error">ERREUR : '.$error.'</div>'; + } +} +?> + +<br /> +<br /> + +Titre du message :<br /> +<input type="text" name="titre" size="50" value="<?php if (isset($_POST['titre'])) echo html(trim($_POST['titre'])); ?>"> +<br /><br /> +Message : <textarea style="height:200px;width:900px;" name="message"><?php if (isset($_POST['message'])) echo trim($_POST['message']); ?></textarea> +<br /><br /> +<input type="submit" class="searchsubmit formbutton" name="go" value="Envoyer"> <input type="reset" value="Annuler" /> +</form> + + + </div> + + <?php include_once('../sidebar.php'); ?> + + <div class="clear"></div> + </div> +</div> + +<div id="footer"> + <?php include_once('../includes/footer.php'); ?> +</div> + +</body> +</html> |