| 1 | <?php |
|---|
| 2 | // $Id: delete.php,v 1.5 2005/08/03 12:39:14 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // This program 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 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | // Author: Kazumi Ono (AKA onokazu) // |
|---|
| 28 | // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // |
|---|
| 29 | // Project: The XOOPS Project // |
|---|
| 30 | // ------------------------------------------------------------------------- // |
|---|
| 31 | |
|---|
| 32 | include 'header.php'; |
|---|
| 33 | |
|---|
| 34 | $ok = 0; |
|---|
| 35 | $forum = isset($_GET['forum']) ? intval($_GET['forum']) : 0; |
|---|
| 36 | $post_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0; |
|---|
| 37 | $topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : 0; |
|---|
| 38 | $order = isset($_GET['order']) ? intval($_GET['order']) : 0; |
|---|
| 39 | $viewmode = (isset($_GET['viewmode']) && $_GET['viewmode'] != 'flat') ? 'thread' : 'flat'; |
|---|
| 40 | $forum = isset($_POST['forum']) ? intval($_POST['forum']) : $forum; |
|---|
| 41 | $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : $post_id; |
|---|
| 42 | $topic_id = isset($_POST['topic_id']) ? intval($_POST['topic_id']) : $topic_id; |
|---|
| 43 | $order = isset($_POST['order']) ? intval($_POST['order']) : $order; |
|---|
| 44 | $viewmode = (isset($_POST['viewmode']) && $_POST['viewmode'] != 'flat') ? 'thread' : $viewmode; |
|---|
| 45 | if ( empty($forum) ) { |
|---|
| 46 | redirect_header("index.php", 2, _MD_ERRORFORUM); |
|---|
| 47 | exit(); |
|---|
| 48 | } elseif ( empty($post_id) ) { |
|---|
| 49 | redirect_header("viewforum.php?forum=$forum", 2, _MD_ERRORPOST); |
|---|
| 50 | exit(); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | if ( $xoopsUser ) { |
|---|
| 54 | if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) { |
|---|
| 55 | if ( !is_moderator($forum, $xoopsUser->uid()) ) { |
|---|
| 56 | redirect_header("viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_DELNOTALLOWED); |
|---|
| 57 | exit(); |
|---|
| 58 | } |
|---|
| 59 | } |
|---|
| 60 | } else { |
|---|
| 61 | redirect_header("viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_DELNOTALLOWED); |
|---|
| 62 | exit(); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | include_once 'class/class.forumposts.php'; |
|---|
| 66 | |
|---|
| 67 | if ( !empty($_POST['ok']) ) { |
|---|
| 68 | if ( !empty($post_id) ) { |
|---|
| 69 | $post = new ForumPosts($post_id); |
|---|
| 70 | $post->delete(); |
|---|
| 71 | sync($post->forum(), "forum"); |
|---|
| 72 | sync($post->topic(), "topic"); |
|---|
| 73 | } |
|---|
| 74 | if ( $post->istopic() ) { |
|---|
| 75 | redirect_header("viewforum.php?forum=$forum", 2, _MD_POSTSDELETED); |
|---|
| 76 | exit(); |
|---|
| 77 | } else { |
|---|
| 78 | redirect_header("viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_POSTSDELETED); |
|---|
| 79 | exit(); |
|---|
| 80 | } |
|---|
| 81 | } else { |
|---|
| 82 | include XOOPS_ROOT_PATH."/header.php"; |
|---|
| 83 | xoops_confirm(array('post_id' => $post_id, 'viewmode' => $viewmode, 'order' => $order, 'forum' => $forum, 'topic_id' => $topic_id, 'ok' => 1), 'delete.php', _MD_AREUSUREDEL); |
|---|
| 84 | } |
|---|
| 85 | include XOOPS_ROOT_PATH.'/footer.php'; |
|---|
| 86 | ?> |
|---|