C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\webboard\admin\announcements.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
/* $Id: announcements.php,v 1.1.1.1 2002/10/28 19:13:48 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";

tb_header();

function 
EditboxEncode($string)
{
    
$string str_replace('&''&amp;'$string);
    
$string str_replace('"''&quot;'$string);
    
$string str_replace('<''&lt;'$string);
    
$string str_replace('>''&gt;'$string);
    
    return 
$string;
}

function 
EditboxDecode($string)
{
    
$string str_replace('&amp;''&'$string);
    
$string str_replace('&quot;''"'$string);
    
$string str_replace('&lt;''<'$string);
    
$string str_replace('&gt;''>'$string);

    return 
$string;
}

function 
selectbox_board($boardids)
{
    global 
$pref;
    global 
$config;
    global 
$session;
    
$r_board query("SELECT boardid, boardname FROM " $pref "board");
    while ( 
$board mysql_fetch_array($r_board) )
    {
    
$selectbox .= "<option value=\"$board[boardid]\" " . ( stristr($boardids,";" $board[boardid] . ";") != false "selected" "" ) . ">$board[boardname]</option>";
    }
    return(
$selectbox);
}

function 
NewsForm($action$news)
{
    global 
$session;
    print 
'<form name="announcements" method="post" action="announcements.php">
  <table border="0" cellspacing="1" cellpadding="2">
    <tr>
      <td>Subject</td>
      <td>
        <input class="tbinput" type="text" name="news[newstopic]" size="45" value="' 
EditboxEncode($news[newstopic]) . '">
      </td>
    </tr>
    <tr>
      <td valign="top">Text</td>
      <td>
        <textarea class="tbinput" name="news[newstext]" cols="60" rows="8">' 
$news[newstext] . '</textarea>
      </td>
    </tr>
    <tr>
      <td valign="top">Boards</td>
      <td>
        <SELECT class="tbinput" name="boardids[]" size="8" multiple>' 
selectbox_board($news[boardid]) . '</select>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>
        <input type="submit" name="Submit" value="Submit">
        <input type="hidden" name="newsid" value="' 
$news[newsid] . '">
        <input type="hidden" name="action" value="' 
$action '">
        <input type="hidden" name="session" value="' 
$session '">
      </td>
    </tr>
  </table>
</form>'
;
}


// ===================================================
// ===================================================
// ===================================================
if( $action == "ListNews" )
{
    print 
'<b>Current Announcements</b><br><a href="announcements.php?action=AddNews&session=' $session '">Add</a> an announcement<br><br>Note: You can use ThWboard Code in announcements.<br><br>';
    
    
$r_news query("SELECT newsid, newstopic, newstext, newstime FROM ".$pref."news ORDER BY newstime DESC");
    echo 
mysql_error();
    while( 
$news mysql_fetch_array($r_news) )
    {
        print 
date('d.m.Y H:i: '$news[newstime]) . "$news[newstopic] [ <a href=\"announcements.php?action=EditNews&session=$session&newsid=$news[newsid]\">edit</a> ] [ <a href=\"announcements.php?action=DeleteNews&session=$session&newsid=$news[newsid]\">delete</a> ]</a><br>";
    }
}


// ===================================================
// ===================================================
// ===================================================
elseif( $action == "EditNews" )
{
    print 
'<b>Edit Announcement</b><br><br>';
    
    
$r_news query("SELECT newsid, boardid, newstopic, newstext, newstime FROM ".$pref."news WHERE newsid=$newsid");
    
$news mysql_fetch_array($r_news);
    
NewsForm("UpdateNews"$news);
}


// ===================================================
// ===================================================
// ===================================================
elseif( $action == "UpdateNews" )
{
    
$news[newstopic] = EditboxDecode($news[newstopic]);
    
    while( list(, 
$boardids2) = @each($boardids) )
    {
        
$add_board $add_board.$boardids2.";";
    }
    
query("UPDATE ".$pref."news SET newstext='" addslashes($news[newstext]) . "', newstopic='" addslashes($news[newstopic]) . "', boardid=';$add_board' WHERE newsid=$newsid");
    print 
'Announcement has been updated!';
}


// ===================================================
// ===================================================
// ===================================================
elseif( $action == "AddNews" )
{
    print 
'<b>Add Announcement</b><br><br>';
    
    
NewsForm("InsertNews", array());
    
}


// ===================================================
// ===================================================
// ===================================================
elseif( $action == "InsertNews" )
{    
    while( list(, 
$boardids2) = @each($boardids) )
    {
        
$add_board $add_board.$boardids2.";";
    }
    
    
query("INSERT INTO ".$pref."news (newstopic,boardid, newstext, newstime) VALUES ('" addslashes($news[newstopic]) . "', ';$add_board', '" addslashes($news[newstext]) . "', " time() . ")");
    print 
'Announcement has been added!';
}


// ===================================================
// ===================================================
// ===================================================
elseif( $action == "DeleteNews" )
{
    if( 
$confirm == )
    {
        
query("DELETE FROM ".$pref."news WHERE newsid=$newsid");
        
        print 
'Announcement has been deleted!';
    }
    else
    {
        print 
'Are you sure?<br><a href="announcements.php?session=' $session '&newsid=' $newsid '&confirm=1&action=DeleteNews">yes</a>';
    }
}

tb_footer();
?>