C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$RTL8YJG\admin\boards.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<?php
/* $Id: boards.php,v 1.1.1.1 2002/10/28 19:13:49 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 
BoardForm($board$action)
{
    global 
$pref;
    global 
$session;
    print 
'<form method="post" action="boards.php">
  <table width="100%" border="0" cellspacing="0" cellpadding="3">
    <tr>
      <td>Forumname</td>
      <td>
        <input class="tbinput" type="text" name="board[boardname]" value="'
.htmlspecialchars($board[boardname]).'">
      </td>
    </tr>
    <tr>
      <td>Description</td>
      <td>
        <input class="tbinput" type="text" name="board[boarddescription]" value="'
.htmlspecialchars($board[boarddescription]).'">
      </td>
    </tr>
    <tr>
      <td>Category</td>
      <td>'
;
    
listbox("board[categoryid]""categoryid""categoryname""".$pref."category"$board['categoryid']);
    print 
'      </td>
    </tr>
    <tr>
      <td>Style</td>
      <td>'
;

    print 
'
<select class="tbinput" name="board[styleid]">
<option value="0">( Use default )</option>'
;
    
$r_style query("SELECT styleid, stylename FROM $pref"."style WHERE styleisdefault=0");
    while( 
$style mysql_fetch_array($r_style) )
    {
        print 
'<option value="'.$style['styleid'].'">'.$style['stylename'].'</option>';
    }
print 
'</select>';

//    listbox("board[styleid]", "styleid", "stylename", "".$pref."style", $board['styleid'], '<option value="0">-- USE DEFAULT --</option>');
    
print '      </td>
    </tr>
    <tr>
      <td><b>Status</b><br>
        <font size="1">Here you can deactivate<BR>this board temporarily</font></td>
      <td align="top"><SELECT class="tbinput" name="board[boarddisabled]"><option value="1" ' 
. ( $board[boarddisabled] == "selected" "" ) . '>Disable board</option><option value="0" ' . ( $board[boarddisabled] == " selected" "" ) . '>Enable board</option></SELECT></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>
        <input type="hidden" name="action" value="' 
$action '">
        <input type="hidden" name="update" value="1">
        <input type="hidden" name="board[boardid]" value="'
.$board['boardid'].'">
        <input type="hidden" name="session" value="' 
$session '">
        <input type="submit" name="Send" value="Send">
      </td>
    </tr>
  </table>
<br><br><br>
Note: You can define the default style <a href="style.php?session=' 
$session '&action=ListStyles">here</a>.
</form>'
;
}

if( 
$action == '' )
{
    print 
'<b>Change board and category order</b><br>';
print 
'
<form name="form1" method="post" action="boards.php">
  <table border="0" cellspacing="0" cellpadding="3">
    <tr> 
      <td colspan="2"><i>Display order</i></td>
      <td colspan="2" align="center"> <i>Options </i></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>'
;

    
$r_category query("SELECT categoryid, categoryname, categoryorder from ".$pref."category order by categoryorder asc");
    while( 
$category mysql_fetch_array($r_category) )
    {
        print 
'
    <tr> 
      <td align="center"> 
        <input type="text" name="catord['
.$category['categoryid'].']" size="2" value="'.$category['categoryorder'].'">
      </td>
      <td>&nbsp;</td>
      <td colspan="2"><a href="boards.php?action=RenameCategory&categoryid='
.$category['categoryid'].'&session='.$session.'">edit</a>
        | <a href="boards.php?action=delcat&id='
.$category['categoryid'].'&session='.$session.'">delete</a></td>
      <td>&nbsp;</td>
      <td><b>'
.$category['categoryname'].'</b></td>
    </tr>
'
;

        
$r_board query("SELECT boardid, boardname, boardthreads, boardposts, boardlastpost, boarddescription, boardorder FROM ".$pref."board where categoryid='$category[categoryid]' order by boardorder asc");
        while( 
$board mysql_fetch_array($r_board) )
        {
            print 
'
    <tr> 
      <td>&nbsp;</td>
      <td align="center"> 
        <input type="text" name="boardord['
.$board['boardid'].']" size="2" value="'.$board['boardorder'].'">
      </td>
      <td colspan="2"><a href="boards.php?action=edit&id='
.$board['boardid'].'&oldboardorder='.$board['boardorder'].'&session='.$session.'">edit</a>
        | <a href="boards.php?action=delete&forumid='
.$board['boardid'].'&session='.$session.'">delete</a>
        | <a href="groups.php?action=grouppermtable&boardid='
.$board['boardid'].'&session='.$session.'">permissions</a></td>
      <td>&nbsp;</td>
      <td>'
.$board['boardname'].'<br>
        <font size="1">'
.$board['boarddescription'].'</font></td>
    </tr>'
;
        }
    }
    print 
'
  </table>
  <br>
  <input type="hidden" name="session" value="'
.$session.'">
  <input type="hidden" name="action" value="updateorder">
  <input type="submit" name="ehnet" value="Update board order">
</form>'
;

}


/*
 * ########################################################################################
 *        updateorder
 * ########################################################################################
 */
