[ Index ]
 

Code source de PunBB 1.2.16

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/upload/ -> delete.php (source)

   1  <?php
   2  /***********************************************************************

   3  

   4    Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)

   5  

   6    This file is part of PunBB.

   7  

   8    PunBB is free software; you can redistribute it and/or modify it

   9    under the terms of the GNU General Public License as published

  10    by the Free Software Foundation; either version 2 of the License,

  11    or (at your option) any later version.

  12  

  13    PunBB is distributed in the hope that it will be useful, but

  14    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 this program; if not, write to the Free Software

  20    Foundation, Inc., 59 Temple Place, Suite 330, Boston,

  21    MA  02111-1307  USA

  22  

  23  ************************************************************************/
  24  
  25  
  26  define('PUN_ROOT', './');
  27  require  PUN_ROOT.'include/common.php';
  28  
  29  
  30  if ($pun_user['g_read_board'] == '0')
  31      message($lang_common['No view']);
  32  
  33  
  34  $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
  35  if ($id < 1)
  36      message($lang_common['Bad request']);
  37  
  38  // Fetch some info about the post, the topic and the forum

  39  $result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
  40  if (!$db->num_rows($result))
  41      message($lang_common['Bad request']);
  42  
  43  $cur_post = $db->fetch_assoc($result);
  44  
  45  // Sort out who the moderators are and if we are currently a moderator (or an admin)

  46  $mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array();
  47  $is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
  48  
  49  // Determine whether this post is the "topic post" or not

  50  $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
  51  $topic_post_id = $db->result($result);
  52  
  53  $is_topic_post = ($id == $topic_post_id) ? true : false;
  54  
  55  // Do we have permission to edit this post?

  56  if (($pun_user['g_delete_posts'] == '0' ||
  57      ($pun_user['g_delete_topics'] == '0' && $is_topic_post) ||
  58      $cur_post['poster_id'] != $pun_user['id'] ||
  59      $cur_post['closed'] == '1') &&
  60      !$is_admmod)
  61      message($lang_common['No permission']);
  62  
  63  // Load the delete.php language file

  64  require PUN_ROOT.'lang/'.$pun_user['language'].'/delete.php';
  65  
  66  
  67  if (isset($_POST['delete']))
  68  {
  69      if ($is_admmod)
  70          confirm_referrer('delete.php');
  71  
  72      require  PUN_ROOT.'include/search_idx.php';
  73  
  74      if ($is_topic_post)
  75      {
  76          // Delete the topic and all of it's posts

  77          delete_topic($cur_post['tid']);
  78          update_forum($cur_post['fid']);
  79  
  80          redirect('viewforum.php?id='.$cur_post['fid'], $lang_delete['Topic del redirect']);
  81      }
  82      else
  83      {
  84          // Delete just this one post

  85          delete_post($id, $cur_post['tid']);
  86          update_forum($cur_post['fid']);
  87  
  88          redirect('viewtopic.php?id='.$cur_post['tid'], $lang_delete['Post del redirect']);
  89      }
  90  }
  91  
  92  
  93  $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_delete['Delete post'];
  94  require  PUN_ROOT.'header.php';
  95  
  96  require  PUN_ROOT.'include/parser.php';
  97  $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
  98  
  99  ?>
 100  <div class="linkst">
 101      <div class="inbox">
 102          <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li>&nbsp;&raquo;&nbsp;<a href="viewforum.php?id=<?php echo $cur_post['fid'] ?>"><?php echo pun_htmlspecialchars($cur_post['forum_name']) ?></a></li><li>&nbsp;&raquo;&nbsp;<?php echo pun_htmlspecialchars($cur_post['subject']) ?></li></ul>
 103      </div>
 104  </div>
 105  
 106  <div class="blockform">
 107      <h2><span><?php echo $lang_delete['Delete post'] ?></span></h2>
 108      <div class="box">
 109          <form method="post" action="delete.php?id=<?php echo $id ?>">
 110              <div class="inform">
 111                  <fieldset>
 112                      <legend class="warntext"><?php echo $lang_delete['Warning'] ?></legend>
 113                      <div class="infldset">
 114                          <div class="postmsg">
 115                              <p><?php echo $lang_common['Author'] ?>: <strong><?php echo pun_htmlspecialchars($cur_post['poster']) ?></strong></p>
 116                              <?php echo $cur_post['message'] ?>
 117                          </div>
 118                      </div>
 119                  </fieldset>
 120              </div>
 121              <p><input type="submit" name="delete" value="<?php echo $lang_delete['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
 122          </form>
 123      </div>
 124  </div>
 125  <?php
 126  
 127  require  PUN_ROOT.'footer.php';


Généré le : Sat Nov 24 22:44:38 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics