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

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