elseif( $action=="updateorder" ) {

  while( list(
$boardid$boardorder)=each($boardord) ) {
    
query("UPDATE ".$pref."board SET boardorder=$boardorder WHERE boardid=$boardid;");
  }

  while( list(
$categoryid$categoryorder)=each($catord) ) {
    
query("UPDATE ".$pref."category SET categoryorder=$categoryorder WHERE categoryid=$categoryid;");
  }

  echo 
"Order has been updated!";

}


/*
 * ########################################################################################
 *        edit
 * ########################################################################################
 */
elseif( $action == "edit" ) {
    if( 
$Send )
    {
        
$r_board query("SELECT categoryid, boardorder FROM ".$pref."board WHERE boardid=$board[boardid]");
        
$oldboard mysql_fetch_array($r_board);

        if( 
$oldboard['categoryid'] != $board['categoryid'] )
        {
            
$result query"SELECT max(boardorder) FROM ".$pref."board WHERE categoryid=$board[boardid]);
            list(
$maxorder) = mysql_fetch_row($result);
            
$maxorder++;
        }
        else
        {
            
$maxorder $oldboard['boardorder'];
        }
        
query("UPDATE ".$pref."board SET boardname='"addslashes($board['boardname']) . "',
        boarddescription='" 
addslashes($board[boarddescription]) . "', categoryid='$board[categoryid]',
        boardorder='
$maxorder', styleid='$board[styleid]',
        boarddisabled = '
$board[boarddisabled]'
         WHERE boardid=
$board[boardid]");
        
        echo 
"Board has been updated!";
    }
    else
    {
        
$r_board query("SELECT boardid, boardname, boardlastpost, boardthreads, boardposts, boarddescription,
        categoryid, styleid, boarddisabled FROM "
.$pref."board WHERE boardid=$id");
        
$board mysql_fetch_array($r_board);

        
BoardForm($board'edit');

    }
}


/*
 * ########################################################################################
 *        addcat
 * ########################################################################################
 */
elseif( $action == "addcat" ) {
  if( 
$catname ) {
    
$result=query"SELECT max(categoryorder) FROM ".$pref."category" );
    list(
$maxorder)=mysql_fetch_row($result);

    
$maxorder++;

    
query"INSERT INTO ".$pref."category (categoryname, categoryorder) VALUES ('" addslashes($catname) . "', $maxorder);" );
    print 
'Category added.';
  } else {
    print 
'<b>New Category</b><br>';
    print 
'<form method="post" action="boards.php">
  Category Name:
  <input class="tbinput" type="text" name="catname">
  <input type="hidden" name="action" value="addcat">
  <input type="hidden" name="session" value="' 
$session '">
  <input type="submit" name="Abschicken" value="Add Category">
</form>'
;
  }
}


/*
 * ########################################################################################
 *           delete
 * ########################################################################################
 */
elseif( $action == "delete" ) {
  if( 
$confirm == ) {

    
// delete the board
    
mysql_query("DELETE FROM ".$pref."board WHERE boardid=$forumid");

    
// delete messages
    
$result=mysql_query("SELECT threadid FROM ".$pref."thread WHERE boardid=$forumid");
    while( 
$topic=mysql_fetch_array($result) ) {
      
mysql_query("DELETE FROM ".$pref."post WHERE threadid=$topic[threadid]");
    }

    
// delete topics
    
mysql_query("DELETE FROM ".$pref."thread WHERE boardid=$forumid");
    
    
// delete permission
    
mysql_query("DELETE FROM ".$pref."groupboard WHERE boardid=$forumid");

    
// lastvisited
    
mysql_query("DELETE FROM $pref"."lastvisited WHERE boardid=$forumid");
    
    echo 
"Board has been deleted!<br>";

  } else {
    print 
'<font color=red><b>WARNING: You are going to DELETE a board!</b></font><br><br>';
    print 
"click <a href=\"boards.php?action=delete&forumid=$forumid&confirm=1&session=$session\">here</a> to confirm";
  }
}


/*
 * ########################################################################################
 *        newboard
 * ########################################################################################
 */
