Ticket #470: adm_email.php

File adm_email.php, 3.5 KB (added by nahuel, 7 years ago)
Line 
1<?php
2/*
3$Id: adm_email.php,v 1.1 2005/09/05 10:55:48 arnodu59 Exp $
4----------------------------------------------------------------------
5AlternC - Web Hosting System
6Copyright (C) 2005 by the AlternC Development Team.
7http://alternc.org/
8----------------------------------------------------------------------
9Based on:
10Valentin Lacambre's web hosting softwares: http://altern.org/
11----------------------------------------------------------------------
12LICENSE
13
14This program is free software; you can redistribute it and/or
15modify it under the terms of the GNU General Public License (GPL)
16as published by the Free Software Foundation; either version 2
17of the License, or (at your option) any later version.
18
19This program is distributed in the hope that it will be useful,
20but WITHOUT ANY WARRANTY; without even the implied warranty of
21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22GNU General Public License for more details.
23
24To read the license please visit http://www.gnu.org/copyleft/gpl.html
25----------------------------------------------------------------------
26Original Author of file: Benjamin Sonntag
27Purpose of file: Show a form to edit a member
28----------------------------------------------------------------------
29*/
30require_once("../class/config.php");
31
32if (!$admin->enabled) {
33    __("This page is restricted to authorized staff");
34    exit();
35}
36
37include("head.php");
38?>
39</head>
40<body>
41<h3>Envoye d'email &agrave; tous les comptes</h3>
42<?php
43@set_time_limit(1200);
44
45$message = '';
46$subject = '';
47
48if ( isset($_POST['submit']) )
49{
50    $subject = stripslashes(trim($_POST['subject']));
51    $message = stripslashes(trim($_POST['message']));
52   
53    $error = FALSE;
54    $error_msg = '';
55
56    if ( empty($subject) )
57    {
58        $error = true;
59        $error_msg .= ( !empty($error_msg) ) ? '<br /><p class="error">Vous devez sp&eacute;cifi&eacute; un sujet pour le mail !</p>' : '<p class="error">vous devez sp&eacute;cifi&eacute; un sujet pour le mail !</p>';
60    }
61
62    if ( empty($message) )
63    {
64        $error = true;
65        $error_msg .= ( !empty($error_msg) ) ? '<br /><p class="error">Votre mail doit contenir un message !</p>' : '<p class="error">Votre mail doit contenir un message !</p>';
66    }
67
68    $sql = "SELECT mail FROM membres WHERE uid <> 2000";
69    $resultat = mysql_query($sql);
70        if ( $row = @mysql_fetch_array($resultat) )
71    {
72                do
73        {
74            $headers = 'From: root@' . $_SERVER['HTTP_HOST'] . "\r\n";
75
76            mail($row['mail'], $subject, $message, $headers);
77        }
78        while ( $row = @mysql_fetch_array($resultat) );
79                @mysql_free_result($resultat);
80    }
81        $error = true;
82        $error_msg .= '<p class="error">envoy&eacute; avec succ&egrave;s.</p>';
83}   
84
85if ($error) 
86{
87    echo "$error_msg";
88}
89?>
90<form method="post" action="adm_email.php">
91
92<table cellspacing="1" cellpadding="4" border="0" align="center">
93        <tr>
94          <th colspan="2">Envoye d'un mail &agrave; tous les utilisateurs</th>
95        </tr>
96        <tr>
97          <td align="right"><b>Sujet</b></td>
98          <td><span><input type="text" name="subject" size="45" maxlength="100" tabindex="2" value="" /></span></td>
99        </tr>
100        <tr>
101          <td align="right" valign="top"> <span><b>Message</b></span>
102          <td><span> <textarea name="message" rows="15" cols="35" wrap="virtual" style="width:450px" tabindex="3"></textarea></span>
103        </tr>
104        <tr>
105          <td class="catBottom" align="center" colspan="2"><input type="submit" value="Envoyer le mail" name="submit" /></td>
106        </tr>
107</table>
108
109</form>
110
111</body>
112</html>