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

Revision 1277, 13.5 KB checked in by kakinaka, 19 years ago (diff)
Line 
1<?php
2// $Id: viewforum.php,v 1.7 2006/05/01 02:37:28 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
32include "header.php";
33// this page uses smarty template
34// this must be set before including main header.php
35$xoopsOption['template_main_path'] = XOOPS_ROOT_PATH . '/modules/newbb/templates/newbb_response.html';
36include XOOPS_ROOT_PATH."/header.php";
37
38/*
39$forum = intval($_GET['forum']);
40if ( $forum < 1 ) {
41    redirect_header("index.php", 2, _MD_ERRORFORUM);
42    exit();
43}
44$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;
45if ( !$result = $xoopsDB->query($sql) ) {
46    redirect_header("index.php", 2, _MD_ERRORCONNECT);
47    exit();
48}
49if ( !$forumdata = $xoopsDB->fetchArray($result) ) {
50    redirect_header("index.php", 2, _MD_ERROREXIST);
51    exit();
52}
53*/
54
55
56/*
57$can_post = 0;
58$show_reg = 0;
59if ( $forumdata['forum_type'] == 1 ) {
60    // this is a private forum.
61    $xoopsTpl->assign('is_private_forum', true);
62    $accesserror = 0;
63    if ( $xoopsUser ) {
64        if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
65            if ( !check_priv_forum_auth($xoopsUser->getVar("uid"), $forum, false) ) {
66                $accesserror = 1;
67            }
68        }
69    } else {
70        $accesserror = 1;
71    }
72    if ( $accesserror == 1 ) {
73        redirect_header("index.php",2,_MD_NORIGHTTOACCESS);
74        exit();
75    }
76    $can_post = 1;
77    $show_reg = 1;
78} else {
79    // this is not a priv forum
80    $xoopsTpl->assign('is_private_forum', false);
81    if ( $forumdata['forum_access'] == 1 ) {
82        // this is a reg user only forum
83        if ( $xoopsUser ) {
84            $can_post = 1;
85        } else {
86            $show_reg = 1;
87        }
88    } elseif ( $forumdata['forum_access'] == 2 ) {
89        // this is an open forum
90        $can_post = 1;
91    } else {
92        // this is an admin/moderator only forum
93        if ( $xoopsUser ) {
94            if ( $xoopsUserIsAdmin || is_moderator($forum, $xoopsUser->uid()) ) {
95                $can_post = 1;
96            }
97        }
98    }
99}
100$xoopsTpl->assign("forum_id", $forum);
101
102if ( $can_post == 1 ) {
103    $xoopsTpl->assign('viewer_can_post', true);
104    $xoopsTpl->assign('forum_post_or_register', "newtopic.php?forum=".$forum);
105} else {
106    $xoopsTpl->assign('viewer_can_post', false);
107    if ( $show_reg == 1 ) {
108        $xoopsTpl->assign('forum_post_or_register', XOOPS_URL.'/user.php?xoops_redirect='.htmlspecialchars($xoopsRequestUri));
109    } else {
110        $xoopsTpl->assign('forum_post_or_register', "");
111    }
112}
113*/
114/*
115$xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX,$xoopsConfig['sitename']));
116$xoopsTpl->assign('forum_image_folder', $bbImage['folder_topic']);
117$myts =& MyTextSanitizer::getInstance();
118$xoopsTpl->assign('forum_name', $myts->makeTboxData4Show($forumdata['forum_name']));
119$xoopsTpl->assign('lang_moderatedby', _MD_MODERATEDBY);
120*/
121/*
122$forum_moderators = "";
123$count = 0;
124$moderators = get_moderators($forum);
125foreach ( $moderators as $mods ) {
126    foreach ( $mods as $mod_id => $mod_name ) {
127        if ( $count > 0 ) {
128            $forum_moderators .= ", ";
129        }
130        $forum_moderators .=  '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$mod_id.'">'.$myts->makeTboxData4Show($mod_name).'</a>';
131        $count = 1;
132    }
133}
134$xoopsTpl->assign('forum_moderators', $forum_moderators);
135
136$sel_sort_array = array("t.topic_response"=>_MD_RESPONSE, "t.topic_title"=>_MD_TOPICTITLE, "t.topic_replies"=>_MD_NUMBERREPLIES, "u.uname"=>_MD_TOPICPOSTER, "t.topic_views"=>_MD_VIEWS, "p.post_time"=>_MD_LASTPOSTTIME);
137if ( !isset($_GET['sortname']) || !in_array($_GET['sortname'], array_keys($sel_sort_array)) ) {
138    $sortname = "p.post_time";
139} else {
140    $sortname = $_GET['sortname'];
141}
142
143$xoopsTpl->assign('lang_sortby', _MD_SORTEDBY);
144
145$forum_selection_sort = '<select name="sortname">';
146foreach ( $sel_sort_array as $sort_k => $sort_v ) {
147    $forum_selection_sort .= '<option value="'.$sort_k.'"'.(($sortname == $sort_k) ? ' selected="selected"' : '').'>'.$sort_v.'</option>';
148}
149$forum_selection_sort .= '</select>';
150
151// assign to template
152$xoopsTpl->assign('forum_selection_sort', $forum_selection_sort);
153
154$sortorder = (!isset($_GET['sortorder']) || $_GET['sortorder'] != "ASC") ? "DESC" : "ASC";
155$forum_selection_order = '<select name="sortorder">';
156$forum_selection_order .= '<option value="ASC"'.(($sortorder == "ASC") ? ' selected="selected"' : '').'>'._MD_ASCENDING.'</option>';
157$forum_selection_order .= '<option value="DESC"'.(($sortorder == "DESC") ? ' selected="selected"' : '').'>'._MD_DESCENDING.'</option>';
158$forum_selection_order .= '</select>';
159
160// assign to template
161$xoopsTpl->assign('forum_selection_order', $forum_selection_order);
162
163$sortsince = !empty($_GET['sortsince']) ? intval($_GET['sortsince']) : 100;
164$sel_since_array = array(1, 2, 5, 10, 20, 30, 40, 60, 75, 100);
165$forum_selection_since = '<select name="sortsince">';
166foreach ($sel_since_array as $sort_since_v) {
167    $forum_selection_since .= '<option value="'.$sort_since_v.'"'.(($sortsince == $sort_since_v) ? ' selected="selected"' : '').'>'.sprintf(_MD_FROMLASTDAYS,$sort_since_v).'</option>';
168}
169$forum_selection_since .= '<option value="365"'.(($sortsince == 365) ? ' selected="selected"' : '').'>'.sprintf(_MD_THELASTYEAR,365).'</option>';
170$forum_selection_since .= '<option value="1000"'.(($sortsince == 1000) ? ' selected="selected"' : '').'>'.sprintf(_MD_BEGINNING,1000).'</option>';
171$forum_selection_since .= '</select>';
172
173// assign to template
174$xoopsTpl->assign('forum_selection_since', $forum_selection_since);
175$xoopsTpl->assign('lang_go', _MD_GO);
176
177$xoopsTpl->assign('h_topic_link', "viewforum.php?forum=$forum&amp;sortname=t.topic_title&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "t.topic_title" && $sortorder == "DESC") ? "ASC" : "DESC"));
178$xoopsTpl->assign('lang_topic', _MD_TOPIC);
179
180// Âбþ¾õ¶·
181$xoopsTpl->assign('h_reply_response', "viewforum.php?forum=$forum&amp;sortname=t.topic_response&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "t.topic_response" && $sortorder == "DESC") ? "ASC" : "DESC"));
182$xoopsTpl->assign('lang_response', _MD_RESPONSE);
183
184$xoopsTpl->assign('h_reply_link', "viewforum.php?forum=$forum&amp;sortname=t.topic_replies&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "t.topic_replies" && $sortorder == "DESC") ? "ASC" : "DESC"));
185$xoopsTpl->assign('lang_replies', _MD_REPLIES);
186
187$xoopsTpl->assign('h_poster_link', "viewforum.php?forum=$forum&amp;sortname=u.uname&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "u.uname" && $sortorder == "DESC") ? "ASC" : "DESC"));
188$xoopsTpl->assign('lang_poster', _MD_POSTER);
189
190$xoopsTpl->assign('h_views_link', "viewforum.php?forum=$forum&amp;sortname=t.topic_views&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "t.topic_views" && $sortorder == "DESC") ? "ASC" : "DESC"));
191$xoopsTpl->assign('lang_views', _MD_VIEWS);
192
193$xoopsTpl->assign('h_date_link', "viewforum.php?forum=$forum&amp;sortname=p.post_time&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "p.post_time" && $sortorder == "DESC") ? "ASC" : "DESC"));
194$xoopsTpl->assign('lang_date', _MD_DATE);
195
196$startdate = time() - (86400* $sortsince);
197$start = !empty($_GET['start']) ? intval($_GET['start']) : 0;
198*/
199
200
201$xoopsTpl->assign('lang_topic', _MD_TOPIC);
202$xoopsTpl->assign('lang_response', _MD_RESPONSE);
203$xoopsTpl->assign('lang_date', _MD_DATE);
204$xoopsTpl->assign('forum_name', 'Âбþ¾õ¶·°ìÍ÷');
205
206$sql = 'SELECT topic_id, topic_title, topic_response, from_unixtime(topic_time) as topic_time, uname FROM xoops_bb_topics as tpc left join xoops_users as usr on tpc.topic_response_uid = usr.uid ORDER BY topic_response, topic_id DESC';
207if ( !$result = $xoopsDB->query($sql) ) {
208    redirect_header('index.php',2,_MD_ERROROCCURED);
209    exit();
210}
211
212// Read topic 'lastread' times from cookie, if exists
213$topic_lastread = newbb_get_topics_viewed();
214while ( $myrow = $xoopsDB->fetchArray($result) ) {
215    $fix = getFixName($myrow['topic_title']);
216   
217    $xoopsTpl->append('topics', array(
218                                'topic_fix'=>$fix,
219                                'topic_title'=>$myrow['topic_title'],
220                                'topic_response'=>$myrow['topic_response'],
221                                'topic_response_user'=>$myrow['uname'],
222                                'topic_time'=>$myrow['topic_time']));
223}
224
225// Âбþ¾õ¶·
226$xoopsTpl->assign('arrResponse', $arrResponse);
227
228/*
229// ¥æ¡¼¥¶¡¼¾ðÊó¼èÆÀ
230$member_handler =& xoops_gethandler('member');
231$xoopsUserIsAdmin = false;
232$user_id = "";
233$user_name = "";
234if (!empty($_SESSION['xoopsUserId'])) {
235     $xoopsUser =& $member_handler->getUser($_SESSION['xoopsUserId']);
236    if (is_object($xoopsUser)) {
237        $xoopsUserIsAdmin = $xoopsUser->isAdmin();
238    }
239    $user_id = $_SESSION['xoopsUserId'];
240    $user_name = $xoopsUser->uname();
241}
242
243//sfprintr($xoopsUser->uname());
244
245// Âбþ¾õ¶·¹¹¿·¤¹¤ë
246//if($_GET['mode'] == 'response' and $xoopsUserIsAdmin and is_numeric($_GET['topic_id'])){
247if($_GET['mode'] == 'response' and is_numeric($_GET['topic_id'])){
248    $sql = 'UPDATE '.$xoopsDB->prefix("bb_topics").' SET topic_response = '.$_GET["response_".$_GET['topic_id']];
249    if($user_id != ""){
250        $sql .= ', topic_response_uid = '.$user_id;
251    }else{
252        $sql .= ', topic_response_uid = NULL';
253    }
254    $sql .= ' WHERE topic_id = '.$_GET['topic_id'];
255
256    if ( !$xoopsDB->queryF($sql)) {
257        redirect_header('index.php',2,_MD_ERROROCCURED);
258        exit();
259    }
260    // ¥ê¥í¡¼¥É
261    header("Location: " . $_SERVER['PHP_SELF'] . "?forum=" . $_GET['forum'] . "&sortname=p.post_time&sortorder=DESC&sortsince=" . $_GET['sortsince'] . "&start=" . $_GET['start']);
262}
263
264$xoopsTpl->assign('xoopsUserIsAdmin', $xoopsUserIsAdmin);
265*/
266/*
267$xoopsTpl->assign('lang_by', _MD_BY);
268
269$xoopsTpl->assign('img_newposts', $bbImage['newposts_topic']);
270$xoopsTpl->assign('img_hotnewposts', $bbImage['hot_newposts_topic']);
271$xoopsTpl->assign('img_folder', $bbImage['folder_topic']);
272$xoopsTpl->assign('img_hotfolder', $bbImage['hot_folder_topic']);
273$xoopsTpl->assign('img_locked', $bbImage['locked_topic']);
274$xoopsTpl->assign('img_sticky', $bbImage['folder_sticky']);
275$xoopsTpl->assign('lang_newposts', _MD_NEWPOSTS);
276$xoopsTpl->assign('lang_hotnewposts', _MD_MORETHAN);
277$xoopsTpl->assign('lang_hotnonewposts', _MD_MORETHAN2);
278$xoopsTpl->assign('lang_nonewposts', _MD_NONEWPOSTS);
279$xoopsTpl->assign('lang_legend', _MD_LEGEND);
280$xoopsTpl->assign('lang_topiclocked', _MD_TOPICLOCKED);
281$xoopsTpl->assign('lang_topicsticky', _MD_TOPICSTICKY);
282$xoopsTpl->assign("lang_search", _MD_SEARCH);
283$xoopsTpl->assign("lang_advsearch", _MD_ADVSEARCH);
284
285$sql = 'SELECT COUNT(*) FROM '.$xoopsDB->prefix('bb_topics').' WHERE forum_id = '.$forum.' AND (topic_time > '.$startdate.' OR topic_sticky = 1)';
286if ( !$r = $xoopsDB->query($sql) ) {
287    //redirect_header('index.php',2,_MD_ERROROCCURED);
288    //exit();
289}
290list($all_topics) = $xoopsDB->fetchRow($r);
291if ( $all_topics > $forumdata['topics_per_page'] ) {
292    include XOOPS_ROOT_PATH.'/class/pagenav.php';
293    $nav = new XoopsPageNav($all_topics, $forumdata['topics_per_page'], $start, "start", 'forum='.$forum.'&amp;sortname='.$sortname.'&amp;sortorder='.$sortorder.'&amp;sortsince='.$sortsince);
294    $xoopsTpl->assign('forum_pagenav', $nav->renderNav(4));
295} else {
296    $xoopsTpl->assign('forum_pagenav', '');
297}
298
299// ¥«¥Æ¥´¥ê̾¼èÆÀ
300$sql = "SELECT c.cat_id, c.cat_title FROM ".$xoopsDB->prefix("bb_categories")." c, ".$xoopsDB->prefix("bb_forums")." f WHERE c.cat_id = f.cat_id AND forum_id = $forum";
301
302if ( !$result = $xoopsDB->query($sql) ) {
303    //redirect_header('index.php',2,_MD_ERROROCCURED);
304    //exit();
305}
306$arrCat = $xoopsDB->fetchArray($result);
307$xoopsTpl->assign('arrCat', $arrCat);
308
309$xoopsTpl->assign('forum_jumpbox', make_jumpbox($forum));
310*/
311include XOOPS_ROOT_PATH."/footer.php";
312?>
Note: See TracBrowser for help on using the repository browser.