Beehive PHP Cross Reference Discussion Forums

Source: /admin_forums.php - 733 lines - 34792 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*======================================================================
   4  Copyright Project Beehive Forum 2002
   5  
   6  This file is part of Beehive Forum.
   7  
   8  Beehive Forum is free software; you can redistribute it and/or modify
   9  it under the terms of the GNU General Public License as published by
  10  the Free Software Foundation; either version 3 of the License, or
  11  (at your option) any later version.
  12  
  13  Beehive Forum is distributed in the hope that it will be useful,
  14  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16  GNU General Public License for more details.
  17  
  18  You should have received a copy of the GNU General Public License
  19  along with Beehive; if not, write to the Free Software
  20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  21  USA
  22  ======================================================================*/
  23  
  24  // Bootstrap
  25  require_once  'boot.php';
  26  
  27  // Required includes
  28  require_once  BH_INCLUDE_PATH . 'admin.inc.php';
  29  require_once  BH_INCLUDE_PATH . 'constants.inc.php';
  30  require_once  BH_INCLUDE_PATH . 'form.inc.php';
  31  require_once  BH_INCLUDE_PATH . 'format.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'forum.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'header.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'myforums.inc.php';
  36  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  37  require_once  BH_INCLUDE_PATH . 'user.inc.php';
  38  // End Required includes
  39  
  40  // Check we're logged in correctly
  41  if (!session::logged_in()) {
  42      html_guest_error();
  43  }
  44  
  45  // Check we have Admin / Moderator access
  46  if (!(session::check_perm(USER_PERM_FORUM_TOOLS, 0, 0))) {
  47      html_draw_error(gettext("You do not have permission to use this section."));
  48  }
  49  
  50  // Perform additional admin login.
  51  admin_check_credentials();
  52  
  53  // Array to hold error messages
  54  $error_msg_array = array();
  55  
  56  $forum_delete_array = null;
  57  $t_webtag = null;
  58  $t_name = null;
  59  $t_owner_uid = null;
  60  $t_database = null;
  61  $t_access = null;
  62  
  63  if (isset($_GET['page']) && is_numeric($_GET['page'])) {
  64      $page = ($_GET['page'] > 0) ? $_GET['page'] : 1;
  65  } else if (isset($_POST['page']) && is_numeric($_POST['page'])) {
  66      $page = ($_POST['page'] > 0) ? $_POST['page'] : 1;
  67  } else {
  68      $page = 1;
  69  }
  70  
  71  // Array of valid forum states
  72  $forum_access_level_array = array(
  73      FORUM_DISABLED => gettext("Disabled"),
  74      FORUM_CLOSED => gettext("Closed"),
  75      FORUM_UNRESTRICTED => gettext("Open"),
  76      FORUM_RESTRICTED => gettext("Restricted"),
  77      FORUM_PASSWD_PROTECTED => gettext("Password Protected")
  78  );
  79  
  80  // Array of available databases
  81  $available_databases = forums_get_available_dbs();
  82  
  83  // Cancel button clicked.
  84  if (isset($_POST['cancel'])) {
  85  
  86      header_redirect("admin_forums.php?webtag=$webtag&page=$page");
  87      exit;
  88  }
  89  
  90  // Confirm forum deletion.
  91  if (isset($_POST['delete'])) {
  92  
  93      if (isset($_POST['t_delete']) && is_array($_POST['t_delete'])) {
  94  
  95          foreach ($_POST['t_delete'] as $forum_fid => $delete_forum) {
  96  
  97              if (($delete_forum == "Y") && ($forum_name = forum_get_name($forum_fid))) {
  98  
  99                  $forum_delete_array[$forum_fid] = "{$forum_name}";
 100              }
 101          }
 102  
 103          html_draw_top(sprintf('title=%s', gettext("Admin - Manage Forums")), 'class=window_title', "js/admin.js", 'main_css=admin.css');
 104  
 105          echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage Forums"), "</h1>\n";
 106          echo "<br />\n";
 107          echo "<div align=\"center\">\n";
 108          echo "<form accept-charset=\"utf-8\" name=\"f_folders\" action=\"admin_forums.php\" method=\"post\">\n";
 109          echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 110          echo "  ", form_input_hidden('page', htmlentities_array($page)), "\n";
 111  
 112          foreach ($forum_delete_array as $forum_fid => $forum_name) {
 113  
 114              echo "  ", form_input_hidden("t_delete[$forum_fid]", "Y"), "\n";
 115          }
 116  
 117          echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 118          echo "    <tr>\n";
 119          echo "      <td align=\"left\">\n";
 120          echo "        <table class=\"box\" width=\"100%\">\n";
 121          echo "          <tr>\n";
 122          echo "            <td align=\"left\" class=\"posthead\">\n";
 123          echo "              <table class=\"posthead\" width=\"100%\">\n";
 124          echo "                <tr>\n";
 125          echo "                  <td align=\"left\" class=\"subhead\">", gettext("WARNING"), "</td>\n";
 126          echo "                </tr>\n";
 127          echo "                <tr>\n";
 128          echo "                  <td align=\"center\">\n";
 129          echo "                    <table class=\"posthead\" width=\"90%\">\n";
 130          echo "                      <tr>\n";
 131          echo "                        <td align=\"left\" colspan=\"2\">", gettext("Are you sure you want to delete all of the selected forums?"), "</td>\n";
 132          echo "                      </tr>\n";
 133          echo "                      <tr>\n";
 134          echo "                        <td align=\"left\"><ul><li><b>", implode("</b></li><li><b>", $forum_delete_array), "</b></li></ul></td>\n";
 135          echo "                      </tr>\n";
 136          echo "                      <tr>\n";
 137          echo "                        <td align=\"left\" colspan=\"2\">", gettext("Please note that you cannot recover deleted forums. Once deleted a forum and all of the associated data is permanently removed from the database. If you do not wish to delete the selected forums please click cancel."), "</td>\n";
 138          echo "                      </tr>\n";
 139          echo "                    </table>\n";
 140          echo "                  </td>\n";
 141          echo "                </tr>\n";
 142          echo "                <tr>\n";
 143          echo "                  <td align=\"left\">&nbsp;</td>\n";
 144          echo "                </tr>\n";
 145          echo "              </table>\n";
 146          echo "            </td>\n";
 147          echo "          </tr>\n";
 148          echo "        </table>\n";
 149          echo "      </td>\n";
 150          echo "    </tr>\n";
 151          echo "    <tr>\n";
 152          echo "      <td align=\"left\">&nbsp;</td>\n";
 153          echo "    </tr>\n";
 154          echo "    <tr>\n";
 155          echo "      <td align=\"center\">", form_submit("t_confirm_delete", gettext("Delete")), "&nbsp;", form_submit("cancel", gettext("Cancel")), "</td>\n";
 156          echo "    </tr>\n";
 157          echo "  </table>\n";
 158          echo "</form>\n";
 159          echo "</div>\n";
 160  
 161          html_draw_bottom();
 162          exit;
 163      }
 164  
 165  } else if (isset($_POST['t_confirm_delete'])) {
 166  
 167      $valid = true;
 168  
 169      if (isset($_POST['t_delete']) && is_array($_POST['t_delete'])) {
 170  
 171          foreach ($_POST['t_delete'] as $forum_fid => $delete_forum) {
 172  
 173              if ($valid && $delete_forum == "Y" && $forum_name = forum_get_name($forum_fid)) {
 174  
 175                  if (!forum_delete($forum_fid)) {
 176  
 177                      $error_msg_array[] = sprintf(gettext("Failed to deleted forum: '%s'"), $forum_name);
 178                  }
 179              }
 180          }
 181  
 182          if ($valid) {
 183  
 184              header_redirect("admin_forums.php?webtag=$webtag&page=$page&deleted=true");
 185              exit;
 186          }
 187      }
 188  
 189  } else if (isset($_GET['default']) && is_numeric($_GET['default'])) {
 190  
 191      $fid = $_GET['default'];
 192      forum_update_default($fid);
 193  
 194  } else if (isset($_POST['addforumsubmit'])) {
 195  
 196      $valid = true;
 197  
 198      if (isset($_POST['t_webtag']) && strlen(trim($_POST['t_webtag'])) > 0) {
 199  
 200          $t_webtag = mb_strtoupper(trim($_POST['t_webtag']));
 201  
 202          if (!preg_match("/^[A-Z0-9_]+$/Du", $t_webtag)) {
 203  
 204              $error_msg_array[] = gettext("Webtag can only contain uppercase A-Z, 0-9 and underscore characters");
 205              $valid = false;
 206          }
 207  
 208          if (strlen(trim($t_webtag)) > 32) {
 209  
 210              $error_msg_array[] = gettext("Webtag must no longer 32 characters in length");
 211              $valid = false;
 212          }
 213  
 214      } else {
 215  
 216          $error_msg_array[] = gettext("You must supply a forum webtag");
 217          $valid = false;
 218      }
 219  
 220      if (isset($_POST['t_name']) && strlen(trim($_POST['t_name'])) > 0) {
 221          $t_name = trim($_POST['t_name']);
 222      } else {
 223          $error_msg_array[] = gettext("You must supply a forum name");
 224          $valid = false;
 225      }
 226  
 227      if (isset($_POST['t_owner']) && strlen(trim($_POST['t_owner'])) > 0) {
 228  
 229          $t_owner = trim($_POST['t_owner']);
 230  
 231          if (($t_user_array = user_get_by_logon($t_owner)) !== false) {
 232  
 233              $t_owner_uid = $t_user_array['UID'];
 234  
 235          } else {
 236  
 237              $valid = false;
 238              $error_msg_array[] = gettext("Unknown user");
 239          }
 240  
 241      } else {
 242  
 243          $t_owner = "";
 244          $t_owner_uid = 0;
 245      }
 246  
 247      if (isset($_POST['t_database'])) {
 248  
 249          $t_database = $_POST['t_database'];
 250  
 251          if (!in_array($t_database, $available_databases)) {
 252  
 253              $error_msg_array[] = gettext("You must supply a forum database name");
 254              $valid = false;
 255          }
 256  
 257      } else {
 258  
 259          $error_msg_array[] = gettext("You must supply a forum database name");
 260          $valid = false;
 261      }
 262  
 263      if (isset($_POST['t_access']) && is_numeric($_POST['t_access'])) {
 264          $t_access = $_POST['t_access'];
 265      } else {
 266          $error_msg_array[] = gettext("You must supply a forum access level");
 267          $valid = false;
 268      }
 269  
 270      if (isset($_POST['t_default']) && $_POST['t_default'] == 'Y') {
 271          $t_default = 1;
 272      } else {
 273          $t_default = 0;
 274      }
 275  
 276      if ($valid) {
 277  
 278          $error_str = null;
 279  
 280          if (($new_fid = forum_create($t_webtag, $t_name, $t_owner_uid, $t_database, $t_access, true, $error_str)) !== false) {
 281  
 282              if ($t_default == 1) forum_update_default($new_fid);
 283              header_redirect("admin_forums.php?webtag=$webtag&page=$page&added=true");
 284  
 285          } else {
 286  
 287              $error_msg_array[] = $error_str;
 288              $valid = false;
 289          }
 290      }
 291  
 292  } else if (isset($_POST['updateforumsubmit'])) {
 293  
 294      $valid = true;
 295  
 296      if (isset($_POST['fid']) && is_numeric($_POST['fid'])) {
 297          $fid = $_POST['fid'];
 298      } else {
 299          $error_msg_array[] = gettext("Invalid forum or forum is not available");
 300          $valid = false;
 301      }
 302  
 303      if (($valid && $forum_data = forum_get($fid))) {
 304  
 305          if (isset($_POST['t_name']) && strlen(trim($_POST['t_name'])) > 0) {
 306              $t_name = trim($_POST['t_name']);
 307          } else {
 308              $error_msg_array[] = gettext("You must supply a forum name");
 309              $valid = false;
 310          }
 311  
 312          if (isset($_POST['t_owner']) && strlen(trim($_POST['t_owner'])) > 0) {
 313  
 314              $t_owner = trim($_POST['t_owner']);
 315  
 316              if (($t_user_array = user_get_by_logon($t_owner)) !== false) {
 317  
 318                  $t_owner_uid = $t_user_array['UID'];
 319  
 320              } else {
 321  
 322                  $valid = false;
 323                  $error_msg_array[] = gettext("Unknown user");
 324              }
 325  
 326          } else {
 327  
 328              $t_owner = "";
 329              $t_owner_uid = 0;
 330          }
 331  
 332          if (isset($_POST['t_access']) && is_numeric($_POST['t_access'])) {
 333              $t_access = $_POST['t_access'];
 334          } else {
 335              $error_msg_array[] = gettext("You must supply a forum access level");
 336              $valid = false;
 337          }
 338  
 339          if (isset($_POST['t_default']) && $_POST['t_default'] == 'Y') {
 340              $t_default = 1;
 341          } else {
 342              $t_default = 0;
 343          }
 344  
 345          if ($valid) {
 346  
 347              if (forum_update($fid, $t_name, $t_owner_uid, $t_access)) {
 348  
 349                  if ($forum_data['DEFAULT_FORUM'] == 1 && $t_default == 0) {
 350                      forum_update_default(0);
 351                  } else if ($t_default == 1) {
 352                      forum_update_default($fid);
 353                  }
 354  
 355                  header_redirect("admin_forums.php?webtag=$webtag&fid=$fid&page=$page&edited=true");
 356                  exit;
 357  
 358              } else {
 359  
 360                  $error_msg_array[] = sprintf(gettext("Failed to update forum: '%s'"), $forum_data['WEBTAG']);
 361                  $valid = false;
 362              }
 363          }
 364  
 365      } else {
 366  
 367          $error_msg_array[] = gettext("Invalid forum or forum is not available");
 368          $valid = false;
 369      }
 370  
 371  } else if (isset($_POST['addforum'])) {
 372  
 373      header_redirect("admin_forums.php?webtag=$webtag&page=$page&addforum=true");
 374      exit;
 375  
 376  } else if (isset($_POST['changepermissions']) && is_array($_POST['changepermissions'])) {
 377  
 378      list($forum_webtag) = array_keys($_POST['changepermissions']);
 379  
 380      $redirect_uri = "admin_forum_access.php?webtag=$forum_webtag&";
 381  
 382      if (isset($_POST['fid']) && is_numeric($_POST['fid'])) {
 383          $redirect_uri .= "ret=" . rawurlencode("admin_forums.php?webtag=$webtag&fid={$_POST['fid']}");
 384      } else if (isset($_GET['fid']) && is_numeric($_GET['fid'])) {
 385          $redirect_uri .= "ret=" . rawurlencode("admin_forums.php?webtag=$webtag&fid={$_GET['fid']}");
 386      }
 387  
 388      header_redirect($redirect_uri);
 389      exit;
 390  
 391  } else if (isset($_POST['changepassword']) && is_array($_POST['changepassword'])) {
 392  
 393      list($forum_webtag) = array_keys($_POST['changepassword']);
 394  
 395      $redirect_uri = "admin_forum_set_passwd.php?webtag=$forum_webtag&";
 396  
 397      if (isset($_POST['fid']) && is_numeric($_POST['fid'])) {
 398          $redirect_uri .= "ret=" . rawurlencode("admin_forums.php?webtag=$webtag&fid={$_POST['fid']}");
 399      } else if (isset($_GET['fid']) && is_numeric($_GET['fid'])) {
 400          $redirect_uri .= "ret=" . rawurlencode("admin_forums.php?webtag=$webtag&fid={$_GET['fid']}");
 401      }
 402  
 403      header_redirect($redirect_uri);
 404      exit;
 405  }
 406  
 407  if (isset($_GET['addforum']) || isset($_POST['addforum'])) {
 408  
 409      html_draw_top(sprintf('title=%s', gettext("Admin - Manage Forums - Add Forum")), 'class=window_title', "js/admin.js", "js/search_popup.js", 'main_css=admin.css');
 410  
 411      echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage Forums"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" /> ", gettext("Add Forum"), "</h1>\n";
 412  
 413      if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 414          html_display_error_array($error_msg_array, '700', 'center');
 415      }
 416  
 417      echo "<br />\n";
 418      echo "<div align=\"center\">\n";
 419      echo "  <form accept-charset=\"utf-8\" name=\"thread_options\" action=\"admin_forums.php\" method=\"post\" target=\"_self\">\n";
 420      echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 421      echo "  ", form_input_hidden('page', htmlentities_array($page)), "\n";
 422      echo "  ", form_input_hidden('addforum', 'true'), "\n";
 423      echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 424      echo "    <tr>\n";
 425      echo "      <td align=\"left\">\n";
 426      echo "        <table class=\"box\" width=\"100%\">\n";
 427      echo "          <tr>\n";
 428      echo "            <td align=\"left\" class=\"posthead\">\n";
 429      echo "              <table class=\"posthead\" width=\"100%\">\n";
 430      echo "                <tr>\n";
 431      echo "                  <td align=\"left\" class=\"subhead\">", gettext("Add Forum"), "</td>\n";
 432      echo "                </tr>\n";
 433      echo "                <tr>\n";
 434      echo "                  <td align=\"center\">\n";
 435      echo "                    <table class=\"posthead\" width=\"95%\">\n";
 436      echo "                      <tr>\n";
 437      echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Forum Webtag"), ":</td>\n";
 438      echo "                        <td align=\"left\">", form_input_text("t_webtag", (isset($_POST['t_webtag']) ? htmlentities_array($_POST['t_webtag']) : ""), 30, 32), "</td>\n";
 439      echo "                      </tr>\n";
 440      echo "                      <tr>\n";
 441      echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Forum Name"), ":</td>\n";
 442      echo "                        <td align=\"left\">", form_input_text("t_name", (isset($_POST['t_name']) ? htmlentities_array($_POST['t_name']) : ""), 30, 255), "</td>\n";
 443      echo "                      </tr>\n";
 444      echo "                      <tr>\n";
 445      echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Forum Leader"), ":</td>\n";
 446      echo "                        <td align=\"left\">", form_input_text_search("t_owner", (isset($_POST['t_owner']) ? htmlentities_array($_POST['t_owner']) : ""), 35, 15), "</td>\n";
 447      echo "                      </tr>\n";
 448      echo "                      <tr>\n";
 449      echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Access level"), ":</td>\n";
 450      echo "                        <td align=\"left\">", form_dropdown_array("t_access", array('' => '&nbsp;', FORUM_DISABLED => gettext("Disabled"), FORUM_CLOSED => gettext("Closed"), FORUM_UNRESTRICTED => gettext("Open"), FORUM_RESTRICTED => gettext("Restricted"), FORUM_PASSWD_PROTECTED => gettext("Password Protected")), (isset($_POST['t_access']) && is_numeric($_POST['t_access'])) ? $_POST['t_access'] : ''), "</td>\n";
 451      echo "                      </tr>\n";
 452  
 453      if (is_array($available_databases)) {
 454  
 455          $available_databases = array_merge(array('&nbsp;'), $available_databases);
 456  
 457          echo "                      <tr>\n";
 458          echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Use Database"), ":</td>\n";
 459          echo "                        <td align=\"left\">", form_dropdown_array("t_database", $available_databases, (isset($_POST['t_database']) ? $_POST['t_database'] : "")), "</td>\n";
 460          echo "                      </tr>\n";
 461      }
 462  
 463      echo "                      <tr>\n";
 464      echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Default Forum"), ":</td>\n";
 465      echo "                        <td align=\"left\">", form_radio("t_default", 'Y', gettext("Yes")), "&nbsp;", "</td>\n";
 466      echo "                      </tr>\n";
 467      echo "                      <tr>\n";
 468      echo "                        <td align=\"left\">&nbsp;</td>\n";
 469      echo "                        <td align=\"left\">", form_radio("t_default", 'N', gettext("No"), true), "&nbsp;", "</td>\n";
 470      echo "                      </tr>\n";
 471      echo "                      <tr>\n";
 472      echo "                        <td align=\"left\">&nbsp;</td>\n";
 473      echo "                        <td align=\"left\">&nbsp;</td>\n";
 474      echo "                      </tr>\n";
 475      echo "                    </table>\n";
 476      echo "                  </td>\n";
 477      echo "                </tr>\n";
 478      echo "              </table>\n";
 479      echo "            </td>\n";
 480      echo "          </tr>\n";
 481      echo "        </table>\n";
 482      echo "      </td>\n";
 483      echo "    </tr>\n";
 484      echo "    <tr>\n";
 485      echo "      <td align=\"left\">&nbsp;</td>\n";
 486      echo "    </tr>\n";
 487      echo "    <tr>\n";
 488      echo "      <td align=\"center\">", form_submit("addforumsubmit", gettext("Add")), "&nbsp;", form_submit("cancel", gettext("Cancel")), "</td>\n";
 489      echo "    </tr>\n";
 490      echo "  </table>\n";
 491      echo "  </form>\n";
 492  
 493      html_display_warning_msg(gettext("When setting Restricted or Password Protected mode you will need to save your changes before you can change the user access privileges or password."), '700', 'center');
 494      html_display_warning_msg(gettext("Please ensure you select the correct database when creating a new forum. Once created a new forum cannot be moved between available databases."), '700', 'center');
 495  
 496      echo "</div>\n";
 497  
 498      html_draw_bottom();
 499  
 500  } else if (isset($_POST['fid']) || isset($_GET['fid'])) {
 501  
 502      if (isset($_POST['fid']) && is_numeric($_POST['fid'])) {
 503  
 504          $fid = $_POST['fid'];
 505  
 506      } else if (isset($_GET['fid']) && is_numeric($_GET['fid'])) {
 507  
 508          $fid = $_GET['fid'];
 509  
 510      } else {
 511  
 512          html_draw_error(gettext("Invalid forum or forum is not available"), 'admin_forums.php', 'get', array('back' => gettext("Back")));
 513      }
 514  
 515      if (!$forum_data = forum_get($fid)) {
 516          html_draw_error(gettext("Invalid forum or forum is not available"), 'admin_forums.php', 'get', array('back' => gettext("Back")));
 517      }
 518  
 519      html_draw_top(sprintf('title=%s', sprintf(gettext("Admin - Manage Forums - Edit Forum - %s"), $forum_data['WEBTAG'])), 'class=window_title', "js/admin.js", "js/search_popup.js", 'main_css=admin.css');
 520  
 521      echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage Forums"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Edit Forum"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />{$forum_data['WEBTAG']}</h1>\n";
 522  
 523      if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 524  
 525          html_display_error_array($error_msg_array, '700', 'center');
 526  
 527      } else if (isset($_GET['edited'])) {
 528  
 529          html_display_success_msg(gettext("Successfully updated forum"), '700', 'center', 'forum_updated');
 530      }
 531  
 532      echo "<br />\n";
 533      echo "<div align=\"center\">\n";
 534      echo "  <form accept-charset=\"utf-8\" name=\"thread_options\" action=\"admin_forums.php\" method=\"post\" target=\"_self\">\n";
 535      echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 536      echo "  ", form_input_hidden('fid', htmlentities_array($fid)), "\n";
 537      echo "  ", form_input_hidden("t_delete[$fid]", "Y"), "\n";
 538      echo "  ", form_input_hidden('page', htmlentities_array($page)), "\n";
 539      echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 540      echo "    <tr>\n";
 541      echo "      <td align=\"left\">\n";
 542      echo "        <table class=\"box\" width=\"100%\">\n";
 543      echo "          <tr>\n";
 544      echo "            <td align=\"left\" class=\"posthead\">\n";
 545      echo "              <table class=\"posthead\" width=\"100%\">\n";
 546      echo "                <tr>\n";
 547      echo "                  <td align=\"left\" class=\"subhead\">", gettext("Edit Forum"), "</td>\n";
 548      echo "                </tr>\n";
 549      echo "                <tr>\n";
 550      echo "                  <td align=\"center\">\n";
 551      echo "                    <table class=\"posthead\" width=\"95%\">\n";
 552      echo "                      <tr>\n";
 553      echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Forum Name"), ":</td>\n";
 554      echo "                        <td align=\"left\">", form_input_text("t_name", (isset($_POST['t_name']) ? htmlentities_array($_POST['t_name']) : (isset($forum_data['FORUM_SETTINGS']['forum_name']) ? htmlentities_array($forum_data['FORUM_SETTINGS']['forum_name']) : "")), 52, 255), form_input_hidden("t_name_old", (isset($forum_data['FORUM_SETTINGS']['forum_name']) ? htmlentities_array($forum_data['FORUM_SETTINGS']['forum_name']) : "")), "</td>\n";
 555      echo "                      </tr>\n";
 556      echo "                      <tr>\n";
 557      echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Forum Leader"), ":</td>\n";
 558      echo "                        <td align=\"left\">", form_input_text_search("t_owner", (isset($_POST['t_owner']) ? htmlentities_array($_POST['t_owner']) : (isset($forum_data['FORUM_SETTINGS']['forum_leader']) ? htmlentities_array($forum_data['FORUM_SETTINGS']['forum_leader']) : "")), 35, 15), form_input_hidden("t_owner_old", (isset($forum_data['FORUM_SETTINGS']['forum_leader']) ? htmlentities_array($forum_data['FORUM_SETTINGS']['forum_leader']) : "")), "</td>\n";
 559      echo "                      </tr>\n";
 560  
 561      if ($forum_data['ACCESS_LEVEL'] == FORUM_RESTRICTED) {
 562  
 563          echo "                      <tr>\n";
 564          echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Access level"), ":</td>\n";
 565          echo "                        <td align=\"left\" style=\"white-space: nowrap\">", form_dropdown_array("t_access", array(FORUM_DISABLED => gettext("Disabled"), FORUM_CLOSED => gettext("Closed"), FORUM_UNRESTRICTED => gettext("Open"), FORUM_RESTRICTED => gettext("Restricted"), FORUM_PASSWD_PROTECTED => gettext("Password Protected")), (isset($_POST['t_access']) && is_numeric($_POST['t_access'])) ? $forum_data['ACCESS_LEVEL'] : (isset($forum_data['ACCESS_LEVEL']) && is_numeric($forum_data['ACCESS_LEVEL'])) ? $forum_data['ACCESS_LEVEL'] : 0), "&nbsp;", form_submit("changepermissions[{$forum_data['WEBTAG']}]", gettext("Change")), "</td>\n";
 566          echo "                      </tr>\n";
 567  
 568      } else if ($forum_data['ACCESS_LEVEL'] == FORUM_PASSWD_PROTECTED) {
 569  
 570          echo "                      <tr>\n";
 571          echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Access level"), ":</td>\n";
 572          echo "                        <td align=\"left\" style=\"white-space: nowrap\">", form_dropdown_array("t_access", array(FORUM_DISABLED => gettext("Disabled"), FORUM_CLOSED => gettext("Closed"), FORUM_UNRESTRICTED => gettext("Open"), FORUM_RESTRICTED => gettext("Restricted"), FORUM_PASSWD_PROTECTED => gettext("Password Protected")), (isset($_POST['t_access']) && is_numeric($_POST['t_access'])) ? $forum_data['ACCESS_LEVEL'] : (isset($forum_data['ACCESS_LEVEL']) && is_numeric($forum_data['ACCESS_LEVEL'])) ? $forum_data['ACCESS_LEVEL'] : 0), "&nbsp;", form_submit("changepassword[{$forum_data['WEBTAG']}]", gettext("Change")), "</td>\n";
 573          echo "                      </tr>\n";
 574  
 575      } else {
 576  
 577          echo "                      <tr>\n";
 578          echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Access level"), ":</td>\n";
 579          echo "                        <td align=\"left\" style=\"white-space: nowrap\">", form_dropdown_array("t_access", array(FORUM_DISABLED => gettext("Disabled"), FORUM_CLOSED => gettext("Closed"), FORUM_UNRESTRICTED => gettext("Open"), FORUM_RESTRICTED => gettext("Restricted"), FORUM_PASSWD_PROTECTED => gettext("Password Protected")), (isset($_POST['t_access']) && is_numeric($_POST['t_access'])) ? $forum_data['ACCESS_LEVEL'] : (isset($forum_data['ACCESS_LEVEL']) && is_numeric($forum_data['ACCESS_LEVEL'])) ? $forum_data['ACCESS_LEVEL'] : 0), "</td>\n";
 580          echo "                      </tr>\n";
 581      }
 582  
 583      echo "                      <tr>\n";
 584      echo "                        <td align=\"left\" width=\"150\" class=\"posthead\">", gettext("Default Forum"), ":</td>\n";
 585      echo "                        <td align=\"left\">", form_radio("t_default", 'Y', gettext("Yes"), (isset($_POST['t_default']) && is_numeric($_POST['t_default']) && $_POST['t_default'] == 1) ? true : (isset($forum_data['DEFAULT_FORUM']) && is_numeric($forum_data['DEFAULT_FORUM']) && $forum_data['DEFAULT_FORUM'] == 1) ? true : false), "&nbsp;", "</td>\n";
 586      echo "                      </tr>\n";
 587      echo "                      <tr>\n";
 588      echo "                        <td align=\"left\">&nbsp;</td>\n";
 589      echo "                        <td align=\"left\">", form_radio("t_default", 'N', gettext("No"), (isset($_POST['t_default']) && is_numeric($_POST['t_default']) && $_POST['t_default'] == 0) ? true : (isset($forum_data['DEFAULT_FORUM']) && is_numeric($forum_data['DEFAULT_FORUM']) && $forum_data['DEFAULT_FORUM'] == 0) ? true : false), "&nbsp;", "</td>\n";
 590      echo "                      </tr>\n";
 591      echo "                      <tr>\n";
 592      echo "                        <td align=\"left\">&nbsp;</td>\n";
 593      echo "                        <td align=\"left\">&nbsp;</td>\n";
 594      echo "                      </tr>\n";
 595      echo "                    </table>\n";
 596      echo "                  </td>\n";
 597      echo "                </tr>\n";
 598      echo "              </table>\n";
 599      echo "            </td>\n";
 600      echo "          </tr>\n";
 601      echo "        </table>\n";
 602      echo "      </td>\n";
 603      echo "    </tr>\n";
 604      echo "    <tr>\n";
 605      echo "      <td align=\"left\">&nbsp;</td>\n";
 606      echo "    </tr>\n";
 607      echo "    <tr>\n";
 608      echo "      <td align=\"center\">", form_submit("updateforumsubmit", gettext("Save")), "&nbsp;", form_submit("delete", gettext("Delete")), "&nbsp;", form_submit("cancel", gettext("Back")), "</td>\n";
 609      echo "    </tr>\n";
 610      echo "  </table>\n";
 611  
 612      html_display_warning_msg(gettext("When setting Restricted or Password Protected mode you will need to save your changes before you can change the user access privileges or password."), '700', 'center');
 613  
 614      echo "  </form>\n";
 615      echo "</div>\n";
 616  
 617      html_draw_bottom();
 618  
 619  } else {
 620  
 621      html_draw_top(sprintf('title=%s', gettext("Admin - Manage Forums")), 'class=window_title', "js/admin.js", 'main_css=admin.css');
 622  
 623      $forums_array = admin_get_forum_list($page);
 624  
 625      echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage Forums"), "</h1>\n";
 626  
 627      if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 628  
 629          html_display_error_array($error_msg_array, '86%', 'center');
 630  
 631      } else if (isset($_GET['added'])) {
 632  
 633          html_display_success_msg(gettext("Successfully created new forum"), '86%', 'center', 'forum_created');
 634  
 635      } else if (isset($_GET['edited'])) {
 636  
 637          html_display_success_msg(gettext("Successfully updated forum"), '86%', 'center', 'forum_updated');
 638  
 639      } else if (isset($_GET['deleted'])) {
 640  
 641          html_display_success_msg(gettext("Successfully deleted selected forums"), '86%', 'center', 'forum_removed');
 642  
 643      } else if (sizeof($forums_array['forums_array']) < 1) {
 644  
 645          html_display_warning_msg(gettext("No existing forums found. To create a new forum click the 'Add New' button below."), '86%', 'center');
 646      }
 647  
 648      echo "<br />\n";
 649      echo "<div align=\"center\">\n";
 650      echo "<form accept-charset=\"utf-8\" name=\"forums\" action=\"admin_forums.php\" method=\"post\">\n";
 651      echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 652      echo "  ", form_input_hidden('page', htmlentities_array($page)), "\n";
 653      echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"86%\">\n";
 654      echo "    <tr>\n";
 655      echo "      <td align=\"left\">\n";
 656      echo "        <table class=\"box\" width=\"100%\">\n";
 657      echo "          <tr>\n";
 658      echo "            <td align=\"left\" class=\"posthead\">\n";
 659      echo "              <table class=\"posthead\" width=\"100%\">\n";
 660      echo "                <tr>\n";
 661      echo "                  <td class=\"subhead\" align=\"center\" width=\"20\">&nbsp;</td>\n";
 662      echo "                  <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\" width=\"150\">", gettext("Webtag"), "</td>\n";
 663      echo "                  <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">", gettext("Name"), "</td>\n";
 664      echo "                  <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">", gettext("Messages"), "</td>\n";
 665      echo "                  <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">", gettext("Access level"), "</td>\n";
 666      echo "                  <td class=\"subhead\" align=\"center\" width=\"20\">&nbsp;</td>\n";
 667      echo "                </tr>\n";
 668  
 669      if (sizeof($forums_array['forums_array']) > 0) {
 670  
 671          foreach ($forums_array['forums_array'] as $forum_data) {
 672  
 673              echo "                <tr>\n";
 674              echo "                  <td valign=\"top\" align=\"center\" width=\"1%\">", form_checkbox("t_delete[{$forum_data['FID']}]", "Y"), "</td>\n";
 675              echo "                  <td align=\"left\"><a href=\"admin_forums.php?webtag=$webtag&amp;fid={$forum_data['FID']}&amp;page=$page\" title=\"", gettext("Edit Forum"), "\">{$forum_data['WEBTAG']}</a></td>\n";
 676              echo "                  <td align=\"left\"><a href=\"index.php?webtag={$forum_data['WEBTAG']}\" title=\"", sprintf(gettext("Visit Forum: %s"), $forum_data['FORUM_NAME']), "\" target=\"_blank\">{$forum_data['FORUM_NAME']}</a></td>\n";
 677  
 678              if (isset($forum_data['MESSAGES'])) {
 679                  echo "                  <td align=\"left\">", number_format($forum_data['MESSAGES'], 0), " ", ($forum_data['MESSAGES'] > 1) ? gettext("Messages") : gettext("Message"), "</td>\n";
 680              } else {
 681                  echo "                  <td align=\"left\">", gettext("Unknown"), "</td>\n";
 682              }
 683  
 684              if (isset($forum_data['ACCESS_LEVEL']) && in_array($forum_data['ACCESS_LEVEL'], array_keys($forum_access_level_array))) {
 685                  echo "                  <td align=\"left\">{$forum_access_level_array[$forum_data['ACCESS_LEVEL']]}</td>\n";
 686              } else {
 687                  echo "                  <td align=\"left\">", gettext("Unknown"), "</td>\n";
 688              }
 689  
 690              echo "                        <td align=\"left\" style=\"white-space: nowrap\"><a href=\"index.php?webtag={$forum_data['WEBTAG']}&amp;final_uri=admin_forum_settings.php%3Fwebtag%3D{$forum_data['WEBTAG']}\" target=\"", html_get_top_frame_name(), "\"><img src=\"", html_style_image('edit.png'), "\" border=\"0\" alt=\"", gettext("Forum Settings"), "\" title=\"", gettext("Forum Settings"), "\" /></a>&nbsp;";
 691  
 692              if (isset($forum_data['DEFAULT_FORUM']) && $forum_data['DEFAULT_FORUM'] == 1) {
 693                  echo "<a href=\"admin_forums.php?webtag=$webtag&amp;page=$page&amp;default=0\"><img src=\"", html_style_image('default_forum.png'), "\" border=\"0\" alt=\"", gettext("Unset Default"), "\" title=\"", gettext("Unset Default"), "\" /></a>\n";
 694              } else {
 695                  echo "<a href=\"admin_forums.php?webtag=$webtag&amp;page=$page&amp;default={$forum_data['FID']}\"><img src=\"", html_style_image('set_default_forum.png'), "\" border=\"0\" alt=\"", gettext("Make Default"), "\" title=\"", gettext("Make Default"), "\" /></a>\n";
 696              }
 697  
 698              echo "                  </td>\n";
 699              echo "                </tr>\n";
 700          }
 701      }
 702  
 703      echo "                <tr>\n";
 704      echo "                  <td align=\"left\">&nbsp;</td>\n";
 705      echo "                </tr>\n";
 706      echo "              </table>\n";
 707      echo "            </td>\n";
 708      echo "          </tr>\n";
 709      echo "        </table>\n";
 710      echo "      </td>\n";
 711      echo "    </tr>\n";
 712      echo "    <tr>\n";
 713      echo "      <td align=\"left\">&nbsp;</td>\n";
 714      echo "    </tr>\n";
 715      echo "    <tr>\n";
 716      echo "      <td class=\"postbody\" align=\"center\">";
 717  
 718      html_page_links("admin_forums.php?webtag=$webtag", $page, $forums_array['forums_count'], 10);
 719  
 720      echo "      </td>\n";
 721      echo "    </tr>\n";
 722      echo "    <tr>\n";
 723      echo "      <td align=\"left\">&nbsp;</td>\n";
 724      echo "    </tr>\n";
 725      echo "    <tr>\n";
 726      echo "      <td align=\"center\">", form_submit("addforum", gettext("Add New")), "&nbsp;", form_submit("delete", gettext("Delete Selected")), "</td>\n";
 727      echo "    </tr>\n";
 728      echo "  </table>\n";
 729      echo "</form>\n";
 730      echo "</div>\n";
 731  
 732      html_draw_bottom();
 733  }

title

Description

title

Description

title

Description

title

title

Body