Beehive PHP Cross Reference Discussion Forums

Source: /admin_startpage.php - 241 lines - 9494 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 . 'emoticons.inc.php';
  31  require_once  BH_INCLUDE_PATH . 'fixhtml.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'form.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'format.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'forum.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'header.inc.php';
  36  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  37  require_once  BH_INCLUDE_PATH . 'session.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_ADMIN_TOOLS, 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  // Get the user's post page preferences.
  54  $page_prefs = session::get_post_page_prefs();
  55  
  56  // Array to hold error messages
  57  $error_msg_array = array();
  58  
  59  // Check to see if we're submitting new page or retrieving the old one.
  60  if (isset($_POST['t_content']) && strlen(trim($_POST['t_content'])) > 0) {
  61      $t_content = fix_html(emoticons_strip($_POST['t_content']));
  62  } else {
  63      $t_content = forum_get_setting('start_page', 'strlen', '');
  64  }
  65  
  66  // Submit code.
  67  if (isset($_POST['save'])) {
  68  
  69      // New array of forum settings.
  70      $new_forum_settings = array(
  71          'start_page' => $t_content
  72      );
  73  
  74      // Save the settings.
  75      if (forum_save_settings($new_forum_settings)) {
  76  
  77          // Update the admin log.
  78          admin_add_log_entry(EDITED_START_PAGE);
  79  
  80          // Redirect back to self.
  81          header_redirect("admin_startpage.php?webtag=$webtag&updated=true");
  82          exit;
  83      }
  84  
  85      // Save failed. Show error message.
  86      $error_msg_array[] = gettext("Start page could not be saved. Please try again.");
  87  
  88  } else if (isset($_POST['upload'])) {
  89  
  90      // Check the temp file is set.
  91      if (isset($_FILES['cssfile']['tmp_name']) && strlen(trim($_FILES['cssfile']['tmp_name'])) > 0) {
  92  
  93          // Check for upload error.
  94          if (isset($_FILES['cssfile']['error']) && $_FILES['cssfile']['error'] != UPLOAD_ERR_OK) {
  95  
  96              // Upload failed. Don't bother going into detail.
  97              $error_msg_array[] = gettext("CSS style sheet could not be uploaded. Please try again.");
  98  
  99          } else if (isset($_FILES['cssfile']['type']) && trim($_FILES['cssfile']['type']) == 'text/css') {
 100  
 101              // Get path info for uploaded file.
 102              $path_parts = pathinfo($_FILES['cssfile']['name']);
 103  
 104              // Check the extension. This isn't fool proof, could be a renamed jpeg. Not sure
 105              // how to validate the content as CSS. Maybe try and parse it?
 106              if ((isset($path_parts['extension']) && $path_parts['extension'] == 'css')) {
 107  
 108                  // Read the contents of the file.
 109                  if (($start_page_css = @file_get_contents($_FILES['cssfile']['tmp_name'])) !== false) {
 110  
 111                      // New array of forum settings.
 112                      $new_forum_settings = array(
 113                          'start_page_css' => $start_page_css
 114                      );
 115  
 116                      // Save the settings.
 117                      if (forum_save_settings($new_forum_settings)) {
 118  
 119                          // Update admin log.
 120                          admin_add_log_entry(EDITED_START_PAGE);
 121  
 122                          // Redirect back to self.
 123                          header_redirect("admin_startpage.php?webtag=$webtag&uploaded=true");
 124                          exit;
 125                      }
 126                  }
 127              }
 128  
 129              // Something went wrong above. Show Error message.
 130              $error_msg_array[] = gettext("CSS style sheet could not be uploaded. Please try again.");
 131  
 132          } else {
 133  
 134              // File does not look like text/css
 135              $error_msg_array[] = gettext("Invalid file type, you can only upload CSS style sheet files");
 136          }
 137      }
 138  }
 139  
 140  html_draw_top(sprintf('title=%s', gettext("Admin - Edit Start Page")), 'ckeditor/ckeditor.js', 'class=window_title', 'main_css=admin.css');
 141  
 142  echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Edit Start Page"), "</h1>\n";
 143  
 144  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 145  
 146      html_display_error_array($error_msg_array, '700', 'center');
 147  
 148  } else if (isset($_GET['updated'])) {
 149  
 150      $start_page_link = sprintf("<a href=\"start_main.php?webtag=$webtag\" target=\"_blank\">%s</a>", gettext("View updated Start Page"));
 151      html_display_success_msg(sprintf(gettext("Start Page updated. %s"), $start_page_link), '700', 'center');
 152  
 153  } else if (isset($_GET['uploaded'])) {
 154  
 155      $start_page_link = sprintf("<a href=\"start_main.php?webtag=$webtag\" target=\"_blank\">%s</a>", gettext("View updated Start Page"));
 156      html_display_success_msg(sprintf(gettext("CSS style sheet uploaded. %s"), $start_page_link), '700', 'center');
 157  }
 158  
 159  echo "<br />\n";
 160  echo "<div align=\"center\">\n";
 161  echo "<form accept-charset=\"utf-8\" name=\"startpage\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin_startpage.php\">\n";
 162  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 163  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 164  echo "    <tr>\n";
 165  echo "      <td align=\"left\">\n";
 166  echo "        <table class=\"box\" width=\"100%\">\n";
 167  echo "          <tr>\n";
 168  echo "            <td align=\"left\" class=\"posthead\">\n";
 169  echo "              <table class=\"posthead\" width=\"100%\">\n";
 170  echo "                <tr>\n";
 171  echo "                  <td align=\"left\" class=\"subhead\">", gettext("Start page"), "</td>\n";
 172  echo "                </tr>\n";
 173  echo "              </table>\n";
 174  echo "              <table class=\"posthead\" width=\"100%\">\n";
 175  echo "                <tr>\n";
 176  echo "                  <td align=\"center\">\n";
 177  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 178  echo "                      <tr>\n";
 179  echo "                        <td align=\"left\">", form_textarea("t_content", htmlentities_array($t_content), 20, 80, null, 'admin_tools_textarea_large editor'), "</td>\n";
 180  echo "                      </tr>\n";
 181  echo "                      <tr>\n";
 182  echo "                        <td align=\"left\">&nbsp;</td>\n";
 183  echo "                      </tr>\n";
 184  echo "                    </table>\n";
 185  echo "                  </td>\n";
 186  echo "                </tr>\n";
 187  echo "              </table>\n";
 188  echo "            </td>\n";
 189  echo "          </tr>\n";
 190  echo "        </table>\n";
 191  echo "      </td>\n";
 192  echo "    </tr>\n";
 193  echo "    <tr>\n";
 194  echo "      <td align=\"left\">&nbsp;</td>\n";
 195  echo "    </tr>\n";
 196  echo "    <tr>\n";
 197  echo "      <td align=\"center\">", form_submit("save", gettext("Save")), "</td>\n";
 198  echo "    </tr>\n";
 199  echo "  </table>\n";
 200  echo "  <br />\n";
 201  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 202  echo "    <tr>\n";
 203  echo "      <td align=\"left\">\n";
 204  echo "        <table class=\"box\" width=\"100%\">\n";
 205  echo "          <tr>\n";
 206  echo "            <td align=\"left\" class=\"posthead\">\n";
 207  echo "              <table class=\"posthead\" width=\"100%\">\n";
 208  echo "                <tr>\n";
 209  echo "                  <td align=\"left\" class=\"subhead\">", gettext("Upload CSS style sheet"), "</td>\n";
 210  echo "                </tr>\n";
 211  echo "              </table>\n";
 212  echo "              <table class=\"posthead\" width=\"100%\">\n";
 213  echo "                <tr>\n";
 214  echo "                  <td align=\"center\">\n";
 215  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 216  echo "                      <tr>\n";
 217  echo "                        <td align=\"left\">", gettext("Filename"), ": ", form_input_file("cssfile", null, 45), "</td>\n";
 218  echo "                      </tr>\n";
 219  echo "                      <tr>\n";
 220  echo "                        <td align=\"left\">&nbsp;</td>\n";
 221  echo "                      </tr>\n";
 222  echo "                    </table>\n";
 223  echo "                  </td>\n";
 224  echo "                </tr>\n";
 225  echo "              </table>\n";
 226  echo "            </td>\n";
 227  echo "          </tr>\n";
 228  echo "        </table>\n";
 229  echo "      </td>\n";
 230  echo "    </tr>\n";
 231  echo "    <tr>\n";
 232  echo "      <td align=\"left\">&nbsp;</td>\n";
 233  echo "    </tr>\n";
 234  echo "    <tr>\n";
 235  echo "      <td align=\"center\">", form_submit("upload", gettext("Upload")), "</td>\n";
 236  echo "    </tr>\n";
 237  echo "  </table>\n";
 238  echo "</form>\n";
 239  echo "</div>\n";
 240  
 241  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body