C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\webboard\admin\newsletter.php


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
<?php
/* $Id: newsletter.php,v 1.1.1.1 2002/10/28 19:13:51 pbaecher Exp $ */
/*
          ThWboard - PHP/MySQL Bulletin Board System
        ==============================================
            (c) 2000, 2001 by
               Paul Baecher         <paul@thewall.de>
               Felix Gonschorek   <funner@thewall.de>

          download the latest version:
            http://www.thwboard.de

          This  program is  free  software;  you can
          redistribute it and/or modify it under the
          terms of the GNU General Public License as
          published by the Free Software Foundation;
          either  version 2 of  the License,  or (at
          your option) any later version.

        ==============================================

*/

include "common.inc.php";

function 
thwb_query($query)
{
    
$start microtime();
    
$result mysql_query($query);
    
$end microtime();

    if( !
$result )
    {
        print 
'<pre><b>ThWboard Error</b><br>MySQL: ' mysql_error() . '
        Query: ' 
$query '</pre>';
        exit;
    }
    return 
$result;
}

tb_header();

if( !
$sendnewsletter )
{
    echo 
'<form method="post" action="newsletter.php"><B>Send newsletter</B><BR>
  <hr width="100%" noshade>
  <table width="100%" border="0" cellspacing="1" cellpadding="3">
    <tr>
        <td colspan="2" bgcolor="#999999">
        <font size="2" color="white"><b>General</b></font>
      </td>
    </tr>
    <tr>
      <td width="100">
        Subject
      </td>
      <td>
      <input class="tbinput" type="text" size="40" name="subject" value="'
.$config['board_name'].' - Newsletter">
      </td>
    </tr>
    <tr>
      <td valign="top">Content</td>
      <td>
        <textarea class="tbinput" name="content" rows="20" cols="40"></textarea>
      </td>
    </tr>
    <tr>
      <td valign="top">Send to</td>
      <td>
        <select class="tbinput" name="a_group[]" size="6" multiple>
          <option value="-1" selected>- All groups -</option>'
;
    
// groups
    
$r_group query("SELECT groupid, name FROM $pref"."group ORDER BY name ASC");
    while( 
$group mysql_fetch_array($r_group) )
    {
        print 
'<option value="'.$group['groupid'].'">'.$group['name'].'</option>';
    }
    
    print 
'
        </select><font size="1"><br>(Use CTRL to select multiple)</font>
      </td>
    </tr>
    <tr>
       <td colspan="2" bgcolor="#999999">
          <font size="2" color="white"><b>Send newsletter as</b></font>
      </td>
    </tr>
    <tr>
      <td valign="top" colspan=2>
      <input type="radio" name="type" value="mail" checked>
      eMail
      <input type="radio" name="type" value="pm">
      Private Message 
      </td>
    </tr>
    <tr>
    <td colspan="2">
      <input type="hidden" value="' 
$session '" name="session">
      <input type="submit" name="sendnewsletter" value="Send newsletter !">
    </td>
  </tr>
</table>
</form>'
;
    
tb_footer();
    exit;
}


$where_sql '';
if( 
count($a_group) > )
{
    
// a_group
    
if( $a_group[0] != -)
    {
        while( list(, 
$groupid) = each($a_group) )
        {
            
$where_sql .= " OR INSTR(groupids, ',$groupid,')>0";
        }
        
$where_sql 'WHERE '.substr($where_sql4);
    }
    
    
$r_user thwb_query("SELECT userid, useremail FROM $pref"."user $where_sql");
    
$usercount mysql_num_rows($r_user);
    while( 
$user mysql_fetch_array($r_user) )
    {
        if( 
$type == "mail" )
        {
            
$content str_replace("\n""\r\n"$content);
            @
mail($user['useremail'], $subject$content"From: ".$config['board_admin']);
        }
        else
        {
            
thwb_query("INSERT INTO $pref"."pm (pmfromid, pmtoid, pmtopic, pmtext, pmtime, pmflags, pmfolder)
    VALUES
    (
$g_user[userid]$user[userid],'" addslashes($subject) . "','" addslashes($content) . "',".time().", 1, 0);");
        }
    }
    echo 
"Newsletter has been sent! (<b>$usercount</b> users)";
}
else
{
    print 
'You need to select a userlevel/group ..';
}

tb_footer();
?>