Beehive PHP Cross Reference Discussion Forums

Source: /edit_signature.php - 335 lines - 11893 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 . 'attachments.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 . 'messages.inc.php';
  38  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  39  require_once  BH_INCLUDE_PATH . 'user.inc.php';
  40  // End Required includes
  41  
  42  // Check we're logged in correctly
  43  if (!session::logged_in()) {
  44      html_guest_error();
  45  }
  46  
  47  $admin_edit = false;
  48  
  49  $sig_uid = $_SESSION['UID'];
  50  
  51  if (session::check_perm(USER_PERM_ADMIN_TOOLS, 0)) {
  52  
  53      if (isset($_GET['sig_uid'])) {
  54  
  55          if (is_numeric($_GET['sig_uid'])) {
  56  
  57              $sig_uid = $_GET['sig_uid'];
  58              $admin_edit = true;
  59  
  60          } else {
  61  
  62              html_draw_error(gettext("No user specified."));
  63          }
  64  
  65      } else if (isset($_POST['sig_uid'])) {
  66  
  67          if (is_numeric($_POST['sig_uid'])) {
  68  
  69              $sig_uid = $_POST['sig_uid'];
  70              $admin_edit = true;
  71  
  72          } else {
  73  
  74              html_draw_error(gettext("No user specified."));
  75          }
  76      }
  77  
  78      if (isset($_POST['cancel'])) {
  79  
  80          header_redirect("admin_user.php?webtag=$webtag&uid=$sig_uid");
  81          exit;
  82      }
  83  }
  84  
  85  if (!(session::check_perm(USER_PERM_ADMIN_TOOLS, 0)) && ($sig_uid != $_SESSION['UID'])) {
  86      html_draw_error(gettext("You do not have permission to use this section."));
  87  }
  88  
  89  $valid = true;
  90  
  91  $error_msg_array = array();
  92  
  93  if (($sig_text = user_get_sig($sig_uid)) !== false) {
  94      $sig_text = fix_html($sig_text);
  95  }
  96  
  97  if (isset($_POST['save']) || isset($_POST['preview'])) {
  98  
  99      if (isset($_POST['sig_content']) && strlen(trim($_POST['sig_content'])) > 0) {
 100          $sig_text = trim($_POST['sig_content']);
 101      } else {
 102          $sig_text = "";
 103      }
 104  
 105      if (isset($_POST['sig_global']) && $_POST['sig_global'] == 'Y') {
 106          $t_sig_global = 'Y';
 107      } else {
 108          $t_sig_global = 'N';
 109      }
 110  
 111      if (session::check_perm(USER_PERM_ADMIN_TOOLS, 0) && $admin_edit === true) $t_sig_global = 'N';
 112  
 113      if (attachments_embed_check($sig_text)) {
 114  
 115          $error_msg_array[] = gettext("You are not allowed to embed attachments in your signature.");
 116          $valid = false;
 117      }
 118  }
 119  
 120  $sig_text = fix_html(emoticons_strip($sig_text));
 121  
 122  if (isset($_POST['save'])) {
 123  
 124      if ($valid) {
 125  
 126          // Update USER_SIG
 127          if (user_update_sig($sig_uid, $sig_text, ($t_sig_global == 'Y'))) {
 128  
 129              if ($admin_edit === true) {
 130  
 131                  $redirect_uri = "admin_user.php?webtag=$webtag&signature_updated=true&uid=$sig_uid";
 132                  header_redirect($redirect_uri, gettext("Signature Updated"));
 133  
 134              } else {
 135  
 136                  if ($t_sig_global == 'Y' && forums_get_available_count() > 1) {
 137  
 138                      $redirect_uri = "edit_signature.php?webtag=$webtag&updated_global=true";
 139                      header_redirect($redirect_uri, gettext("Signature Updated For All Forums"));
 140  
 141                  } else {
 142  
 143                      $redirect_uri = "edit_signature.php?webtag=$webtag&updated=true";
 144                      header_redirect($redirect_uri, gettext("Signature Updated"));
 145                  }
 146              }
 147          }
 148      }
 149  }
 150  
 151  // Start Output Here
 152  if ($admin_edit === true) {
 153  
 154      $user = user_get($sig_uid);
 155  
 156      html_draw_top(sprintf('title=%s', sprintf(gettext("Admin - Manage User - %s "), format_user_name($user['LOGON'], $user['NICKNAME']))), "basetarget=_blank", "resize_width=700", "js/post.js", 'ckeditor/ckeditor.js', 'class=window_title');
 157  
 158      echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage User"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", format_user_name($user['LOGON'], $user['NICKNAME']), "</h1>\n";
 159  
 160  } else {
 161  
 162      html_draw_top(sprintf('title=%s', gettext("My Controls - Edit Signature")), "basetarget=_blank", "resize_width=700", "js/post.js", 'ckeditor/ckeditor.js', 'class=window_title');
 163  
 164      echo "<h1>", gettext("Edit Signature"), "</h1>\n";
 165  }
 166  
 167  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 168  
 169      html_display_error_array($error_msg_array, '700', 'left');
 170  
 171  } else if (isset($_GET['updated'])) {
 172  
 173      html_display_success_msg(gettext("Signature Updated"), '700', 'left');
 174  
 175  } else if (isset($_GET['updated_global'])) {
 176  
 177      html_display_success_msg(gettext("Signature Updated For All Forums"), '700', 'left');
 178  }
 179  
 180  echo "<br />\n";
 181  
 182  if ($admin_edit === true) echo "<div align=\"center\">\n";
 183  
 184  if ((session::check_perm(USER_PERM_ADMIN_TOOLS, 0, 0) && $admin_edit) || (($sig_uid == $_SESSION['UID']) && $admin_edit === false)) {
 185      $show_set_all = (forums_get_available_count() > 1);
 186  } else {
 187      $show_set_all = false;
 188  }
 189  
 190  echo "<form accept-charset=\"utf-8\" name=\"prefs\" action=\"edit_signature.php\" method=\"post\" target=\"_self\">\n";
 191  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 192  
 193  if ($admin_edit === true) {
 194      echo "  ", form_input_hidden('sig_uid', htmlentities_array($sig_uid)), "\n";
 195  }
 196  
 197  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 198  echo "    <tr>\n";
 199  echo "      <td align=\"left\">\n";
 200  echo "        <table class=\"box\" width=\"100%\">\n";
 201  echo "          <tr>\n";
 202  echo "            <td align=\"left\" class=\"posthead\">\n";
 203  
 204  if (isset($_POST['preview'])) {
 205  
 206      if ($valid) {
 207  
 208          $preview_message['RECIPIENTS'] = array();
 209  
 210          $preview_from_user = user_get($sig_uid);
 211  
 212          $preview_message['FROM_LOGON'] = $preview_from_user['LOGON'];
 213          $preview_message['FROM_NICKNAME'] = $preview_from_user['NICKNAME'];
 214          $preview_message['FROM_UID'] = $preview_from_user['UID'];
 215  
 216          $preview_message['CONTENT'] = gettext("Signature Preview");
 217          $preview_message['CONTENT'] .= "<div class=\"sig\">$sig_text</div>";
 218  
 219          $preview_message['CREATED'] = time();
 220  
 221          echo "              <table class=\"posthead\" width=\"100%\">\n";
 222          echo "                <tr>\n";
 223          echo "                  <td align=\"left\" class=\"subhead\">", gettext("Preview"), "</td>\n";
 224          echo "                </tr>\n";
 225          echo "              </table>\n";
 226          echo "              <table class=\"posthead\" width=\"100%\">\n";
 227          echo "                <tr>\n";
 228          echo "                  <td align=\"center\">\n";
 229          echo "                    <table class=\"posthead\" width=\"100%\">\n";
 230          echo "                      <tr>\n";
 231          echo "                        <td align=\"left\">\n";
 232          echo "                          <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
 233          echo "                            <tr>\n";
 234          echo "                              <td align=\"left\"><br />";
 235  
 236          message_display(0, $preview_message, 0, 0, 0, false, false, false, true, true);
 237  
 238          echo "                              </td>\n";
 239          echo "                            </tr>\n";
 240          echo "                          </table>\n";
 241          echo "                        </td>\n";
 242          echo "                      </tr>\n";
 243          echo "                    </table>\n";
 244          echo "                  </td>\n";
 245          echo "                </tr>\n";
 246          echo "              </table>\n";
 247      }
 248  }
 249  
 250  echo "              <table class=\"posthead\" width=\"100%\">\n";
 251  echo "                <tr>\n";
 252  echo "                  <td align=\"left\" class=\"subhead\">", gettext("Signature"), "</td>\n";
 253  echo "                </tr>\n";
 254  echo "              </table>\n";
 255  echo "              <table class=\"posthead\" width=\"100%\">\n";
 256  echo "                <tr>\n";
 257  echo "                  <td align=\"center\">\n";
 258  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 259  echo "                      <tr>\n";
 260  echo "                        <td align=\"left\">\n";
 261  echo "                          ", form_textarea('sig_content', $sig_text, 12, 85, 'tabindex="7"', 'edit_signature_content editor');
 262  echo "                        </td>\n";
 263  echo "                      </tr>\n";
 264  echo "                      <tr>\n";
 265  echo "                        <td align=\"left\">&nbsp;</td>\n";
 266  echo "                      </tr>\n";
 267  echo "                    </table>\n";
 268  echo "                  </td>\n";
 269  echo "                </tr>\n";
 270  echo "              </table>\n";
 271  echo "            </td>\n";
 272  echo "          </tr>\n";
 273  echo "        </table>\n";
 274  echo "      </td>\n";
 275  echo "    </tr>\n";
 276  echo "    <tr>\n";
 277  echo "      <td align=\"left\">&nbsp;</td>\n";
 278  echo "    </tr>\n";
 279  
 280  if ($admin_edit === true) {
 281  
 282      echo "    <tr>\n";
 283      echo "      <td align=\"center\">", form_submit("save", gettext("Save")), "&nbsp;", form_submit("preview", gettext("Preview")), "&nbsp;", form_submit("cancel", gettext("Cancel")), "</td>\n";
 284      echo "    </tr>\n";
 285  
 286  } else {
 287  
 288      echo "    <tr>\n";
 289      echo "      <td align=\"center\">", form_submit("save", gettext("Save")), "&nbsp;", form_submit("preview", gettext("Preview")), "</td>\n";
 290      echo "    </tr>\n";
 291  }
 292  
 293  echo "  </table>\n";
 294  
 295  if ($show_set_all) {
 296  
 297      echo "  <br />\n";
 298      echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 299      echo "    <tr>\n";
 300      echo "      <td align=\"left\">\n";
 301      echo "        <table class=\"box\" width=\"100%\">\n";
 302      echo "          <tr>\n";
 303      echo "            <td align=\"left\" class=\"posthead\">\n";
 304      echo "              <table class=\"posthead\" width=\"100%\">\n";
 305      echo "                <tr>\n";
 306      echo "                  <td align=\"left\" class=\"subhead\">", gettext("Options"), "</td>\n";
 307      echo "                </tr>\n";
 308      echo "              </table>\n";
 309      echo "              <table class=\"posthead\" width=\"100%\">\n";
 310      echo "                <tr>\n";
 311      echo "                  <td align=\"center\">\n";
 312      echo "                    <table class=\"posthead\" width=\"95%\">\n";
 313      echo "                      <tr>\n";
 314      echo "                        <td align=\"left\">", form_checkbox("sig_global", "Y", gettext("Save signature for use on all forums"), (isset($t_sig_global) && $t_sig_global == 'Y')), "</td>\n";
 315      echo "                      </tr>\n";
 316      echo "                      <tr>\n";
 317      echo "                        <td align=\"left\">&nbsp;</td>\n";
 318      echo "                      </tr>\n";
 319      echo "                    </table>\n";
 320      echo "                  </td>\n";
 321      echo "                </tr>\n";
 322      echo "              </table>\n";
 323      echo "            </td>\n";
 324      echo "          </tr>\n";
 325      echo "        </table>\n";
 326      echo "      </td>\n";
 327      echo "    </tr>\n";
 328      echo "  </table>\n";
 329  }
 330  
 331  echo "</form>\n";
 332  
 333  if ($admin_edit === true) echo "</div>\n";
 334  
 335  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body