Beehive PHP Cross Reference Discussion Forums

Source: /delete.php - 204 lines - 6691 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 . 'header.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'messages.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'poll.inc.php';
  36  require_once  BH_INCLUDE_PATH . 'post.inc.php';
  37  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  38  require_once  BH_INCLUDE_PATH . 'thread.inc.php';
  39  // End Required includes
  40  
  41  // Check we're logged in correctly
  42  if (!session::logged_in()) {
  43      html_guest_error();
  44  }
  45  
  46  $error_msg_array = array();
  47  
  48  $show_sigs = session::show_sigs();
  49  
  50  $valid = true;
  51  
  52  $tid = null;
  53  $pid = null;
  54  $t_fid = null;
  55  $preview_message = null;
  56  
  57  if (isset($_POST['msg']) && validate_msg($_POST['msg'])) {
  58  
  59      $msg = $_POST['msg'];
  60  
  61      list($tid, $pid) = explode(".", $msg);
  62  
  63      if (!$t_fid = thread_get_folder_fid($tid)) {
  64          html_draw_error(gettext("The requested thread could not be found or access was denied."));
  65      }
  66  
  67  } else if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
  68  
  69      $msg = $_GET['msg'];
  70  
  71      list($tid, $pid) = explode(".", $msg);
  72  
  73      if (!$t_fid = thread_get_folder_fid($tid)) {
  74          html_draw_error(gettext("The requested thread could not be found or access was denied."));
  75      }
  76  
  77  } else {
  78  
  79      html_draw_error(gettext("No message specified for deletion"));
  80  }
  81  
  82  if (isset($_POST['return_msg']) && validate_msg($_POST['return_msg'])) {
  83      $return_msg = $_POST['return_msg'];
  84  } else if (isset($_GET['return_msg']) && validate_msg($_GET['return_msg'])) {
  85      $return_msg = $_GET['return_msg'];
  86  } else {
  87      $return_msg = $msg;
  88  }
  89  
  90  if (isset($_POST['cancel'])) {
  91  
  92      header_redirect("discussion.php?webtag=$webtag&msg=$return_msg");
  93      exit;
  94  }
  95  
  96  if (session::check_perm(USER_PERM_EMAIL_CONFIRM, 0)) {
  97  
  98      html_email_confirmation_error();
  99      exit;
 100  }
 101  
 102  if (!session::check_perm(USER_PERM_POST_EDIT | USER_PERM_POST_READ, $t_fid)) {
 103      html_draw_error(gettext("You cannot delete posts in this folder"));
 104  }
 105  
 106  if (!$thread_data = thread_get($tid)) {
 107      html_draw_error(gettext("The requested thread could not be found or access was denied."));
 108  }
 109  
 110  if (isset($tid) && isset($pid) && is_numeric($tid) && is_numeric($pid)) {
 111  
 112      if (($preview_message = messages_get($tid, $pid, 1)) !== false) {
 113  
 114          $preview_message['CONTENT'] = message_get_content($tid, $pid);
 115  
 116          if ((strlen(trim($preview_message['CONTENT'])) < 1) && !thread_is_poll($tid)) {
 117              post_edit_refuse($tid, $pid);
 118          }
 119  
 120          if (($_SESSION['UID'] != $preview_message['FROM_UID'] || session::check_perm(USER_PERM_PILLORIED, 0)) && !session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid)) {
 121              post_edit_refuse($tid, $pid);
 122          }
 123  
 124      } else {
 125  
 126          html_draw_error(gettext("That post does not exist in this thread!"));
 127      }
 128  }
 129  
 130  if (isset($_POST['delete']) && is_numeric($tid) && is_numeric($pid)) {
 131  
 132      if (post_delete($tid, $pid)) {
 133  
 134          post_add_edit_text($tid, $pid);
 135  
 136          if (session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid) && $preview_message['FROM_UID'] != $_SESSION['UID']) {
 137              admin_add_log_entry(DELETE_POST, array($t_fid, $tid, $pid));
 138          }
 139  
 140          header_redirect("discussion.php?webtag=$webtag&msg=$return_msg&delete_success=$msg");
 141          exit;
 142  
 143      } else {
 144  
 145          $error_msg_array[] = gettext("Error deleting post");
 146      }
 147  }
 148  
 149  html_draw_top(sprintf("title=%s", gettext("Delete Message")), "js/post.js", "resize_width=720", "basetarget=_blank", 'class=window_title');
 150  
 151  echo "<h1>", gettext("Delete Message"), " {$tid}.{$pid}</h1>\n";
 152  
 153  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 154      html_display_error_array($error_msg_array, '720', 'left');
 155  }
 156  
 157  echo "<br />\n";
 158  echo "<form accept-charset=\"utf-8\" name=\"f_delete\" action=\"delete.php\" method=\"post\" target=\"_self\">\n";
 159  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 160  echo "  ", form_input_hidden('msg', htmlentities_array($msg)), "\n";
 161  echo "  ", form_input_hidden('return_msg', htmlentities_array($return_msg)), "\n";
 162  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"720\">\n";
 163  echo "    <tr>\n";
 164  echo "      <td align=\"left\">\n";
 165  echo "        <table class=\"box\" width=\"100%\">\n";
 166  echo "          <tr>\n";
 167  echo "            <td align=\"left\" class=\"posthead\">\n";
 168  echo "              <table class=\"posthead\" width=\"100%\">\n";
 169  echo "                <tr>\n";
 170  echo "                  <td align=\"left\" class=\"subhead\">", gettext("Delete Message"), "</td>\n";
 171  echo "                </tr>\n";
 172  echo "                <tr>\n";
 173  echo "                  <td align=\"left\"><br />";
 174  
 175  if (thread_is_poll($tid) && $pid == 1) {
 176  
 177      poll_display($tid, $thread_data['LENGTH'], $pid, $thread_data['FID'], false, $thread_data['CLOSED'], $show_sigs, true);
 178  
 179  } else {
 180  
 181      message_display($tid, $preview_message, $thread_data['LENGTH'], $pid, $thread_data['FID'], false, false, false, $show_sigs, true);
 182  }
 183  
 184  echo "                  </td>\n";
 185  echo "                </tr>\n";
 186  echo "                <tr>\n";
 187  echo "                  <td align=\"left\">&nbsp;</td>\n";
 188  echo "                </tr>\n";
 189  echo "              </table>\n";
 190  echo "            </td>\n";
 191  echo "          </tr>\n";
 192  echo "        </table>\n";
 193  echo "      </td>\n";
 194  echo "    </tr>\n";
 195  echo "    <tr>\n";
 196  echo "      <td align=\"left\">&nbsp;</td>\n";
 197  echo "    </tr>\n";
 198  echo "    <tr>\n";
 199  echo "      <td align=\"center\">", form_submit("delete", gettext("Delete")), "&nbsp;" . form_submit("cancel", gettext("Cancel")), "</td>\n";
 200  echo "    </tr>\n";
 201  echo "  </table>\n";
 202  echo "</form>\n";
 203  
 204  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body