source: temp/test-xoops.ec-cube.net/html/modules/newbb/edit.php @ 405

Revision 405, 5.3 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: edit.php,v 1.4 2005/09/04 20:46:10 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// ------------------------------------------------------------------------- //
31include 'header.php';
32foreach (array('forum', 'topic_id', 'post_id', 'order', 'pid') as $getint) {
33    ${$getint} = isset($_GET[$getint]) ? intval($_GET[$getint]) : 0;
34}
35$viewmode = (isset($_GET['viewmode']) && $_GET['viewmode'] != 'flat') ? 'thread' : 'flat';
36if ( empty($forum) ) {
37    redirect_header("index.php", 2, _MD_ERRORFORUM);
38    exit();
39} elseif ( empty($post_id) ) {
40    redirect_header("viewforum.php?forum=$forum", 2, _MD_ERRORPOST);
41    exit();
42} else {
43    $sql = sprintf("SELECT forum_type, forum_name, forum_access, allow_html, allow_sig, posts_per_page, hot_threshold, topics_per_page FROM %s WHERE forum_id = %u", $xoopsDB->prefix("bb_forums"), $forum);
44    if ( !$result = $xoopsDB->query($sql) ) {
45        redirect_header('index.php',2,_MD_ERROROCCURED);
46        exit();
47    }
48    $forumdata = $xoopsDB->fetchArray($result);
49    $myts =& MyTextSanitizer::getInstance();
50    if ( $forumdata['forum_type'] == 1 ) {
51        // To get here, we have a logged-in user. So, check whether that user is allowed to post in
52        // this private forum.
53        $accesserror = 0; //initialize
54        if ( $xoopsUser ) {
55            if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
56                if ( !check_priv_forum_auth($xoopsUser->uid(), $forum, true) ) {
57                    $accesserror = 1;
58                }
59            }
60        } else {
61            $accesserror = 1;
62        }
63        if ( $accesserror == 1 ) {
64            redirect_header("viewtopic.php?topic_id=$topic_id&amp;post_id=$post_id&amp;order=$order&amp;viewmode=$viewmode&amp;pid=$pid&amp;forum=$forum",2,_MD_NORIGHTTOPOST);
65            exit();
66        }
67    } else {
68        $accesserror = 0;
69        if ( $forumdata['forum_access'] == 3 ) {
70            if ( $xoopsUser ) {
71                if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
72                    if ( !is_moderator($forum, $xoopsUser->uid()) ) {
73                        $accesserror = 1;
74                    }
75                }
76            } else {
77                $accesserror = 1;
78            }
79        } elseif ( $forumdata['forum_access'] == 1 && !$xoopsUser ) {
80            $accesserror = 1;
81        }
82        if ( $accesserror == 1 ) {
83            redirect_header("viewtopic.php?topic_id=$topic_id&amp;post_id=$post_id&amp;order=$order&amp;viewmode=$viewmode&amp;pid=$pid&amp;forum=$forum",2,_MD_NORIGHTTOPOST);
84            exit();
85        }
86    }
87    include XOOPS_ROOT_PATH."/header.php";
88    include_once 'class/class.forumposts.php';
89    $forumpost = new ForumPosts($post_id);
90    $editerror = false;
91    if ( $forumpost->islocked() ) {
92        if ( $xoopsUser ) {
93            if (!$xoopsUser->isAdmin($xoopsModule->mid()) || !is_moderator($forum, $xoopsUser->uid())) {
94                $editerror = true;
95            }
96        } else {
97            $editerror = true;
98        }
99    }
100    if ( $editerror ) {
101        redirect_header("viewtopic.php?topic_id=$topic_id&amp;post_id=$post_id&amp;order=$order&amp;viewmode=$viewmode&amp;pid=$pid&amp;forum=$forum",2,_MD_NORIGHTTOPOST);
102        exit();
103    }
104    $nohtml = $forumpost->nohtml();
105    $nosmiley = $forumpost->nosmiley();
106    $icon = $forumpost->icon();
107    $attachsig = $forumpost->attachsig();
108    $topic_id=$forumpost->topic();
109    if ( $forumpost->istopic() ) {
110        $istopic = 1;
111    } else {
112        $istopic = 0;
113    }
114    $subject=$forumpost->subject("Edit");
115    $message=$forumpost->text("Edit");
116    $hidden = "";
117    $myts =& MyTextSanitizer::getInstance();
118    $viewmode = $myts->htmlspecialchars($viewmode);
119    include 'include/forumform.inc.php';
120    include XOOPS_ROOT_PATH.'/footer.php';
121}
122?>
Note: See TracBrowser for help on using the repository browser.