Verzeichnisstruktur phpBB-1.0.0


Veröffentlicht
15.12.2000

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

admin_forums.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 31.03 KiB


001  <?php
002  /***************************************************************************
003                            admin_forums.php  -  description
004                               -------------------
005      begin                : Wed July 19 2000
006      copyright            : (C) 2000 by James Atkinson
007      email                : james@totalgeek.org
008   
009      $Id: admin_forums.php,v 1.30 2000/11/23 08:00:59 thefinn Exp $
010   ***************************************************************************/
011   
012  /***************************************************************************
013   *                                                                                         
014   *   This program is free software; you can redistribute it and/or modify      
015   *   it under the terms of the GNU General Public License as published by  
016   *   the Free Software Foundation; either version 2 of the License, or            
017   *   (at your option) any later version.
018   *
019   ***************************************************************************/
020   
021  /**
022  * Thursday, July 20, 2000 - Yokhannan - I added [$url_admin] to most of the links.
023  * I fixed a few typo errors
024  *
025  * 09/13/2000 - John B. Abela (abela@4cm.com)
026  *     Added Some Cosmetic HTML Code, fixed a Hyperlink typo.
027  */
028  include('../extention.inc');
029  include('../functions.'.$phpEx);
030  include('../config.'.$phpEx);
031  require('../auth.'.$phpEx);
032   
033  if($login) {
034        if ($username == '') {
035             die("You have to enter your username. Go back and do so.");
036        }
037        if ($password == '') {
038             die("You have to enter your password. Go back and do so.");
039        }
040        if (!check_username($username, $db)) {
041             die("Invalid username \"$username\". Go back and try again.");
042        }
043        if (!check_user_pw($username, $password, $db)) {
044             die("Invalid password. Go back and try again.");
045        }
046             
047        $userdata = get_userdata($username, $db);
048        $sessid = new_session($userdata[user_id], $REMOTE_ADDR, $sesscookietime, $db);
049        set_session_cookie($sessid, $sesscookietime, $sesscookiename, $cookiepath, $cookiedomain, $cookiesecure);
050             
051        header("Location: $url_admin");
052  }
053  else if(!$user_logged_in) {
054        $pagetitle = "Forum Administration";
055        $pagetype = "admin";
056        include('../page_header.'.$phpEx);
057     
058     ?>
059       <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="<?php echo $TableWidth?>">
060       <TR><TD  BGCOLOR="<?php echo $table_bgcolor?>">
061       <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="100%">
062       <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
063       <TD><P><BR><FONT FACE="<?php echo $FontFace?>" SIZE="<? echo $FontSize2?>" COLOR="<?php echo $textcolor?>">
064       Please enter your username and password to login.<BR>
065       <i>(NOTE: You MUST have cookies enabled in order to login to the administration section of this forum)</i><BR>
066       <UL>
067       <FORM ACTION="<?php echo $PHP_SELF?>" METHOD="POST">
068       <b>User Name: </b><INPUT TYPE="TEXT" NAME="username" SIZE="25" MAXLENGTH="40" VALUE="<?php echo $userdata[username]?>"><BR>
069       <b>Password: </b><INPUT TYPE="PASSWORD" NAME="password" SIZE="25" MAXLENGTH="25"><br><br>
070       <INPUT TYPE="SUBMIT" NAME="login" VALUE="Submit">&nbsp;&nbsp;&nbsp;<INPUT TYPE="RESET" VALUE="Clear"></ul>
071       </FORM>
072       </TD></TR></TABLE></TD></TR></TABLE>
073       <?php
074            include('../page_tail.'.$phpEx);
075          exit();
076  }
077  else if($user_logged_in && $userdata[user_level] == 4) {
078     
079  $pagetitle = "Forum Administration";
080  $pagetype = "admin";
081  include('../page_header.'.$phpEx);
082   
083  switch($mode) {
084   case 'editforum':
085     if($save) {
086        if(!$delete) {
087       $name = addslashes($name);
088       $desc = addslashes($desc);
089       /* 
090        This isn't even close to secure so don't tell anyone how it works :) 
091        I'll write a real 2 way encryption algo. for the next release  
092        */
093       $pass = base64_encode($forum_pass);
094       
095       if($type == 1) 
096         $sql = "UPDATE forums SET forum_name = '$name', forum_desc = '$desc', forum_type = '$type', cat_id = '$cat', forum_pass = '$pass', forum_access = '$forum_access' WHERE forum_id = '$forum'";
097       else 
098         $sql = "UPDATE forums SET forum_name = '$name', forum_desc = '$desc', forum_type = '$type', cat_id = '$cat', forum_access = '$forum_access' WHERE forum_id = '$forum'";
099       
100       if(!$r = mysql_query($sql, $db))
101         die("Error - could not update the database, please go back and try again.");
102       $count = 0;
103       if(isset($mods)) {
104          while(list($null, $mod) = each($mods)) {
105             $mod_data = get_userdata_from_id($mod, $db);
106             if($mod_data[user_level] < 2) {
107            if(!isset($user_query))
108              $user_query = "UPDATE users SET user_level = 2 WHERE ";
109            if($count > 0)
110              $user_query .= "OR ";
111            $user_query .= "user_id = '$mod";
112            $count++;
113             }
114             $mod_query = "INSERT INTO forum_mods (forum_id, user_id) VALUES ('$forum', '$mod')";
115             if(!mysql_query($mod_query, $db))
116           die("Mod Query Error!<BR>".mysql_error($db)."<BR>$mod_query");
117          }
118       }
119       
120       if(!isset($mods)) {
121          $current_mods = "SELECT count(*) AS total FROM forum_mods WHERE forum_id = '$forum'";
122          $r = @mysql_query($current_mods, $db);
123          list($total) = mysql_fetch_array($r);
124       }
125       else 
126         $total = count($mods) + 1;
127   
128       if(isset($rem_mods) && $total > 1) {
129          while(list($null, $mod) = each($rem_mods)) {
130             $rem_query = "DELETE FROM forum_mods WHERE forum_id = '$forum' AND user_id = '$mod'";
131             if(!mysql_query($rem_query))
132           die("Error removing moderators for forum!<BR>".mysql_error($db)."<BR>$rem_query");
133          }
134       }
135       else {
136          if(isset($rem_mods))
137            $mod_not_removed = 1;
138       }
139       if(isset($user_query)) {
140          if(!mysql_query($user_query, $db))
141            die("User Error!<BR>".mysql_error($db)."<BR>$user_query");
142       }
143             
144       echo "<TABLE width=\"95%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" bordercolor=\"$table_bgcolor\">";
145       echo "<tr><td align=\"center\" width=\"100%\" bgcolor=\"$color1\"><font face=\"$FontFace\" size=\"$FontSize1\" color=\"$FontColor\"><B>Forum Updated.</B></font></td>";
146       if($mod_not_removed) 
147         echo "<tr><td align=\"center\" width=\"100%\" bgcolor=\"$color1\"><font face=\"$FontFace\" size=\"$FontSize1\" color=\"$FontColor\"><b>However the selected moderator(s) have not be removed because if they had been there would no longer be any moderators on this forum.</b></font></td>";
148          
149       echo "</tr><TR><TD><TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><TR>";
150       echo "<td align=\"center\" width=\"100%\" bgcolor=\"$color2\"><font face=\"$FontFace\" size=\"$FontSize1\" color=\"$FontColor\"><P><BR>&nbsp;&nbsp;Click <a href=\"$url_admin\">here</a> to return to the Administration Panel.<P>Click <a href=\"$url_phpbb\">here</a> to return to the forum index.</font><P><BR><P></TD>";
151       echo "</TR></table></TD></TR></TABLE>";
152        }
153        else {
154       $sql = "DELETE FROM posts WHERE forum_id = '$forum'";
155       if(!$r = mysql_query($sql, $db))
156         die("Error could not delete the posts in this forum");
157       
158       $sql = "DELETE FROM topics WHERE forum_id = '$forum'";
159       if(!$r = mysql_query($sql, $db))
160         die("Error could not delete the topics in this forum");
161       
162       $sql = "DELETE FROM forums WHERE forum_id = '$forum'";
163       if(!$r = mysql_query($sql, $db))
164         die("Error could not delete the forum");
165       echo "<TABLE width=\"95%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" bordercolor=\"$table_bgcolor\">";
166       echo "<tr><td align=\"center\" width=\"100%\" bgcolor=\"$color1\"><font face=\"$FontFace\" size=\"$FontSize1\" color=\"$FontColor\"><B>Forum Removed.</B></font></td>";
167       echo "</tr><TR><TD><TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><TR>";
168       echo "<td align=\"center\" width=\"100%\" bgcolor=\"$color2\"><font face=\"$FontFace\" size=\"$FontSize1\" color=\"$FontColor\"><P><BR>&nbsp;&nbsp;Forum removed from database along with all its posts.<P>Click <a href=\"$url_admin\">here</a> to return to the Administration Panel.<P>Click <a href=\"$url_phpbb\">here</a> to return to the forum index.</font><P><BR><P></TD>";
169       echo "</TR></table></TD></TR></TABLE>";
170        }
171     }
172     if($submit && !$save) {
173        $sql = "SELECT * FROM forums WHERE forum_id = '$forum'";
174        if(!$result = mysql_query($sql, $db))
175      die("Error connecting to the database.");
176        if(!$myrow = mysql_fetch_array($result)) {
177       echo "No such forum";
178       include('page_tail.'.$phpEx);
179        }
180        $name = stripslashes($myrow[forum_name]);
181        $desc = stripslashes($myrow[forum_desc]);
182        ?>
183  <FORM ACTION="<?php echo $PHP_SELF?>" METHOD="POST">
184  <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="95%"><TR><TD  BGCOLOR="<?php echo $table_bgcolor?>">
185  <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="100%">
186  <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
187          <TD ALIGN="CENTER" COLSPAN="2"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>"><B>Edit This Forum</B></FONT></TD>
188  </TR>
189  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
190          <TD COLSPAN=2><INPUT TYPE="CHECKBOX" NAME="delete" VALUE="1"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>"> Delete this forum (This will also remove all posts in this forum!)</FONT></TD>
191  </TR>
192  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
193          <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Forum Name:</FONT></TD>
194          <TD><INPUT TYPE="TEXT" NAME="name" SIZE="40" MAXLENGTH="150" VALUE="<?php echo $name?>"></TD>
195  </TR>
196  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
197          <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Forum Description:</FONT></TD>
198          <TD><TEXTAREA NAME="desc" ROWS="15" COLS="45" WRAP="VIRTUAL"><?php echo $desc?></TEXTAREA></TD>
199  </TR>
200  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
201          <TD valign="top"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Moderator(s):</FONT></TD>
202          <TD><b>Current:</b><BR>
203  <?php
204      $sql = "SELECT u.username, u.user_id FROM users u, forum_mods f WHERE f.forum_id = '$forum' AND u.user_id = f.user_id";
205        if(!$r = mysql_query($sql, $db))
206      die("Error connecting to the database.");
207        if($row = mysql_fetch_array($r)) {
208       do {
209          echo "$row[username] (<input type=\"checkbox\" name=\"rem_mods[]\" value=\"$row[user_id]\"> Remove)<BR>";
210          $current_mods[] = $row[user_id];
211       } while($row = mysql_fetch_array($r));
212       echo "<BR>";
213        }
214        else {
215       echo "No Moderators Assigned<BR><BR>\n";
216        }
217  ?>
218      <b>Add:</b><BR>
219      <SELECT NAME="mods[]" size="5" multiple>
220  <?php
221      $sql = "SELECT user_id, username FROM users WHERE user_id != -1 AND user_level != -1 ";
222        while(list($null, $currMod) = each($current_mods)) {
223       $sql .= "AND user_id != $currMod ";
224        }
225        $sql .= "ORDER BY username";
226        if(!$r = mysql_query($sql, $db))
227      die("An Error Occurred<HR>Could not connect to the database. Please check the config file.");
228        if($row = mysql_fetch_array($r)) {
229       do {
230          $s = "";
231          if($row[user_id] == $myrow[forum_moderator])
232            $s = "SELECTED";
233          echo "<OPTION VALUE=\"$row[user_id]\" $s>$row[username]</OPTION>\n";
234       } while($row = mysql_fetch_array($r));
235        }
236        else {
237       echo "<OPTION VALUE=\"0\">None</OPTION>\n";
238        }
239  ?>
240          </SELECT></TD>
241  </TR>
242  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
243          <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Category:</FONT></TD>
244          <TD><SELECT NAME="cat">
245  <?php
246      $sql = "SELECT * FROM catagories";
247        if(!$r = mysql_query($sql, $db))
248      die("An Error Occurred<HR>Could not connect to the database. Please check the config file.");
249        if($row = mysql_fetch_array($r)) {
250       do {
251          $s = "";
252          if($row[cat_id] == $myrow[cat_id])
253                          $s = "SELECTED";
254          echo "<OPTION VALUE=\"$row[cat_id]\" $s>$row[cat_title]</OPTION>\n";
255       } while($row = mysql_fetch_array($r));
256        }       
257        else {          
258       echo "<OPTION VALUE=\"0\">None</OPTION>\n";
259        }
260  ?>                      
261          </SELECT></TD>          
262  <?php
263  if($myrow[forum_access] == 1)
264      $access1 = "SELECTED";
265  if($myrow[forum_access] == 2)
266      $access2 = "SELECTED";
267  if($myrow[forum_access] == 3)
268      $access3 = "SELECTED";
269  ?>           
270  </TR>                    
271  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
272           <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Access Level:</font></TD>
273       <TD><SELECT NAME="forum_access">
274           <OPTION VALUE="2" <?php echo $access2?>>Anonymous Posting</OPTION>
275           <OPTION VALUE="1" <?php echo $access1?>>Registered users only</OPTION>
276           <OPTION VALUE="3" <?php echo $access3?>>Moderators/Administrators only</OPTION>
277           </SELECT>
278          </TD>
279  </TR>
280               
281               
282  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
283      <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Type:</FONT></TD>
284      <TD><SELECT NAME="type">
285  <?php
286      if($myrow[forum_type] == 1)
287          $priv = "SELECTED";
288      else
289          $pub = "SELECTED";
290  ?>
291      <OPTION VALUE="0" <?php echo $pub?>>Public</OPTION>
292      <OPTION VALUE="1" <?php echo $priv?>>Private</OPTION>
293      </SELECT>
294      </TD>
295  </TR>
296  <?php
297      $forum_pass = base64_decode($myrow[forum_pass]);
298  ?>
299  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
300      <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Password (If Private):</FONT></TD>
301      <TD><INPUT TYPE="TEXT" NAME="forum_pass" SIZE="25" MAXLENGTH="30" VALUE="<?php echo $forum_pass?>"></TD>
302  </TR>
303  <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
304          <TD ALIGN="CENTER" COLSPAN="2">
305                  <INPUT TYPE="HIDDEN" NAME="mode" VALUE="editforum">
306                  <INPUT TYPE="HIDDEN" NAME="forum" VALUE="<?php echo $forum?>">
307                  <INPUT TYPE="SUBMIT" NAME="save" VALUE="Save Changes">&nbsp;&nbsp;
308                  <INPUT TYPE="RESET" VALUE="Clear">
309          </TD>
310  </TR>
311  </TR>                   
312  </TABLE></TD></TR></TABLE>
313   
314  <?php
315          }
316          if(!$submit && !$save) {
317  ?>
318  <FORM ACTION="<?php echo $PHP_SELF?>" METHOD="POST">
319  <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="95%"><TR><TD  BGCOLOR="<?php echo $table_bgcolor?>">
320  <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="100%">
321  <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
322      <TD ALIGN="CENTER" COLSPAN="2"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>"><B>Select a Forum to Edit</B><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>"></TD>
323  </TR>
324  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
325      <TD ALIGN="CENTER" COLSPAN="2"><SELECT NAME="forum" SIZE="0">
326      <?php
327   
328      $sql = "SELECT forum_name, forum_id FROM forums ORDER BY forum_id";
329      if($result = mysql_query($sql, $db)) {
330          if($myrow = mysql_fetch_array($result)) {
331              do {
332                  $name = stripslashes($myrow[forum_name]);
333                  echo "<OPTION VALUE=\"$myrow[forum_id]\">$name</OPTION>\n";
334              } while($myrow = mysql_fetch_array($result));
335          }
336          else {
337              echo "<OPTION VALUE=\"-1\">No Forums in Database</OPTION>\n";
338          }
339      }
340  /*
341      Your Mother is a Monkey!
342  */
343      else {
344          echo "<OPTION VALUE=\"-1\">Database Error</OPTION>\n";
345      }
346  /*
347      Yea, Well... your Father is a Ape!
348   
349      How dare you! My father is not an Ape, he's a Buffalo, and proud of it!
350  */
351      ?>
352      </SELECT></TD>
353  </TR>
354  <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
355      <TD ALIGN="CENTER" COLSPAN="2">
356          <INPUT TYPE="HIDDEN" NAME="mode" VALUE="editforum">
357          <INPUT TYPE="SUBMIT" NAME="submit" VALUE="Edit">&nbsp;&nbsp;
358      </TD>
359  </TR>
360  </TR>
361  </TABLE></TD></TR></TABLE>
362  <?php
363          }
364     break;
365   case 'remcat':
366     if($submit) {
367        $sql = "DELETE FROM catagories WHERE cat_id = '$cat'";
368        if(!$r = mysql_query($sql, $db))
369      die("Error Deleteing Category<BR>".mysql_error($db));
370        echo "<TABLE width=\"95%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" bordercolor=\"$table_bgcolor\">";
371        echo "<tr><td align=\"center\" width=\"100%\" bgcolor=\"$color1\"><font face=\"$FontFace\" size=\"$FontSize1\" color=\"$FontColor\"><B>Category Created.</B></font></td>";
372        echo "</tr><TR><TD><TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><TR>";
373        echo "<td align=\"center\" width=\"100%\" bgcolor=\"$color2\"><font face=\"$FontFace\" size=\"$FontSize1\" color=\"$FontColor\"><P><BR>&nbsp;&nbsp;Click <a href=\"$url_admin\">here</a> to return to the Administration Panel.<P>Click <a href=\"$url_phpbb\">here</a> to return to the forum index.</font><P><BR><P></TD>";
374        echo "</TR></table></TD></TR></TABLE>";      
375        
376     }
377     else {
378  ?>
379      <FORM ACTION="<?php echo $PHP_SELF?>" METHOD="POST">
380      <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="95%"><TR><TD  BGCOLOR="<?php echo $table_bgcolor?>">
381      <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="100%">
382      <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
383      <TD ALIGN="CENTER" COLSPAN="2"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>"><B>Remove a Category</B></FONT></TD>
384      </TR>
385      <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
386      <TD ALIGN="CENTER" COLSPAN="2"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>"><i>Note: This will NOT remove the forums under the category, you must do that via the Edit Forum section.</i></FONT></TD>
387      </TR>
388      <TR BGCOLOR="<?php echo $color2?>">
389      <TD ALIGN="CENTER" COLSPAN="2"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">
390      <SELECT NAME="cat">
391      
392  <?php
393        $sql = "SELECT * FROM catagories ORDER BY cat_title";
394        if(!$r = mysql_query($sql, $db))
395      die("Error conencting to the database!");
396        while($m = mysql_fetch_array($r)) {
397       echo "<OPTION VALUE=\"$m[cat_id]\">".stripslashes($m[cat_title])."</OPTION>\n";
398        }
399  ?>
400      </SELECT>
401      <INPUT TYPE="HIDDEN" NAME="mode" VALUE="<?php echo $mode ?>"></TD>
402      </TR>
403      <TR BGCOLOR="<?php echo $color1?>">
404      <TD ALIGN="CENTER" COLSPAN="2"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">
405      <INPUT TYPE="SUBMIT" NAME="submit" VALUE="Remove Category"></TD></TR>
406      </TABLE></TABLE></FORM>
407  <?php
408     }
409     break;
410   case 'addcat':
411     if($submit) {
412        $sql = "SELECT max(cat_order) AS highest FROM catagories";
413        if(!$r = mysql_query($sql, $db))
414      die("Error - Could not query the DB");
415        list($highest) = mysql_fetch_array($r);
416        $highest++;
417        $title = addslashes($title);
418        $sql = "INSERT INTO catagories (cat_title, cat_order) VALUES ('$title', '$highest')";
419        if(!$result = mysql_query($sql, $db))
420      die("Error - Could not insert category into the database, please go back and try again.");
421        echo "<TABLE width=\"95%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" bordercolor=\"$table_bgcolor\">";
422        echo "<tr><td align=\"center\" width=\"100%\" bgcolor=\"$color1\"><font face=\"$FontFace\" size=\"$FontSize1\" color=\"$FontColor\"><B>Category Created.</B></font></td>";
423        echo "</tr><TR><TD><TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><TR>";
424        echo "<td align=\"center\" width=\"100%\" bgcolor=\"$color2\"><font face=\"$FontFace\" size=\"$FontSize1\" color=\"$FontColor\"><P><BR>&nbsp;&nbsp;Click <a href=\"$url_admin\">here</a> to return to the Administration Panel.<P>Click <a href=\"$url_phpbb\">here</a> to return to the forum index.</font><P><BR><P></TD>";
425        echo "</TR></table></TD></TR></TABLE>";
426     }
427     else {
428  ?>
429  <FORM ACTION="<?php echo $PHP_SELF?>" METHOD="POST">
430  <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="95%"><TR><TD  BGCOLOR="<?php echo $table_bgcolor?>">
431  <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="100%">
432  <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
433      <TD ALIGN="CENTER" COLSPAN="2"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>"><B>Create a New Category</B></FONT></TD>
434  </TR>
435  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
436      <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Category Title:</FONT></TD>
437      <TD><INPUT TYPE="TEXT" NAME="title" SIZE="40" MAXLENGTH="100"></TD>
438  </TR>
439  <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
440      <TD ALIGN="CENTER" COLSPAN="2">
441          <INPUT TYPE="HIDDEN" NAME="mode" VALUE="addcat">
442          <INPUT TYPE="SUBMIT" NAME="submit" VALUE="Create Category">&nbsp;&nbsp;
443          <INPUT TYPE="RESET" VALUE="Clear">
444      </TD>
445  </TR>
446  </TR>
447  </TABLE></TD></TR></TABLE>
448  <?
449          }
450     break;
451   case 'addforum':
452     if($submit) {
453        if($name == '' || $desc == '' || !isset($mods))
454      die("You did not fill out all the parts of the form, please go back and do so.");
455        $desc = str_replace("\n", "<BR>", $desc);
456        $desc = addslashes($desc);
457        $name = addslashes($name);
458        if($type == 1) {
459       $forum_pass = base64_encode($forum_pass);
460       $sql = "INSERT INTO forums (forum_name, forum_desc, forum_access, cat_id, forum_type, forum_pass) VALUES ('$name', '$desc', '$forum_access', '$cat', '$type', '$forum_pass')";
461        }
462        else
463      $sql = "INSERT INTO forums (forum_name, forum_desc, forum_access, cat_id) VALUES ('$name', '$desc', '$forum_access', '$cat')";
464        
465        if(!$result = mysql_query($sql, $db))
466      die("An Error Occurred<HR>Could not contact the database. Please check your config file.<BR>".mysql_error()."<BR>$sql");
467        $forum = mysql_insert_id($db);
468        $count = 0;
469        while(list($null, $mod) = each($mods)) {
470       $mod_data = get_userdata_from_id($mod, $db);
471       if($mod_data[user_level] < 2) {
472          if(!isset($user_query))
473            $user_query = "UPDATE users SET user_level = 2 WHERE ";
474          if($count > 0)
475            $user_query .= "OR ";
476          $user_query .= "user_id = '$mod";
477          $count++;
478       }   
479       $mod_query = "INSERT INTO forum_mods (forum_id, user_id) VALUES ('$forum', '$mod')";
480       if(!mysql_query($mod_query, $db))
481         die("Mod Query Error!<BR>".mysql_error($db)."<BR>$mod_query");
482        }
483        if(isset($user_query)) {
484       if(!mysql_query($user_query, $db))
485         die("User Error!<BR>".mysql_error($db)."<BR>$user_query");
486        }
487        echo "<TABLE width=\"95%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" bordercolor=\"$table_bgcolor\">";
488        echo "<tr><td align=\"center\" width=\"100%\" bgcolor=\"$color1\"><font face=\"$FontFace\" size=\"$FontSize2\" color=\"$FontColor\"><B>Forum Created.</B></font></td>";
489        echo "</tr><TR><TD><TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><TR>";
490        echo "<td align=\"center\" width=\"100%\" bgcolor=\"$color2\"><font face=\"$FontFace\" size=\"$FontSize1\" color=\"$FontColor\"><P><BR>&nbsp;&nbsp;Click <a href=\"$url_admin/index.$phpEx\">here</a> to return to the Administration Panel.<P>Click <a href=\"$url_phpbb/viewforum.$phpEx?forum=$forum\">here</a> to view the forum  you just created.</font><P><BR><P></TD>";
491        echo "</TR></table></TD></TR></TABLE>";
492     }
493     else {
494        $sql = "SELECT count(*) AS total FROM catagories";
495        if(!$r = mysql_query($sql, $db))
496      die("Error querying the database!");
497        list($total) = mysql_fetch_array($r);
498        if($total < 1 || !isset($total))
499      die("Error, you must add a category before you add forums");
500        ?>
501  <FORM ACTION="<?php echo $PHP_SELF?>" METHOD="POST">
502  <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="95%"><TR><TD  BGCOLOR="<?php echo $table_bgcolor?>">
503  <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="100%">
504  <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
505      <TD ALIGN="CENTER" COLSPAN="2"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>"><B>Create a New Forum</B></FONT></TD>
506  </TR>
507  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
508      <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Forum Name:</FONT></TD>
509      <TD><INPUT TYPE="TEXT" NAME="name" SIZE="40" MAXLENGTH="150"></TD>
510  </TR>
511  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
512      <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Forum Description:</FONT></TD>
513      <TD><TEXTAREA NAME="desc" ROWS="15" COLS="45" WRAP="VIRTUAL"></TEXTAREA></TD>
514  </TR>
515  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
516      <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Moderator:</FONT></TD>
517      <TD><SELECT NAME="mods[]" size="5" multiple>
518  <?php
519      $sql = "SELECT user_id, username FROM users WHERE user_id != -1 AND user_level != -1 ORDER BY username";
520        if(!$result = mysql_query($sql, $db))
521      die("An Error Occurred<HR>Could not connect to the database. Please check the config file.");
522        if($myrow = mysql_fetch_array($result)) {
523       do {
524          echo "<OPTION VALUE=\"$myrow[user_id]\">$myrow[username]</OPTION>\n";
525       } while($myrow = mysql_fetch_array($result));
526        }
527        else {
528       echo "<OPTION VALUE=\"0\">None</OPTION>\n";
529        }
530  ?>
531      </SELECT></TD>
532  </TR>
533  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
534      <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Catagory:</FONT></TD>
535      <TD><SELECT NAME="cat">
536  <?php
537              $sql = "SELECT * FROM catagories";
538              if(!$result = mysql_query($sql, $db))
539                  die("An Error Occurred<HR>Could not connect to the database. Please check the config file.");
540              if($myrow = mysql_fetch_array($result)) {
541                  do {
542                      echo "<OPTION VALUE=\"$myrow[cat_id]\">$myrow[cat_title]</OPTION>\n";
543                  } while($myrow = mysql_fetch_array($result));
544              }
545              else {
546                  echo "<OPTION VALUE=\"0\">None</OPTION>\n";
547              }
548  ?>
549      </SELECT></TD>
550  </TR>
551  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
552       <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Access Level:</font></TD>
553       <TD><SELECT NAME="forum_access">
554           <OPTION VALUE="2">Anonymous Posting</OPTION>
555           <OPTION VALUE="1">Registered users only</OPTION>
556           <OPTION VALUE="3">Moderators/Administrators only</OPTION>
557           </SELECT>
558       </TD>
559  </TR>             
560  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
561          <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Type:</FONT></TD>
562          <TD><SELECT NAME="type">
563          <OPTION VALUE="0">Public</OPTION>
564          <OPTION VALUE="1">Private</OPTION>
565          </SELECT>
566          </TD>
567  </TR>
568  <TR BGCOLOR="<?php echo $color2?>" ALIGN="LEFT">
569          <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>">Password (If Private):</FONT></TD>
570          <TD><INPUT TYPE="TEXT" NAME="forum_pass" SIZE="25" MAXLENGTH="30"></TD>
571  </TR>
572  <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
573      <TD ALIGN="CENTER" COLSPAN="2">
574          <INPUT TYPE="HIDDEN" NAME="mode" VALUE="addforum">
575          <INPUT TYPE="SUBMIT" NAME="submit" VALUE="Create Forum">&nbsp;&nbsp;
576          <INPUT TYPE="RESET" VALUE="Clear">
577      </TD>
578  </TR>
579  </TR>
580   
581  </TABLE></TD></TR></TABLE>
582  <?php
583          }
584     break;
585   case 'catorder':
586  //    update catagories set cat_order = cat_order + 1 WHERE cat_order >= 2; update catagories set cat_order = cat_order - 2 where cat_id = 3;
587   
588        if($up) {
589       if($current_order != "1") {
590          $order = $current_order - 1;
591          $sql1 = "UPDATE catagories SET cat_order = $order WHERE cat_id = '$cat_id'";
592          if(!$r = mysql_query($sql1, $db))
593            die("Error connecting to the database<BR>".mysql_error($db));
594          $sql2 = "UPDATE catagories SET cat_order = $current_order WHERE cat_id = '$last_id'";
595          if(!$r = mysql_query($sql2, $db))
596            die("Error connecting to the database<BR>".mysql_error($db));
597          echo "<div align=\"center\"><font size=\"$FontSize4\" face=\"$FontFace\" color=\"$textcolor\">Category Moved Up</font></div><BR>";
598       }
599       else 
600         echo "<div align=\"center\"><font size=\"$FontSize4\" face=\"$FontFace\" color=\"$textcolor\">This category is already the highest up.</font></div><br>";
601       
602        }
603        else if($down) {
604       $sql = "SELECT cat_order FROM catagories ORDER BY cat_order DESC LIMIT 1";
605       if(!$r  = mysql_query($sql, $db))
606         die("Error quering the database");
607       list($last_number) = mysql_fetch_array($r);
608       if($last_number != $current_order) {
609          $order = $current_order + 1;
610          $sql = "UPDATE catagories SET cat_order = $current_order WHERE cat_order = $order";
611          if(!$r  = mysql_query($sql, $db))
612            die("Error quering the database");
613          $sql = "UPDATE catagories SET cat_order = $order where cat_id = $cat_id";
614          if(!$r  = mysql_query($sql, $db))
615            die("Error quering the database");
616          echo "<div align=\"center\"><font size=\"$FontSize4\" face=\"$FontFace\" color=\"$textcolor\">Category Moved Down</font></div><BR>";
617          
618       }
619       else 
620         echo "<div align=\"center\"><font size=\"$FontSize4\" face=\"$FontFace\" color=\"$textcolor\">This category is already the lowest down.</font></div><BR>";
621        }
622        
623  ?>
624       <FORM ACTION="<?php echo $PHP_SELF?>" METHOD="POST">
625       <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="95%"><TR><TD  BGCOLOR="<?php echo $table_bgcolor?>">
626       <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="100%">
627       <TR BGCOLOR="<?php echo $color1?>" ALIGN="LEFT">
628       <TD ALIGN="CENTER" COLSPAN="3"><FONT FACE="<?php echo $FontFace?>" SIZE="<?php echo $FontSize2?>" COLOR="<?php echo $textcolor?>"><B>Set Category Ordering</B></FONT><BR>
629       The order displayed here is the order the categories will display on the index page. To move a category up in the ordering click 'Move Up' to move it down click 'Move Down'.<BR>
630       Each click will move the category 1 place up or down in the ordering.</TD>
631       </TR>
632       <TR BGCOLOR="<?php echo $color1?>" ALIGN="CENTER">
633       <TD>Category</TD><TD>Move Up</TD><TD>Move Down</TD>
634       </TR>
635  <?php
636       $sql = "SELECT * FROM catagories ORDER BY cat_order";
637     if(!$r = mysql_query($sql, $db)) {
638        echo "<TR><TD colspan=\"3\">Error Connecting to the database!</TD></TR>";
639        exit();
640     }
641     while($m = mysql_fetch_array($r)) {
642        echo "<!-- New Row -->\n";
643        echo "<FORM ACTION=\"$PHP_SELF\" METHOD=\"POST\">\n";
644        echo "<tr bgcolor=\"$color2\" align=\"center\">\n";
645        echo "<td>".stripslashes($m[cat_title])."</TD>\n";
646        echo "<td><input type=\"hidden\" name=\"mode\" value=\"$mode\">\n";
647        echo "<input type=\"hidden\" name=\"cat_id\" value=\"$m[cat_id]\">\n";
648        echo "<input type=\"hidden\" name=\"last_id\" value=\"$last_id\">\n";
649        echo "<input type=\"hidden\" name=\"current_order\" value=\"$m[cat_order]\"><input type=\"submit\" name=\"up\" value=\"Move Up\"></td>\n";
650        echo "<td><input type=\"submit\" name=\"down\" value=\"Move Down\"></td></tr></form>\n<!-- End of Row -->\n";
651        $last_id = $m[cat_id];
652     }
653  ?>
654       </TABLE></TABLE>
655  <?php     
656     break;
657     
658  }
659  }
660  else {
661        $pagetype = "admin";
662        $pagetitle = "Access Denied!";
663     
664        include('../page_header.'.$phpEx);
665     ?>
666            <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="<?php echo $TableWidth?>">
667            <TR><TD  BGCOLOR="<?php echo $table_bgcolor?>">
668            <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="100%">
669            <TR BGCOLOR="<?php echo $color1?>" ALIGN="center" VALIGN="TOP">
670            <TD><FONT FACE="<?php echo $FontFace?>" SIZE="<? echo $FontSize2?>" COLOR="<?php echo $textcolor?>">
671            <B>You do not have acess to this area!</b><BR>
672            Go <a href="<?php echo $url_phpbb?>">Back</a>
673            </TD></TR></TABLE></TD></TR></TABLE>
674       <?php
675  }
676   
677  include('../page_tail.'.$phpEx);
678  ?>
679