elseif( $action == "newboard" )
{
    if( isset(
$Send) )
    {
        
// add forum
        
$result query"SELECT max(boardorder) FROM ".$pref."board WHERE categoryid=$board[categoryid]);
        list(
$maxorder) = mysql_fetch_row($result);
        
$maxorder++;

        
query("INSERT INTO ".$pref."board (boardname, boarddescription, categoryid, boardorder, styleid,
            boarddisabled) VALUES (
            '" 
addslashes($board[boardname]) . "', '" addslashes($board[boarddescription]) . "',
            '
$board[categoryid]', '$maxorder', '$board[styleid]', 
            '
$board[boarddisabled]')");

        print 
'Forum has been added. Please verify board order.';
    }
    else
    {
        print 
'<b>Add Board</b><br><br>';
        
BoardForm(array(), 'newboard');
    }
}


/*
 * ########################################################################################
 *        delcat
 * ########################################################################################
 */
elseif( $action == "delcat" ) {
    
$r_board query("SELECT count(boardid) AS boardcount FROM ".$pref."board WHERE categoryid=$id");
    
$board mysql_fetch_array($r_board);
    
    if( 
$board[boardcount] > )
    {
        print 
'Error: Cannot delete a category which contains boards!';
    }
    else
    {
        
query("DELETE FROM ".$pref."category WHERE categoryid=$id");
        print 
'Category has been deleted.';
    }
}



/*
 * ########################################################################################
 *        RenameCategory
 * ########################################################################################
 */
elseif( $action == "RenameCategory" )
{
    
$r_category query("SELECT categoryid, categoryname FROM ".$pref."category WHERE categoryid=$categoryid");
    
$category mysql_fetch_array($r_category);
    
    print 
'<b>Rename Category</b><br><form method="post" action="boards.php">
  Rename to: <input class="tbinput" type="text" name="newname" value="' 
$category[categoryname] . '">
  <input type="hidden" name="action" value="SetCategoryName">
  <input type="hidden" name="session" value="' 
$session '">
  <input type="hidden" name="categoryid" value="' 
$category[categoryid] . '">
  <input type="submit" value="rename">
</form>'
;
}



/*
 * ########################################################################################
 *        SetCategoryName
 * ########################################################################################
 */
elseif( $action == "SetCategoryName" )
{
    
query("UPDATE ".$pref."category SET categoryname='" addslashes($newname) . "' WHERE categoryid=$categoryid");
    
    print 
'category has been renamed.';
}






/*
 * ########################################################################################
 *        EditBoardUsers
 * ########################################################################################
 */
elseif( $action == "EditBoardUsers" )
{
    
$r_board query("SELECT boardname FROM ".$pref."board WHERE boardid=$boardid");
    
$board mysql_fetch_array($r_board);
    
    print 
'<b>Userlist for "' $board['boardname'] . '"</b><br><br>';

    
$r_boardaccess query("SELECT boardaccess.userid, user.username FROM ".$pref."boardaccess AS boardaccess LEFT JOIN ".$pref."user AS user ON boardaccess.userid=user.userid WHERE boardaccess.boardid=$boardid");
    while( 
$boardaccess mysql_fetch_array($r_boardaccess) )
    {
        print 
$boardaccess['username'] . ' [ <a href="boards.php?action=RemoveUserFromBoard&userid=' $boardaccess['userid'] . '&boardid=' $boardid '&session=' $session '">remove</a> ]<br>';
    }
    
    print 
'<form name="theform" method="post" action="boards.php">
  User to add: 
  <input type="text" name="username">
  <input type="hidden" name="action" value="AddUserToBoard">
  <input type="hidden" name="boardid" value="' 
$boardid '">
  <input type="hidden" name="session" value="' 
$session '">
  <input type="submit" name="Submit" value="Add User">
</form>'
;

}




/*
 * ########################################################################################
 *        RemoveUserFromBoard
 * ########################################################################################
 */
elseif( $action == 'RemoveUserFromBoard' )
{
    
query("DELETE FROM ".$pref."boardaccess WHERE userid=$userid AND boardid=$boardid");
    
    if( 
mysql_affected_rows() == )
    {
        print 
'user has been removed from board access list';
    }
    else
    {
        print 
'error';
    }

    print 
'<br><br><a href="boards.php?action=EditBoardUsers&session=' $session '&boardid=' $boardid '">back</a> to board userlist.';
}



/*
 * ########################################################################################
 *        AddUserToBoard
 * ########################################################################################
 */
elseif( $action == 'AddUserToBoard' )
{
    
$r_user query("SELECT userid FROM ".$pref."user WHERE username='$username'");
    
$user mysql_fetch_array($r_user);

    
query("INSERT INTO ".$pref."boardaccess (boardid, userid) VALUES ($boardid$user[userid])");
    print 
'user has been added';
    
    print 
'<br><br><a href="boards.php?action=EditBoardUsers&session=' $session '&boardid=' $boardid '">back</a> to board userlist.';
}











tb_footer();
?>