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

Revision 954, 5.7 KB checked in by uehara, 20 years ago (diff)
Line 
1<?php
2// $Id: reply.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';
32
33foreach (array('forum', 'topic_id', 'post_id', 'order', 'pid') as $getint) {
34    ${$getint} = isset($_GET[$getint]) ? intval($_GET[$getint]) : 0;
35}
36$viewmode = (isset($_GET['viewmode']) && $_GET['viewmode'] != 'flat') ? 'thread' : 'flat';
37if ( empty($forum) ) {
38    redirect_header("index.php", 2, _MD_ERRORFORUM);
39    exit();
40} elseif ( empty($topic_id) ) {
41    redirect_header("viewforum.php?forum=$forum", 2, _MD_ERRORTOPIC);
42    exit();
43} elseif ( empty($post_id) ) {
44    redirect_header("viewtopic.php?topic_id=$topic_id&amp;order=$order&amp;viewmode=$viewmode&amp;pid=$pid&amp;forum=$forum", 2, _MD_ERRORPOST);
45    exit();
46} else {
47    if ( is_locked($topic_id) ) {
48        redirect_header("viewtopic.php?topic_id=$topic_id&amp;order=$order&amp;viewmode=$viewmode&amp;pid=$pid&amp;forum=$forum", 2, _MD_TOPICLOCKED);
49        exit();
50    }
51    $sql = "SELECT forum_type, forum_name, forum_access, allow_html, allow_sig, posts_per_page, hot_threshold, topics_per_page FROM ".$xoopsDB->prefix("bb_forums")." WHERE forum_id = $forum";
52    if ( !$result = $xoopsDB->query($sql) ) {
53        redirect_header('index.php',1,_MD_ERROROCCURED);
54        exit();
55    }
56    $forumdata = $xoopsDB->fetchArray($result);
57    $myts =& MyTextSanitizer::getInstance();
58    if ( $forumdata['forum_type'] == 1 ) {
59        // To get here, we have a logged-in user. So, check whether that user is allowed to post in
60        // this private forum.
61        $accesserror = 0; //initialize
62        if ( $xoopsUser ) {
63            if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
64                if ( !check_priv_forum_auth($xoopsUser->uid(), $forum, true) ) {
65                    $accesserror = 1;
66                }
67            }
68        } else {
69            $accesserror = 1;
70        }
71        if ( $accesserror == 1 ) {
72            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);
73            exit();
74        }
75        // Ok, looks like we're good.
76    } else {
77        $accesserror = 0;
78        if ( $forumdata['forum_access'] == 3 ) {
79            if ( $xoopsUser ) {
80                if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
81                    if ( !is_moderator($forum, $xoopsUser->uid()) ) {
82                        $accesserror = 1;
83                    }
84                }
85            } else {
86                $accesserror = 1;
87            }
88        } elseif ( $forumdata['forum_access'] == 1 && !$xoopsUser ) {
89            $accesserror = 1;
90        }
91        if ( $accesserror == 1 ) {
92            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);
93            exit();
94        }
95    }
96    include XOOPS_ROOT_PATH.'/header.php';
97    include_once 'class/class.forumposts.php';
98    $forumpost = new ForumPosts($post_id);
99    $r_message = $forumpost->text();
100    $r_date = formatTimestamp($forumpost->posttime());
101    $r_name = ($forumpost->uid() != 0) ? XoopsUser::getUnameFromId($forumpost->uid()) : $xoopsConfig['anonymous'];
102    $r_content = _MD_BY." ".$r_name." "._MD_ON." ".$r_date."<br /><br />";
103    $r_content .= $r_message;
104    $r_subject=$forumpost->subject();
105    if (!preg_match("/^Re:/i",$r_subject)) {
106        $subject = 'Re: '.$myts->htmlSpecialChars($r_subject);
107    } else {
108        $subject = $myts->htmlSpecialChars($r_subject);
109    }
110    $q_message = $forumpost->text("Quotes");
111    $hidden = "[quote]\n";
112    $hidden .= sprintf(_MD_USERWROTE,$r_name);
113    $hidden .= "\n".$q_message."[/quote]";
114    $message = "";
115    echo "<div style='padding: 15px 0;'>";
116    themecenterposts($r_subject,$r_content);
117    echo "</div>";
118    $pid=$post_id;
119    unset($post_id);
120    $topic_id=$forumpost->topic();
121    $forum=$forumpost->forum();
122    $isreply =1;
123    $istopic = 0;
124    include 'include/forumform.inc.php';
125    include XOOPS_ROOT_PATH.'/footer.php';
126}
127?>
Note: See TracBrowser for help on using the repository browser.