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

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