Beehive PHP Cross Reference Discussion Forums

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

title

Description

title

Description

title

Description

title

title

Body